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 --- src/java/org/apache/fop/render/pdf/PDFRenderer.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 5b7dd840e..19f274902 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -1086,10 +1086,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** * {@inheritDoc} */ - protected void fillRect(float x, float y, float w, float h) { - if (w != 0 && h != 0) { + protected void fillRect(float x, float y, float width, float height) { + if (width > 0 && height > 0) { currentStream.add(format(x) + " " + format(y) + " " - + format(w) + " " + format(h) + " re f\n"); + + format(width) + " " + format(height) + " re f\n"); } } @@ -1684,7 +1684,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { endTextObject(); putImage(url, pos, foreignAttributes); } - + /** * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced. * @param uri URL of the bitmap @@ -1767,6 +1767,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { this.pdfDoc.output(ostream); } catch (IOException ioe) { // ioexception will be caught later + log.error(ioe.getMessage()); } } -- cgit v1.2.3 From 068f78cf23e72c8f596c982eda4f295e7e7d5aed Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Tue, 1 Apr 2008 15:08:24 +0000 Subject: Merged revisions 611142,611175,611278,611285,611766-611768,612560,612785,612815-612816,612825,613144,613185,613828,613831,613835,613896,614156,614169-614170,614191,614201-614202,614566,614845,614920,614924,614964,614966,614993,615144,615164,615197,615251,615598,615604,615845,615906,615917,616080,616191,616260,616334,616485,616691,616694,616798,617126,617473,617512,617531,617550,617708,617716,617765,617812,617907,617909,617976,617989,618239,618470,618626-618627,618992,619417,619461,619670,619674,619790,619854,619856,619870,619923,619979,620272,620276-620278,620283,620285,620558-620559,620565,620567,620570,620723,620750,620761,627318,627324,627367,627495,627497,627553,627576,627679,627698,627702,627712,627719,627721,628140,628280,628652,628668,628775,628804,628816,628826,628829,629048,629093,629103,629129,629131,629169,629769,629902,630215,630772,630814,631178,631226,631276,631575,631609,631984,632121-632122,632321,632558,632716,632784,632938,632972,633389-633391,633396-633397,633437,633460,633470,633473,633525,633557,633559,633561,633961,634187,635508,635686,635701,635741,635884,635961,635967,636276,636293,636295,636405,636409,636471,637057,637076,638396,640089,640242,641742,641764,641827 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ................ r611142 | jeremias | 2008-01-11 11:13:42 +0000 (Fri, 11 Jan 2008) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-594557" from https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ImagePackageRedesign ................ r611175 | jeremias | 2008-01-11 13:41:54 +0000 (Fri, 11 Jan 2008) | 4 lines Removed merge tracking for "svnmerge" for https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ImagePackageRedesign (I'm not happy with the result) ................ r611278 | jeremias | 2008-01-11 19:50:53 +0000 (Fri, 11 Jan 2008) | 925 lines Merged branch https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ImagePackageRedesign (revs 594558 to 611138) into Trunk: A new image loading framework has been introduced to fix various problems with external graphics and improve performance. Switched to Batik 1.7. Added xml-apis-ext.jar as needed by Batik 1.7. Updated to latest XML Graphics Commons snapshot. Changelog of branch: ------------------------------------------------------------------------ r594558 | jeremias | 2007-11-13 16:04:56 +0100 (Di, 13 Nov 2007) | 1 line Branch for image package redesign ------------------------------------------------------------------------ r594560 | jeremias | 2007-11-13 16:10:35 +0100 (Di, 13 Nov 2007) | 1 line Implementation of Dijkstra's algorithm for finding the shortest path. Used in the new image package to find the best combination of image loaders and image converters to provide an image in the optimal form for a renderer. ------------------------------------------------------------------------ r594848 | jeremias | 2007-11-14 13:12:50 +0100 (Mi, 14 Nov 2007) | 3 lines Initial upload of what I have already for the image package redesign. For now, it's in a parallel package (image2). The final package name is TBD. The code isn't hooked into the renderers, yet, and there's no image cache. This is still all work in progress. ------------------------------------------------------------------------ r594851 | jeremias | 2007-11-14 13:20:12 +0100 (Mi, 14 Nov 2007) | 1 line Test cases and additional test files for the new image package. ------------------------------------------------------------------------ r595305 | jeremias | 2007-11-15 15:01:37 +0100 (Do, 15 Nov 2007) | 1 line Small mistake while reimplementing JPEG. ------------------------------------------------------------------------ r595308 | jeremias | 2007-11-15 15:13:36 +0100 (Do, 15 Nov 2007) | 5 lines Introduced a usage penalty for ImageLoaders so we can calculate an overall penalty for a pipeline. Multiple image flavors can be passed to ImageManager.getImage() if the caller supports multiple formats. The image package chooses the best pipeline. Implemented a converter from RenderedImage to PNG. Implemented loaders for raw formats (EMF, JPEG and PNG). Hooked the new image package into the RTF handler as first real proof-of-concept. ------------------------------------------------------------------------ r596240 | jeremias | 2007-11-19 11:02:13 +0100 (Mo, 19 Nov 2007) | 1 line Fixed bug in pipeline selection. ------------------------------------------------------------------------ r596242 | jeremias | 2007-11-19 11:03:06 +0100 (Mo, 19 Nov 2007) | 1 line MIME type in parentheses behind the URI makes more sense. ------------------------------------------------------------------------ r599430 | jeremias | 2007-11-29 14:08:01 +0100 (Do, 29 Nov 2007) | 1 line Support for baseline information (needed by at least MathML). ------------------------------------------------------------------------ r599433 | jeremias | 2007-11-29 14:09:04 +0100 (Do, 29 Nov 2007) | 1 line Bugfix: BMP don't all have resolution information. ------------------------------------------------------------------------ r599434 | jeremias | 2007-11-29 14:10:54 +0100 (Do, 29 Nov 2007) | 1 line Change MIME type ------------------------------------------------------------------------ r599436 | jeremias | 2007-11-29 14:17:14 +0100 (Do, 29 Nov 2007) | 3 lines Started integrating into Java2D and PostScript renderers and ExternalGraphic. Added support for EPS graphics. Added support for raw embedding of JPEG images (for PostScript). ------------------------------------------------------------------------ r600821 | jeremias | 2007-12-04 08:51:06 +0100 (Di, 04 Dez 2007) | 5 lines Clean up Javadocs Generally make more useful. Reuse FOProcessor instance for the whole run to actually feel the effect of an image cache attached to the FopFactory. Add option to prompt the user before actually starting (in order to connect a VM monitor). ------------------------------------------------------------------------ r600870 | jeremias | 2007-12-04 11:27:51 +0100 (Di, 04 Dez 2007) | 14 lines Note: The API of the new image package has changed a bit. (it became necessary when I introduced caching) The direct dependency on FOUserAgent has been removed to make the image package more universally usable. Instead an ImageContext (provided by FopFactory in FOP) and ImageSessionContext (provided by FOUserAgent in FOP) was introduced. Introduced image caching with soft references (I didn't reintroduce the FOUserAgent lock, yet, because it doesn't help much) ImageInfo doesn't carry the Source for the image anymore. The Source is provided by the new ImageSessionContext.java and only shared within the same thread to make things simpler and to avoid complex synchronization and cleanup. Image instances now indicate whether they are cacheable (not all Image instances are cacheable, for example when they just carry an InputStream). Moved the converter pipeline functionality into its own subpackage to keep "spi" clean. Added checks in ImageSize to detect incomplete Preloaders. ImageSource can now indicate whether its a fast source (loading from local file) or a slow source (loading over the network). (but this isn't used, yet) Fixed a bug in WMF and SVG preloaders: they didn't close their Sources after fully loading the images. Bugfix in ImageRawJPEG: it illegally reported being an EPS file ImageRawStream got an "InputStreamFactory" so it is possible to reuse raw images if they have been loaded into memory (or to a local file which hasn't been implemented, yet). The pipeline code now converts single-use raw images to reusable raw images when possible. But there's nothing built in to restrict the image size to a maximum, yet. Improved JPEG preloader so it can stop early an deal with images that have to APP0 segment. Images from digicams are such an example. They carry the resolution info in the EXIF block which is currently not interpreted. Fallback is to the configured source resolution. ------------------------------------------------------------------------ r600930 | jeremias | 2007-12-04 14:25:43 +0100 (Di, 04 Dez 2007) | 1 line Package HTML Files. ------------------------------------------------------------------------ r600934 | jeremias | 2007-12-04 14:34:41 +0100 (Di, 04 Dez 2007) | 1 line Javadoc fixes ------------------------------------------------------------------------ r602023 | jeremias | 2007-12-07 09:46:56 +0100 (Fr, 07 Dez 2007) | 2 lines Bugfix for bug in SVG preloader which didn't calculate the size of an SVG correctly when there's no explicit size. ------------------------------------------------------------------------ r602024 | jeremias | 2007-12-07 09:49:49 +0100 (Fr, 07 Dez 2007) | 1 line Some small javadoc and logging improvements/refinements. ------------------------------------------------------------------------ r602025 | jeremias | 2007-12-07 09:50:22 +0100 (Fr, 07 Dez 2007) | 1 line Enable assert keyword for javadoc production. ------------------------------------------------------------------------ r602032 | jeremias | 2007-12-07 09:59:10 +0100 (Fr, 07 Dez 2007) | 11 lines Added color space information and an optional ICC color profile to the basic Image interface. Reimplemented transparency support (for now only for ImageIO loader and PDF output) ImageIO preloader passes the already loaded metadata to the ImageIO loader through the "custom objects" so it doesn't have to load them again. PDF library: Corrected the naming of the method indicating the "bits per component" (bits per component != bits per pixel) PDF library: Added a method which lets a user override values in an XObject's dictionary after the major values have been set (useful not to make the PDFImage interface more complicated). PDF library: Support for gray transparent colors. PDF library: Added a convenience class for alpha channel bitmaps (AlphaRasterImage) Integration of the new image package into the PDFRenderer (currently supports all previous embedding methods except deprecated EPS embedding and CCITT embedding, now supports even more transparency options than before) ------------------------------------------------------------------------ r602033 | jeremias | 2007-12-07 09:59:57 +0100 (Fr, 07 Dez 2007) | 1 line Small optimization from my failed experiments to support native PNG embedding. ------------------------------------------------------------------------ r602034 | jeremias | 2007-12-07 10:01:34 +0100 (Fr, 07 Dez 2007) | 1 line Don't use "content" filter for ICC profiles. Instead compress using "default". "content" is for page content. ------------------------------------------------------------------------ r602036 | jeremias | 2007-12-07 10:02:25 +0100 (Fr, 07 Dez 2007) | 1 line Added general key for precompressed content of any kind. ------------------------------------------------------------------------ r602037 | jeremias | 2007-12-07 10:03:39 +0100 (Fr, 07 Dez 2007) | 1 line Various variants of the FOP logo for testing. Some of them have transparency info. ------------------------------------------------------------------------ r602228 | jeremias | 2007-12-07 22:30:17 +0100 (Fr, 07 Dez 2007) | 4 lines Discarded PreloaderPNG in favor of PreloaderImageIO which now supports all formats supported by ImageIO (meaning that you can uses JPEG-2000 images if you have a suitable ImageIO codec installed). ImagePreloader.getMimeType() removed because it isn't really used in the new setup. ImagePreloader.getPriority() introduced which allows to prioritize preloaders and thus gives the opportunity to tweak the order in which the preloaders are checked when an image is inspected. ImageLoaderImageIO can now use multiple Readers if one fails (one codec may not support all format variants, for example). ------------------------------------------------------------------------ r602229 | jeremias | 2007-12-07 22:30:48 +0100 (Fr, 07 Dez 2007) | 1 line Added a toString() impl for debugging. ------------------------------------------------------------------------ r602442 | jeremias | 2007-12-08 11:36:32 +0100 (Sa, 08 Dez 2007) | 6 lines Support handling images with no associated URI (from instream-foreign-object). These images are not cached. Add support for plain image conversion (i.e. with no loading) for instream-foreign-object. Add convenience writeTo() methods in ImageRawStream to save a few lines of code. Support for instream-foreign-object in RTF output. Teach RTF library to handle images without an associated URL. ------------------------------------------------------------------------ r603191 | jeremias | 2007-12-11 11:03:32 +0100 (Di, 11 Dez 2007) | 2 lines Bugfix: Graphics2DAdapter didn't do the graphics state save correct so subsequent images may have been painted with the wrong transformation matrix. Bugfix: bitmap images didn't scale correctly when the resolutions were changed. ------------------------------------------------------------------------ r603207 | jeremias | 2007-12-11 12:08:36 +0100 (Di, 11 Dez 2007) | 1 line Convenience method for obtaining the image size in points. ------------------------------------------------------------------------ r603208 | jeremias | 2007-12-11 12:12:50 +0100 (Di, 11 Dez 2007) | 3 lines Precisely define the expectations for the area parameter in Graphics2DImagePainter. New ImageConverter: Bitmap -> Graphics2D ------------------------------------------------------------------------ r603209 | jeremias | 2007-12-11 12:15:49 +0100 (Di, 11 Dez 2007) | 3 lines Refine pipeline building: Expose a method to allow the PS Renderer to predict what kind of pipeline will be selected (because it doesn't support all image types as PostScript forms) If there are multiple candidate pipelines for one conversion type, choose the one with the lowest penalty, not just the one that happens to be first. ------------------------------------------------------------------------ r603250 | jeremias | 2007-12-11 15:17:32 +0100 (Di, 11 Dez 2007) | 1 line Removing failed experiment: raw PNG embedding didn't work out. ------------------------------------------------------------------------ r603254 | jeremias | 2007-12-11 15:29:48 +0100 (Di, 11 Dez 2007) | 2 lines Plugged new image package into form generation for PostScript. XML images and EPS files are currently supported as forms. They are added inline. ------------------------------------------------------------------------ r603256 | jeremias | 2007-12-11 15:34:52 +0100 (Di, 11 Dez 2007) | 1 line Embedding EPS in PDF is no longer implemented as it is a deprecated feature in PDF. Therefore, this test is not needed anymore. The PDF renderer will say: "Cannot load image (no suitable loader/converter combination available) for myfile.eps (application/postscript)" ------------------------------------------------------------------------ r603266 | jeremias | 2007-12-11 16:16:22 +0100 (Di, 11 Dez 2007) | 1 line Size calculation for images can be slightly different after the redesign due to different rounding. Give a little tolerance. ------------------------------------------------------------------------ r603271 | jeremias | 2007-12-11 16:24:08 +0100 (Di, 11 Dez 2007) | 1 line Bugfix: Only generate the FixedLength if there is baseline information. ------------------------------------------------------------------------ r603358 | jeremias | 2007-12-11 22:13:22 +0100 (Di, 11 Dez 2007) | 1 line Switched background images to new image package. ------------------------------------------------------------------------ r603632 | jeremias | 2007-12-12 15:52:09 +0100 (Mi, 12 Dez 2007) | 1 line Switch to new image package for PDF/SVG support. ------------------------------------------------------------------------ r603642 | jeremias | 2007-12-12 16:30:16 +0100 (Mi, 12 Dez 2007) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-594557" from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ------------------------------------------------------------------------ r603656 | jeremias | 2007-12-12 17:13:06 +0100 (Mi, 12 Dez 2007) | 307 lines Merged revisions 594558-603642 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r594571 | vhennebert | 2007-11-13 17:24:32 +0100 (Di, 13 Nov 2007) | 7 lines Moved the creation of grid units to the FO tree building stage. Brought a few improvements along with the move: - bugfix: border-resolution for border-end on row-spanning cells was wrong - bugfix: in case of missing cells the border-end of the table was applied to an inner cell, instead of the cell in the last column (but missing cells aren't painted yet :-\) - bugfix: in collapsing-border model, border-before and -after specified on table-column were applied to every cell of the column, instead of only the first and the last ones - border resolution is now made progressively when possible, and no longer triggers the fetching of all the rows of the table Added testcases for the border conflict resolution (between the various elements of a table and not only the cells) ........ r594578 | vhennebert | 2007-11-13 17:50:09 +0100 (Di, 13 Nov 2007) | 2 lines Moved *GridUnit from layoutmgr/table to fo/flow/table ........ r594579 | vhennebert | 2007-11-13 17:55:54 +0100 (Di, 13 Nov 2007) | 2 lines Changed back visibility of fields from public to package-private, due to the move of *GridUnit in the fo.flow.table package ........ r594584 | vhennebert | 2007-11-13 18:13:19 +0100 (Di, 13 Nov 2007) | 2 lines Use a singleton for a default BorderInfo of style none, instead of every time a new instance ........ r594592 | vhennebert | 2007-11-13 18:39:17 +0100 (Di, 13 Nov 2007) | 2 lines Cleaned up RowGroupLayoutManager and TableRowIterator ........ r594821 | vhennebert | 2007-11-14 11:18:45 +0100 (Mi, 14 Nov 2007) | 2 lines Moved EffRow to the fo.flow.table package ........ r594829 | vhennebert | 2007-11-14 11:41:52 +0100 (Mi, 14 Nov 2007) | 2 lines Reduced visibility of some methods and constructors from public to package-private, as a consequence of the move of *GridUnit to the fo.flow.table package ........ r594836 | vhennebert | 2007-11-14 12:14:03 +0100 (Mi, 14 Nov 2007) | 2 lines Restored the setting of the parent table-row element on grid units ........ r594852 | vhennebert | 2007-11-14 13:21:53 +0100 (Mi, 14 Nov 2007) | 2 lines Restored the setting of rowIndex on primary grid units (although testcases were already working...) ........ r595297 | jeremias | 2007-11-15 14:28:58 +0100 (Do, 15 Nov 2007) | 2 lines Bugzilla #43143: Had to remove the Expert(Subset) Encoding detection as this caused problems with a barcode font that used dfCharset=2 but was not using ExpertSubset encoding. To detect Expert(Subset)Encoding, the AFM needs to be parsed. And since we don't support that encoding, yet, the fallback to WinAnsiEncoding should work well enough. ........ r595637 | acumiskey | 2007-11-16 13:12:52 +0100 (Fr, 16 Nov 2007) | 3 lines This should improve the ability of the FontLoader when resolving PFM files for Type 1 fonts on case sensitive Unix systems. ........ r596072 | jeremias | 2007-11-18 11:48:53 +0100 (So, 18 Nov 2007) | 4 lines ApacheCon US is over. OSSSummit was cancelled/postponed. Added example for total page count using XSL 1.1 Adjusted total page count example to new FOP API. (Thanks to Miroslav Gregan for the hint) ........ r596097 | jeremias | 2007-11-18 17:56:09 +0100 (So, 18 Nov 2007) | 6 lines Bugzilla #43605: Added methods for page-number-citation and page-number-citation-last in FOEventHandler.java Submitted by: V. Schappert Patch modified by Jeremias: Bugfix: FOEventHandler.startPageNumberCitation() was also called in the case of a page-number-citation-last. Introduced abstract base classes to avoid this. ........ r596100 | jeremias | 2007-11-18 18:17:24 +0100 (So, 18 Nov 2007) | 1 line Added sample as suggested by Kumar Puppala. ........ r596390 | vhennebert | 2007-11-19 19:25:27 +0100 (Mo, 19 Nov 2007) | 2 lines Bugzilla #43766: breaks generated by the merging algorithm for table rows containing empty cells has always a penalty of 900 ........ r596554 | jeremias | 2007-11-20 08:14:33 +0100 (Di, 20 Nov 2007) | 2 lines Bugzilla #43904: Buffer the OutputStreams in our transcoders if the users forget. ........ r596600 | jeremias | 2007-11-20 11:20:29 +0100 (Di, 20 Nov 2007) | 3 lines Bugzilla #43910: Avoid a NullPointerException in AreaTreeHandler.endDocument(). Submitted by: David Delbecq ........ r596724 | jeremias | 2007-11-20 16:56:33 +0100 (Di, 20 Nov 2007) | 3 lines Bugfix: Bugfix for URI resolution: Make StreamSources without system identifier work again. Bugfix: Close streams opened by test font resolution in font configuration (the font URIs will be resolved again later anyway). Better error message when the loading of font metric files doesn't work due to missing information in the returned Source instances. ........ r596727 | vhennebert | 2007-11-20 17:07:32 +0100 (Di, 20 Nov 2007) | 2 lines Bugfix in tables: wrong element generation by the merging algorithm when glues must be produced to cope with conditional spaces. The corresponding length was added twice: one in the glue itself and one in the following box. ........ r596739 | cbowditch | 2007-11-20 17:49:13 +0100 (Di, 20 Nov 2007) | 1 line bug fix: memory leak in PropertyCache. Fix provided by Jeremias. There are still some thread synchronization issues to be addressed in the PropertyCache. See the following thread for details: http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-dev/200711.mbox/%3cBAY117-DAV109E36CC066889386AB917FB870@phx.gbl%3e ........ r596742 | vhennebert | 2007-11-20 18:08:46 +0100 (Di, 20 Nov 2007) | 2 lines Added a news entry about Max Berger becoming a committer. Welcome Max! ........ r596776 | vhennebert | 2007-11-20 19:47:39 +0100 (Di, 20 Nov 2007) | 2 lines Bugzilla #43803: table cells having no children are allowed in relaxed validation mode. ........ r597052 | vhennebert | 2007-11-21 13:23:59 +0100 (Mi, 21 Nov 2007) | 2 lines Bugfix: the last element generated by the merging algorithm may now be a glue ........ r597448 | jeremias | 2007-11-22 17:13:05 +0100 (Do, 22 Nov 2007) | 2 lines First draft of a possible new intermediate format for Apache FOP. Details on: http://wiki.apache.org/xmlgraphics-fop/AreaTreeIntermediateXml/NewDesign ........ r598558 | jeremias | 2007-11-27 09:36:23 +0100 (Di, 27 Nov 2007) | 6 lines Bugzilla #40230: Bugfix: no empty page is generated anymore if there's no content after a break-after. Bugzilla #43917: Bugfix for border-after painting and element list generation when a forced break is involved. ........ r599536 | vhennebert | 2007-11-29 19:31:13 +0100 (Do, 29 Nov 2007) | 4 lines Added fixes-bug attributes for: - wrong element generation in table when glues are produced - border-resolution on row-spanning cells ........ r599746 | jeremias | 2007-11-30 10:04:54 +0100 (Fr, 30 Nov 2007) | 2 lines Bugzilla #37993: Bugfix: allow multiple bookmarks to point at the same destination. ........ r600195 | adelmelle | 2007-12-01 22:11:53 +0100 (Sa, 01 Dez 2007) | 1 line Correction and simplification of the PropertyCache: subclass WeakReference and remove internal threading ........ r600467 | jeremias | 2007-12-03 11:16:27 +0100 (Mo, 03 Dez 2007) | 2 lines Log RuntimeExceptions during rendering so that they are at least visible somewhere if someone doesn't set an ErrorListener on the XSLT processor (this could lead to exceptions being swallowed). This is a temporary measure until we have time to improve the exception handling in FOP. The original problem that led to this change was: "The number of this PDFNumber must not be empty" while producing a PDF/A with customized filter entries in the PDF configuration. The exception was a follow-up exception after a PDFConformanceException that was swallowed by a default ErrorListener. ........ r600521 | jeremias | 2007-12-03 14:21:06 +0100 (Mo, 03 Dez 2007) | 1 line Added a possibility to rerun the whole run a defined number of times to test for possible issues outside a single rendering run. ........ r600529 | jeremias | 2007-12-03 14:32:04 +0100 (Mo, 03 Dez 2007) | 1 line Oops. ........ r601413 | vhennebert | 2007-12-05 17:56:47 +0100 (Mi, 05 Dez 2007) | 2 lines Typo in property: svn:kewords -> svn:keywords ........ r601415 | acumiskey | 2007-12-05 18:11:44 +0100 (Mi, 05 Dez 2007) | 2 lines Corrected javadocs ........ r601416 | acumiskey | 2007-12-05 18:12:54 +0100 (Mi, 05 Dez 2007) | 2 lines Corrected javadoc ........ r601417 | acumiskey | 2007-12-05 18:13:31 +0100 (Mi, 05 Dez 2007) | 2 lines Corrected javadoc ........ r601419 | acumiskey | 2007-12-05 18:15:46 +0100 (Mi, 05 Dez 2007) | 2 lines Improved use of logging ........ r601423 | acumiskey | 2007-12-05 18:19:43 +0100 (Mi, 05 Dez 2007) | 2 lines Corrected javadoc, fixed checkstyle issues, and now also correctly caters for negative number conversions ........ r601424 | acumiskey | 2007-12-05 18:21:15 +0100 (Mi, 05 Dez 2007) | 2 lines Fixed checkstyle issues ........ r601426 | acumiskey | 2007-12-05 18:24:15 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601427 | acumiskey | 2007-12-05 18:25:07 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601428 | acumiskey | 2007-12-05 18:25:58 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601429 | acumiskey | 2007-12-05 18:27:06 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601430 | acumiskey | 2007-12-05 18:28:03 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601431 | acumiskey | 2007-12-05 18:28:48 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601432 | acumiskey | 2007-12-05 18:29:31 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601433 | acumiskey | 2007-12-05 18:30:04 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601434 | acumiskey | 2007-12-05 18:31:20 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601435 | acumiskey | 2007-12-05 18:32:29 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601436 | acumiskey | 2007-12-05 18:34:44 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601437 | acumiskey | 2007-12-05 18:35:31 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601438 | acumiskey | 2007-12-05 18:36:12 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes and cleanup ........ r601439 | acumiskey | 2007-12-05 18:37:40 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601440 | acumiskey | 2007-12-05 18:39:54 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601442 | acumiskey | 2007-12-05 18:42:13 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601443 | acumiskey | 2007-12-05 18:42:48 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601444 | acumiskey | 2007-12-05 18:43:46 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601445 | acumiskey | 2007-12-05 18:44:36 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601446 | acumiskey | 2007-12-05 18:45:20 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601447 | acumiskey | 2007-12-05 18:47:44 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601448 | acumiskey | 2007-12-05 18:48:56 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601449 | acumiskey | 2007-12-05 18:49:46 +0100 (Mi, 05 Dez 2007) | 2 lines Checkstyle fixes ........ r601712 | acumiskey | 2007-12-06 12:57:14 +0100 (Do, 06 Dez 2007) | 2 lines Temporary fix to the build ........ r602045 | jeremias | 2007-12-07 10:20:28 +0100 (Fr, 07 Dez 2007) | 1 line Avoid a NPE in toString(). ........ r602125 | maxberger | 2007-12-07 16:36:53 +0100 (Fr, 07 Dez 2007) | 6 lines Updated xmlgraphics from SVN Added autodetection of fonts in jar files (x-font and x-font-truetype) Added files needed for testcase Please note: Actual testcase is still missing! ........ r602898 | maxberger | 2007-12-10 14:35:33 +0100 (Mo, 10 Dez 2007) | 2 lines Added documentation for font-in-jar-files ........ r603590 | acumiskey | 2007-12-12 13:24:10 +0100 (Mi, 12 Dez 2007) | 4 lines * Added an SVG handler and Graphics2D implementation for AFP which injects AFP GOCA structured fields into the AFPDataStream. * Fixed many checkstyle problems. * Updated xmlgraphics-commons-1.3svn.jar to include changes to TextHandler ........ r603592 | acumiskey | 2007-12-12 13:26:39 +0100 (Mi, 12 Dez 2007) | 2 lines Updated status with SVG support for AFP. ........ ------------------------------------------------------------------------ r603661 | jeremias | 2007-12-12 17:20:09 +0100 (Mi, 12 Dez 2007) | 1 line Fix javadoc ------------------------------------------------------------------------ r603886 | jeremias | 2007-12-13 12:15:48 +0100 (Do, 13 Dez 2007) | 1 line Copy/paste programming is dangerous. :-) ------------------------------------------------------------------------ r603902 | jeremias | 2007-12-13 13:17:56 +0100 (Do, 13 Dez 2007) | 2 lines Factored out all image handling code in the PDFRenderer into PDFImageHandler classes. The interface was introduced to handle PDF-in-PDF images. The PDFImageHandler interface changes in a backwards-incompatible way but since the PDF-in-PDF plug-in probably has the only implementation, that's not very problematic. I'll release a new version as soon as the image stuff is merged back into Trunk. ------------------------------------------------------------------------ r603937 | jeremias | 2007-12-13 16:20:46 +0100 (Do, 13 Dez 2007) | 1 line Some cleanup ------------------------------------------------------------------------ r603938 | jeremias | 2007-12-13 16:23:23 +0100 (Do, 13 Dez 2007) | 2 lines Switch PCL renderer to new image package. Add an option to force a color canvas (RGB) instead of a gray canvas. Set this to true for all SVG graphics since Batik does not seem to support gradients on a grayscale canvas (IllegalArgumentException). ------------------------------------------------------------------------ r604122 | jeremias | 2007-12-14 08:58:56 +0100 (Fr, 14 Dez 2007) | 1 line Stupid copy/paste again. ------------------------------------------------------------------------ r604135 | jeremias | 2007-12-14 10:04:43 +0100 (Fr, 14 Dez 2007) | 1 line Preliminary changes to switch to the new image library. TIFF optimizations still missing. Untested. ------------------------------------------------------------------------ r604144 | jeremias | 2007-12-14 11:12:41 +0100 (Fr, 14 Dez 2007) | 1 line Switch to new image package. At some point we will probably want to remove this example as JEuclid has a better plug-in now. ------------------------------------------------------------------------ r604150 | jeremias | 2007-12-14 11:27:39 +0100 (Fr, 14 Dez 2007) | 1 line Old JEuclid doesn't notice itself if no MathML document is loaded. ------------------------------------------------------------------------ r604155 | jeremias | 2007-12-14 11:48:07 +0100 (Fr, 14 Dez 2007) | 2 lines Switched to new image package. The preloader simply loads the full document and converts it to SVG. That's the only way to determine the intrinsic size of the image. ------------------------------------------------------------------------ r604157 | jeremias | 2007-12-14 11:51:21 +0100 (Fr, 14 Dez 2007) | 1 line No longer needed. ------------------------------------------------------------------------ r604214 | jeremias | 2007-12-14 17:07:30 +0100 (Fr, 14 Dez 2007) | 1 line Added work-around for decoding CMYK JPEGs with ImageIO (no guarantees for color fidelity but it's better than not being able to use CMYK images). ------------------------------------------------------------------------ r604297 | jeremias | 2007-12-14 22:14:12 +0100 (Fr, 14 Dez 2007) | 68 lines Merged revisions 603643-604293 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r603890 | vhennebert | 2007-12-13 12:35:17 +0100 (Do, 13 Dez 2007) | 2 lines Fixed @throws statements in javadoc ........ r603926 | adelmelle | 2007-12-13 15:43:08 +0100 (Do, 13 Dez 2007) | 4 lines Minor tweaks: * only add text to a fo:wrapper if it is not a direct flow-descendant * error if an fo:wrapper that is a direct flow-descendant contains inline-level children ........ r603943 | vhennebert | 2007-12-13 16:55:29 +0100 (Do, 13 Dez 2007) | 2 lines Removed calls to removeLegalBreaks since they aren't necessary (the whole content is put in a single box anyway) and the method is buggy. ........ r603945 | vhennebert | 2007-12-13 17:10:32 +0100 (Do, 13 Dez 2007) | 2 lines Implemented the resolution of collapsing borders in the FO tree, for every situation (normal, cell at the top of a page, cell broken), taking conditionality, headers and footers into account. ........ r603959 | vhennebert | 2007-12-13 18:21:24 +0100 (Do, 13 Dez 2007) | 2 lines Reverted change accidentally introduced in the previous commit. A proper fix needs to be found for this one. ........ r603961 | vhennebert | 2007-12-13 18:31:26 +0100 (Do, 13 Dez 2007) | 2 lines Ok, now /really/ revert the previous commit :-\ ........ r603962 | vhennebert | 2007-12-13 18:32:43 +0100 (Do, 13 Dez 2007) | 2 lines Style only: removed trailing white spaces ........ r603968 | vhennebert | 2007-12-13 19:28:56 +0100 (Do, 13 Dez 2007) | 2 lines Fixed the handling of columns in the border resolution, especially in case of column-spanning cells ........ r603975 | vhennebert | 2007-12-13 19:52:48 +0100 (Do, 13 Dez 2007) | 2 lines Removed parameter from the endPart method, since the part is already passed as a parameter of the previously called startPart method ........ r603979 | vhennebert | 2007-12-13 19:57:25 +0100 (Do, 13 Dez 2007) | 2 lines Removed parameter from the endTablePart method, as the part is already passed as as a parameter of the previously called startTablePart method ........ r603990 | vhennebert | 2007-12-13 20:17:12 +0100 (Do, 13 Dez 2007) | 2 lines Throw a ValidationException if table-footer is put after table-body and the table uses the collapsing border model. The footer must be known to properly resolve borders. ........ r604171 | vhennebert | 2007-12-14 12:32:51 +0100 (Fr, 14 Dez 2007) | 2 lines Clean up: removed all reset and resetPosition methods, which pre-date the Knuth era and are no longer needed ........ r604180 | vhennebert | 2007-12-14 13:23:10 +0100 (Fr, 14 Dez 2007) | 2 lines Reduced visibility of methods from public to package-private ........ r604185 | acumiskey | 2007-12-14 14:16:06 +0100 (Fr, 14 Dez 2007) | 2 lines Fixed copy constructor ........ r604293 | jeremias | 2007-12-14 21:58:53 +0100 (Fr, 14 Dez 2007) | 2 lines Bugfix: DecodeParms -> DecodeParams (introduced when I changed to generic PDF structures) (fixes CCITT encoded images) ........ ------------------------------------------------------------------------ r604301 | jeremias | 2007-12-14 22:26:27 +0100 (Fr, 14 Dez 2007) | 9 lines Merged revisions 604294-604299 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r604299 | jeremias | 2007-12-14 22:24:14 +0100 (Fr, 14 Dez 2007) | 1 line Don't hack when you're tired! Reverting r604293 and instead fixing the right value. It's DecodeParams -> DecodeParms! ........ ------------------------------------------------------------------------ r604930 | jeremias | 2007-12-17 18:05:47 +0100 (Mo, 17 Dez 2007) | 2 lines Dispose ImageReader when done reading. Don't close streams as some codecs appear to do "late reading" of the image, i.e. only when the rasters are accessed, at which point they still seek on the stream. For this, the streams must remain open. I hope the codecs all properly close the streams once they don't need them anymore. The javadocs are not clear enough in this regards, IMO. ------------------------------------------------------------------------ r604968 | jeremias | 2007-12-17 20:03:45 +0100 (Mo, 17 Dez 2007) | 3 lines Added an isSupported() method to ImageLoaderFactory so we can check early if an ImageLoader may or may not support a particular subformat. This is used to allow optimized loading of CCITT compressed TIFF images. Support for undecoded embedding of single-strip CCITT compressed images for PDF, PostScript and AFP. Added a fallback mechanism for ImageLoaders: if one ImageLoader cannot load a particular image, try equivalent others registered for the same format. ------------------------------------------------------------------------ r604972 | jeremias | 2007-12-17 20:07:43 +0100 (Mo, 17 Dez 2007) | 1 line Update Commons ------------------------------------------------------------------------ r605138 | jeremias | 2007-12-18 09:42:41 +0100 (Di, 18 Dez 2007) | 2 lines Support for specifying a particular page number of a multi-page image (such as TIFF). Format: http://localhost/images/scan1.tif#page=3 ------------------------------------------------------------------------ r605479 | jeremias | 2007-12-19 10:18:33 +0100 (Mi, 19 Dez 2007) | 3 lines Removed new image package after the copying it to XML Graphics Commons. Adjusted to use the Commons' version. Batik-dependent plugins remain but will eventually need a different resting place. ------------------------------------------------------------------------ r605486 | jeremias | 2007-12-19 10:39:33 +0100 (Mi, 19 Dez 2007) | 1 line Adjust the (pre)loader registration for the demo extensions. ------------------------------------------------------------------------ r605567 | jeremias | 2007-12-19 16:03:25 +0100 (Mi, 19 Dez 2007) | 1 line Fixed scaling and translation (didn't work correctly in certain situations) ------------------------------------------------------------------------ r607034 | jeremias | 2007-12-27 11:47:12 +0100 (Do, 27 Dez 2007) | 71 lines Merged revisions 604300-607033 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r604475 | vhennebert | 2007-12-15 19:16:01 +0100 (Sa, 15 Dez 2007) | 2 lines Testcase for the resolution of collapsed and conditional borders in the FO tree ........ r604678 | adelmelle | 2007-12-16 20:54:00 +0100 (So, 16 Dez 2007) | 8 lines Streamlining/Correction of the changes made in r603926 - delegate validation of the fo:wrapper's children to the parent: added static FONode.validateChildNode() - narrow the condition for processing text-childnodes: this is not only constrained to fo:flow and fo:static-content, but the same goes for a fo:wrapper that is a direct descendant of a fo:block-container or fo:inline-container, which only allow block-level content (interpretation) - minor javadoc fixups/improvements ........ r604814 | vhennebert | 2007-12-17 11:21:04 +0100 (Mo, 17 Dez 2007) | 2 lines Organized imports ........ r604965 | vhennebert | 2007-12-17 19:56:46 +0100 (Mo, 17 Dez 2007) | 2 lines Renaming GridUnitPart into the more accurate CellPart. Moreover I was always making the confusion between gup and pgu ........ r604970 | vhennebert | 2007-12-17 20:05:27 +0100 (Mo, 17 Dez 2007) | 2 lines Simplified addAreasAndFlushRow: there can no longer be null GridUnits, every hole in the grid is now filled with an EmptyGridUnit ........ r605195 | vhennebert | 2007-12-18 12:56:38 +0100 (Di, 18 Dez 2007) | 2 lines Reset previousRowsLength before a new row-group is handled ........ r605246 | vhennebert | 2007-12-18 17:48:03 +0100 (Di, 18 Dez 2007) | 2 lines Simplification in RowPainter: avoid the use of an array to store rowOffsets and firstRow index for each part of the table (header, footer, body). One at a time is enough. ........ r605253 | vhennebert | 2007-12-18 18:01:45 +0100 (Di, 18 Dez 2007) | 2 lines Renamed firstRow into firstRowIndex and moved its initialization into handeTableContentPosition ........ r605295 | vhennebert | 2007-12-18 19:58:29 +0100 (Di, 18 Dez 2007) | 2 lines Streamlined the recording of row offsets, by replacing Map with a List. Fixed bug #43633 in the same time. ........ r605297 | vhennebert | 2007-12-18 20:02:02 +0100 (Di, 18 Dez 2007) | 3 lines SVG support for AFP is an important addition IMO. IIUC it will have to be advertised in the next release as "Support for SVG images using primitive AFP graphics commands instead of bitmap images", or something like that? ........ r605517 | vhennebert | 2007-12-19 12:47:38 +0100 (Mi, 19 Dez 2007) | 2 lines I said currentGU can no longer be null ........ r605978 | jeremias | 2007-12-20 18:00:46 +0100 (Do, 20 Dez 2007) | 1 line Remove commented code. ........ r606004 | jeremias | 2007-12-20 20:19:19 +0100 (Do, 20 Dez 2007) | 1 line Added support for scale-down-to-fit and scale-up-to-fit. ........ r607032 | jeremias | 2007-12-27 11:34:15 +0100 (Do, 27 Dez 2007) | 4 lines Added new extension element: fox:external-document. It allows to add whole documents such as multi-page TIFF images to be inserted as peers to a page-sequence. Each image will make up an entire page. See the documentation for details. ATM, only single pages are possible. Multi-page images will be supported with the new image package. Some preparations for page-position="only" but the implementation is incomplete and "only" has no effect, yet. (Just uploaded some stuff I once started) Some javadoc cleanups. ........ ------------------------------------------------------------------------ r607091 | jeremias | 2007-12-27 18:13:45 +0100 (Do, 27 Dez 2007) | 1 line Avoid cutting away the URI fragment when building URLs from filenames. ------------------------------------------------------------------------ r607092 | jeremias | 2007-12-27 18:15:49 +0100 (Do, 27 Dez 2007) | 3 lines Switched fox:external-document to new image package. Added multi-page support for fox:external-document. Changed multi-page.tiff: page 4 is now bigger than all other pages. (to make sure that individually sized pages are handled properly) ------------------------------------------------------------------------ r607188 | jeremias | 2007-12-28 09:38:26 +0100 (Fr, 28 Dez 2007) | 2 lines Throwing IllegalStateException causes a prior exception to be swallowed by Xalan-J. Need to throw a SAXException instead. Instead of logging an error about the element mismatch throw a SAXException because the logging only confuses the user as it's practically always a follow-up exception of an exception happening earlier in the respective startElement() event. ------------------------------------------------------------------------ r607249 | jeremias | 2007-12-28 15:27:39 +0100 (Fr, 28 Dez 2007) | 1 line Metadata didn't get transported to the renderer when only fox:external-document is used. ------------------------------------------------------------------------ r607256 | jeremias | 2007-12-28 16:06:35 +0100 (Fr, 28 Dez 2007) | 1 line Corrected content model. ------------------------------------------------------------------------ r607261 | jeremias | 2007-12-28 16:11:56 +0100 (Fr, 28 Dez 2007) | 1 line Added -imagein to command-line so (multi-page) images such as TIFF files can be converted to PDF and other formats supported by FOP. The default stylesheet can be overwritten (with -xslt) if desired. ------------------------------------------------------------------------ r609530 | jeremias | 2008-01-07 09:16:09 +0100 (Mo, 07 Jan 2008) | 1 line Fixed copy/paste mistake. Thanks for spotting it, Vincent. ------------------------------------------------------------------------ r609600 | jeremias | 2008-01-07 14:28:53 +0100 (Mo, 07 Jan 2008) | 1 line Removed "image2" package again and moved the Batik-dependent implementations under the old "image" package. In this form, the deprecated code doesn't conflict with the new implementations anymore. ------------------------------------------------------------------------ r610029 | jeremias | 2008-01-08 16:48:53 +0100 (Di, 08 Jan 2008) | 3 lines Added minimal support for the .minimum/.maximum components of block/inline-progression-dimension on fo:external-graphic and fo:instream-foreign-object. This will only constrain the image itself but not allow the layout engine itself to resize the image as seen fit. Added missing Javadocs in ImageLayout.java. ------------------------------------------------------------------------ r611120 | jeremias | 2008-01-11 10:20:57 +0100 (Fr, 11 Jan 2008) | 100 lines Merged revisions 607034-611115 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r607036 | jeremias | 2007-12-27 11:51:11 +0100 (Do, 27 Dez 2007) | 1 line Don't just exit with no error message if the document contains no content. Pretty irritating if it does so. ........ r608812 | acumiskey | 2008-01-04 13:14:33 +0100 (Fr, 04 Jan 2008) | 3 lines The fonts variable would have always had an empty Configuration node (non-null value) even if a wasn't present in the fop configuration. ........ r609567 | jeremias | 2008-01-07 11:52:09 +0100 (Mo, 07 Jan 2008) | 4 lines Reenabled documentation for fox:destination. Enabled intermediate format functionality for fox:destination. Added a test case to check fox:destination. Deprecated FOP's XMLizable in favor of the XML Graphics Commons variant (and extend that variant). ........ r609627 | jeremias | 2008-01-07 16:06:24 +0100 (Mo, 07 Jan 2008) | 5 lines Bugzilla #44176: Support for custom fonts in Java2DRenderer and derived renderers. Submitted by: Patrick Jaromin Patch modified slightly by jeremias. ........ r610020 | acumiskey | 2008-01-08 16:27:02 +0100 (Di, 08 Jan 2008) | 2 lines cleaned up ........ r610021 | acumiskey | 2008-01-08 16:28:56 +0100 (Di, 08 Jan 2008) | 2 lines Appears to be unused/referenced and superceeded by PageGroup ........ r610022 | acumiskey | 2008-01-08 16:34:07 +0100 (Di, 08 Jan 2008) | 2 lines cleaned up ........ r610023 | acumiskey | 2008-01-08 16:35:18 +0100 (Di, 08 Jan 2008) | 2 lines fixed javadoc ........ r610337 | vhennebert | 2008-01-09 12:02:08 +0100 (Mi, 09 Jan 2008) | 2 lines Fixed checkstyle issues: tabs and trailing spaces ........ r610355 | vhennebert | 2008-01-09 13:01:21 +0100 (Mi, 09 Jan 2008) | 2 lines keep-together is an inherited property ........ r610420 | acumiskey | 2008-01-09 16:40:25 +0100 (Mi, 09 Jan 2008) | 2 lines cleanup ........ r610704 | jeremias | 2008-01-10 08:38:47 +0100 (Do, 10 Jan 2008) | 1 line Added basic support for PDF page labels. ........ r610739 | jeremias | 2008-01-10 11:13:21 +0100 (Do, 10 Jan 2008) | 1 line PostScript output now generates the bounding box DSC comments for the whole document. ........ r610821 | vhennebert | 2008-01-10 16:53:20 +0100 (Do, 10 Jan 2008) | 4 lines - renamed variables for clarity - moved the computation of a cell's content length in PrimaryGridUnit - better javadoc for getHeight method in EffRow ........ r610848 | vhennebert | 2008-01-10 18:41:52 +0100 (Do, 10 Jan 2008) | 2 lines No need to check if the end of the cell is reached when creating the areas for a row ........ r610853 | vhennebert | 2008-01-10 18:54:16 +0100 (Do, 10 Jan 2008) | 2 lines Simplified addAreasAndFlushRow ........ r610886 | vhennebert | 2008-01-10 20:23:56 +0100 (Do, 10 Jan 2008) | 2 lines Removed endPart() method and moved its content into addAreasAndFlushRow() ........ r610891 | vhennebert | 2008-01-10 20:34:13 +0100 (Do, 10 Jan 2008) | 2 lines Removed accumulatedBPD which is redundant with yoffset ........ r610893 | vhennebert | 2008-01-10 20:35:24 +0100 (Do, 10 Jan 2008) | 2 lines The return value of addAreasAndFlushRow is never used, changed it to void ........ r610905 | vhennebert | 2008-01-10 20:57:29 +0100 (Do, 10 Jan 2008) | 2 lines Renamed lastRow into currentRow and yoffset into currentRowOffset ........ r611114 | jeremias | 2008-01-11 10:04:28 +0100 (Fr, 11 Jan 2008) | 2 lines Bugfix: Some string objects were not encrypted (for example in named destinations) I had to refactor the PDF library a little bit but since it only affects the inner API it shouldn't be a problem that I removed some methods which caused trouble because a didn't think about encryption when I worked on the PDF library last year. ........ ------------------------------------------------------------------------ r611133 | jeremias | 2008-01-11 11:45:01 +0100 (Fr, 11 Jan 2008) | 4 lines Fixed merge problems. Fixed a NPE when a mask is null in BitmapImage.java Add support for properly encoding binary data as a hexadecimal string object (including encryption). Adjust palette generation for indexed bitmaps to work correctly with encryption. ------------------------------------------------------------------------ r611138 | jeremias | 2008-01-11 11:59:27 +0100 (Fr, 11 Jan 2008) | 1 line Removed empty package. ------------------------------------------------------------------------ ................ r611285 | jeremias | 2008-01-11 20:03:36 +0000 (Fri, 11 Jan 2008) | 1 line Removed stray reference to ImageFactory. ................ r611766 | jeremias | 2008-01-14 11:01:11 +0000 (Mon, 14 Jan 2008) | 1 line java.net.URI doesn't eat non-escaped URIs so I added an escaping method to URISpecification that should cover most cases. Usually, it's just about a space in a filename. ................ r611767 | jeremias | 2008-01-14 11:02:34 +0000 (Mon, 14 Jan 2008) | 1 line Restore default constructor for PDFArray. ................ r611768 | jeremias | 2008-01-14 11:02:54 +0000 (Mon, 14 Jan 2008) | 1 line Clear parent if later on an object number is assigned to a PDFObject which means it is a top-level object. ................ r612560 | jeremias | 2008-01-16 20:14:56 +0000 (Wed, 16 Jan 2008) | 1 line Fixed dead link. ................ r612785 | acumiskey | 2008-01-17 10:36:36 +0000 (Thu, 17 Jan 2008) | 1 line added serial version id ................ r612815 | jeremias | 2008-01-17 13:37:04 +0000 (Thu, 17 Jan 2008) | 6 lines Fixed logic error setting the transformation matrix for block-container viewports (applies to absolute and fixed block-containers only). The CTM now only rotates and shifts the content as necessary for reference-orientation and writing-mode. All the rest of the transformation is done by the renderer which allows to add additional transformations as made possible by fox:transform (see below). Important: External renderer implementations need to adjust for the change and implement the new method concatenateTransformationMatrix(AffineTransform) if the renderer is derived from AbstractPathOrientedRenderer. New extension attribute fox:transform on fo:block-container allows free-form transformation (rotation, scaling etc.) of absolute and fixed block-containers. Supported only for PDF, PS and Java2D-based renderers. Added missing region background painting for PCL renderer. ................ r612816 | jeremias | 2008-01-17 13:43:33 +0000 (Thu, 17 Jan 2008) | 1 line Slight performance improvement on multi-core CPUs using a cheap trick. ................ r612825 | jeremias | 2008-01-17 14:23:13 +0000 (Thu, 17 Jan 2008) | 2 lines Fixed layout problem in two of the changes. Categorized the individual changes a bit. ................ r613144 | jeremias | 2008-01-18 12:44:56 +0000 (Fri, 18 Jan 2008) | 1 line Forgot to adjust the JAR name when updating to Batik 1.7 ................ r613185 | jeremias | 2008-01-18 15:25:26 +0000 (Fri, 18 Jan 2008) | 1 line Copy/Paste problem with TTF has long been fixed. ................ r613828 | jeremias | 2008-01-21 10:21:25 +0000 (Mon, 21 Jan 2008) | 1 line Removed stray System.out ................ r613831 | jeremias | 2008-01-21 10:33:10 +0000 (Mon, 21 Jan 2008) | 1 line A name object can be encoded as a stand-along PDF object with object number and all, so extend from PDFObject. Fixes a possible ClassCastException with the PDF-in-PDF extension. ................ r613835 | jeremias | 2008-01-21 10:40:38 +0000 (Mon, 21 Jan 2008) | 1 line Correct inline writing when object has an object number. ................ r613896 | jeremias | 2008-01-21 14:13:29 +0000 (Mon, 21 Jan 2008) | 1 line A note about the internal coordinate system when using fox:transform. ................ r614156 | jeremias | 2008-01-22 09:26:05 +0000 (Tue, 22 Jan 2008) | 2 lines Complete overhaul of the "Graphics" page after the new image loading framework has been introduced. Some updates on external links and about Java 1.4. ................ r614169 | vhennebert | 2008-01-22 10:48:43 +0000 (Tue, 22 Jan 2008) | 2 lines Fixed minor typos ................ r614170 | vhennebert | 2008-01-22 10:50:24 +0000 (Tue, 22 Jan 2008) | 2 lines Updated text to reflect the upgrading of the minimum Java requirement to 1.4 ................ r614191 | jeremias | 2008-01-22 12:31:11 +0000 (Tue, 22 Jan 2008) | 1 line A note on the difference between JAI Image I/O Tools, the codec package, and JAI, the image library. ................ r614201 | jeremias | 2008-01-22 14:02:27 +0000 (Tue, 22 Jan 2008) | 2 lines Bugzilla #44160: Fixed a possible IndexOutOfBoundsException that could happen with certain constellations when footnotes are used. Note: I haven't been able to come up with a scaled-down testcase for regression testing. Maybe someone more intimate with the footnote handling can. ................ r614202 | jeremias | 2008-01-22 14:13:22 +0000 (Tue, 22 Jan 2008) | 1 line We need JAI Image I/O Tools now rather than Jimi or JAI. ................ r614566 | vhennebert | 2008-01-23 15:22:05 +0000 (Wed, 23 Jan 2008) | 3 lines Added support for conditional borders (and paddings) in tables. The proper borders are not selected yet between the header/footer and the body. There might still be a few glitches in some cases ................ r614845 | vhennebert | 2008-01-24 11:32:07 +0000 (Thu, 24 Jan 2008) | 2 lines Removed the no longer needed maxColumnCount parameter ................ r614920 | vhennebert | 2008-01-24 16:40:46 +0000 (Thu, 24 Jan 2008) | 6 lines Cleanup: - renamed startRow/startCol into rowIndex/colIndex - improved javadoc of PrimaryGridUnit.getRowIndex() - moved colIndex from GridUnit into PrimaryGridUnit since it's only needed there - simplified EmptyGridUnit constructor ................ r614924 | vhennebert | 2008-01-24 16:51:53 +0000 (Thu, 24 Jan 2008) | 2 lines Removed no longer needed reference to TableColumn in GridUnit ................ r614964 | vhennebert | 2008-01-24 19:56:05 +0000 (Thu, 24 Jan 2008) | 2 lines Replaced 'non-lead' with 'normal' ................ r614966 | vhennebert | 2008-01-24 19:59:20 +0000 (Thu, 24 Jan 2008) | 2 lines Added license header ................ r614993 | vhennebert | 2008-01-24 21:10:22 +0000 (Thu, 24 Jan 2008) | 2 lines Bugzilla #44289: Wrong border resolution when header/footer omitted at break ................ r615144 | jeremias | 2008-01-25 08:26:54 +0000 (Fri, 25 Jan 2008) | 1 line Added support for DOMSource to Preloader SVG so a URI Resolver can be written that provides the SVG as a W3C SVG DOM. ................ r615164 | jeremias | 2008-01-25 09:59:29 +0000 (Fri, 25 Jan 2008) | 1 line Fix exception when closing Source that doesn't have any streams. ................ r615197 | jeremias | 2008-01-25 12:14:52 +0000 (Fri, 25 Jan 2008) | 1 line Improved error tolerance: an enum property value with leading or trailing spaces is still recognized. Example: content-width="scale-to-fit " ................ r615251 | vhennebert | 2008-01-25 15:52:53 +0000 (Fri, 25 Jan 2008) | 2 lines Fixed a bug in computeContentLength when there are empty cells ................ r615598 | adelmelle | 2008-01-27 13:35:39 +0000 (Sun, 27 Jan 2008) | 4 lines Bugzilla #44286: Fixed a memory-leak in XMLWhiteSpaceHandler. Submitted by: Stefan Ziel ................ r615604 | vhennebert | 2008-01-27 14:09:12 +0000 (Sun, 27 Jan 2008) | 2 lines Of course startIndex == endIndex means there is one element whose length must be computed... Changed >= into > ................ r615845 | jeremias | 2008-01-28 10:32:46 +0000 (Mon, 28 Jan 2008) | 1 line Improve breaking for block-container and static-content so there are no more "breaking artifacts" (like additional border lines) in the overflowing part of the content anymore. This is done by removing all breaks from the result list prior to constructing the area tree. The presence of breaks simply indicates that there is an overflow. ................ r615906 | jeremias | 2008-01-28 15:04:39 +0000 (Mon, 28 Jan 2008) | 2 lines Added support for the natural language indentifier ("Lang" in the document catalog) for PDF documents based on the language/country values on fo:page-sequence. This required a few changes in the AreaTreeModel and the Renderer interface because it didn't support passing through the PageSequence object, only its title. Now, we can put other values on the PageSequence and transport them to the renderers. ................ r615917 | jeremias | 2008-01-28 15:45:10 +0000 (Mon, 28 Jan 2008) | 1 line A note on country/language. ................ r616080 | jeremias | 2008-01-28 22:05:39 +0000 (Mon, 28 Jan 2008) | 1 line Bugfix for invalid numTables entry in subset TrueType fonts if there was no "fpgm" table (Example: FreeSerif). ................ r616191 | jeremias | 2008-01-29 07:30:08 +0000 (Tue, 29 Jan 2008) | 1 line A more detailed comment on RTF output explaining that RTF has limitations besides the incomplete implementation on the FOP side. ................ r616260 | vhennebert | 2008-01-29 11:15:29 +0000 (Tue, 29 Jan 2008) | 2 lines Added more tests to ensure no weird things occurs when keep-with-previous/next is set on table. Runs ok ................ r616334 | vhennebert | 2008-01-29 14:15:52 +0000 (Tue, 29 Jan 2008) | 2 lines Renamed testcase for clarity ................ r616485 | vhennebert | 2008-01-29 19:12:58 +0000 (Tue, 29 Jan 2008) | 2 lines Replaced testcases for forced break on table-row with more complete ones. Tests failing because of bug #44320 have been commented out and will need to be re-enabled once the bug is fixed ................ r616691 | jeremias | 2008-01-30 08:53:48 +0000 (Wed, 30 Jan 2008) | 1 line "cvt ", "fpgm" and "prep" are all optional tables in TrueType. Some PDF viewers fail because FOP didn't handle those correctly. ................ r616694 | jeremias | 2008-01-30 09:05:30 +0000 (Wed, 30 Jan 2008) | 1 line Removing the previous entry because the new one basically covers the other, too. ................ r616798 | jeremias | 2008-01-30 16:03:00 +0000 (Wed, 30 Jan 2008) | 1 line Removed the Dijkstra stuff as it was moved to Commons. ................ r617126 | jeremias | 2008-01-31 13:44:46 +0000 (Thu, 31 Jan 2008) | 1 line Update lib README based on recent findings. ................ r617473 | jeremias | 2008-02-01 11:11:02 +0000 (Fri, 01 Feb 2008) | 1 line Implemented drawRenderedImage() which fixes painting of PNG images embedded inside SVG images. ................ r617512 | jeremias | 2008-02-01 14:58:30 +0000 (Fri, 01 Feb 2008) | 4 lines AlphaRasterImage now knows how to deal with TYPE_INT Rasters. Streamlined image handling in Graphics2D. Support natively handling CCITT images in SVG images. Add fallback to device RGB if sRGB isn't set up as the default color space in PDF. ................ r617531 | jeremias | 2008-02-01 16:02:33 +0000 (Fri, 01 Feb 2008) | 2 lines Move sRGB installation into the PDF library. That way it can be used in PDFDocumentGraphics2D, too (via AbstractImageAdapter). Ensures correct handling of sRGB images in PDFTranscoder. ................ r617550 | jeremias | 2008-02-01 16:31:24 +0000 (Fri, 01 Feb 2008) | 1 line Add a note about color space overrides which currently aren't supported for natively handled images, yet. ................ r617708 | adelmelle | 2008-02-01 23:30:13 +0000 (Fri, 01 Feb 2008) | 5 lines Bugzilla 44343: Fixed a bug when using relative (smaller/larger) font-sizes in combination with percentages. Percentages now resolved as per the spec (XSL-FO 1.1 7.9.4): "A percentage value specifies an absolute font size relative to the parent element's font-size." ................ r617716 | adelmelle | 2008-02-02 00:06:29 +0000 (Sat, 02 Feb 2008) | 4 lines Minor cleanup/improvement: - FontSizePropertyMaker: remove redundant casts (FixedLength already casts the doubles internally) - FixedLength: reduce visibility of 'fishy' convert() method (not used anywhere else) ................ r617765 | jeremias | 2008-02-02 06:45:39 +0000 (Sat, 02 Feb 2008) | 1 line Fixed transcoder test after yesterday's changes. ................ r617812 | adelmelle | 2008-02-02 15:13:40 +0000 (Sat, 02 Feb 2008) | 6 lines Further cleanup/refinement of FixedLength: * improve consistency in use of the PropertyCache remove public constructor -> replaced by getInstance() in a handful of classes * added a sourceResolution parameter to getInstance() and the private constructor to allow better handling of device-dependent units (px) ................ r617907 | adelmelle | 2008-02-02 22:11:12 +0000 (Sat, 02 Feb 2008) | 4 lines Further improvement in FixedLength: * added a special ZERO_FIXED_LENGTH instance * store only non-zero values in the PropertyCache ................ r617909 | adelmelle | 2008-02-02 22:18:30 +0000 (Sat, 02 Feb 2008) | 2 lines Slight correction for pixel-values: pass the ratio of pixels-per-point into FixedLength.getInstance() ................ r617976 | adelmelle | 2008-02-03 12:05:49 +0000 (Sun, 03 Feb 2008) | 5 lines Added very basic parsing for the xml:lang shorthand. No validation of the specified value, but the language and country properties now do take the shorthand into account to determine their value. ................ r617989 | adelmelle | 2008-02-03 14:11:40 +0000 (Sun, 03 Feb 2008) | 5 lines Bugzilla 43705: Fixed a bug when the rgb-icc() function was used before the fo:declarations, or in documents without fo:declarations. Function now correctly (?) reverts to the sRGB fallback in those cases. ................ r618239 | vhennebert | 2008-02-04 11:25:13 +0000 (Mon, 04 Feb 2008) | 2 lines Fixed minor typo I stumbled upon while doing something completely unrelated ................ r618470 | adelmelle | 2008-02-04 22:26:53 +0000 (Mon, 04 Feb 2008) | 1 line Added testcase for Bugzilla 44343 ................ r618626 | jeremias | 2008-02-05 12:34:56 +0000 (Tue, 05 Feb 2008) | 1 line Change PDFPage to use PDFDictionary in order to make it possible to better set MediaBox/TrimBox/BleedBox. ................ r618627 | jeremias | 2008-02-05 12:35:42 +0000 (Tue, 05 Feb 2008) | 1 line FOX_TRANSFORM constant should be static. ................ r618992 | jeremias | 2008-02-06 14:07:03 +0000 (Wed, 06 Feb 2008) | 4 lines Bugzilla #36391: Fixed problem with positioning of content when reference-orientation="180" is used. CTM is now correct. It is updated after the height of the content is known. Instead of somehow inverting the element list, I've simply declared this case non-breakable, i.e. I generate one box. Fixed a few other problems mostly occurring when rotating block-container content by 90 or 270 degrees plus a few remaining auto-height handling problems. This involved switching off some sometimes unwanted side-effects from auto-updating the BPD in some area classes. ................ r619417 | jeremias | 2008-02-07 14:02:44 +0000 (Thu, 07 Feb 2008) | 1 line Added an option to disable the default sRGB profile in PDF output for those who don't care about color fidelity, but care about PDF file size. Note that this option is not possible if PDF/A, PDF/X or an output profile is used. Makes simple PDFs about 4KB smaller. Ha! ................ r619461 | jeremias | 2008-02-07 15:42:03 +0000 (Thu, 07 Feb 2008) | 2 lines Bugfix for date formatting with negative time zones in the PDF's Info object. Update of xmlgraphics-commons-1.3.jar because of a similar bug with formatting dates in XMP. ................ r619670 | adelmelle | 2008-02-07 22:32:27 +0000 (Thu, 07 Feb 2008) | 1 line Tweak: early percentage resolution by the parser (if the base is known and absolute). Reduces the number of PercentLength instances in favor of cached FixedLengths. ................ r619674 | adelmelle | 2008-02-07 22:41:26 +0000 (Thu, 07 Feb 2008) | 3 lines Tweak: modify PercentLength.toString() to return a value that facilitates debugging. Moved the original code to a getString() implementation, which is now used by the fotree test suite. ................ r619790 | jeremias | 2008-02-08 07:27:06 +0000 (Fri, 08 Feb 2008) | 1 line Added a clarification that this bug affected PDF/A compliance. ................ r619854 | vhennebert | 2008-02-08 12:11:04 +0000 (Fri, 08 Feb 2008) | 3 lines Removed the 900 penalty mechanism which anyway almost always produced visually bad results. Now the first step for a row is computed so that each cell starting on it can contribute some content. Used a similar mechanism to replace backtracking: the current row is now allowed to grow as long as there is not enough space on the current page to make the next row fit. The next row is "delayed", so this mechanism is called "row-delaying" ................ r619856 | vhennebert | 2008-02-08 12:14:01 +0000 (Fri, 08 Feb 2008) | 2 lines Also display the column index in the toString method ................ r619870 | jeremias | 2008-02-08 13:23:47 +0000 (Fri, 08 Feb 2008) | 1 line Added missing width for Euro glyph. ................ r619923 | vhennebert | 2008-02-08 15:59:21 +0000 (Fri, 08 Feb 2008) | 2 lines Testcase for bug #43676, which is now fixed ................ r619979 | spepping | 2008-02-08 19:20:27 +0000 (Fri, 08 Feb 2008) | 5 lines In addKnuthElementsForBorderPaddingXXX, if the returnlist is a BlockKnuthSequence, the border and padding should be added to the first or last paragraph inside it, but it is too late to do that now. At least, avoid adding it to the bpd sequence. ................ r620272 | adelmelle | 2008-02-10 12:31:46 +0000 (Sun, 10 Feb 2008) | 5 lines Some minor tweaks: * added convenience shortcut to PropertyInfo to get to the user agent. * replaced occurrences to use the shortcut in PropertyParser and RGBColorFunction. * PropertyParser -> 0% of a length always yields FixedLength.ZERO_FIXED_LENGTH ................ r620276 | adelmelle | 2008-02-10 12:50:47 +0000 (Sun, 10 Feb 2008) | 3 lines Revisit background-position shorthand implementation: always convert to percentages (more possibilities/precision). ................ r620277 | adelmelle | 2008-02-10 13:01:07 +0000 (Sun, 10 Feb 2008) | 2 lines Tweak: wrap numeric values internally in Integers or Longs if possible, Doubles only if necessary. ................ r620278 | adelmelle | 2008-02-10 13:07:34 +0000 (Sun, 10 Feb 2008) | 2 lines Missing file from r620272 ................ r620283 | adelmelle | 2008-02-10 13:17:20 +0000 (Sun, 10 Feb 2008) | 5 lines Correction/Rectification of changes made in r617989: * adjustment in ColorUtil to cater for the change * added check to the color_1.xml testcase, checking for bug 43705 ................ r620285 | adelmelle | 2008-02-10 13:42:39 +0000 (Sun, 10 Feb 2008) | 3 lines Bugzilla 41631: Percentage resolution for arguments to proportional-column-width() ................ r620558 | vhennebert | 2008-02-11 18:10:09 +0000 (Mon, 11 Feb 2008) | 2 lines Added full support for breaks inside table-cell elements ................ r620559 | vhennebert | 2008-02-11 18:11:09 +0000 (Mon, 11 Feb 2008) | 2 lines Fixed illegal character in the file ................ r620565 | vhennebert | 2008-02-11 18:18:13 +0000 (Mon, 11 Feb 2008) | 2 lines Better javadoc for break class ................ r620567 | vhennebert | 2008-02-11 18:24:00 +0000 (Mon, 11 Feb 2008) | 2 lines Disabled region-body_column-count_bug#37468 testcase because of bug 44393 ................ r620570 | adelmelle | 2008-02-11 18:36:14 +0000 (Mon, 11 Feb 2008) | 1 line Missing file from r620283 ................ r620723 | jeremias | 2008-02-12 08:23:04 +0000 (Tue, 12 Feb 2008) | 2 lines Bugzilla #44393: Recognize the newly used EN_AUTO constant for break values. Other LMs generate a -1 value for this case. ................ r620750 | jeremias | 2008-02-12 10:45:50 +0000 (Tue, 12 Feb 2008) | 1 line Simplification. ................ r620761 | vhennebert | 2008-02-12 11:12:25 +0000 (Tue, 12 Feb 2008) | 2 lines Fixed wrong numbering of cells ................ r627318 | maxberger | 2008-02-13 09:12:25 +0000 (Wed, 13 Feb 2008) | 1 line Added *.xml to svn:ignore ................ r627324 | maxberger | 2008-02-13 09:35:01 +0000 (Wed, 13 Feb 2008) | 1 line Ensured all SVN properties are set equally ................ r627367 | maxberger | 2008-02-13 12:03:30 +0000 (Wed, 13 Feb 2008) | 1 line Ensured all SVN properties are set equally ................ r627495 | jeremias | 2008-02-13 15:55:34 +0000 (Wed, 13 Feb 2008) | 1 line Replace useless javadoc comment. ................ r627497 | jeremias | 2008-02-13 15:57:01 +0000 (Wed, 13 Feb 2008) | 1 line Easy way to force the discarding of the user's font cache file (especially after the recent changes). ................ r627553 | vhennebert | 2008-02-13 18:11:06 +0000 (Wed, 13 Feb 2008) | 2 lines Added support for breaks before and after table cells ................ r627576 | vhennebert | 2008-02-13 20:10:01 +0000 (Wed, 13 Feb 2008) | 2 lines Moved to the FO tree stage the check for break-before/after on table-row while spanning in progress, and fixed bug #44321 as well ................ r627679 | jeremias | 2008-02-14 08:12:34 +0000 (Thu, 14 Feb 2008) | 10 lines Added support for Type 1 fonts which don't use the AdobeStandardEncoding for PDF and PS output. Details: Added an Type 1 AFM parser (only basic ltr script fonts are properly supported). Font loading changed slightly to allow loading an AFM in addition to a PFM. Added some mapping functionality to CodePointMapping. Now we also build custom CodePointMapping instances from AFM files and use it in SingleByteFonts. Changed more PDF object classes to make use of the generic PDFDictionary and PDFArray base classes. Type 1 Fonts with a special encoding now register their encoding in the Encoding value of the font dictionary so the mapping is correct. For PS this isn't necessary as the interpreter just uses the font's default encoding. Refactored CMap building code to it can also be used outside the PDF context. A CMap can now also be built from a single byte encoding. Update of XML Graphics Commons snapshot. ................ r627698 | acumiskey | 2008-02-14 10:12:48 +0000 (Thu, 14 Feb 2008) | 3 lines When I first saw this it surprised me, it seems to have been here for quite some time. The code block directly following this if/else condition was identical so I removed the copy/paste duplication and refactored it. ................ r627702 | jeremias | 2008-02-14 10:41:26 +0000 (Thu, 14 Feb 2008) | 2 lines Fix problem with alternate Unicode code point overriding existing better ones in CodePointMapping (ex. a char code for NBSP was used in place of SPACE for non-standard encodings). Made PFM completely optional if an AFM is available. Widths and Kerning are now also read from the AFM. Fallbacks for missing values are in place. If both AFM and PFM are available, both are used to get the best possible result for certain metrics. ................ r627712 | vhennebert | 2008-02-14 11:36:01 +0000 (Thu, 14 Feb 2008) | 2 lines Simplified the detection of double as integer ................ r627719 | maxberger | 2008-02-14 11:57:05 +0000 (Thu, 14 Feb 2008) | 1 line Created Constants for unit descriptions ................ r627721 | vhennebert | 2008-02-14 12:09:05 +0000 (Thu, 14 Feb 2008) | 2 lines break-after set on the last child of a row-spanning cell must apply to the last row spanned by the cell ................ r628140 | vhennebert | 2008-02-15 18:33:12 +0000 (Fri, 15 Feb 2008) | 2 lines rowStarted doesn't need to be set in the signalNewRow method. If it is, it will prevent the startTablePart event from being triggered on RowGroupBuilder, in addChildNode. This will lead to a NPE being thrown in CollapsingBorderResolver because it would be improperly set up. ................ r628280 | jeremias | 2008-02-16 12:28:48 +0000 (Sat, 16 Feb 2008) | 7 lines Extracted most of the code in CodePointMapping (generated by XSLT) into a base class for easier maintenance and proper Javadocs. Deprecated FOP's copy of Glyphs.java. Took a different approach at handling mapping alternatives for single-byte fonts. The AFM now only lists the main character. Substitution is done through Glyphs.java later in CodePointMapping. Fixed a problem in Type1FontLoader where the PFM overrides asc/desc/cap/x even though the AFM provides the values. It showed itself because the URW Symbol font has wrong values in the PFM. Added a note to myself in Type1FontLoader to implement the "Flags" value. The whole thing still seems to work without that part. Added a glyph name list to the CodePointMapping so we can work with the original list from the AFM. Otherwise, various mapping operations to and from resulted in unwanted mappings (because the mappings are not necessarily 1:1) and in the end the PDF received an incorrect Encoding map. Now there's no such problem anymore. ................ r628652 | jeremias | 2008-02-18 09:00:08 +0000 (Mon, 18 Feb 2008) | 1 line No stack traces with missing images. ................ r628668 | jeremias | 2008-02-18 09:41:03 +0000 (Mon, 18 Feb 2008) | 2 lines Extract original exception in BasePDFTestCase.java. They are normally embedded in a TransformerException and sometimes additionally in a SAXException (depending on the JAXP implementation). Restore validation for Base14 font check when PDF/A is active. Got lost when I refactored to generic structures in the PDF library. ................ r628775 | jeremias | 2008-02-18 15:02:39 +0000 (Mon, 18 Feb 2008) | 2 lines fop-rgb-icc() function did not make the round-trip which caused an error in the color_1.xml test case (intermediate format tests). Added a unit test to test the parsing and round-trip. Documented the cmyk() function. ................ r628804 | jeremias | 2008-02-18 16:45:18 +0000 (Mon, 18 Feb 2008) | 1 line Reducing noise. Better messages. ................ r628816 | jeremias | 2008-02-18 17:06:39 +0000 (Mon, 18 Feb 2008) | 1 line It currently doesn't work properly without a layout-master-set. ................ r628826 | jeremias | 2008-02-18 17:24:23 +0000 (Mon, 18 Feb 2008) | 1 line Made the necessary changes to remove the long-standing deprecations in the apps package as discussed. ................ r628829 | jeremias | 2008-02-18 17:30:15 +0000 (Mon, 18 Feb 2008) | 1 line Makes sense to mention the removal of deprecated methods. ................ r629048 | vhennebert | 2008-02-19 09:36:23 +0000 (Tue, 19 Feb 2008) | 2 lines Style only: removed spurious ^M characters at the end of lines ................ r629093 | jeremias | 2008-02-19 13:08:39 +0000 (Tue, 19 Feb 2008) | 9 lines Bugzilla #44451: The patch fixes two problems: - If distinct fonts declare the same font family name, the resulting font mapping is currently arbitrary; now, a name-similarity heuristic is used to prioritize the font mappings. - "Medium" and "demi" fonts are now recognized as "bold", solving several real-world problems (although this solution may be an oversimplification). Submitted by: Justus Piater Patch modified by jeremias: - Style fixes (tab chars) - Refined font weight identification: medium -> 500, semi/demi -> 600 ................ r629103 | jeremias | 2008-02-19 14:16:08 +0000 (Tue, 19 Feb 2008) | 1 line Bugfix: a specified font-weight of 100 could result into a resolved font-weight of 400 even when a font with weight 200 is registered. ................ r629129 | jeremias | 2008-02-19 15:43:31 +0000 (Tue, 19 Feb 2008) | 1 line Fixed NPE when no AFM is available and the PFM didn't provide a xHeight. ................ r629131 | jeremias | 2008-02-19 15:47:48 +0000 (Tue, 19 Feb 2008) | 2 lines Added support for reading the OS/2 table's usWeightClass value which supports the same font weight values as we use in XSL-FO. However, in my tests these values proved to be unreliable (like ExtraBlack fonts returning 400). I just hooked the whole thing in so this work isn't lost if anyone has an idea to make it work. The FontInfoFinder will continue to only use guessed font weights for now. ................ r629169 | vhennebert | 2008-02-19 17:32:18 +0000 (Tue, 19 Feb 2008) | 2 lines Fixed a bug leading to the content of row-spanning cells being duplicated at page breaks, when it's small enough to fit on the previous row ................ r629769 | maxberger | 2008-02-21 12:52:33 +0000 (Thu, 21 Feb 2008) | 1 line Moved me to commiters :) ................ r629902 | maxberger | 2008-02-21 18:22:22 +0000 (Thu, 21 Feb 2008) | 1 line Turned on XInclude processing for the main source given on the command line. ................ r630215 | maxberger | 2008-02-22 14:17:20 +0000 (Fri, 22 Feb 2008) | 2 lines Fixed backward compatiblity with 1.4 ................ r630772 | jeremias | 2008-02-25 09:17:43 +0000 (Mon, 25 Feb 2008) | 1 line Bugfix: When scale-up/down-to-fit was used, the image scaling rule was not always respected. ................ r630814 | vhennebert | 2008-02-25 11:30:43 +0000 (Mon, 25 Feb 2008) | 5 lines - added full support for keep-with-previous on table-row and in table-cell - added more testcases for keeps in tables - assign the right table-row element to grid units that are not on the first row spanned - slightly re-worked the RowGroupBuilder interface to make it more SAX-like ................ r631178 | jeremias | 2008-02-26 11:07:20 +0000 (Tue, 26 Feb 2008) | 3 lines Reverted revision 603590 which broke the AFP renderer. The other changes after revision 603590 should be preserved as well as possible, including the switch to the new image library. Adjustments for change in behaviour of the block viewport CTM. Bugfix: SVG painting is now always done on a color canvas (like for PCL) because Batik cannot handle gradients on a grayscale canvas. ................ r631226 | jeremias | 2008-02-26 14:30:50 +0000 (Tue, 26 Feb 2008) | 1 line GOCA support temporarily removed. ................ r631276 | vhennebert | 2008-02-26 16:23:15 +0000 (Tue, 26 Feb 2008) | 2 lines Moved the getBody method into PrimaryGridUnit, since it's only needed there and that allows to simplify EmptyGridUnit ................ r631575 | jeremias | 2008-02-27 13:00:54 +0000 (Wed, 27 Feb 2008) | 2 lines Bugzilla #44497: AFP Renderer: Bugfix for broken reference orientation on absolutely positioned block-containers. ................ r631609 | vhennebert | 2008-02-27 15:09:06 +0000 (Wed, 27 Feb 2008) | 2 lines bpBeforeNormal and bpAfterNormal already include border-separation, no need to re-substract it from the box height ................ r631984 | jeremias | 2008-02-28 14:30:46 +0000 (Thu, 28 Feb 2008) | 2 lines Slight improvement for thin lines in Java2D/AWT output. Submitted by: Gordon Cooke ................ r632121 | adelmelle | 2008-02-28 21:29:04 +0000 (Thu, 28 Feb 2008) | 6 lines Minor tweaks/updates: - change toString() to getLocalizedMessage() for exceptions passed to warning() - removed deprecated method isLocatorDisabled() - removed superfluous try-catch block - some javadoc changes ................ r632122 | adelmelle | 2008-02-28 21:33:11 +0000 (Thu, 28 Feb 2008) | 2 lines Minor tweak: switch from toString() to getLocalizedMessage() for Exceptions passed into warning() ................ r632321 | jeremias | 2008-02-29 14:03:01 +0000 (Fri, 29 Feb 2008) | 1 line Bugfix: Disabled setting widths from AFM since we're using WinAnsiEncoding internally but the AFM delivers the character widths using the font's native encoding which causes problems with some characters. ................ r632558 | clay | 2008-03-01 07:10:03 +0000 (Sat, 01 Mar 2008) | 1 line Preparing for FOP 0.95 release. ................ r632716 | clay | 2008-03-02 06:42:02 +0000 (Sun, 02 Mar 2008) | 1 line Adding Quick Start Guide. ................ r632784 | jeremias | 2008-03-02 16:53:24 +0000 (Sun, 02 Mar 2008) | 1 line Further preparations for the 0.95 release. This was tested with the latest Forrest Trunk (which uses FOP 0.94 for the PDFs). ................ r632938 | clay | 2008-03-03 04:44:28 +0000 (Mon, 03 Mar 2008) | 2 lines Updated the Apache FOP Quick Start to include a 'Hello World' document and make it more geared toward newbies (thanks Jeremias!). ................ r632972 | jeremias | 2008-03-03 07:51:14 +0000 (Mon, 03 Mar 2008) | 1 line Tried to make font configuration easier to understand by splitting the basics from the advanced stuff. Otherwise, people will believe for the next 100 years that generating XML font metrics file is still always necessary. ................ r633389 | jeremias | 2008-03-04 08:37:05 +0000 (Tue, 04 Mar 2008) | 1 line Removed 0.93 and 0.94, added 0.95. There's no noticeable difference between 0.94 and 0.95 so I removed a column to regain some space. ................ r633390 | jeremias | 2008-03-04 08:38:36 +0000 (Tue, 04 Mar 2008) | 1 line Switched to Commons 1.3 being released. ................ r633391 | jeremias | 2008-03-04 08:39:12 +0000 (Tue, 04 Mar 2008) | 1 line Added ApacheCon US 2008. ................ r633396 | jeremias | 2008-03-04 09:06:03 +0000 (Tue, 04 Mar 2008) | 1 line Various updates. ................ r633397 | jeremias | 2008-03-04 09:15:50 +0000 (Tue, 04 Mar 2008) | 1 line Using Forrest Trunk from now on (in order to use FOP 0.94 for PDFs). We'll switch to a stable release as soon as a release with a new FOP version is available. ................ r633437 | jeremias | 2008-03-04 11:50:34 +0000 (Tue, 04 Mar 2008) | 3 lines Renamed to 0.95beta. Made changes and release notes work again by switching to the projectInfo plug-in rather than relying on our local copy of the stylesheets. There's a little bug (missing images) in the release notes for which I submitted a patch (https://issues.apache.org/jira/browse/FOR-1076) to Forrest. Brought status.xml more in line with the official status DTD. ................ r633460 | jeremias | 2008-03-04 12:59:57 +0000 (Tue, 04 Mar 2008) | 1 line Copyright year ................ r633470 | jeremias | 2008-03-04 13:25:12 +0000 (Tue, 04 Mar 2008) | 1 line Noted some of the major change areas in this release. ................ r633473 | jeremias | 2008-03-04 13:40:11 +0000 (Tue, 04 Mar 2008) | 2 lines Ha! Almost forgot the most important change: Java 1.4! Plus a note on image libraries. ................ r633525 | jeremias | 2008-03-04 16:13:17 +0000 (Tue, 04 Mar 2008) | 1 line Bugfix: Without the system ID (base URI), the XSLT processor cannot resolve document(, .) function calls correctly. ................ r633557 | jeremias | 2008-03-04 17:30:40 +0000 (Tue, 04 Mar 2008) | 1 line Bugfix: If there's shrink available in an auto-height situation, the difference is now set to 0 in order to avoid unwanted effects. IOW, never shrink in an auto-height situation. ................ r633559 | jeremias | 2008-03-04 17:35:52 +0000 (Tue, 04 Mar 2008) | 2 lines Update FOP poster for OpenExpo 2008 in Bern. This fixes various warnings, updates the history and simplifies configuration (if you're on Windows, it will work out of the box because all fonts are available). ................ r633561 | jeremias | 2008-03-04 17:39:08 +0000 (Tue, 04 Mar 2008) | 1 line Update README. ................ r633961 | vhennebert | 2008-03-05 18:22:06 +0000 (Wed, 05 Mar 2008) | 5 lines - Fixed the rendering of the area of a table corresponding to border-separation, which must be filled with the background of the table, and not the rows. - Improved conformance: even if a table-cell spans several rows its background must correspond to the first row spanned. - Added support for background on fo:table-column and fo:table-header/footer/body TODO more testcases needed, especially tables with collapsing border model and tables broken over pages ................ r634187 | jeremias | 2008-03-06 08:21:06 +0000 (Thu, 06 Mar 2008) | 1 line Added some notes on getting the same output for PDF/PS and Java2D-based renderers. ................ r635508 | jeremias | 2008-03-10 10:06:37 +0000 (Mon, 10 Mar 2008) | 4 lines Fixed NPE in BlockContainerLayoutManager when used as a child of an inline-level FO. Split IP and BP stack limits in LayoutContext (there's now a certain amount of redundancy with "refIPD" in LayoutContext which I didn't resolve). Areas are now generated for block-level FOs when used as children of inline-level FOs. ClassCastException in ListLayoutManager.mustKeepTogether() fixed (occured if used as child of an inline-level FO). ................ r635686 | vhennebert | 2008-03-10 20:52:43 +0000 (Mon, 10 Mar 2008) | 2 lines Bugfix: forced break ignored when the minimum height of a table-row isn't reached ................ r635701 | jeremias | 2008-03-10 21:28:08 +0000 (Mon, 10 Mar 2008) | 1 line Need to clean up after myself. ................ r635741 | jeremias | 2008-03-10 22:39:38 +0000 (Mon, 10 Mar 2008) | 1 line Bugfix for row/body/col background painting when padding is used in the table-cells. ................ r635884 | vhennebert | 2008-03-11 11:02:27 +0000 (Tue, 11 Mar 2008) | 2 lines Fixed a copy-paste error (getPaddingStart instead of getPaddingEnd) ................ r635961 | vhennebert | 2008-03-11 15:05:27 +0000 (Tue, 11 Mar 2008) | 2 lines Forgot to add the testcase for forced break vs explicit row height in revision 635686 ................ r635967 | vhennebert | 2008-03-11 15:13:51 +0000 (Tue, 11 Mar 2008) | 2 lines Updated the disabled-testcases.xml file: re-enabled testcases which could easily be updated, removed the other ones which anyway were superseded by more complete ones ................ r636276 | vhennebert | 2008-03-12 10:51:09 +0000 (Wed, 12 Mar 2008) | 2 lines Since compliance.ihtml is now the source file and it would cost too much to revert to an xml version, tidied the file a bit. No content change. ................ r636293 | vhennebert | 2008-03-12 12:14:51 +0000 (Wed, 12 Mar 2008) | 2 lines Updated the compliance page. Re-added the 0.94 column since there are some noteworthy changes between the 0.94 and 0.95 versions ................ r636295 | vhennebert | 2008-03-12 12:19:15 +0000 (Wed, 12 Mar 2008) | 3 lines Update of the documentation before the release. Added notes about improved checks and conformance in tables. ................ r636405 | vhennebert | 2008-03-12 16:25:52 +0000 (Wed, 12 Mar 2008) | 2 lines Initialized merge tracking via "svnmerge" from the 0.95 branch ................ r636409 | vhennebert | 2008-03-12 16:36:29 +0000 (Wed, 12 Mar 2008) | 8 lines Blocked revisions 636406 via svnmerge ........ r636406 | vhennebert | 2008-03-12 16:28:00 +0000 (Wed, 12 Mar 2008) | 2 lines Set the version to 0.95beta ........ ................ r636471 | vhennebert | 2008-03-12 19:24:05 +0000 (Wed, 12 Mar 2008) | 2 lines Removed no longer used borderAndPaddingBPD field ................ r637057 | jeremias | 2008-03-14 11:15:24 +0000 (Fri, 14 Mar 2008) | 2 lines Bugzilla #44412: Bugfix: When there was a forced break after a block with (conditional) borders the border-after wasn't painted. ................ r637076 | vhennebert | 2008-03-14 12:22:44 +0000 (Fri, 14 Mar 2008) | 2 lines Reverting changes of rev. 637057. I applied the changes to the 0.95 branch instead so that they make their way into the 0.95 release. I will merge them back to the Trunk via svnmerge ................ r638396 | vhennebert | 2008-03-18 15:01:43 +0000 (Tue, 18 Mar 2008) | 53 lines Merged revisions 636400-636405,636407-638388 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95 ........ r636403 | vhennebert | 2008-03-12 16:24:48 +0000 (Wed, 12 Mar 2008) | 2 lines Updated copyright years ........ r637075 | vhennebert | 2008-03-14 12:19:45 +0000 (Fri, 14 Mar 2008) | 4 lines Bugzilla #44412: Bugfix: When there was a forced break after a block with (conditional) borders the border-after wasn't painted. Changes made by Jeremias ........ r637119 | jeremias | 2008-03-14 14:41:03 +0000 (Fri, 14 Mar 2008) | 2 lines Bugzilla #44412: Bugfix: The before border of a block is no longer swallowed if its first child issues a break-before. ........ r637791 | jeremias | 2008-03-17 08:59:51 +0000 (Mon, 17 Mar 2008) | 3 lines Removed old image adapters. Removed support for Java 1.3 building as it didn't work anymore anyway. Added a check to require Java 1.4 for building. ........ r637857 | jeremias | 2008-03-17 12:24:33 +0000 (Mon, 17 Mar 2008) | 3 lines Partially reverted revision 637791: Restored JAI as a required dependency for distribution builds (used for error diffusion dithering in the PCL Renderer). It is optional otherwise. Updated the licensing info and release notes to make the changes clear. ........ r637993 | vhennebert | 2008-03-17 17:48:44 +0000 (Mon, 17 Mar 2008) | 3 lines Bugzilla #44621: when the after border of a cell, in the trailing case, is bigger than in the normal case, the generated sequence of Knuth elements was wrong, leading to content being swallowed This is a partial fix only: the content is no longer swallowed, but the penalty is wrong (shorter than it should be). This will lead to the table overflowing the region-body without warning. ........ r638048 | vhennebert | 2008-03-17 20:00:36 +0000 (Mon, 17 Mar 2008) | 2 lines Changed the documentation to reflect the move to Java 1.4 as a minimum requirement ........ r638308 | vhennebert | 2008-03-18 10:26:32 +0000 (Tue, 18 Mar 2008) | 2 lines Simplified the getNextKnuthElements method a little bit ........ r638316 | vhennebert | 2008-03-18 11:06:59 +0000 (Tue, 18 Mar 2008) | 2 lines Removed the 'jdk1.4' suffix appended to the binary artifacts. There's no point in making the distinction anymore since there is only one binary now ........ r638317 | vhennebert | 2008-03-18 11:08:29 +0000 (Tue, 18 Mar 2008) | 2 lines Updated the probable date of the release ........ ................ r640089 | clay | 2008-03-22 21:54:27 +0000 (Sat, 22 Mar 2008) | 1 line updates to Forrest web site (expand menu structure). ................ r640242 | adelmelle | 2008-03-23 19:36:36 +0000 (Sun, 23 Mar 2008) | 11 lines Cleanup and minor refactoring: * consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... ................ r641742 | jeremias | 2008-03-27 08:49:41 +0000 (Thu, 27 Mar 2008) | 6 lines Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. Typeface: getEncoding() changed to getEncodingName() to make clearer what is held here. Some cleanup in the font classes to put the various things in more appropriate places. Created a common base class for all Base 14 fonts (makes the hierarchy clearer). Made PDFTextUtil more universally useful and made use of it in PDFRenderer, too. Made PDFStream.add(String) more efficient. The encoding converter is not called for each invocation anymore as the whole thing get buffered by a BufferedWriter (as suggested by the javadoc of OutputStreamWriter). ................ r641764 | maxberger | 2008-03-27 10:02:25 +0000 (Thu, 27 Mar 2008) | 1 line Added my key ................ r641827 | jeremias | 2008-03-27 14:29:44 +0000 (Thu, 27 Mar 2008) | 2 lines When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which are not sRGB. The images drifted into yellow. The color profile is simply disabled in this case. Please let us know if you know what the problem could be. ................ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@643433 13f79535-47bb-0310-9956-ffa450edef68 --- KEYS | 24 +- README | 40 + build.properties | 4 +- build.xml | 80 +- fop.bat | 2 +- forrest.properties | 7 +- forrest.properties.xml | 22 + lib/README.txt | 14 +- lib/xmlgraphics-commons-1.3svn.jar | Bin 510302 -> 0 bytes lib/xmlgraphics-commons-1.4svn.jar | Bin 0 -> 511830 bytes src/codegen/fonts/font-file.xsl | 6 +- src/documentation/content/.htaccess | 4 +- src/documentation/content/doap.rdf | 8 +- src/documentation/content/xdocs/0.93/anttask.xml | 197 - src/documentation/content/xdocs/0.93/compiling.xml | 140 - .../content/xdocs/0.93/configuration.xml | 335 - src/documentation/content/xdocs/0.93/embedding.xml | 682 - .../content/xdocs/0.93/extensions.xml | 125 - src/documentation/content/xdocs/0.93/fonts.xml | 298 - .../xdocs/0.93/fotree/disabled-testcases.xml | 31 - src/documentation/content/xdocs/0.93/graphics.xml | 338 - .../content/xdocs/0.93/hyphenation.xml | 237 - src/documentation/content/xdocs/0.93/index.xml | 54 - .../content/xdocs/0.93/intermediate.xml | 146 - .../content/xdocs/0.93/known-issues.xml | 102 - .../content/xdocs/0.93/knownissues_overview.xml | 72 - .../xdocs/0.93/layoutengine/disabled-testcases.xml | 328 - src/documentation/content/xdocs/0.93/output.xml | 772 -- src/documentation/content/xdocs/0.93/pdfa.xml | 133 - .../content/xdocs/0.93/pdfencryption.xml | 234 - src/documentation/content/xdocs/0.93/pdfx.xml | 136 - src/documentation/content/xdocs/0.93/running.xml | 349 - src/documentation/content/xdocs/0.93/servlets.xml | 260 - src/documentation/content/xdocs/0.93/upgrading.xml | 136 - src/documentation/content/xdocs/0.94/index.xml | 2 +- src/documentation/content/xdocs/0.95/anttask.xml | 197 + src/documentation/content/xdocs/0.95/compiling.xml | 141 + .../content/xdocs/0.95/configuration.xml | 394 + src/documentation/content/xdocs/0.95/embedding.xml | 689 + .../content/xdocs/0.95/extensions.xml | 234 + src/documentation/content/xdocs/0.95/fonts.xml | 410 + .../xdocs/0.95/fotree/disabled-testcases.xml | 26 + src/documentation/content/xdocs/0.95/graphics.xml | 551 + .../content/xdocs/0.95/hyphenation.xml | 237 + src/documentation/content/xdocs/0.95/index.xml | 54 + .../content/xdocs/0.95/intermediate.xml | 146 + .../content/xdocs/0.95/known-issues.xml | 70 + .../content/xdocs/0.95/knownissues_overview.xml | 70 + .../xdocs/0.95/layoutengine/disabled-testcases.xml | 260 + src/documentation/content/xdocs/0.95/output.xml | 888 ++ src/documentation/content/xdocs/0.95/pdfa.xml | 159 + .../content/xdocs/0.95/pdfencryption.xml | 225 + src/documentation/content/xdocs/0.95/pdfx.xml | 136 + src/documentation/content/xdocs/0.95/running.xml | 350 + src/documentation/content/xdocs/0.95/servlets.xml | 325 + src/documentation/content/xdocs/0.95/upgrading.xml | 126 + src/documentation/content/xdocs/compliance.ihtml | 12770 +++++++++++-------- src/documentation/content/xdocs/dev/doc.xml | 4 +- src/documentation/content/xdocs/dev/release.xml | 2 +- src/documentation/content/xdocs/download.xml | 21 +- src/documentation/content/xdocs/faq.xml | 15 + src/documentation/content/xdocs/index.xml | 7 +- .../content/xdocs/quickstartguide.xml | 124 + src/documentation/content/xdocs/site.xml | 25 +- src/documentation/content/xdocs/status.xml | 8 +- src/documentation/content/xdocs/tabs.xml | 8 +- src/documentation/content/xdocs/team.xml | 32 +- .../content/xdocs/trunk/compiling.xml | 4 +- src/documentation/content/xdocs/trunk/fonts.xml | 210 +- src/documentation/content/xdocs/trunk/output.xml | 29 + .../content/xdocs/trunk/pdfencryption.xml | 6 +- src/documentation/content/xdocs/trunk/running.xml | 2 +- src/documentation/poster/README.txt | 5 +- src/documentation/poster/cfg/README.txt | 7 - src/documentation/poster/cfg/VERDANA.ttf.xml | 1817 --- src/documentation/poster/cfg/VERDANAB.ttf.xml | 1167 -- src/documentation/poster/cfg/fop.xconf | 12 +- src/documentation/poster/cfg/lucon.ttf.xml | 925 -- .../poster/svg/pepe-business-card.svg | 3 +- .../poster/xml/business-card-demo.xml | 19 +- src/documentation/poster/xml/fop-history.xml | 11 +- src/documentation/poster/xml/fop-poster.xml | 10 +- .../poster/xml/fop-transformation-chain.xml | 2 +- src/documentation/poster/xml/fop-use-cases.xml | 3 +- src/documentation/poster/xslt/common.xsl | 6 +- src/documentation/poster/xslt/fop-poster.xsl | 13 +- src/documentation/sitemap.xmap | 43 +- src/documentation/skinconf.xml | 20 +- .../org/apache/fop/svg/GraphicsConfiguration.java | 31 - .../org/apache/fop/image/ImageIOImage.java | 237 - .../org/apache/fop/image/JpegImageIOImage.java | 161 - .../org/apache/fop/svg/GraphicsConfiguration.java | 51 - src/java/org/apache/fop/apps/FopFactory.java | 10 - src/java/org/apache/fop/cli/InputHandler.java | 8 +- src/java/org/apache/fop/fo/ElementMapping.java | 6 +- src/java/org/apache/fop/fo/FOPropertyMapping.java | 6 + src/java/org/apache/fop/fo/FOTreeBuilder.java | 104 +- .../apache/fop/fo/flow/table/EmptyGridUnit.java | 7 - .../org/apache/fop/fo/flow/table/GridUnit.java | 9 - .../apache/fop/fo/flow/table/PrimaryGridUnit.java | 26 +- .../fop/fo/properties/CommonHyphenation.java | 5 +- .../fop/fo/properties/XMLLangShorthandParser.java | 2 +- .../apache/fop/fonts/AbstractCodePointMapping.java | 23 +- src/java/org/apache/fop/fonts/Base14Font.java | 27 + src/java/org/apache/fop/fonts/CIDFont.java | 33 +- src/java/org/apache/fop/fonts/CIDSubset.java | 177 + src/java/org/apache/fop/fonts/Font.java | 2 +- src/java/org/apache/fop/fonts/LazyFont.java | 24 +- src/java/org/apache/fop/fonts/MultiByteFont.java | 156 +- src/java/org/apache/fop/fonts/NamedCharacter.java | 142 + .../apache/fop/fonts/SimpleSingleByteEncoding.java | 145 + .../org/apache/fop/fonts/SingleByteEncoding.java | 50 + src/java/org/apache/fop/fonts/SingleByteFont.java | 214 +- src/java/org/apache/fop/fonts/Typeface.java | 7 +- .../apache/fop/fonts/truetype/TTFSubSetFile.java | 19 +- .../org/apache/fop/fonts/type1/AFMCharMetrics.java | 46 +- src/java/org/apache/fop/fonts/type1/AFMFile.java | 12 +- src/java/org/apache/fop/fonts/type1/AFMParser.java | 17 +- .../apache/fop/fonts/type1/Type1FontLoader.java | 33 +- .../org/apache/fop/image/AbstractFopImage.java | 376 - src/java/org/apache/fop/image/BmpImage.java | 220 - src/java/org/apache/fop/image/EPSImage.java | 122 - src/java/org/apache/fop/image/EmfImage.java | 51 - src/java/org/apache/fop/image/FopImage.java | 207 - .../org/apache/fop/image/FopImageConsumer.java | 211 - src/java/org/apache/fop/image/GifImage.java | 218 - src/java/org/apache/fop/image/ImageCache.java | 72 - src/java/org/apache/fop/image/ImageFactory.java | 708 - src/java/org/apache/fop/image/ImageLoader.java | 64 - src/java/org/apache/fop/image/JAIImage.java | 194 - src/java/org/apache/fop/image/JimiImage.java | 186 - src/java/org/apache/fop/image/JpegImage.java | 239 - src/java/org/apache/fop/image/PNGImage.java | 87 - .../fop/image/RegisterableImageProvider.java | 49 - src/java/org/apache/fop/image/TIFFImage.java | 207 - src/java/org/apache/fop/image/XMLImage.java | 78 - .../apache/fop/image/XmlGraphicsCommonsImage.java | 239 - .../org/apache/fop/image/analyser/BMPReader.java | 134 - .../org/apache/fop/image/analyser/EMFReader.java | 162 - .../org/apache/fop/image/analyser/EPSReader.java | 253 - .../org/apache/fop/image/analyser/GIFReader.java | 104 - .../org/apache/fop/image/analyser/ImageReader.java | 56 - .../fop/image/analyser/ImageReaderFactory.java | 108 - .../org/apache/fop/image/analyser/JPEGReader.java | 264 - .../org/apache/fop/image/analyser/PNGReader.java | 115 - .../org/apache/fop/image/analyser/SVGReader.java | 188 - .../org/apache/fop/image/analyser/SVGZReader.java | 53 - .../org/apache/fop/image/analyser/TIFFReader.java | 117 - .../org/apache/fop/image/analyser/XMLReader.java | 167 - .../org/apache/fop/image/analyser/package.html | 23 - src/java/org/apache/fop/image/package.html | 2 +- .../org/apache/fop/layoutmgr/AbstractBreaker.java | 4 +- .../fop/layoutmgr/AbstractLayoutManager.java | 16 +- .../org/apache/fop/layoutmgr/AreaAdditionUtil.java | 2 +- .../fop/layoutmgr/BlockContainerLayoutManager.java | 54 +- .../apache/fop/layoutmgr/BlockLayoutManager.java | 11 +- .../fop/layoutmgr/BlockStackingLayoutManager.java | 21 +- .../apache/fop/layoutmgr/FlowLayoutManager.java | 2 +- .../org/apache/fop/layoutmgr/LayoutContext.java | 108 +- .../org/apache/fop/layoutmgr/MinOptMaxUtil.java | 13 +- src/java/org/apache/fop/layoutmgr/PageBreaker.java | 2 +- .../fop/layoutmgr/PageBreakingAlgorithm.java | 8 +- .../fop/layoutmgr/StaticContentLayoutManager.java | 8 +- src/java/org/apache/fop/layoutmgr/TraitSetter.java | 87 +- .../inline/AbstractGraphicsLayoutManager.java | 7 - .../AbstractPageNumberCitationLayoutManager.java | 17 +- .../layoutmgr/inline/CharacterLayoutManager.java | 23 +- .../fop/layoutmgr/inline/ContentLayoutManager.java | 24 +- .../fop/layoutmgr/inline/ICLayoutManager.java | 5 - .../fop/layoutmgr/inline/InlineLayoutManager.java | 18 +- .../inline/InlineStackingLayoutManager.java | 26 +- .../fop/layoutmgr/inline/LeaderLayoutManager.java | 5 - .../layoutmgr/inline/LeafNodeLayoutManager.java | 10 - .../fop/layoutmgr/inline/LineLayoutManager.java | 14 +- .../layoutmgr/inline/PageNumberLayoutManager.java | 6 +- .../fop/layoutmgr/list/ListBlockLayoutManager.java | 36 +- .../list/ListItemContentLayoutManager.java | 30 +- .../fop/layoutmgr/list/ListItemLayoutManager.java | 58 +- .../org/apache/fop/layoutmgr/table/ActiveCell.java | 144 +- .../fop/layoutmgr/table/RowGroupLayoutManager.java | 220 +- .../org/apache/fop/layoutmgr/table/RowPainter.java | 116 +- .../table/TableAndCaptionLayoutManager.java | 7 +- .../layoutmgr/table/TableCaptionLayoutManager.java | 5 +- .../layoutmgr/table/TableCellLayoutManager.java | 123 +- .../layoutmgr/table/TableContentLayoutManager.java | 164 +- .../fop/layoutmgr/table/TableContentPosition.java | 7 + .../layoutmgr/table/TableHFPenaltyPosition.java | 5 + .../layoutmgr/table/TableHeaderFooterPosition.java | 5 + .../fop/layoutmgr/table/TableLayoutManager.java | 75 +- src/java/org/apache/fop/pdf/PDFCMap.java | 5 +- src/java/org/apache/fop/pdf/PDFEncoding.java | 8 + src/java/org/apache/fop/pdf/PDFFactory.java | 133 +- src/java/org/apache/fop/pdf/PDFResources.java | 2 +- src/java/org/apache/fop/pdf/PDFStream.java | 38 +- src/java/org/apache/fop/pdf/PDFTTFStream.java | 2 +- src/java/org/apache/fop/pdf/PDFTextUtil.java | 295 + .../fop/render/AbstractGenericSVGHandler.java | 2 +- .../org/apache/fop/render/afp/AFPRenderer.java | 22 +- .../fop/render/afp/AFPRendererConfigurator.java | 3 +- .../org/apache/fop/render/afp/AFPSVGHandler.java | 10 +- .../fop/render/afp/extensions/AFPElement.java | 7 +- .../render/afp/extensions/AFPElementMapping.java | 18 +- .../render/afp/extensions/AFPExtensionHandler.java | 2 +- .../apache/fop/render/afp/fonts/OutlineFont.java | 7 +- .../apache/fop/render/afp/fonts/RasterFont.java | 7 +- .../fop/render/afp/modca/AbstractAFPObject.java | 10 +- .../fop/render/afp/modca/AbstractDescriptor.java | 14 +- .../render/afp/modca/AbstractNamedAFPObject.java | 23 +- .../fop/render/afp/modca/AbstractPageObject.java | 2 +- .../apache/fop/render/afp/modca/ImageContent.java | 98 +- .../fop/render/afp/modca/ImageDataDescriptor.java | 81 +- .../apache/fop/render/afp/modca/ImageSegment.java | 2 +- .../fop/render/afp/modca/ObjectAreaDescriptor.java | 21 +- .../fop/render/afp/modca/PageDescriptor.java | 12 +- .../apache/fop/render/afp/modca/PageObject.java | 8 +- .../fop/render/afp/modca/PresentationTextData.java | 122 +- .../afp/modca/PresentationTextDescriptor.java | 13 +- .../render/afp/modca/PresentationTextObject.java | 3 +- .../render/afp/modca/TagLogicalElementBean.java | 4 +- .../fop/render/java2d/CustomFontMetricsMapper.java | 2 +- .../apache/fop/render/java2d/Java2DRenderer.java | 2 + .../fop/render/java2d/SystemFontMetricsMapper.java | 2 +- .../fop/render/pdf/AbstractImageAdapter.java | 10 +- .../apache/fop/render/pdf/ImageRawJPEGAdapter.java | 101 +- .../fop/render/pdf/PDFGraphics2DAdapter.java | 4 +- .../org/apache/fop/render/pdf/PDFRenderer.java | 258 +- src/java/org/apache/fop/render/ps/PSFontUtils.java | 128 +- .../org/apache/fop/render/ps/PSImageUtils.java | 73 - src/java/org/apache/fop/render/ps/PSRenderer.java | 91 +- .../org/apache/fop/render/rtf/SVGConverter.java | 70 - .../org/apache/fop/svg/GraphicsConfiguration.java | 51 + src/java/org/apache/fop/svg/PDFGraphics2D.java | 11 +- src/java/org/apache/fop/svg/PDFTextPainter.java | 11 +- src/java/org/apache/fop/svg/PDFTextUtil.java | 231 +- status.xml | 259 +- .../java/org/apache/fop/URIResolutionTestCase.java | 11 +- .../apache/fop/render/pdf/PDFEncodingTestCase.java | 6 +- test/layoutengine/disabled-testcases.xml | 48 - ...ock-container_absolute-position_no-height_3.xml | 63 + .../block-level_break-after_bug44412.xml | 112 + .../block_break-before_bug44412.xml | 64 + .../inline_block-level_nested_1.xml | 104 + .../table-body_background-image.xml | 110 - .../table-cell_block_keep-with-previous.xml | 85 - .../table-cell_conditional-spaces_2.xml | 64 +- .../table-footer_omit-footer-at-break.xml | 38 +- .../table-header_background-image.xml | 101 - .../table-header_omit-header-at-break.xml | 34 +- .../table-header_table-footer_1.xml | 40 +- .../table-header_table-footer_2.xml | 46 +- .../table-row_background-image.xml | 20 +- .../standard-testcases/table-row_height.xml | 34 +- .../table-row_keep-with-previous.xml | 250 +- .../standard-testcases/table_backgrounds.xml | 392 + .../standard-testcases/table_backgrounds_2.xml | 113 + .../table_border-collapse_collapse_1.xml | 130 - .../table_border-collapse_collapse_2.xml | 70 - .../table_border-collapse_separate_1.xml | 2 +- .../standard-testcases/table_border_padding.xml | 28 +- .../standard-testcases/table_bug44621.xml | 105 + .../table_row-delay_fixed-row-height.xml | 6 +- .../standard-testcases/table_row-height_break.xml | 87 + 262 files changed, 18053 insertions(+), 23274 deletions(-) create mode 100644 forrest.properties.xml delete mode 100644 lib/xmlgraphics-commons-1.3svn.jar create mode 100644 lib/xmlgraphics-commons-1.4svn.jar delete mode 100644 src/documentation/content/xdocs/0.93/anttask.xml delete mode 100644 src/documentation/content/xdocs/0.93/compiling.xml delete mode 100644 src/documentation/content/xdocs/0.93/configuration.xml delete mode 100644 src/documentation/content/xdocs/0.93/embedding.xml delete mode 100644 src/documentation/content/xdocs/0.93/extensions.xml delete mode 100644 src/documentation/content/xdocs/0.93/fonts.xml delete mode 100644 src/documentation/content/xdocs/0.93/fotree/disabled-testcases.xml delete mode 100644 src/documentation/content/xdocs/0.93/graphics.xml delete mode 100644 src/documentation/content/xdocs/0.93/hyphenation.xml delete mode 100644 src/documentation/content/xdocs/0.93/index.xml delete mode 100644 src/documentation/content/xdocs/0.93/intermediate.xml delete mode 100644 src/documentation/content/xdocs/0.93/known-issues.xml delete mode 100644 src/documentation/content/xdocs/0.93/knownissues_overview.xml delete mode 100644 src/documentation/content/xdocs/0.93/layoutengine/disabled-testcases.xml delete mode 100644 src/documentation/content/xdocs/0.93/output.xml delete mode 100644 src/documentation/content/xdocs/0.93/pdfa.xml delete mode 100644 src/documentation/content/xdocs/0.93/pdfencryption.xml delete mode 100644 src/documentation/content/xdocs/0.93/pdfx.xml delete mode 100644 src/documentation/content/xdocs/0.93/running.xml delete mode 100644 src/documentation/content/xdocs/0.93/servlets.xml delete mode 100644 src/documentation/content/xdocs/0.93/upgrading.xml create mode 100644 src/documentation/content/xdocs/0.95/anttask.xml create mode 100644 src/documentation/content/xdocs/0.95/compiling.xml create mode 100644 src/documentation/content/xdocs/0.95/configuration.xml create mode 100644 src/documentation/content/xdocs/0.95/embedding.xml create mode 100644 src/documentation/content/xdocs/0.95/extensions.xml create mode 100644 src/documentation/content/xdocs/0.95/fonts.xml create mode 100644 src/documentation/content/xdocs/0.95/fotree/disabled-testcases.xml create mode 100644 src/documentation/content/xdocs/0.95/graphics.xml create mode 100644 src/documentation/content/xdocs/0.95/hyphenation.xml create mode 100644 src/documentation/content/xdocs/0.95/index.xml create mode 100644 src/documentation/content/xdocs/0.95/intermediate.xml create mode 100644 src/documentation/content/xdocs/0.95/known-issues.xml create mode 100644 src/documentation/content/xdocs/0.95/knownissues_overview.xml create mode 100644 src/documentation/content/xdocs/0.95/layoutengine/disabled-testcases.xml create mode 100644 src/documentation/content/xdocs/0.95/output.xml create mode 100644 src/documentation/content/xdocs/0.95/pdfa.xml create mode 100644 src/documentation/content/xdocs/0.95/pdfencryption.xml create mode 100644 src/documentation/content/xdocs/0.95/pdfx.xml create mode 100644 src/documentation/content/xdocs/0.95/running.xml create mode 100644 src/documentation/content/xdocs/0.95/servlets.xml create mode 100644 src/documentation/content/xdocs/0.95/upgrading.xml create mode 100644 src/documentation/content/xdocs/quickstartguide.xml delete mode 100644 src/documentation/poster/cfg/README.txt delete mode 100644 src/documentation/poster/cfg/VERDANA.ttf.xml delete mode 100644 src/documentation/poster/cfg/VERDANAB.ttf.xml delete mode 100644 src/documentation/poster/cfg/lucon.ttf.xml delete mode 100644 src/java-1.3/org/apache/fop/svg/GraphicsConfiguration.java delete mode 100644 src/java-1.4/org/apache/fop/image/ImageIOImage.java delete mode 100644 src/java-1.4/org/apache/fop/image/JpegImageIOImage.java delete mode 100644 src/java-1.4/org/apache/fop/svg/GraphicsConfiguration.java create mode 100644 src/java/org/apache/fop/fonts/Base14Font.java create mode 100644 src/java/org/apache/fop/fonts/CIDSubset.java create mode 100644 src/java/org/apache/fop/fonts/NamedCharacter.java create mode 100644 src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java create mode 100644 src/java/org/apache/fop/fonts/SingleByteEncoding.java delete mode 100644 src/java/org/apache/fop/image/AbstractFopImage.java delete mode 100644 src/java/org/apache/fop/image/BmpImage.java delete mode 100644 src/java/org/apache/fop/image/EPSImage.java delete mode 100644 src/java/org/apache/fop/image/EmfImage.java delete mode 100644 src/java/org/apache/fop/image/FopImage.java delete mode 100644 src/java/org/apache/fop/image/FopImageConsumer.java delete mode 100644 src/java/org/apache/fop/image/GifImage.java delete mode 100644 src/java/org/apache/fop/image/ImageCache.java delete mode 100644 src/java/org/apache/fop/image/ImageFactory.java delete mode 100644 src/java/org/apache/fop/image/ImageLoader.java delete mode 100644 src/java/org/apache/fop/image/JAIImage.java delete mode 100644 src/java/org/apache/fop/image/JimiImage.java delete mode 100644 src/java/org/apache/fop/image/JpegImage.java delete mode 100644 src/java/org/apache/fop/image/PNGImage.java delete mode 100644 src/java/org/apache/fop/image/RegisterableImageProvider.java delete mode 100644 src/java/org/apache/fop/image/TIFFImage.java delete mode 100644 src/java/org/apache/fop/image/XMLImage.java delete mode 100644 src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java delete mode 100644 src/java/org/apache/fop/image/analyser/BMPReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/EMFReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/EPSReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/GIFReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/ImageReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/ImageReaderFactory.java delete mode 100644 src/java/org/apache/fop/image/analyser/JPEGReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/PNGReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/SVGReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/SVGZReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/TIFFReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/XMLReader.java delete mode 100644 src/java/org/apache/fop/image/analyser/package.html create mode 100644 src/java/org/apache/fop/pdf/PDFTextUtil.java delete mode 100644 src/java/org/apache/fop/render/ps/PSImageUtils.java delete mode 100644 src/java/org/apache/fop/render/rtf/SVGConverter.java create mode 100644 src/java/org/apache/fop/svg/GraphicsConfiguration.java create mode 100644 test/layoutengine/standard-testcases/block-container_absolute-position_no-height_3.xml create mode 100644 test/layoutengine/standard-testcases/block-level_break-after_bug44412.xml create mode 100644 test/layoutengine/standard-testcases/block_break-before_bug44412.xml create mode 100644 test/layoutengine/standard-testcases/inline_block-level_nested_1.xml delete mode 100644 test/layoutengine/standard-testcases/table-body_background-image.xml delete mode 100644 test/layoutengine/standard-testcases/table-cell_block_keep-with-previous.xml delete mode 100644 test/layoutengine/standard-testcases/table-header_background-image.xml create mode 100644 test/layoutengine/standard-testcases/table_backgrounds.xml create mode 100644 test/layoutengine/standard-testcases/table_backgrounds_2.xml delete mode 100644 test/layoutengine/standard-testcases/table_border-collapse_collapse_1.xml delete mode 100644 test/layoutengine/standard-testcases/table_border-collapse_collapse_2.xml create mode 100644 test/layoutengine/standard-testcases/table_bug44621.xml create mode 100644 test/layoutengine/standard-testcases/table_row-height_break.xml (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/KEYS b/KEYS index f49f8d6be..c11ca63c3 100644 --- a/KEYS +++ b/KEYS @@ -19,7 +19,8 @@ pub 1024D/5F298824 2006-09-30 Simon Pepping sub 2048g/40F32100 2006-09-30 pub 1024D/4358C584 2006-12-08 Vincent Hennebert sub 2048g/0BD6AC9B 2006-12-08 - +pub 1024D/CC31AE97 2008-03-27 [expires: 2011-01-01] +uid Maximilian Berger -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.0.6 (GNU/Linux) @@ -167,3 +168,24 @@ SQQYEQIACQUCRXmZwgIbDAAKCRCgctTQQ1jFhBc3AKCQ1X7oIVR8g7GvSGEUw6DE HgEaUgCgkl30lcl9gGa9hqk4cuGYn1OTyks= =XphF -----END PGP PUBLIC KEY BLOCK----- + +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.7 (OpenBSD) + +mQGiBEfrX/ARBADulGs9V7StbfK8CFfClihdh4lRpw2tktMuYiQJ/rIsNq4zghkT +UGxFU0eUC2ZVPYvwG6sXgZ5SSm6i8Ii79YdIIxUG7oNwXaY/e9rK+xX193xqmDgl +Vh5vm4LUtncHi9TZDSF+g1YU1DVHbSjTd2oQEHxbBppL0CLfaLv3U1qr2wCgxeGw +ZIwb6KD6yesRLx6vGDkDzAMEAL99p0m4sNnjZdKC25Rrt6NZ7CROXWs89/+dkewg +JCZiVEoAcdSa0z5d8+XaSzmqR8BJWM1PBPjG48eEdqOevwypd0F/U1mwZ42MvQEw +oBayUY+7/pptW7C5L3Fjk18drE0a8lIzt9VBGX5fe3GoXtZKuOzDv0hEuHyzR9q9 +JLXsA/sELFfrHf0tBfXAdE7pj/Mahalu17/GAyb0RHSvuOfoUvXSXZA91cFg8ycB +4x265NtYZk52M32wi5ePrYeSJIZ6vWRvPuWVAXDg5S6HCMjcXc6ElkgLcUt1NoPI +DmRXe4FIDZkGSYSXdLTUByu7+8fCuWQHCFG2sALdOyVlucij2LQoTWF4aW1pbGlh +biBCZXJnZXIgPG1heGJlcmdlckBhcGFjaGUub3JnPohmBBMRAgAmBQJH61/wAhsD +BQkFM4sABgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQ4+RAT8wxrpcs1wCeIAoI +B0MwZfWLV+wD3pt1wDkPXbsAnjuOsyZ7EeNOcpoqSteB17aPRGeLiEYEEBECAAYF +Akfrb00ACgkQByq3OugVkrx76ACgqJ8W64IhBYgBvp3dTDLS825gCQQAnjB6X5+4 +eW/0pQUpJcvolxbT9xvF +=bbQO +-----END PGP PUBLIC KEY BLOCK----- + diff --git a/README b/README index 67a3b0fe1..133232276 100644 --- a/README +++ b/README @@ -90,6 +90,46 @@ http://xmlgraphics.apache.org/fop/stable/running.html RELEASE NOTES ============================================================================== +Version 0.95beta +================ + +This is a pre-version of the third production grade release of the new FOP +codebase. It contains many bug fixes and new features. See below for details. + +Compliance +---------- + +This release implements the XSL 1.0 and 1.1 recommendations to a high +degree of compliance. See the compliance page +http://xmlgraphics.apache.org/fop/compliance.html for a detailed +overview. + +Known issues +------------ + +The known issues of this release are listed at +http://xmlgraphics.apache.org/fop/0.95/knownissues_overview.html. + +Major Changes in Version 0.95 +----------------------------- + +* Add new fox:external-document extension element that allows to insert whole + documents into a page-sequence (JM) +* Add support for background on fo:table-column and fo:table-header/footer/body + elements (VH) +* Add support for conditional borders in tables (VH) +* Add support for scale-down-to-fit and scale-up-to-fit (JM) +* Fix various bugs and performance problems with external graphics by + introducing a new image loading framework (JM) + +The long list of changes in this release is available at +http://xmlgraphics.apache.org/fop/0.95/changes_0.95.html. + +The long list of changes in this and earlier releases is available at +http://xmlgraphics.apache.org/fop/changes.html. + + + Version 0.94 ============ diff --git a/build.properties b/build.properties index 06630b4b3..2a8b4c80c 100644 --- a/build.properties +++ b/build.properties @@ -24,8 +24,8 @@ # javac.debug = on # javac.optimize = off # javac.deprecation = on -# javac.source = 1.3 -# javac.target = 1.3 +# javac.source = 1.4 +# javac.target = 1.4 # javac.fork = on ## JUnit task switches diff --git a/build.xml b/build.xml index 18bf3e8d7..2169003f8 100644 --- a/build.xml +++ b/build.xml @@ -131,10 +131,6 @@ list of possible build targets. - - - - @@ -148,7 +144,7 @@ list of possible build targets. - + @@ -214,7 +210,7 @@ list of possible build targets. - + @@ -224,18 +220,6 @@ list of possible build targets. - - - - - - - - - - - @@ -261,7 +245,8 @@ list of possible build targets. - + + @@ -292,22 +277,6 @@ list of possible build targets. - - - - - - - - - - - - - - - - @@ -401,12 +370,9 @@ list of possible build targets. source="${javac.source}" target="${javac.target}"> - - - @@ -543,7 +509,6 @@ list of possible build targets. - @@ -1032,7 +997,6 @@ NOTE: - @@ -1206,37 +1170,24 @@ NOTE: --> - - - - - - - - - - - - - - - - + - + - - - + + + + + @@ -1252,10 +1203,9 @@ NOTE: - - + + destfile="${name}-${version}-bin.tar"> @@ -1264,8 +1214,8 @@ NOTE: - - + + diff --git a/fop.bat b/fop.bat index 774e2a8b6..c2444a083 100644 --- a/fop.bat +++ b/fop.bat @@ -61,7 +61,7 @@ set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xercesImpl-2.7.1.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan-2.7.0.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\serializer-2.7.0.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\batik-all-1.7.jar -set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xmlgraphics-commons-1.3svn.jar +set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xmlgraphics-commons-1.4svn.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\avalon-framework-4.2.0.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-1.3.1.jar set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-logging-1.0.4.jar diff --git a/forrest.properties b/forrest.properties index 537cb15e3..add080783 100644 --- a/forrest.properties +++ b/forrest.properties @@ -56,7 +56,7 @@ project.skin=pelt #project.images-dir=${project.resources-dir}/images #project.schema-dir=${project.resources-dir}/schema #project.skins-dir=${project.content-dir}/skins -#project.skinconf=${project.content-dir}/skinconf.xml +project.skinconf=${project.content-dir}/skinconf.xml #project.lib-dir=${project.content-dir}/lib #project.classes-dir=${project.content-dir}/classes #project.translations-dir=${project.content-dir}/translations @@ -97,7 +97,8 @@ forrest.validate.skins.stylesheets=${forrest.validate.skins} # server, set to -Djava.awt.headless=true #forrest.jvmargs= # The bugtracking URL - the issue number will be appended -#project.bugtracking-url=http://issues.apache.org/bugzilla/show_bug.cgi?id= +project.bugtracking-url=http://issues.apache.org/bugzilla/show_bug.cgi?id= +bugtracking-url=http://issues.apache.org/bugzilla/show_bug.cgi?id= #project.bugtracking-url=http://issues.apache.org/jira/browse/ # The issues list as rss #project.issues-rss-url= @@ -106,4 +107,4 @@ forrest.validate.skins.stylesheets=${forrest.validate.skins} # The names of plugins that are required to build the project # comma separated list (no spaces) # project.required.plugins= -project.required.plugins=org.apache.forrest.plugin.output.pdf-0.1 +project.required.plugins=org.apache.forrest.plugin.input.projectInfo,org.apache.forrest.plugin.output.pdf diff --git a/forrest.properties.xml b/forrest.properties.xml new file mode 100644 index 000000000..d0c01bf4a --- /dev/null +++ b/forrest.properties.xml @@ -0,0 +1,22 @@ + + + + + + + diff --git a/lib/README.txt b/lib/README.txt index 46c716b77..db0c2cdcf 100644 --- a/lib/README.txt +++ b/lib/README.txt @@ -142,8 +142,16 @@ Please make sure you've read the license of each package. https://jai-imageio.dev.java.net/ BSD license - Note: Not the whole JAI is needed, only the ImageIO-compatible codecs - packaged as "Image I/O Tools". The name may be misleading. + Note: This is not the same as JAI! Only the ImageIO-compatible codecs + are packaged as "Image I/O Tools". The name may be misleading. + + - JAI (Java Advanced Imaging API) + + http://java.sun.com/products/java-media/jai + Java Research License and Java Distribution License (Check which one applies to you!) + + Currently used for: + - Grayscale error diffusion dithering in the PCL Renderer - JEuclid (MathML implementation, for the MathML extension) @@ -182,4 +190,4 @@ Additional development-time dependencies (not bundled, to be added to your Apache Ant installation) http://xmlunit.sourceforge.net/ - BSD style license \ No newline at end of file + BSD style license diff --git a/lib/xmlgraphics-commons-1.3svn.jar b/lib/xmlgraphics-commons-1.3svn.jar deleted file mode 100644 index 55b9d9b2a..000000000 Binary files a/lib/xmlgraphics-commons-1.3svn.jar and /dev/null differ diff --git a/lib/xmlgraphics-commons-1.4svn.jar b/lib/xmlgraphics-commons-1.4svn.jar new file mode 100644 index 000000000..cb386bd59 Binary files /dev/null and b/lib/xmlgraphics-commons-1.4svn.jar differ diff --git a/src/codegen/fonts/font-file.xsl b/src/codegen/fonts/font-file.xsl index dbca3eba5..21a6507b8 100644 --- a/src/codegen/fonts/font-file.xsl +++ b/src/codegen/fonts/font-file.xsl @@ -40,10 +40,10 @@ import java.util.Map; import java.util.Set; import org.apache.fop.fonts.FontType; -import org.apache.fop.fonts.Typeface; +import org.apache.fop.fonts.Base14Font; import org.apache.fop.fonts.CodePointMapping; -public class extends Typeface { +public class extends Base14Font { private final static String fontName = ""; private final static String fullName = ""; private final static Set familyNames; @@ -84,7 +84,7 @@ public class extends Typeface { this.enableKerning = enableKerning; } - public String getEncoding() { + public String getEncodingName() { return encoding; } diff --git a/src/documentation/content/.htaccess b/src/documentation/content/.htaccess index db766b7c4..561900fde 100644 --- a/src/documentation/content/.htaccess +++ b/src/documentation/content/.htaccess @@ -18,8 +18,8 @@ RedirectMatch Permanent ^/fop/upgrading(.*) http://xmlgraphics.apache.org/fop/0. # redirect to versioned documentation Redirect Temp /fop/stable http://xmlgraphics.apache.org/fop/0.94 -Redirect Temp /fop/current http://xmlgraphics.apache.org/fop/0.94 -Redirect Temp /fop/unstable http://xmlgraphics.apache.org/fop/trunk +Redirect Temp /fop/current http://xmlgraphics.apache.org/fop/0.95 +Redirect Temp /fop/unstable http://xmlgraphics.apache.org/fop/0.95 Redirect Temp /fop/latest http://xmlgraphics.apache.org/fop/trunk Redirect Temp /fop/maintenance http://xmlgraphics.apache.org/fop/0.93 Redirect Temp /fop/previous http://xmlgraphics.apache.org/fop/0.93 diff --git a/src/documentation/content/doap.rdf b/src/documentation/content/doap.rdf index 82be83e32..1c4253cea 100644 --- a/src/documentation/content/doap.rdf +++ b/src/documentation/content/doap.rdf @@ -77,15 +77,15 @@ Previous release - 2003-07-16 - 0.20.5 + 2007-01-02 + 0.93 Latest stable release - 2007-01-02 - 0.93 + 2007-08-23 + 0.94 diff --git a/src/documentation/content/xdocs/0.93/anttask.xml b/src/documentation/content/xdocs/0.93/anttask.xml deleted file mode 100644 index 44550c3d7..000000000 --- a/src/documentation/content/xdocs/0.93/anttask.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - -
- Ant task - $Revision$ -
- -

- Apache FOP provides an Ant task for automating the document build process. -

-
- Description -

- The FOP Ant task will convert XSL-FO documents to PDF, PS, PCL etc. output - (see Output formats for available formats). -

-

- To call FOP tasks within Ant, first add a FOP task definition to your Ant build file. - One method of defining the task is as follows: -

- - - - - - - - - - - - - - ]]> -

- Then create FOP tasks within your Ant build file, using the FOP task parameters listed below.

-
- -
Parameters for FOP Ant task - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Parameters specified as attributes
AttributeDescriptionRequired
fofileXSL-FO file to be renderedYes, if no fileset nested element is used
outfileOutput filenameYes, when fofile is used. (This attribute is not valid for filesets.)
formatPossible output formats:
- application/X-fop-awt-preview
- application/X-fop-print
- application/X-fop-areatree
- application/pdf
- application/postscript
- application/mif
- application/rtf, - text/richtext, - text/rtf
- application/x-pcl, - application/vnd.hp-PCL
- application/x-afp, - application/vnd.ibm.modcap
- text/plain
- image/svg+xml
- image/gif
- image/png
- image/tiff
-
No, defaults to application/pdf
outdirOutput directoryRequired if a fileset is used to specify the files to render; optional for fofile. (Can alternatively specify the full path in the fofile value.)
forceRecreate target files, even if they are newer than their corresponding - source files. Note: This attribute is available in post-0.20.5 - versions (0.20.x nightly build and 1.0dev) only; target files are - always generated (i.e., force=true) in 0.20.5 release. - No, default is false
basedirBase directory to resolve relative references (e.g., graphics files) within the - FO document. - No, for single FO File entry, default is to use the location - of that FO file. -
relativebaseFor fileset usage only. A value of true specifies using the location - of each .fo file as the base directory for resolving relative file references located - within that .fo file. A value of false specifies using the value of - basedir for all files within the fileset, or just the current working directory - if basedir is not specified. - No, default is false. -
userconfigUser configuration file (same as the FOP "-c" command line option).No
messagelevelLogging level
- Possible values: error, warn, info, verbose, debug. Currently doesn't work in FOP Trunk!!!
No, defaults to verbose
logFilesControls whether the names of the files that are processed are logged - (true) or not (false). Currently doesn't work in FOP Trunk!!!No, default is true
-

- - - - - - - - - - - -
Parameters specified as nested elements
AttributeDescriptionRequired
filesetFileSets - are used to specify multiple XSL-FO files to be rendered.Yes, if no fofile attribute is supplied
-

-
- Examples -

- The following example converts a single XSL-FO file to a PDF document: -

- - - - - ]]> -

- This example converts all XSL-FO files within an entire directory to PostScript: -

- - - - - - - - ]]> -
- -
- diff --git a/src/documentation/content/xdocs/0.93/compiling.xml b/src/documentation/content/xdocs/0.93/compiling.xml deleted file mode 100644 index 76d7b214f..000000000 --- a/src/documentation/content/xdocs/0.93/compiling.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - -
- Apache FOP: Building from Source Code - $Revision$ -
- -
- Do You Need To Build? -

- FOP distributions are either pre-compiled binary or source. - If you are using a binary distribution, it is already built and there is no need to build it again. - See the Download Instructions for information about whether a - binary or source distribution is best for your needs. -

-

- If you got the source code from a repository snapshot or via Subversion you will need to build FOP - in any case. -

-
-
- Set Up Your Environment -
- JDK -

- Building FOP requires a minimum Java Development Kit (JDK/SDK) of 1.3 - (A Java Runtime Environment is not sufficient). -

-
-
- CLASSPATH -

- There is generally no need to setup a classpath. All libraries needed to compile FOP are included - in the source distribution and are referenced by the build script. - You will only need to adjust the classpath if you build FOP in some other way. See the build - script build.xml for details. -

-
-
- JAVA_HOME -

- The build script uses Apache Ant, a popular - Java-based build tool, which usually requires that the environment variable JAVA_HOME point to - your local JDK root directory. This is true even if you use JDK 1.2 or above, which normally - does not need this setting. -

-
-
- Apache Ant -

- Apache Ant must be installed in order to - build FOP. Following best practices we don't include Ant with FOP anymore. You can find the - instructions to install Ant in the Ant manual on the web. -

-
-
-
- Run the Build Script -

- Change to the FOP root directory and build FOP by executing the build script (build.xml) - using the "ant" command. -

- - The "ant" command is only available on your system if you've properly - installed Apache Ant and added Ant's location to the PATH - environment variable. - -

- The file build.xml in the FOP root directory is the blueprint that Ant uses for the build. It - contains information for numerous build targets, many of which are building blocks to more - useful target, and others which are primarily used by the FOP developers. - You may benefit from looking through this file to learn more about the various build targets. - To obtain a complete list of useful build targets: -

- ant -projecthelp -

The most useful targets are:

-
    -
  • - package: Generates the JAR files (default). This is the normal build that - produces a jar file usable for running FOP. -
  • -
  • - clean : Cleans the build directory. This is useful for making sure that - any build errors are cleaned up before starting a new build. It should not ordinarily be - needed, but may be helpful if you are having problems with the build process itself. -
  • -
  • - javadocs: Generates javadocs. This creates the FOP API documentation. -
  • -
-

To run the build:

- ant [target ...] -

For example to do a normal build for the "all" target (which is the default):

- ant -

OR

- ant all -

To clean the build directory first:

- ant clean all - - If you want to shorten the build time you can just call the "package" target which - doesn't perform any automated tests during the build. - -
-
- Troubleshooting -

If you have problems building FOP, please try the following:

-
    -
  • Run the build with the target of "clean", then rerun the build.
  • -
  • Delete the build directory completely, then rerun the build.
  • -
  • - Make sure you do not have a non-FOP version of xerces.jar, xalan.jar, batik.jar, - or another dependency product somewhere in your CLASSPATH. -
  • -
  • - If the build still fails, see the Getting Help - page for further help. -
  • -
-
- -
- diff --git a/src/documentation/content/xdocs/0.93/configuration.xml b/src/documentation/content/xdocs/0.93/configuration.xml deleted file mode 100644 index ed96c3eb7..000000000 --- a/src/documentation/content/xdocs/0.93/configuration.xml +++ /dev/null @@ -1,335 +0,0 @@ - - - - - -
- Apache FOP: Configuration - $Revision$ -
- - -
- Configuration File Basics -

- The FOP configuration file is an XML file containing a variety of settings that are useful - for controlling FOP's behavior, and for helping it find resources that you wish it to use. -

-

- The easiest way to get started using a FOP configuration file is to copy the sample found - at {fop-dir}/conf/fop.xconf to a location of your choice, and then to - edit it according to your needs. - It contains templates for the various configuration options, most of which are commented - out. Remove the comments and change the settings for entries that you wish to use. - Be sure to follow any instructions, including comments which specify the value range. - Also, since the configuration file is XML, be sure to keep it well-formed. -

-
- Making Configuration Available to FOP -

After creating your configuration file, you must tell FOP how to find it:

- -

- See Setting the Configuration Programmatically - for instructions on how to do so in an embedded environment. -

-
-
-
- Summary of the General Configuration Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ElementData Type (for the value)Default Value
baseURL or directorySpecifies the base URL based on which relative URL will be resolved.
font-baseURL or directorySpecifies the base URL based on which relative font URLs will be resolved. - If not specified defaults to the base URL above. -
hyphenation-baseURL or directorySpecifies the base URL based on which relative URLs to hyphenation pattern - files will be resolved. If not specified, support for user-supplied hyphenation - patterns remains disabled. -
source-resolutionInteger, dpi - Resolution in dpi (dots per inch) which is used internally to determine the pixel - size for SVG images and bitmap images without resolution information. -
target-resolutionInteger, dpi - Resolution in dpi (dots per inch) used to specify the output resolution for bitmap - images generated by bitmap renderers (such as the TIFF renderer) and by bitmaps - generated by Apache Batik for filter effects and such. -
strict-validationBoolean (true, false) - Setting this option to 'false' causes FOP to be more forgiving about XSL-FO validity, - for example, you're allowed to specify a border on a region-body which is supported - by some FO implementations but is non-standard. Note that such a border would - currently have no effect in Apache FOP.
break-indent-inheritanceBoolean (true, false) - Setting this option to 'true' causes FOP to use an alternative rule set to determine - text indents specified through margins, start-indent and end-indent. Many commercial - FO implementations have chosen to break the XSL specification in this aspect. This - option tries to mimic their behaviour. Please note that Apache FOP may still not - behave exactly like those implementations either because FOP has not fully matched - the desired behaviour and because the behaviour among the commercial implementations - varies. The default for this option (i.e. false) is to behave exactly like the - specification describes.
default-page-settingsn/a - Specifies the default width and height of a page if "auto" is specified - for either or both values. Use "height" and "width" attributes on the - default-page-settings element to specify the two values.
renderers(see text below)Contains the configuration for each renderer. See below.
-

- This is an excerpt from the example configuration file coming with FOP: -

- - - - ./ - - - ./ - - - 72 - - 72 - - - - - -]]> -
-
- Renderer configuration -

- Each Renderer has its own configuration section which is identified by the - MIME type the Renderer is written for, ex. "application/pdf" for the PDF Renderer. -

-

- The configuration for the PDF Renderer could look like this: -

- - - - - flate - - - - - - - - - - - - - - - ]]> -

- The details on the font configuration can be found on the separate Fonts page. - Note especially the section entitled Register Fonts with FOP. -

-
- Special Settings for the PDF Renderer -

- The configuration element for the PDF renderer contains two elements. One is for the font configuration - (please follow the link above) and one is for the "filter list". The filter list controls how the - individual objects in a PDF file are encoded. By default, all objects get "flate" encoded (i.e. simply - compressed with the same algorithm that is also used in ZIP files). Most users don't need to change that - setting. For debugging purposes, it may be desired not to compress the internal objects at all so the - generated PDF commands can be read. In that case, you can simply use the following filter list. The - second filter list (type="image") ensures that all images still get compressed but also ASCII-85 encoded - so the produced PDF file is still easily readable in a text editor. -

- - - null - - - flate - ascii-85 - - - ]]> -

- Another (optional) setting specific to the PDF Renderer is an output color profile, an ICC - color profile which indicates the target color space the PDF file is generated for. This - setting is mainly used in conjunction with the PDF/X feature. - An example: -

- - C:\FOP\Color\EuropeISOCoatedFOGRA27.icc - - ]]> -
-
- Special Settings for the PostScript Renderer -

- Besides the normal font configuration (the same "fonts" element as for the PDF renderer) the PostScript - renderer has an additional setting to force landscape pages to be rotated to fit on a page inserted into - the printer in portrait mode. Set the value to "true" to activate this feature. The default is "false". - Example: -

- - true - - - - - - - - - - - - ]]> -
-
- Special Settings for the PCL Renderer -

- Non-standard fonts for the PCL renderer are made available through the Java2D subsystem which means that - you don't have to do any custom font configuration in this case but you have to use the font names - offered by Java. -

-

- Additionally, there are certain settings that control who the renderer handles various elements. -

- - quality - bitmap -]]> -

- The default value for the "rendering" setting is "speed" which causes borders - to be painted as plain rectangles. In this mode, no special borders (dotted, - dashed etc.) are available. If you want support for all border modes, set the - value to "quality" as indicated above. This will cause the borders to be painted - as bitmaps. -

-

- The default value for the "text-rendering" setting is "auto" which paints the - base fonts using PCL fonts. Non-base fonts are painted as bitmaps through Java2D. - If the mix of painting methods results in unwelcome output, you can set this - to "bitmap" which causes all text to be rendered as bitmaps. -

-
-
- -
- When it does not work - -

FOP searches the configuration file for the information it -expects, at the position it expects. When that information is not -present, FOP will not complain, it will just continue. When there is -other information in the file, FOP will not complain, it will just -ignore it. That means that when your configuration information is in -the file but in a different XML element, or in a different XML path, -than FOP expects, it will be silently ignored.

- -

Check the following possibilities:

- -
    -
  • The format of the configuration file has changed -considerably between FOP 0.20.5 and FOP 1.0 and its beta versions. Did -you convert your file to the new format?
  • - -
  • The FOP distribution contains a schema for configuration -files, at src/foschema/fop-configuration.xsd. Did you validate your -configuration file against it? Add the following schema location to -the schema element: - -]]> - - -and run the configuration file through a validating schema -parser. Note that the schema cannot detect all errors, and that it is -stricter about the order of some elements than FOP itself is.
  • - -
  • Run FOP in debug mode (command line option --d). This makes FOP report which configuration -information it finds. Check if FOP finds what you expect.
  • - -
- -
- -
- diff --git a/src/documentation/content/xdocs/0.93/embedding.xml b/src/documentation/content/xdocs/0.93/embedding.xml deleted file mode 100644 index 00d57c75e..000000000 --- a/src/documentation/content/xdocs/0.93/embedding.xml +++ /dev/null @@ -1,682 +0,0 @@ - - - - - - -
- Apache FOP: Embedding - How to Embed FOP in a Java application - $Revision$ -
- - -
- Overview -

- Review Running FOP for important information that applies - to embedded applications as well as command-line use, such as options and performance. -

-

- To embed Apache FOP in your application, first create a new - org.apache.fop.apps.FopFactory instance. This object can be used to launch multiple - rendering runs. For each run, create a new org.apache.fop.apps.Fop instance through - one of the factory methods of FopFactory. In the method call you specify which output - format (i.e. Renderer) to use and, if the selected renderer requires an OutputStream, - which OutputStream to use for the results of the rendering. You can customize FOP's - behaviour in a rendering run by supplying your own FOUserAgent instance. The - FOUserAgent can, for example, be used to set your own Renderer instance (details - below). Finally, you retrieve a SAX DefaultHandler instance from the Fop object and - use that as the SAXResult of your transformation. -

- - We recently changed FOP's outer API to what we consider the final API. This might require - some changes in your application. The main reasons for these changes were performance - improvements due to better reuse of reusable objects and reduced use of static variables - for added flexibility in complex environments. - -
-
- Basic Usage Pattern -

- Apache FOP relies heavily on JAXP. It uses SAX events exclusively to receive the XSL-FO - input document. It is therefore a good idea that you know a few things about JAXP (which - is a good skill anyway). Let's look at the basic usage pattern for FOP... -

-

Here is the basic pattern to render an XSL-FO file to PDF: -

- -

- Let's discuss these 5 steps in detail: -

-
    -
  • - Step 1: You create a new FopFactory instance. The FopFactory instance holds - references to configuration information and cached data. It's important to reuse this - instance if you plan to render multiple documents during a JVM's lifetime. -
  • -
  • - Step 2: You set up an OutputStream that the generated document - will be written to. It's a good idea to buffer the OutputStream as demonstrated - to improve performance. -
  • -
  • - Step 3: You create a new Fop instance through one of the factory - methods on the FopFactory. You tell the FopFactory what your desired output format - is. This is done by using the MIME type of the desired output format (ex. "application/pdf"). - You can use one of the MimeConstants.* constants. The second parameter is the - OutputStream you've setup up in step 2. -
  • -
  • - Step 4 We recommend that you use JAXP Transformers even - if you don't do XSLT transformations to generate the XSL-FO file. This way - you can always use the same basic pattern. The example here sets up an - "identity transformer" which just passes the input (Source) unchanged to the - output (Result). You don't have to work with a SAXParser if you don't do any - XSLT transformations. -
  • -
  • - Step 5: Here you set up the input and output for the XSLT - transformation. The Source object is set up to load the "myfile.fo" file. - The Result is set up so the output of the XSLT transformation is sent to FOP. - The FO file is sent to FOP in the form of SAX events which is the most efficient - way. Please always avoid saving intermediate results to a file or a memory buffer - because that affects performance negatively. -
  • -
  • - Step 6: Finally, we start the XSLT transformation by starting - the JAXP Transformer. As soon as the JAXP Transformer starts to send its output - to FOP, FOP itself starts its processing in the background. When the - transform() method returns FOP will also have finished converting - the FO file to a PDF file and you can close the OutputStream. - - It's a good idea to enclose the whole conversion in a try..finally statement. If - you close the OutputStream in the finally section, this will make sure that the - OutputStream is properly closed even if an exception occurs during the conversion. - -
  • -
-

- If you're not totally familiar with JAXP Transformers, please have a look at the - Embedding examples below. The section contains examples - for all sorts of use cases. If you look at all of them in turn you should be able - to see the patterns in use and the flexibility this approach offers without adding - too much complexity. -

-

- This may look complicated at first, but it's really just the combination of an - XSL transformation and a FOP run. It's also easy to comment out the FOP part - for debugging purposes, for example when you're tracking down a bug in your - stylesheet. You can easily write the XSL-FO output from the XSL transformation - to a file to check if that part generates the expected output. An example for that - can be found in the Embedding examples (See "ExampleXML2FO"). -

-
- Logging -

- Logging is now a little different than it was in FOP 0.20.5. We've switched from - Avalon Logging to Jakarta Commons Logging. - While with Avalon Logging the loggers were directly given to FOP, FOP now retrieves - its logger(s) through a statically available LogFactory. This is similar to the - general pattern that you use when you work with Apache Log4J directly, for example. - We call this "static logging" (Commons Logging, Log4J) as opposed to "instance logging" - (Avalon Logging). This has a consequence: You can't give FOP a logger for each - processing run anymore. The log output of multiple, simultaneously running FOP instances - is sent to the same logger. -

- - We know this may be an issue in multi-threaded server environments if you'd like to - know what's going on in every single FOP processing run. We're planning to add an - additional feedback facility to FOP which can be used to obtain all sorts of specific - feedback (validation messages, layout problems etc.). "Static logging" is mainly - interesting for a developer working on FOP and for advanced users who are debugging - FOP. We don't consider the logging output to be useful to normal FOP users. Please - have some patience until we can add this feature or jump in and help us build it. We've - set up a Wiki page - which documents what we're going to build. - -

- By default, Jakarta Commons Logging uses - JDK logging (available in JDKs 1.4 or higher) as its backend. You can configure Commons - Logging to use an alternative backend, for example Log4J. Please consult the - documentation for Jakarta Commons Logging on - how to configure alternative backends. -

-
- -
- Processing XSL-FO -

- Once the Fop instance is set up, call getDefaultHandler() to obtain a SAX - DefaultHandler instance to which you can send the SAX events making up the XSL-FO - document you'd like to render. FOP processing starts as soon as the DefaultHandler's - startDocument() method is called. Processing stops again when the - DefaultHandler's endDocument() method is called. Please refer to the basic - usage pattern shown above to render a simple XSL-FO document. -

-
- -
- Processing XSL-FO generated from XML+XSLT -

- If you want to process XSL-FO generated from XML using XSLT we recommend - again using standard JAXP to do the XSLT part and piping the generated SAX - events directly through to FOP. The only thing you'd change to do that - on the basic usage pattern above is to set up the Transformer differently: -

- -
-
-
- Input Sources -

- The input XSL-FO document is always received by FOP as a SAX stream (see the - Parsing Design Document for the rationale). -

-

- However, you may not always have your input document available as a SAX stream. - But with JAXP it's easy to convert different input sources to a SAX stream so you - can pipe it into FOP. That sounds more difficult than it is. You simply have - to set up the right Source instance as input for the JAXP transformation. - A few examples: -

-
    -
  • - URL: Source src = new StreamSource("http://localhost:8080/testfile.xml"); -
  • -
  • - File: Source src = new StreamSource(new File("C:/Temp/myinputfile.xml")); -
  • -
  • - String: Source src = new StreamSource(new StringReader(myString)); // myString is a String -
  • -
  • - InputStream: Source src = new StreamSource(new MyInputStream(something)); -
  • -
  • - Byte Array: Source src = new StreamSource(new ByteArrayInputStream(myBuffer)); // myBuffer is a byte[] here -
  • -
  • - DOM: Source src = new DOMSource(myDocument); // myDocument is a Document or a Node -
  • -
  • - Java Objects: Please have a look at the Embedding examples which contain an example for this. -
  • -
-

- There are a variety of upstream data manipulations possible. - For example, you may have a DOM and an XSL stylesheet; or you may want to - set variables in the stylesheet. Interface documentation and some cookbook - solutions to these situations are provided in - Xalan Basic Usage Patterns. -

-
-
- Configuring Apache FOP Programmatically -

- Apache FOP provides two levels on which you can customize FOP's - behaviour: the FopFactory and the user agent. -

-
- Customizing the FopFactory -

- The FopFactory holds configuration data and references to objects which are reusable over - multiple rendering runs. It's important to instantiate it only once (except in special - environments) and reuse it every time to create new FOUserAgent and Fop instances. -

-

- You can set all sorts of things on the FopFactory: -

-
    -
  • -

    - The font base URL to use when resolving relative URLs for fonts. Example: -

    - fopFactory.setFontBaseURL("file:///C:/Temp/fonts"); -
  • -
  • -

    - Disable strict validation. When disabled FOP is less strict about the rules - established by the XSL-FO specification. Example: -

    - fopFactory.setStrictValidation(false); -
  • -
  • -

    - Enable an alternative set of rules for text indents that tries to mimic the behaviour of many commercial - FO implementations, that chose to break the specification in this respect. The default of this option is - 'false', which causes Apache FOP to behave exactly as described in the specification. To enable the - alternative behaviour, call: -

    - fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary(true); -
  • -
  • -

    - Set the source resolution for the document. This is used internally to determine the pixel - size for SVG images and bitmap images without resolution information. Default: 72 dpi. Example: -

    - fopFactory.setSourceResolution(96); // =96dpi (dots/pixels per Inch) -
  • -
  • -

    - Manually add an ElementMapping instance. If you want to supply a special FOP extension - you can give the instance to the FOUserAgent. Normally, the FOP extensions can be automatically detected - (see the documentation on extension for more info). Example: -

    - fopFactory.addElementMapping(myElementMapping); // myElementMapping is a org.apache.fop.fo.ElementMapping -
  • -
  • -

    - Set a URIResolver for custom URI resolution. By supplying a JAXP URIResolver you can add - custom URI resolution functionality to FOP. For example, you can use - Apache XML Commons Resolver to make use of XCatalogs. Example: -

    - fopFactory.setURIResolver(myResolver); // myResolver is a javax.xml.transform.URIResolver - - Both the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FopFactory - is primarily used to resolve URIs on factory-level (hyphenation patterns, for example) and it is always used - if no other URIResolver (for example on the FOUserAgent) resolved the URI first. - -
  • -
-
-
- Customizing the User Agent -

- The user agent is the entity that allows you to interact with a single rendering run, i.e. the processing of a single - document. If you wish to customize the user agent's behaviour, the first step is to create your own instance - of FOUserAgent using the appropriate factory method on FopFactory and pass that - to the factory method that will create a new Fop instance: -

- -

- You can do all sorts of things on the user agent: -

-
    -
  • -

    - The base URL to use when resolving relative URLs. Example: -

    - userAgent.setBaseURL("file:///C:/Temp/"); -
  • -
  • -

    - Set the producer of the document. This is metadata information that can be used for certain output formats such as PDF. The default producer is "Apache FOP". Example: -

    - userAgent.setProducer("MyKillerApplication"); -
  • -
  • -

    - Set the creating user of the document. This is metadata information that can be used for certain output formats such as PDF. Example: -

    - userAgent.setCreator("John Doe"); -
  • -
  • -

    - Set the author of the document. This is metadata information that can be used for certain output formats such as PDF. Example: -

    - userAgent.setAuthor("John Doe"); -
  • -
  • -

    - Override the creation date and time of the document. This is metadata information that can be used for certain output formats such as PDF. Example: -

    - userAgent.setCreationDate(new Date()); -
  • -
  • -

    - Set the title of the document. This is metadata information that can be used for certain output formats such as PDF. Example: -

    - userAgent.setTitle("Invoice No 138716847"); -
  • -
  • -

    - Set the keywords of the document. This is metadata information that can be used for certain output formats such as PDF. Example: -

    - userAgent.setKeywords("XML XSL-FO"); -
  • -
  • -

    - Set the target resolution for the document. This is used to - specify the output resolution for bitmap images generated by bitmap renderers - (such as the TIFF renderer) and by bitmaps generated by Apache Batik for filter - effects and such. Default: 72 dpi. Example: -

    - userAgent.setTargetResolution(300); // =300dpi (dots/pixels per Inch) -
  • -
  • -

    - Set your own Renderer instance. If you want to supply your own renderer or - configure a Renderer in a special way you can give the instance to the FOUserAgent. Normally, - the Renderer instance is created by FOP. Example: -

    - userAgent.setRendererOverride(myRenderer); // myRenderer is an org.apache.fop.render.Renderer -
  • -
  • -

    - Set your own FOEventHandler instance. If you want to supply your own FOEventHandler or - configure an FOEventHandler subclass in a special way you can give the instance to the FOUserAgent. Normally, - the FOEventHandler instance is created by FOP. Example: -

    - userAgent.setFOEventHandlerOverride(myFOEventHandler); // myFOEventHandler is an org.apache.fop.fo.FOEventHandler -
  • -
  • -

    - Set a URIResolver for custom URI resolution. By supplying a JAXP URIResolver you can add - custom URI resolution functionality to FOP. For example, you can use - Apache XML Commons Resolver to make use of XCatalogs. Example: -

    - userAgent.setURIResolver(myResolver); // myResolver is a javax.xml.transform.URIResolver - - Both the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FOUserAgent is - used for resolving URIs which are document-related. If it's not set or cannot resolve a URI, the URIResolver - from the FopFactory is used. - -
  • -
- - You should not reuse an FOUserAgent instance between FOP rendering runs although you can. Especially - in multi-threaded environment, this is a bad idea. - -
-
-
- Using a Configuration File -

- Instead of setting the parameters manually in code as shown above you can also set - many values from an XML configuration file: -

- -

- The layout of the configuration file is described on the Configuration page. -

-
-
- Hints -
- Object reuse -

- Fop instances shouldn't (and can't) be reused. Please recreate - Fop and FOUserAgent instances for each rendering run using the FopFactory. - This is a cheap operation as all reusable information is held in the - FopFactory. That's why it's so important to reuse the FopFactory instance. -

-
-
- AWT issues -

- If your XSL-FO files contain SVG then Apache Batik will be used. When Batik is - initialised it uses certain classes in java.awt that - intialise the Java AWT classes. This means that a daemon thread - is created by the JVM and on Unix it will need to connect to a - DISPLAY. -

-

- The thread means that the Java application may not automatically quit - when finished, you will need to call System.exit(). These - issues should be fixed in the JDK 1.4. -

-

- If you run into trouble running FOP on a head-less server, please see the - notes on Batik. -

-
-
- Getting information on the rendering process -

- To get the number of pages that were rendered by FOP you can call - Fop.getResults(). This returns a FormattingResults object - where you can look up the number of pages produced. It also gives you the - page-sequences that were produced along with their id attribute and their - numbers of pages. This is particularly useful if you render multiple - documents (each enclosed by a page-sequence) and have to know the number of - pages of each document. -

-
-
-
- Improving performance -

- There are several options to consider: -

-
    -
  • - Whenever possible, try to use SAX to couple the individual components involved - (parser, XSL transformer, SQL datasource etc.). -
  • -
  • - Depending on the target OutputStream (in case of a FileOutputStream, but not - for a ByteArrayOutputStream, for example) it may improve performance considerably - if you buffer the OutputStream using a BufferedOutputStream: - out = new java.io.BufferedOutputStream(out); -
    - Make sure you properly close the OutputStream when FOP is finished. -
  • -
  • - Cache the stylesheet. If you use the same stylesheet multiple times - you can set up a JAXP Templates object and reuse it each time you do - the XSL transformation. (More information can be found - here.) -
  • -
  • - Use an XSLT compiler like XSLTC - that comes with Xalan-J. -
  • -
  • - Fine-tune your stylesheet to make the XSLT process more efficient and to create XSL-FO that can - be processed by FOP more efficiently. Less is more: Try to make use of property inheritance where possible. -
  • -
-
-
- Multithreading FOP -

- Apache FOP may currently not be completely thread safe. - The code has not been fully tested for multi-threading issues, yet. - If you encounter any suspicious behaviour, please notify us. -

-

- There is also a known issue with fonts being jumbled between threads when using - the Java2D/AWT renderer (which is used by the -awt and -print output options). - In general, you cannot safely run multiple threads through the AWT renderer. -

-
-
- Examples -

- The directory "{fop-dir}/examples/embedding" contains several working examples. -

-
- ExampleFO2PDF.java -

This - - example -demonstrates the basic usage pattern to transform an XSL-FO -file to PDF using FOP. -

-
-
-
- ExampleXML2FO.java -

This - - example -has nothing to do with FOP. It is there to show you how an XML -file can be converted to XSL-FO using XSLT. The JAXP API is used to do the -transformation. Make sure you've got a JAXP-compliant XSLT processor in your -classpath (ex. Xalan). -

-
-
-
- ExampleXML2PDF.java -

This - - example -demonstrates how you can convert an arbitrary XML file to PDF -using XSLT and XSL-FO/FOP. It is a combination of the first two examples -above. The example uses JAXP to transform the XML file to XSL-FO and FOP to -transform the XSL-FO to PDF. -

-
-

-The output (XSL-FO) from the XSL transformation is piped through to FOP using -SAX events. This is the most efficient way to do this because the -intermediate result doesn't have to be saved somewhere. Often, novice users -save the intermediate result in a file, a byte array or a DOM tree. We -strongly discourage you to do this if it isn't absolutely necessary. The -performance is significantly higher with SAX. -

-
-
- ExampleObj2XML.java -

This - - example -is a preparatory example for the next one. It's an example that -shows how an arbitrary Java object can be converted to XML. It's an often -needed task to do this. Often people create a DOM tree from a Java object and -use that. This is pretty straightforward. The example here, however, shows how -to do this using SAX, which will probably be faster and not even more -complicated once you know how this works. -

-
-

-For this example we've created two classes: ProjectTeam and ProjectMember -(found in xml-fop/examples/embedding/java/embedding/model). They represent -the same data structure found in -xml-fop/examples/embedding/xml/xml/projectteam.xml. We want to serialize to XML a -project team with several members which exist as Java objects. -Therefore we created the two classes: ProjectTeamInputSource and -ProjectTeamXMLReader (in the same place as ProjectTeam above). -

-

-The XMLReader implementation (regard it as a special kind of XML parser) is -responsible for creating SAX events from the Java object. The InputSource -class is only used to hold the ProjectTeam object to be used. -

-

-Have a look at the source of ExampleObj2XML.java to find out how this is -used. For more detailed information see other resources on JAXP (ex. -An older JAXP tutorial). -

-
-
- ExampleObj2PDF.java -

This - - example -combines the previous and the third to demonstrate -how you can transform a Java object to a PDF directly in one smooth run -by generating SAX events from the Java object that get fed to an XSL -transformation. The result of the transformation is then converted to PDF -using FOP as before. -

-
-
-
- ExampleDOM2PDF.java -

This - - example -has FOP use a DOMSource instead of a StreamSource in order to -use a DOM tree as input for an XSL transformation. -

-
-
- ExampleSVG2PDF.java (PDF Transcoder example) -

This - - example -shows the usage of the PDF Transcoder, a sub-application within FOP. -It is used to generate a PDF document from an SVG file. -

-
-
- Final notes -

-These examples should give you an idea of what's possible. It should be easy -to adjust these examples to your needs. Also, if you have other examples that you -think should be added here, please let us know via either the fop-users or fop-dev -mailing lists. Finally, for more help please send your questions to the fop-users -mailing list. -

-
-
- -
- diff --git a/src/documentation/content/xdocs/0.93/extensions.xml b/src/documentation/content/xdocs/0.93/extensions.xml deleted file mode 100644 index 0c22ca123..000000000 --- a/src/documentation/content/xdocs/0.93/extensions.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - -
- Standard FOP Extensions - $Revision$ -
- -

- By "extension", we mean any data that can be placed in the input XML document that - is not addressed by the XSL-FO standard. - By having a mechanism for supporting extensions, FOP is able to add features that - are not covered in the specification. -

-

- The extensions documented here are included with FOP, and are automatically available - to you. If you wish to add an extension of your own to FOP, please see the - Developers' Extension Page. -

- All extensions required the correct use of an appropriate namespace in your input document. -
- SVG -

- Please see the SVG documentation for more details. -

-
-
- FO Extensions -
- Namespace -

- By convention, FO extensions in FOP use the "fox" namespace prefix. - To use any of the FO extensions, add a namespace entry for - http://xml.apache.org/fop/extensions to the root element: -

- ]]> - - Currently, no extension elements are implemented in FOP Trunk which use the - FOP extension namespace. - -
-
- PDF Bookmarks -

- In previous versions of Apache FOP there was a fox:outline element - which was used to create outlines in PDF files. The redesigned code makes use - of the new bookmark feature defined in the latest XSL 1.1 working draft. -

-
-
- Anchors or Named Destinations -

This extension element hasn't been reimplemented for the redesigned code, yet.

- -
-
- Table Continuation Label -

This extension element hasn't been reimplemented for the redesigned code, yet.

- -
-
- fox:orphan-content-limit and fox:widow-content-limit -

- The two proprietary extension properties, fox:orphan-content-limit and - fox:widow-content-limit, are used to improve the layout of list-blocks and tables. - If you have a table with many entries, you don't want a single row to be left over - on a page. You will want to make sure that at least two or three lines are kept - together. The properties take an absolute length which specifies the area at the - beginning (fox:widow-content-limit) or at the end (fox:orphan-content-limit) of a - table or list-block. The properties are inherited and only have an effect on fo:table - and fo:list-block. An example: fox:widow-content-limit="3 * 1.2em" would make sure - the you'll have at least three lines (assuming line-height="1.2") together on a table - or list-block. -

-
-
- -
- diff --git a/src/documentation/content/xdocs/0.93/fonts.xml b/src/documentation/content/xdocs/0.93/fonts.xml deleted file mode 100644 index 53d4bd97f..000000000 --- a/src/documentation/content/xdocs/0.93/fonts.xml +++ /dev/null @@ -1,298 +0,0 @@ - - - - - -
- Apache FOP: Fonts - $Revision$ - - - - -
- -
- Summary - The FOP Font subsystem is currently undergoing a significant change. - The details provided here especially related to the generation of FOP Font - Metrics files and the FOP Font configuration are likely to change substantially - in the future. - -

The following table summarizes the font capabilities of the various FOP renderers:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RendererBase-14AWT/OSCustomCustom Embedding
PDFyesnoyesyes
PostScriptyesnoyesyes
TXTyes (used for layout but not for output)noyes (used for layout but not for output)no
AWTif available from OSyesyesn/a (display only)
Printif available from OSyesyescontrolled by OS printer driver
RTFn/a (font metrics not needed)n/an/an/a
MIFn/a (font metrics not needed)n/an/an/a
SVGif available from OSyesnono
XMLyesnoyesn/a
-
-
- Base-14 Fonts -

The Adobe PDF Specification specifies a set of 14 fonts that must be available to every PDF reader: Helvetica (normal, bold, italic, bold italic), Times (normal, bold, italic, bold italic), Courier (normal, bold, italic, bold italic), Symbol and ZapfDingbats.

-
-
- AWT/Operating System Fonts -

The AWT family of renderers (AWT, Print, SVG), use the Java AWT libraries for font metric information. Through operating system registration, the AWT libraries know what fonts are available on the system, and the font metrics for each one.

-
-
- Custom Fonts -

Support for custom fonts is added by creating font metric files (written in XML) from the actual font files, and registering them with FOP. Currently only Type 1 and TrueType fonts can be added. -More information about fonts can be found at:

- -
- Type 1 Font Metrics -

FOP includes PFMReader, which reads the PFM file that normally comes with a Type 1 font, and generates an appropriate font metrics file for it. -To use it, run the class org.apache.fop.fonts.apps.PFMReader:

-

Windows (on JDK 1.4 and later):

- java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar - org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file -

Windows (on JDK 1.3.x):

- java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar;lib\xml-apis.jar; - lib\xercesImpl.jar;lib\xalan.jar;lib\serializer.jar - org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file -

Unix (on JDK 1.4 and later):

- java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar - org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file -

Unix (on JDK 1.3.1):

- java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar:lib/xml-apis.jar: - lib/xercesImpl.jar:lib/xalan.jar:lib/serializer.jar - org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file -

PFMReader [options]:

-
    -
  • -fn <fontname> By default, FOP uses the fontname from the -.pfm file when embedding the font. Use the "-fn" option to override this name with one you have -chosen. This may be useful in some cases to ensure that applications using the output document -(Acrobat Reader for example) use the embedded font instead of a local font with the same -name.
  • -
- The classpath in the above example has been simplified for readability. -You will have to adjust the classpath to the names of the actual JAR files in the lib directory. -xml-apis.jar, xercesImpl.jar, xalan.jar and serializer.jar are not necessary for JDK version 1.4 or later. - The tool will construct some values (FontBBox, StemV and ItalicAngle) based on assumptions and calculations which are only an approximation to the real values. -FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file. -The PFMReader tool does not yet interpret PFB or AFM files, so if you want to be correct, you may have to adjust the values in the XML file manually. -The constructed values however appear to have no visible influence. -
-
- TrueType Font Metrics -

FOP includes TTFReader, which reads the TTF file and generates an appropriate font metrics file for it. -Use it in a similar manner to PFMReader. -For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf:

- java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar - org.apache.fop.fonts.apps.TTFReader [options] - C:\myfonts\cmr10.ttf ttfcm.xml -

TTFReader [options]:

-
    -
  • -d <DEBUG | INFO > Sets the debug level (default is -INFO).
  • -
  • -fn <fontname> Same as for PFMReader.
  • -
  • -ttcname <fontname> If you're reading data from a -TrueType Collection (.ttc file) you must specify which font from the collection you will read -metrics from. -If you read from a .ttc file without this option, the fontnames will be listed for you.
  • -
  • -enc ansi Creates a WinAnsi-encoded font metrics file. -Without this option, a CID-keyed font metrics file is created. -The table below summarizes the differences between these two encoding options as currently -used within FOP. -Please note that this information only applies to TrueType fonts and TrueType collections:
  • -
- - - - - - - - - - - - - - - - -
IssueWinAnsiCID-keyed
Usable Character SetLimited to WinAnsi character set, which is roughly equivalent to iso-8889-1.Limited only by the characters in the font itself.
Embedding the FontOptional.Mandatory. Not embedding the font produces invalid PDF documents.
- - You may experience failures with certain TrueType fonts, especially if they don't contain - the so-called Unicode "cmap" table. TTFReader can currently not deal with font like this. - -
-
- TrueType Collections Font Metrics -

TrueType collections (.ttc files) contain more than one font. -To create metrics files for these fonts, you must specify which font in the collection should be generated, by using the "-ttcname" option with the TTFReader.

-

To get a list of the fonts in a collection, just start the TTFReader as if it were a normal TrueType file (without the -ttcname option). -It will display all of the font names and exit with an Exception.

-

Here is an example of generating a metrics file for a .ttc file:

- java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar - org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho" - msmincho.ttc msminch.xml -
-
- Register Fonts with FOP -

You must tell FOP how to find and use the font metrics files by registering them in the FOP Configuration. Add entries for your custom fonts, regardless of font type, to the configuration file in a manner similar to the following:

- - -]]> - Review the documentation for FOP Configuration for instructions on making the FOP configuration available to FOP when it runs. Otherwise, FOP has no way of finding your custom font information. -
    -
  • - URLs are used to access the font metric and font files. - Relative URLs are resolved relative to the font-base property (or base) if available. - See FOP: Configuration for more information. -
  • -
  • The "kerning" and "embed-url" attributes are optional. Kerning is currently not used at all. If embedding is off, the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.
  • -
  • When setting the embed-url attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.
  • -
  • - If relative URLs are specified, they are evaluated relative to the value of the - "font-base" setting. If there is no "font-base" setting, the fonts are evaluated - relative to the base directory. -
  • -
- -
-
- Embedding - The PostScript renderer does not yet support TrueType fonts, but can embed Type 1 fonts. - The font is simply embedded into the PDF file, it is not converted. -

Font embedding is enabled in the userconfig.xml file and controlled by the embed-url attribute. -If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.

- - Omitting the embed-url attribute for CID-encoded TrueType fonts will currently produce invalid - PDF files! If you create the XML font metric file using the "-enc ansi" option, you can omit - the embed-url attribute for TrueType fonts but you're restricted to the WinAnsi character set. - -

When FOP embeds a font, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font. -This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.

-

When embedding PostScript fonts, the entire font is always embedded.

-

When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the original font, containing only the glyphs used, is embedded in the output document. -Currently, this embedded font contains only the minimum data needed to be embedded in a pdf document, and does not contain any codepage information. -The PDF document contains indexes to the glyphs in the font instead of to encoded characters. -While the document will be displayed correctly, the net effect of this is that searching, indexing, and cut-and-paste will not work properly.

-

One workaround for this behavior is to use the "-enc ansi" option when generating metrics with TTFReader. -This will cause the whole font to be embedded in the pdf document. -Characters will be WinAnsi encoded (as specified in the PDF spec), so you lose the ability to use characters from other character sets. -See Table of TTF Encoding Options for more details.

-
-
- Explicitely embedding the base 14 fonts -

- There are cases where you might want to force the embedding of one or more of the base 14 fonts that - can normally be considered available on the target platform (viewer, printer). One of these cases is - PDF/A which mandates the embedding of even the base 14 fonts. Embedding a font such as Helvetica or - Courier is straight-forward. The "Symbol" and "ZapfDingbats" fonts, however, currently present a - problem because FOP cannot correctly determine the encoding of these two single-byte fonts through - the PFM file. FOP now correctly interprets the "encoding" value in the XML font metrics file, but the - PFMReader application writes "UnknownEncoding" to the generated XML file. In order to embed "Symbol" - and "ZapfDingbats" you have to manually change the XML font metrics file and specify "SymbolEncoding" - or "ZapfdingbatsEncoding" encoding respectively as the value for the "encoding" element. -

-

Example:

- - - Symbol - - SymbolEncoding - 673 - 766 - [..]]]> -
-
- -
diff --git a/src/documentation/content/xdocs/0.93/fotree/disabled-testcases.xml b/src/documentation/content/xdocs/0.93/fotree/disabled-testcases.xml deleted file mode 100644 index 196eafcc4..000000000 --- a/src/documentation/content/xdocs/0.93/fotree/disabled-testcases.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - demo test failure - demo-test-failure.fo - - - - Markers and core function evaluation - from-table-column_marker.fo - The code currently evaluates this function according to the column in which the - marker appears in the source document, rather than the column it is retrieved in. - - diff --git a/src/documentation/content/xdocs/0.93/graphics.xml b/src/documentation/content/xdocs/0.93/graphics.xml deleted file mode 100644 index beb860223..000000000 --- a/src/documentation/content/xdocs/0.93/graphics.xml +++ /dev/null @@ -1,338 +0,0 @@ - - - - - -
- Apache FOP: Graphics Formats - $Revision$ -
- -
- Overview of Graphics Support -

- The table below summarizes the theoretical support for graphical formats within FOP. In other words, within the constraints of the limitations listed here, these formats should work. However, many of them have not been tested, and there may be limitations that have not yet been discovered or documented. The packages needed to support some formats are not included in the FOP distribution and must be installed separately. Follow the links in the "Support Thru" column for more details. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FormatTypeFOP native supportBatik SVGBatik codecsImage I/OJAIJIMI
BMP (Microsoft Windows Bitmap)bitmapX
EPS (Encapsulated PostScript)metafile (both bitmap and vector), probably most frequently used for vector drawings(X)
GIF (Graphics Interchange Format)bitmapXXXX
JPEG (Joint Photographic Experts Group)bitmap(X)
PNG (Portable Network Graphic)bitmapX
SVG (Scalable Vector Graphics)vector (with embedded bitmaps)X
TIFF (Tag Image Format File)bitmap(X)XX
- "(X)" means restricted support. Please see the details below. -
-
- Graphics Packages -
- FOP Native -

- FOP has native ability to handle some graphic file formats. -

-
-
- Batik codecs -

- Apache Batik contains codecs for PNG and TIFF access. FOP can use these. -

-
-
- Image I/O (JDK 1.4 or higher) -

- For JDKs 1.4 or higher, FOP provides a wrapper to load images through the - JDK's Image I/O API (JSR 015). - Image I/O allows to dynamically add additional image codecs. An example of such an add-on library are the - JAI Image I/O Tools available from Sun. -

-
-
- JIMI -

- Because of licensing issues, the JIMI image library is not included in the FOP distribution. First, download and install it. -Then, copy the file "JimiProClasses.zip" from the archive to {fop-install-dir}/lib/jimi-1.0.jar. Please note that FOP binary distributions are compiled with JIMI support, so there is no need for you to build FOP to add the support. If jimi-1.0.jar is installed in the right place, it will automatically be used by FOP, otherwise it will not. -

-
-
- JAI (Java Advanced Imaging API) - JAI support is available for Release 0.20.5 and later. The comments in this section do not apply to releases earlier than 0.20.5. -

- FOP has been compiled with JAI support, but JAI is not included in the FOP distribution. -To use it, install JAI, then copy the jai_core.jar and the jai_codec.jar files to {fop-install-dir}/lib. -JAI is much faster than JIMI, but is not available for all platforms. See What platforms are supported? on the JAI FAQ page for more details. -

-
-
- Batik -

Current FOP distributions include a distribution of the Apache Batik version 1.6. -It is automatically installed with FOP. -Because Batik's API changes frequently, it is highly recommended that you use the version that ships with FOP, at least when running FOP.

- Batik must be run in a graphical environment. -

Batik must be run in a graphical environment. -It uses AWT classes for rendering SVG, which in turn require an X server on Unixish systems. -If you run a server without X, or if you can't connect to the X server due to security restrictions or policies (a so-called "headless" environment), SVG rendering will fail.

-

Here are some workarounds:

-
    -
  • If you are using JDK 1.4, start it with the -Djava.awt.headless=true command line option.
  • -
  • Install an X server which provides an in-memory framebuffer without actually using a screen device or any display hardware. One example is Xvfb.
  • -
  • Install a toolkit which emulates AWT without the need for an underlying X server. One example is the PJA toolkit, which is free and comes with detailed installation instructions.
  • -
-
-
-
- BMP -

FOP native support for BMP images is limited to the RGB color-space.

-
-
- EPS -

FOP provides support for two output targets:

-
    -
  • PostScript (full support).
  • -
  • - PDF (partial support). Due to the lack of a built-in PostScript interpreter, FOP - can only embed the EPS file into the PDF. Acrobat Reader will not currently display - the EPS (it doesn't have a PostScript interpreter, either) but it will be shown - correctly when you print the PDF on a PostScript-capable printer. PostScript devices - (including GhostScript) will render the EPS correctly. -
  • -
-

- Other output targets can't be supported at the moment because - FOP lacks a PostScript interpreter. Furthermore, FOP is not able - to parse the preview bitmaps sometimes contained in EPS files. -

-
-
- JPEG -

FOP native support of JPEG does not include all variants, especially those containing unusual color lookup tables and color profiles. -If you have trouble with a JPEG image in FOP, try opening it with an image processing program (such as Photoshop or Gimp) and then saving it. -Specifying 24-bit color output may also help. -For the PDF and PostScript renderers most JPEG images can be passed through without decompression. -User reports indicate that grayscale, RGB, and CMYK color-spaces are all rendered properly. -

-
-
- PNG -

If using JAI for PNG support, only RGB and RGBA color-spaces are supported for FOP rendering.

-
-
- SVG -
- Introduction -

FOP uses Batik for SVG support. -This format can be handled as an fo:instream-foreign-object or in a separate -file referenced with fo:external-graphic.

- -Batik's SVG Rasterizer utility may also be used to convert standalone SVG -documents into PDF. For more information please see the -SVG Rasterizer documentation -on the Batik site. - -
-
- Placing SVG Graphics into PDF -

-The SVG is rendered into PDF by using PDF commands to draw and fill -lines and curves. This means that the graphical objects created with -this remain as vector graphics. -

-

-There are a number of SVG things that cannot be converted directly into -PDF. Parts of the graphic such as effects, patterns and images are inserted -into the PDF as a raster graphic. The resolution of this graphic may not -be ideal depending on the FOP dpi (72dpi) and the scaling for that graphic. -We hope to improve this in the future.

-

-Currently transparency is not supported in PDF so many svg images that -contain effects or graphics with transparent areas will not be displayed -correctly. -

-
-
- Placing SVG Text into PDF -

If possible, Batik will use normal PDF text when inserting text. It does -this by checking if the text can be drawn normally and the font is -supported. This example svg text.svg / -text.pdf -shows how various types and effects with text are handled. -Note that tspan and outlined text are not yet implemented.

-

-Otherwise, text is converted and drawn as a set of shapes by batik, using the stroking text painter. -This means that a typical character will -have about 10 curves (each curve consists of at least 20 characters). -This can make the pdf files large and when the pdf is viewed the -viewer does not normally draw those fine curves very well (turning on -Smooth Line Art in the Acrobat preferences will fix this). -If the text is inserted into the PDF using the inbuilt text commands -for PDF it will use a single character. -

-

Note that because SVG text can be rendered as either text or a vector graphic, you may need to consider settings in your viewer for both. -The Acrobat viewer has both "smooth line art" and "smooth text" settings that may need to be set for SVG images to be displayed nicely on your screen (see Edit / Preferences / Display). -This setting will not affect the printing of your document, which should be OK in any case, but will only affect the quality of the screen display.

-
-
- Scaling -

Currently, SVG images are rendered with the dimensions specified in the SVG file, within the viewport specified in the fo:external-graphic element. -For everything to work properly, the two should be equal. -The SVG standard leaves this issue as an implementation detail. -FOP will probably implement a scaling mechanism in the future.

-
-
- Known Problems -
    -
  • -soft mask transparency is combined with white so that it looks better -on pdf 1.3 viewers but this causes the soft mask to be slightly lighter -or darker on pdf 1.4 viewers -
  • -
  • -there is some problem with a gradient inside a pattern causing a pdf -error when viewed in acrobat 5 -
  • -
  • -text is not always handled correctly, it may select the wrong font -especially if characters have multiple fonts in the font list -
  • -
  • -more pdf text handling could be implemented -It could draw the string using the attributed character iterator -to handle tspans and other simple changes of text. -
  • -
  • -JPEG images are not inserted directly into the pdf document -This area has not been implemented yet since the appropriate -method in batik is static -
  • -
  • -Uniform transparency for images and other svg elements that are converted -into a raster graphic are not drawn properly in PDF. The image is opaque. -
  • -
-
-
-
- TIFF -

FOP-native TIFF support is limited to PDF and PostScript output only. Also, according to user reports, FOP's native support for TIFF is limited to images with the following characteristics (all must be true for successful rendering):

-
    -
  • single channel images (i.e., bi-level and grayscale only)
  • -
  • uncompressed images, or images using CCITT T.4, CCITT T.6, or JPEG compression
  • -
  • images using white-is-zero encoding in the TIFF PhotometricInterpretation tag
  • -
-

JAI: Supports RGB and RGBA only for FOP rendering.

-
-
- Graphics Resolution -

Some bitmapped image file formats store a dots-per-inch (dpi) or other resolution value. Since PDF and most output formats do not have a concept of resolution, but only of absolute image units (i.e. pixels) FOP ignores the resolution values as well. Instead, FOP uses the dimensions of the image as specified in the fo:external-graphic element to render the image:

-
    -
  • If no dimensions are given, FOP uses a default value of 72 dpi to compute the graphic's dimensions. For example, suppose a graphic 300 pixels wide and 400 pixels high. FOP will render the graphic at 4.167 inches wide, 5.555 inches high, with an apparent resolution of 72 dpi.
  • -
  • If only one dimension is given, FOP by default uses the same aspect ratio to compute the other dimension (to avoid the appearance of stretching). For example, suppose a graphic 300 pixels wide and 400 pixels high, for which content-width = ".5in". FOP will compute the content-height = .667 inches, and will render the graphic at that size, with an apparent resolution of 600 dpi.
  • -
  • If both dimensions are given, FOP simply renders the image in that space. For example, suppose a graphic 300 pixels wide and 400 pixels high, for which content-width = "3in" and content-height = "4in". FOP will render the graphic at that size, with an apparent resolution of 100 dpi.
  • -
-

If you need a higher apparent output resolution for bitmapped images, first make sure that at least one dimension of the image is defined in your XSL-FO input. Apart from that, resolution problems are in the image file itself, and must be corrected there: use or create a higher-resolution image file.

- The explanation above describes only the basic default behavior. There are other attributes of the fo:external-graphic element that can affect the behavior described above. -
-
- Image caching -

- FOP caches images between runs. The URL is used as a key to identify images which means that when - a particular URL appears again, the image is taken from the cache. If you have a servlet that - generates a different image each time it is called with the same URL you need to use a constantly - changing dummy parameter on the URL to avoid caching. -

-

- The image cache has been improved considerably in the redesigned code. Therefore, a resetCache() method - has become unnecessary. If you still experience OutOfMemoryErrors, please notify us. -

-
- -
diff --git a/src/documentation/content/xdocs/0.93/hyphenation.xml b/src/documentation/content/xdocs/0.93/hyphenation.xml deleted file mode 100644 index ed97c6868..000000000 --- a/src/documentation/content/xdocs/0.93/hyphenation.xml +++ /dev/null @@ -1,237 +0,0 @@ - - - - - -
- Apache FOP: Hyphenation - $Revision$ -
- -
- Hyphenation Support -
- Introduction -

FOP uses Liang's hyphenation algorithm, well known from TeX. It needs - language specific pattern and other data for operation.

-

Because of licensing issues (and for - convenience), all hyphenation patterns for FOP are made available through - the Objects For - Formatting Objects project.

- If you have made improvements to an existing FOP hyphenation pattern, - or if you have created one from scratch, please consider contributing these - to OFFO so that they can benefit other FOP users as well. - Please inquire on the FOP User - mailing list. -
-
- License Issues -

Many of the hyphenation files distributed with TeX and its offspring are - licenced under the LaTeX - Project Public License (LPPL), which prevents them from being - distributed with Apache software. The LPPL puts restrictions on file names - in redistributed derived works which we feel can't guarantee. Some - hyphenation pattern files have other or additional restrictions, for - example against use for commercial purposes.

-

Although Apache FOP cannot redistribute hyphenation pattern files that do - not conform with its license scheme, that does not necessarily prevent users - from using such hyphenation patterns with FOP. However, it does place on - the user the responsibility for determining whether the user can rightly use - such hyphenation patterns under the hyphenation pattern license.

- The user is responsible to settle license issues for hyphenation - pattern files that are obtained from non-Apache sources. -
-
- Sources of Custom Hyphenation Pattern Files -

The most important source of hyphenation pattern files is the - CTAN TeX - Archive.

-
-
- Installing Custom Hyphenation Patterns -

To install a custom hyphenation pattern for use with FOP:

-
    -
  1. Convert the TeX hyphenation pattern file to the FOP format. The FOP - format is an xml file conforming to the DTD found at - {fop-dir}/hyph/hyphenation.dtd.
  2. -
  3. Name this new file following this schema: - languageCode_countryCode.xml. The country code is - optional, and should be used only if needed. For example: -
      -
    • en_US.xml would be the file name for American - English hyphenation patterns.
    • -
    • it.xml would be the file name for Italian - hyphenation patterns.
    • -
    - The language and country codes must match the XSL-FO input, which - follows ISO - 639 (languages) and ISO - 3166 (countries). NOTE: The ISO 639/ISO 3166 convention is that - language names are written in lower case, while country codes are written - in upper case. FOP does not check whether the language and country specified - in the FO source are actually from the current standard, but it relies - on it being two letter strings in a few places. So you can make up your - own codes for custom hyphenation patterns, but they should be two - letter strings too (patches for proper handling extensions are welcome)
  4. -
  5. There are basically three ways to make the FOP-compatible hyphenation pattern - file(s) accessible to FOP: -
      -
    • Download the precompiled JAR from OFFO - and place it either in the {fop-dir}/lib directory, or - in a directory of your choice (and append the full path to the JAR to - the environment variable FOP_HYPHENATION_PATH).
    • -
    • Download the desired FOP-compatible hyphenation pattern file(s) from - OFFO, - and/or take your self created hyphenation pattern file(s), -
        -
      • place them in the directory {fop-dir}/hyph,
      • -
      • or place them in a directory of your choice and set the Ant variable - user.hyph.dir to point to that directory (in - build-local.properties),
      • -
      - and run Ant with build target - jar-hyphenation. This will create a JAR containing the - compiled patterns in {fop-dir}/build that will be added to the - classpath on the next run. - (When FOP is built from scratch, and there are pattern source file(s) - present in the directory pointed to by the - user.hyph.dir variable, this JAR will automatically - be created from the supplied pattern(s)).
    • -
    • Put the pattern source file(s) into a directory of your choice and - configure FOP to look for custom patterns in this directory, by setting the - <hyphenation-base> - configuration option.
    • -
    -
  6. -
- - Either of these three options will ensure hyphenation is working when using - FOP from the command-line. If FOP is being embedded, remember to add the location(s) - of the hyphenation JAR(s) to the CLASSPATH (option 1 and 2) or to set the - <hyphenation-dir> - configuration option programmatically (option 3). - -
-
-
- Hyphenation Patterns -

If you would like to build your own hyphenation pattern files, or modify - existing ones, this section will help you understand how to do so. Even - when creating a pattern file from scratch, it may be beneficial to start - with an existing file and modify it. See - OFFO's Hyphenation page for examples. - Here is a brief explanation of the contents of FOP's hyphenation patterns:

- The remaining content of this section should be considered "draft" - quality. It was drafted from theoretical literature, and has not been - tested against actual FOP behavior. It may contain errors or omissions. - Do not rely on these instructions without testing everything stated here. - If you use these instructions, please provide feedback on the - FOP User mailing list, either - confirming their accuracy, or raising specific problems that we can - address. -
    -
  • The root of the pattern file is the <hyphenation-info> element.
  • -
  • <hyphen-char>: its attribute "value" contains the character signalling - a hyphen in the <exceptions> section. It has nothing to do with the - hyphenation character used in FOP, use the XSLFO hyphenation-character - property for defining the hyphenation character there. At some points - a dash U+002D is hardwired in the code, so you'd better use this too - (patches to rectify the situation are welcome). There is no default, - if you declare exceptions with hyphenations, you must declare the - hyphen-char too.
  • -
  • <hyphen-min> contains two attributes: -
      -
    • before: the minimum number of characters in a word allowed to exist - on a line immediately preceding a hyphenated word-break.
    • -
    • after: the minimum number of characters in a word allowed to exist - on a line immediately after a hyphenated word-break.
    • -
    - This element is unused and not even read. It should be considered a - documentation for parameters used during pattern generation. -
  • -
  • <classes> contains whitespace-separated character sets. The members - of each set should be treated as equivalent for purposes of hyphenation, - usually upper and lower case of the same character. The first character - of the set is the canonical character, the patterns and exceptions - should only contain these canonical representation characters (except - digits for weight, the period (.) as word delimiter in the patterns and - the hyphen char in exceptions, of course).
  • -
  • <exceptions> contains whitespace-separated words, each of which - has either explicit hyphen characters to denote acceptable breakage - points, or no hyphen characters, to indicate that this word should - never be hyphenated, or contain explicit <hyp> elements for specifying - changes of spelling due to hyphenation (like backen -> bak-ken or - Stoffarbe -> Stoff-farbe in the old german spelling). Exceptions override - the patterns described below. Explicit <hyp> declarations don't work - yet (patches welcome). Exceptions are generally a bit brittle, test - carefully.
  • -
  • <patterns> includes whitespace-separated patterns, which are what - drive most hyphenation decisions. The characters in these patterns are - explained as follows: -
      -
    • non-numeric characters represent characters in a sub-word to be - evaluated
    • -
    • the period character (.) represents a word boundary, i.e. either - the beginning or ending of a word
    • -
    • numeric characters represent a scoring system for indicating the - acceptability of a hyphen in this location. Odd numbers represent an - acceptable location for a hyphen, with higher values overriding lower - inhibiting values. Even numbers indicate an unacceptable location, with - higher values overriding lower values indicating an acceptable position. - A value of zero (inhibiting) is implied when there is no number present. - Generally patterns are constructed so that valuse greater than 4 are rare. - Due to a bug currently patterns with values of 8 and greater don't - have an effect, so don't wonder.
    • -
    - Here are some examples from the English patterns file: -
      -
    • Knuth (The TeXBook, Appendix H) uses the example hach4, which indicates that it is extremely undesirable to place a hyphen after the substring "hach", for example in the word "toothach-es".
    • -
    • .leg5e indicates that "leg-e", when it occurs at the beginning of a word, is a very good place to place a hyphen, if one is needed. Words like "leg-end" and "leg-er-de-main" fit this pattern.
    • -
    - Note that the algorithm that uses this data searches for each of the word's substrings in the patterns, and chooses the highest value found for letter combination. -
  • -
-

If you want to convert a TeX hyphenation pattern file, you have to undo - the TeX encoding for non-ASCII text. FOP uses Unicode, and the patterns - must be proper Unicode too. You should be aware of the XML encoding issues, - preferably use a good Unicode editor.

-

Note that FOP does not do Unicode character normalization. If you use - combining chars for accents and other character decorations, you must - declare character classes for them, and use the same sequence of base character - and combining marks in the XSLFO source, otherwise the pattern wouldn't match. - Fortunately, Unicode provides precomposed characters for all important cases - in common languages, until now nobody run seriously into this issue. Some dead - languages and dialects, especially ancient ones, may pose a real problem - though.

-

If you want to generate your own patterns, an open-source utility called - patgen is available on many Unix/Linux distributions and every TeX - distribution which can be used to assist in - creating pattern files from dictionaries. Pattern creation for languages like - english or german is an art. If you can, read Frank Liang's original paper - "Word Hy-phen-a-tion by Com-pu-ter" (yes, with hyphens). It is not available - online. The original patgen.web source, included in the TeX source distributions, - contains valuable comments, unfortunately technical details obscure often the - high level issues. Another important source is - The - TeX Book, appendix H (either read the TeX source, or run it through - TeX to typeset it). Secondary articles, for example the works by Petr Sojka, - may also give some much needed insight into problems arising in automated - hyphenation.

-
- -
diff --git a/src/documentation/content/xdocs/0.93/index.xml b/src/documentation/content/xdocs/0.93/index.xml deleted file mode 100644 index 3542e1d5f..000000000 --- a/src/documentation/content/xdocs/0.93/index.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - -
- Apache FOP Version 0.93 - $Revision$ -
- -
- Introduction -

- The Apache FOP team is proud to present to you this production quality release. It has taken - over three years to get this far and over two years without a new release from the FOP - project. We're still in the process of adding new features. We welcome any feedback you - might have and even more, any other form of help to get the project forward. -

-

- This fourth release contains many bug fix release and new features compared - to 0.92beta. To see what has changed since the last release, please visit the - Changes Page and the Release Notes. -

-
-
- Upgrading from an earlier version -

- If you're upgrading to this version from an earlier version of FOP, please read the - information contained on the Upgrading page! -

-
-
- Download -

- To download this version, please visit the download page. -

-
- -
diff --git a/src/documentation/content/xdocs/0.93/intermediate.xml b/src/documentation/content/xdocs/0.93/intermediate.xml deleted file mode 100644 index 4744185aa..000000000 --- a/src/documentation/content/xdocs/0.93/intermediate.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - -
- Intermediate Format - $Revision$ -
- - - Please note that the intermediate format is an advanced feature and can be ignored by most - users of Apache FOP. - -
- Introduction -

- The intermediate format (IF) is a proprietary XML format that represents the area tree - generated by the layout engine. The area tree is conceptually defined in the - XSL-FO specification in chapter 1.1.2. - The IF can be generated through the area tree XML Renderer (the XMLRenderer). -

-

- The intermediate format can be used to generate intermediate documents that are modified - before they are finally rendered to their ultimate output format. Modifications include - adjusting and changing trait values, adding or modifying area objects, inserting prefabricated - pages, overlays, imposition (n-up, rotation, scaling etc.). Multiple IF files can be combined - to a single output file. -

-
-
- Usage of the Intermediate Format -

- As already mentioned, the IF is generated by using the XMLRenderer (MIME type: - application/X-fop-areatree). So, you basically set the right MIME type for - the output format and process your FO files as if you would create a PDF file. However, there - is an important detail to consider: The various Renderers don't all use the same font sources. - To be able to create the right area tree for the ultimate output file, you need to create - the IF file using the right font setup. This is achieved by telling the XMLRenderer to mimic - another renderer. This is done by calling the XMLRenderer's mimicRenderer() method with an - instance of the ultimate target renderer as the single parameter. This has a consequence: An - IF file rendered with the Java2DRenderer may not look as expected when it was actually generated - for the PDF renderer. For renderers that use the same font setup, this restriction does not - apply (PDF and PS, for example). Generating the intermediate format file is the first step. -

-

- The second step is to reparse the IF file using the AreaTreeParser which is - found in the org.apache.fop.area package. The pages retrieved from the IF file are added to an - AreaTreeModel instance from where they are normally rendered using one of the available Renderer - implementations. You can find examples for the IF processing in the - examples/embedding - directory in the FOP distribution -

-

- The basic pattern to parse the IF format looks like this: -

- -

- This example simply reads an IF file and renders it to a PDF file. Please note, that in normal - FOP operation you're shielded from having to instantiate the FontInfo object yourself. This - is normally a task of the AreaTreeHandler which is not present in this scenario. The same - applies to the AreaTreeModel instance, in this case an instance of a subclass called - RenderPagesModel. RenderPagesModel is ideal in this case as it has very little overhead - processing the individual pages. An important line in the example is the call to - endDocument() on the AreaTreeModel. This lets the Renderer know that the processing - is now finished. -

-

- The intermediate format can also be used from the command-line - by using the "-atin" parameter for specifying the area tree XML as input file. You can also - specify a "mimic renderer" by inserting a MIME type between "-at" and the output file. -

-
- Concatenating Documents -

- This initial example is obviously not very useful. It would be faster to create the PDF file - directly. As the ExampleConcat.java - example shows you can easily parse multiple IF files in a row and add the parsed pages to the - same AreaTreeModel instance which essentially concatenates all the input document to one single - output document. -

-
-
- Modifying Documents -

- One of the most important use cases for the intermediate format is obviously modifying the area - tree XML before finally rendering it to the target format. You can easily use XSLT to process - the IF file according to your needs. Please note, that we will currently not formally describe - the intermediate format. You need to have a good understanding its structure so you don't - create any non-parseable files. We may add an XML Schema and more detailed documentation at a - later time. You're invited to help us with that. -

-
-
- Advanced Use -

- The generation of the intermediate format as well as it parsing process has been designed to allow - for maximum flexibility and optimization. Please note that you can call setTransformerHandler() on - XMLRenderer to give the XMLRenderer your own TransformerHandler instance in case you would like to - do custom serialization (to a W3C DOM, for example) and/or to directly modify the area tree using - XSLT. The AreaTreeParser on the other side allows you to retrieve a ContentHandler instance where - you can manually send SAX events to to start the parsing process (see getContentHandler()). -

-
-
- -
diff --git a/src/documentation/content/xdocs/0.93/known-issues.xml b/src/documentation/content/xdocs/0.93/known-issues.xml deleted file mode 100644 index 25af2a217..000000000 --- a/src/documentation/content/xdocs/0.93/known-issues.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - MIF and SVG output support have not been restored, yet. - - - Java2D/AWT support has been improved, but some problems remain, - for example with block-containers. - - - Auto table layout is not implemented, yet. - - - The collapsing border model on tables is not implemented, yet. Please - use border-collapse="separate" for now. - - - Footnotes may overlap with text of the region-body in multi-column - documents. - - - Space resolution does not work between footnote regions. - - - There's a problem involving nested block-containers and - reference-orientation 180/-180 (Bugzilla #36391) - - - block-containers with no height currently don't create a fence for - spaces as they should (they behave like a normal block). - - - Preserved linefeeds in fo:character are not handled correctly. - - - An empty block currently produces a fence for stacking constraints - which it shouldn't. - - - There are several small problems around white space handling. - - - Images currently don't shrink so they fit on a page when they are - too big and shrinking is allowed to happen. - - - inline-container may not work as expected. - - - letter-spacing and word-spacing properties may not work as expected. - - - leaders with leader-pattern="use-content" may not work as expected. - - - keep-with-previous doesn't work inside tables and lists, yet. - - - If two consecutive pages don't have the same available width, the - content currently isn't properly fit into the available space on - the new page. - - - background-images on page-number-citations are not placed correctly. - - - Not all FO elements can be referenced by their "id", most notably: - table-body, table-header, table-footer and table-row. - - - The backgrounds of table-body, table-header, table-footer and - table-column are not painted, yet. - - - Border and padding conditionality are not supported on table-cells, yet. - - - Column balancing in multi-column documents may not work as expected - (Bugzilla #36356) - - - Internal basic-links don't point to the exact location on a page, yet, as they - did in 0.20.5. Currently you land in the upper left corner of the page. - - diff --git a/src/documentation/content/xdocs/0.93/knownissues_overview.xml b/src/documentation/content/xdocs/0.93/knownissues_overview.xml deleted file mode 100644 index 0f91bb482..000000000 --- a/src/documentation/content/xdocs/0.93/knownissues_overview.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - -
- Apache FOP: Known Issues - $Revision$ -
- -
- Known issues -

- This page lists currently known issues in the current release. -

- -

- For additional information on known issues in Apache FOP, please have a look at the following pages, too: -

- -
-

- Apache FOP has an extensive automated testing infrastructure. Parts of this infrastructure are several - sets of test cases. When a test case is listed in disabled-testcases.xml it is disabled in the JUnit - tests during the normal build process. This indicates a problem in the current codebase. When a bug is - fixed or a missing feature is added the entry for the relevant test case(s) are removed. -

-
- FO Tree -

- This section lists currently disabled test cases in the test suite for the FO tree tests. - The data for this section comes from - test/fotree/disabled-testcases.xml. -

- -
-
- Layout Engine -

- This section lists currently disabled test cases in the test suite for the layout engine tests. - The data for this section comes from - test/layoutengine/disabled-testcases.xml. -

- -
-
- Other known issues -

This section lists other known issues.

- -
-
- -
- diff --git a/src/documentation/content/xdocs/0.93/layoutengine/disabled-testcases.xml b/src/documentation/content/xdocs/0.93/layoutengine/disabled-testcases.xml deleted file mode 100644 index cdaaaa741..000000000 --- a/src/documentation/content/xdocs/0.93/layoutengine/disabled-testcases.xml +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - External link around an SVG not properly sized - basic-link_external-destination_2.xml - The bpd trait of the inlineparent area for the basic-link - is not sized correctly if it wraps an image that is higher than the - nominal line. - - - Bugzilla #36391: reference-orientation - block-container_reference-orientation_bug36391.xml - There's a problem involving nested block-containers - and reference-orientation 180/-180. - http://issues.apache.org/bugzilla/show_bug.cgi?id=36391 - - - Auto-height block-containers produce fences - block-container_space-before_space-after_3.xml - Block-containers with no height currently don't - create a fence for spaces as they should (they behave like a - normal block). - - - font-stretch NYI - block_font-stretch.xml - Font-stretch is not implemented, yet. - - - Hyphenation with preserved linefeeds - block_hyphenation_linefeed_preserve.xml - When hyphenation is enabled and linefeeds are preserved linefeeds - are painted as '#' and the text is output multiple times. - - - linefeed-treatment - block_linefeed-treatment.xml - Preserved linefeeds in a fo:character are not handled - correctly. - - - white-space-treatment - block_white-space-treatment_3.xml - White space handling incorrectly stops at fo:inline - boundaries when it comes to formatter generated line breaks. - - - Empty blocks produce fences - block_space-before_space-after_8.xml - An empty block currently produces a fence for - stacking constraints which it shouldn't. - - - block white-space nbsp 2 - block_white-space_nbsp_2.xml - The nbsp given as an fo:character is not adjustable and therefore - the justification does not work in this case. - - - block word-spacing - block_word-spacing.xml - Word-spacing may not work as expected. - - - block word-spacing text-align justify - block_word-spacing_text-align_justify.xml - Word-spacing may not work as expected. - - - external-graphic don't shrink - external-graphic_oversized.xml - Images currently don't shrink so they fit on a page - when they are too big and shrinking is allowed to - happen (min/opt/max). - - - Test case with HTTP URL - external-graphic_src_uri.xml - Doesn't work behind a proxy which requires - authorization. - - - Space Resolution in foot note area - footnote_space-resolution.xml - Space resolution does not work between footnote - regions. - - - Footnotes swallowed in hyphenated fo:inlines - footnote_in_inline.xml - getChangedKnuthElements probably loses the footnote - layout manager somewhere along the way. - - - Footnotes swallowed in lists - footnote_in_list.xml - Element lists for lists are created by combining the - element lists from list-item-label and list-item-body. The - footnotes contained in the KnuthBlockBoxes are not propagated to - the combined element list. - http://issues.apache.org/bugzilla/show_bug.cgi?id=37579 - - - Footnotes swallowed in tables - footnote_in_table.xml - Element lists for tables are created by combining the - element lists from the individual table-cells. The footnotes - contained in the KnuthBlockBoxes are not propagated to the combined - element list. - http://issues.apache.org/bugzilla/show_bug.cgi?id=37579 - - - keeps on inlines NYI - inline_keep-together.xml - Keeps are not implemented in inline-level elements, yet. - - - NPE for table inside an inline - inline_block_nested_3.xml - Placing a table as a child of an fo:inline produces a - NullPointerException. - - - inline-container is not implemented, yet. - inline-container_block_nested.xml - inline-container is not implemented, yet. Content of an - inline-container will get swallowed. The test case contains no checks. - - - inline-container is not implemented, yet. - inline-container_border_padding.xml - inline-container is not implemented, yet. Content of an - inline-container will get swallowed. - - - inline letter-spacing - inline_letter-spacing.xml - Letter-spacing may not work as - expected within fo:inline. - - - inline word-spacing - inline_word-spacing.xml - Word-spacing may not work as expected within - fo:inline. - - - inline word-spacing text-align justify - inline_word-spacing_text-align_justify.xml - - - - leader-alignment NYI - leader-alignment.xml - Leader-alignment is not yet - implemented. - - - leader-pattern="use-content": Problem with line height - leader_leader-pattern_use-content_bug.xml - Line height is not correctly calculated for - use-content leaders whose height is larger than the rest of the - line. - http://www.nabble.com/leaders-with-leader-pattern%3D%22use-content%22-t546244.html - - - keep-with-previous doesn't work in lists - list-block_keep-with-previous.xml - Keep-with-previous doesn't work inside tables and - lists, yet. - - - keep-with-previous doesn't work in lists - list-item_block_keep-with-previous.xml - Keep-with-previous doesn't work inside tables and - lists, yet. - - - Page breaking doesn't deal with IPD changes - page-breaking_4.xml - Page breaking currently doesn't support changing available IPD - between pages of a single page-sequence. Element list generation has to be reset to - redetermine line breaks in this case. - - - Overflow handing is incomplete - page-breaking_6.xml - Line breaking is not 100% correct when there's too little space. - Overflows are not detected and warned. - - - Indefinite page height handling is imcomplete - page-height_indefinite_simple.xml - A RuntimeException is thrown for a page of indefinite height. Lots of warnings. - - - page-number-citation: Problem with background-image - page-number-citation_background-image.xml - Background-images on page-number-citations are not - placed correctly. - - - page-number-citation-last: FOs spanning multiple pages are not properly handled. - page-number-citation-last_basic.xml - Resolution of forward references does not wait until an FO is fully finished when an FO spans multiple pages. - - - IDs are not working on all FO elements - page-number-citation_complex_1.xml - The "id" attributes are not properly handled for all block-level FO elements. - - - IDs are not working on all FO elements - page-number-citation_complex_2.xml - The "id" attributes are not properly handled for all inline-level FO elements. - - - Footnotes in multi-column documents - region-body_column-count_footnote.xml - Footnotes may overlap with text of the region-body in - multi-column documents. - - - Column Balancing problems - region-body_column-count_balance_4col.xml - Situation in a 4-column document where the column balancing doesn't work and even causes some - content to disappear. - - - Column Balancing problems - region-body_column-count_bug36356.xml - Column balancing doesn't work as expected. - - - No background-images on table-body - table-body_background-image.xml - The backgrounds of table-body, table-header, - table-footer and table-column are not painted, yet. - - - Collapsing Border Model NYI - table_border-collapse_collapse_1.xml - Border-collapse="collapse" is not yet - implemented. - - - Collapsing Border Model NYI - table_border-collapse_collapse_2.xml - Border-collapse="collapse" is not yet - implemented. - - - Problems with border and padding on tables - table_border_padding.xml - The element list seems to not be fully correct, yet, causing - the layout to look odd. - - - keep-with-previous doesn't work inside tables - table-cell_block_keep-with-previous.xml - Keep-with-previous doesn't work inside tables and - lists, yet. - - - Border and padding conditionality is NYI on table-cells - table-cell_border_padding_conditionality.xml - Border and padding conditionality are not supported - on table-cells, yet. - - - No background-images on table-header - table-header_background-image.xml - The backgrounds of table-body, table-header, - table-footer and table-column are not painted, yet. - - - keep-with-previous doesn't work on table-rows - table-row_keep-with-previous.xml - Keep-with-previous doesn't work inside tables and - lists, yet. - - - table-cell empty area with marker.xml - table-cell_empty_area_with_marker.xml - A table-cell producing an empty area does currently not add any markers to a page. - See TODO entry in AreaAdditionUtil. - - - Border conditionality on table - table_border-width_conditionality.xml - The code should be ok, but the test case uses shorthands and therefore - is probably not expressing the indended outcome according to the spec. The test - case should be revisited. - - - fo:wrapper around block-level content - wrapper_block.xml - A ClassCastException occurs when fo:wrapper directly surrounds a - block-level element because its layout manager is written to handle only - inline content. - - - Bugzilla #40230: invalid extra page break - block_break-after_bug40230.xml - Currently an extra page is created even if there is nothing - after a block with break-after="page" - http://issues.apache.org/bugzilla/show_bug.cgi?id=40230 - - diff --git a/src/documentation/content/xdocs/0.93/output.xml b/src/documentation/content/xdocs/0.93/output.xml deleted file mode 100644 index fdc37931d..000000000 --- a/src/documentation/content/xdocs/0.93/output.xml +++ /dev/null @@ -1,772 +0,0 @@ - - - - - - -
- Apache FOP Output Formats - $Revision$ - - - - -
- - -

- FOP supports multiple output formats by using a different renderer for each format. - The renderers do not all have the same set of capabilities, sometimes because of - the output format itself, sometimes because some renderers get more development - attention than others. -

-
- General Information -
- Fonts -

- Most FOP renderers use a FOP-specific system for font registration. - However, the Java2D/AWT and print renderers use the Java AWT package, which gets its - font information from the operating system registration. - This can result in several differences, including actually using different fonts, - and having different font metrics for the same font. - The net effect is that the layout of a given FO document can be quite different between - renderers that do not use the same font information. -

-
-
- Output to a Printer or Other Device -

- The most obvious way to print your document is to use the FOP - print renderer, which uses the Java2D API (AWT). - However, you can also send output from the Postscript renderer directly to a Postscript - device, or output from the PCL renderer directly to a PCL device. -

-

- Here are Windows command-line examples for Postscript and PCL: -

- - -

- Here is some Java code to accomplish the task in UNIX: -

- -

- Set the output MIME type to "application/x-pcl" (MimeConstants.MIME_PCL) and - it happily sends the PCL to the UNIX printer queue. -

-
-
-
- PDF -

- PDF is the best supported output format. It is also the most accurate - with text and layout. This creates a PDF document that is streamed out - as each page is rendered. This means that the internal page index - information is stored near the end of the document. - The PDF version supported is 1.4. PDF versions are forwards/backwards - compatible. -

-

- Note that FOP does not currently support "tagged PDF" or PDF/A-1a. - Support for PDF/A-1b and PDF/X has recently been added, however. -

-
- Fonts -

- PDF has a set of fonts that are always available to all PDF viewers; - to quote from the PDF Specification: - - "PDF prescribes a set of 14 standard fonts that can be used without prior - definition. - These include four faces each of three Latin text typefaces (Courier, - Helvetica, and Times), as well as two symbolic fonts (Symbol and ITC Zapf - Dingbats). These fonts, or suitable substitute fonts with the same metrics, are - guaranteed to be available in all PDF viewer applications." -

-
-
- Post-processing -

- FOP does not currently support several desirable PDF features: XMP metadata and watermarks. - One workaround is to use Adobe Acrobat (the full version, not the Reader) to process - the file manually or with scripting that it supports. -

-

- Another popular post-processing tool is iText, - which has tools for adding security features, document properties, watermarks, and many - other features to PDF files. -

- - Caveat: iText may swallow PDF bookmarks. But - Jens Stavnstrup tells us - that this doesn't happen if you use iText's PDFStamper. - -

- Here is some sample code that uses iText to encrypt a FOP-generated PDF. (Note that FOP now - supports PDF encryption. However the principles for using - iText for other PDF features are similar.) -

- -

- Check the iText tutorial and documentation for setting access flags, password, - encryption strength and other parameters. -

-
-
- Watermarks -

- In addition to the PDF Post-processing options, consider the following workarounds: -

-
    -
  • - Use a background image for the body region. -
  • -
  • - (submitted by Trevor Campbell) Place an image in a - region that overlaps the flowing text. For example, make - region-before large enough to contain your image. Then include a - block (if necessary, use an absolutely positioned block-container) - containing the watermark image in the static-content for the - region-before. Note that the image will be drawn on top of the - normal content. -
  • -
-
-
-
- PostScript -

- The PostScript renderer has been brought up to a similar quality as the - PDF renderer, but may still be missing certain features. It provides good - support for most text and layout. - Images and SVG are not fully supported, yet. Currently, the PostScript - renderer generates PostScript Level 3 with most DSC comments. Actually, - the only Level 3 feature used is FlateDecode, everything else is Level 2. -

-
- Limitations -
    -
  • Images and SVG may not be displayed correctly. SVG support is far from being complete. No image transparency is available.
  • -
  • Only Type 1 fonts are supported.
  • -
  • Multibyte characters are not supported.
  • -
  • PPD support is still missing.
  • -
-
-
-
- PCL -

- This format is for the Hewlett-Packard PCL printers and other printers - supporting PCL. It should produce output as close to identical as possible - to the printed output of the PDFRenderer within the limitations of the - renderer, and output device. -

-

- The output created by the PCLRenderer is generic PCL 5, HP GL/2 and PJL. - This should allow any device fully supporting PCL 5 to be able to - print the output generated by the PCLRenderer. PJL is used to control the - print job and switch to the PCL language. PCL 5 is used for text, raster - graphics and rectangular fill graphics. HP GL/2 is used for more complex - painting operations. Certain painting operations are done off-screen and - rendered to PCL as bitmaps because of limitations in PCL 5. -

-
- References - -
-
- Limitations -
    -
  • - Text or graphics outside the left or top of the printable area are not - rendered properly. This is a limitation of PCL, not FOP. In general, - things that should print to the left of the printable area are shifted - to the right so that they start at the left edge of the printable area. -
  • -
  • - The Helvetica and Times fonts are not well supported among PCL printers - so Helvetica is mapped to Arial and Times is mapped to Times New. This - is done in the PCLRenderer, no changes are required in the FO's. The - metrics and appearance for Helvetica/Arial and Times/Times New are - nearly identical, so this has not been a problem so far. -
  • -
  • For the non-symbol fonts, the ISO 8859-1 symbol set is used (PCL set "0N").
  • -
  • - All fonts available to the Java2D subsystem are usable. The texts are - painted as bitmap much like the Windows PCL drivers do. -
  • -
  • Multibyte characters are not supported.
  • -
  • - At the moment, only monochrome output is supported. PCL5c color extensions - will only be implemented on demand. Color and grayscale images are converted - to monochrome bitmaps (1-bit). Dithering only occurs if the JAI image library - is available. -
  • -
  • - Images are scaled up to the next resolution level supported by PCL (75, - 100, 150, 200, 300, 600 dpi). For color and grayscale images an even - higher PCL resolution is selected to give the dithering algorithm a chance - to improve the bitmap quality. -
  • -
  • - Currently, there's no support for clipping and image transparency, largely - because PCL 5 has certain limitations. -
  • -
-
-
- Configuration -

- The PCL renderer configuration currently allows the following settings: -

- - quality - bitmap -]]> -

- The default value for the "rendering" setting is "speed" which causes borders - to be painted as plain rectangles. In this mode, no special borders (dotted, - dashed etc.) are available. If you want support for all border modes, set the - value to "quality" as indicated above. This will cause the borders to be painted - as bitmaps. -

-

- The default value for the "text-rendering" setting is "auto" which paints the - base fonts using PCL fonts. Non-base fonts are painted as bitmaps through Java2D. - If the mix of painting methods results in unwelcome output, you can set this - to "bitmap" which causes all text to be rendered as bitmaps. -

-

- You can control the output resolution for the PCL using the "target resolution" - setting on the FOUserAgent. The actual value will be rounded up to the next - supported PCL resolution. Currently, only 300 and 600 dpi are supported which - should be enough for most use cases. Note that this setting directly affects - the size of the output file and the print quality. -

-
-
- Extensions -

The PCL Renderer supports some PCL specific extensions which can be embedded - into the input FO document. To use the extensions the appropriate namespace must - be declared in the fo:root element like this:

- -]]> -
- Page Source (Tray selection) -

- The page-source extension attribute on fo:simple-page-master allows to - select the paper tray the sheet for a particular simple-page-master is - to be taken from. Example: -

- - - ... - - -]]> -

- Note: the tray number is a positive integer and the value depends on - the target printer. Not all PCL printers support the same paper trays. - 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. -

-
-
-
-
- AFP - The AFP Renderer is a new addition (27-Apr-2006) to the sandbox and as such not yet fully tested or feature complete. -

- The FOP AFP Renderer deals with creating documents conforming to the IBM AFP document architecture - also refered to as MO:DCA (Mixed Object Document Content Architecture). -

-
- References - -
-
- Limitations -

This list is most likely badly incomplete.

-
    -
  • - Clipping of text and graphics is not supported. -
  • -
  • - Only IBM outline and raster fonts and to a limited extend the original fonts built into FOP are supported. - Support for TrueType fonts may be added later. -
  • -
-
-
- Configuration -
- Fonts -

The AFP Renderer requires special configuration particularly related to fonts. - AFP Render configuration is done through the normal FOP configuration file. The MIME type - for the AFP Renderer is application/x-afp which means the AFP Renderer section in the FOP configuration file - looks like:

- - - ... -]]> -

There are 3 font configuration variants supported:

-
    -
  1. IBM Raster fonts
  2. -
  3. IBM Outline fonts
  4. -
  5. FOP built-in Base14 fonts
  6. -
-

A typical raster font configuration looks like:

- - - - - - - - - - - - - - - - - - - - - - - - ]]> -

An outline font configuration is simpler as the individual font size entries are not required. - However, the characterset definition is now required within the afp-font element.

- - - - - - -]]> -

Experimentation has shown that the font metrics for the FOP built-in Base14 fonts are actually - very similar to some of the IBM outline and raster fonts. In cases were the IBM font files are not - available the path attribute in the afp-font element can be replaced by a base14-font attribute - giving the name of the matching Base14 font. In this case the AFP Renderer will take the - font metrics from the built-in font.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]]> -
-
- Images -

By default the AFP Renderer converts all images to 8 bit grey level. - This can be overridden by the <images> configuration element. Example:

- -]]> -

This will put images as RGB images into the AFP output stream. The default setting is:

- -]]> -

Only the values "color" and "b+w" are allowed for the mode attribute. The bits-per-pixel - attribute is ignored if mode is "color". For "b+w" mode is must be 1, 4, or 8.

-
-
-
- Extensions -

The AFP Renderer supports some AFP specific extensions which can be embedded into the input - fo document. To use the extensions the appropriate namespace must be declared in the fo:root element like this:

- -]]> -
- Page Overlay Extension -

The include-page-overlay extension element allows to define on a per simple-page-master basis a page overlay resource. Example:

- - - - ... - - -]]> -

The mandatory name attribute must refer to an 8 character (space padded) resource name that - must be known in the AFP processing environment.

-
-
- Page Segment Extension -

The include-page-segment extension element allows to define resource substitution for fo:external-graphics elements. - Example:

- - - - - - - -]]> -

The include-page-segment extension element can only occur within a simple-page-master. - Multiple include-page-segment extension elements within a simple-page-master are allowed. - The mandatory name attribute must refer to an 8 character - (space padded) resource name that must be known in the AFP processing environment. - The value of the mandatory src attribute is compared against the value of the src attribute in - fo:external-graphic elements and if it is identical (string matching is used) in the generated - AFP the external graphic is replaced by a reference to the given resource. -

-
-
- Tag Logical Element Extension -

The tag-logical-element extension element allows to injects TLEs into the AFP output stream. Example: - Example:

- - - - - - - -]]> -

The tag-logical-element extension element can only occur within a simple-page-master. - Multiple tag-logical-element extension elements within a simple-page-master are allowed. - The name and value attributes are mandatory. -

-
-
-
-
- RTF -

- JFOR, an open source XSL-FO to RTF converter has been integrated into Apache FOP. - This will create an RTF (rich text format) document that will - attempt to contain as much information from the fo document as - possible. The RTF output follows Microsoft's RTF specifications - and produces best results on Microsoft Word. -

-
-
- XML (Area Tree XML) -

- This is primarily for testing and verification. The XML created is simply - a representation of the internal area tree put into XML. We use that to verify - the functionality of FOP's layout engine. -

-

- The other use case of the Area Tree XML is as FOP's "intermediate format". More information - on that can be found on the page dedicated to the Intermediate Format. -

-
-
- Java2D/AWT -

- The Java2DRenderer provides the basic functionality for all - Java2D-based output formats (AWT viewer, direct print, PNG, TIFF). -

-

- The AWT viewer shows a window with the pages displayed inside a - Java graphic. It displays one page at a time. - The fonts used for the formatting and viewing depend on the fonts - available to your JRE. -

-
-
- Print -

- It is possible to directly print the document from the command line. - This is done with the same code that renders to the Java2D/AWT renderer. -

-
-
- Bitmap (TIFF/PNG) -

- It is possible to directly create bitmap images from the individual - pages generated by the layout engine. - This is done with the same code that renders to the Java2D/AWT renderer. -

-

- Currently, two output formats are supported: PNG and TIFF. TIFF produces - one file with multiple pages, while PNG output produces one file per - page. The quality of the bitmap depends on the target resolution setting - on the FOUserAgent. -

-
- Configuration -

- The TIFF and PNG renderer configuration currently allows the following settings: -

- - true - -]]> -

- The default value for the "transparent-page-background" setting is "false" which - paints an opaque, white background for the whole image. If you set this to true, - no such background will be painted and you will get a transparent image if - an alpha channel is available in the output format. -

-
-
- TIFF-specific Configuration -

- In addition to the above values the TIFF renderer configuration allows some additional - settings: -

- - true - CCITT T.6 - -]]> -

- The default value for the "compression" setting is "PackBits" which is a - widely supported RLE compression scheme for TIFF. The set of compression - names to be used here matches the set that the Image I/O API uses. Note that - not all compression schemes may be available during runtime. This depends on the - actual codecs being available. Here is a list of possible values: -

-
    -
  • NONE (no compression)
  • -
  • PackBits (RLE, run-length encoding)
  • -
  • JPEG
  • -
  • Deflate
  • -
  • LZW
  • -
  • ZLib
  • -
  • CCITT T.4 (Fax Group 3)
  • -
  • CCITT T.6 (Fax Group 4)
  • -
- - If you want to use CCITT compression, please make sure you've got a J2SE 1.4 or later and - - Java Advanced Imaging Image I/O Tools - - in your classpath. The Sun JRE doesn't come with a TIFF codec built in, so it has to be - added separately. The internal TIFF codec from XML Graphics Commons only supports PackBits, - Deflate and JPEG compression for writing. - -
-
-
- TXT -

- The text renderer produces plain ASCII text output - that attempts to match the output of the PDFRenderer as closely as - possible. This was originally developed to accommodate an archive system - that could only accept plain text files, and is primarily useful for getting - a quick-and-dirty view of the document text. The renderer is very limited, - so do not be surprised if it gives unsatisfactory results. -

-

- The Text renderer works with a fixed size page buffer. The size of this - buffer is controlled with the textCPI and textLPI public variables. - The textCPI is the effective horizontal characters per inch to use. - The textLPI is the vertical lines per inch to use. From these values - and the page width and height the size of the buffer is calculated. - The formatting objects to be rendered are then mapped to this grid. - Graphic elements (lines, borders, etc) are assigned a lower priority - than text, so text will overwrite any graphic element representations. -

-

- Because FOP lays the text onto a grid during layout, there are frequently - extra or missing spaces between characters and lines, which is generally - unsatisfactory. - Users have reported that the optimal settings to avoid such spacing problems are: -

-
    -
  • font-family="Courier"
  • -
  • font-size="7.3pt"
  • -
  • line-height="10.5pt"
  • -
-
-
- Output Formats in the Sandbox -

- Due to the state of certain renderers we moved some of them to a "sandbox" area until - they are ready for more serious use. The renderers and FOEventHandlers in the sandbox - can be found under src/sandbox and are compiled into build/fop-sandbox.jar during the - main build. The output formats in the sandbox are marked as such below. -

-
- MIF - The MIF handler is in the sandbox and not yet functional in FOP Trunk!!! Please help us ressurrect this feature. -

- This format is the Maker Interchange Format which is used by - Adobe Framemaker. -

-
-
- SVG - The SVG renderer is in the sandbox and may not work as expected in FOP Trunk!!! Please help us improve this feature. -

- This format creates an SVG document that has links between the pages. - This is primarily for slides and creating svg images of pages. - Large documents will create SVG files that are far too large for - an SVG viewer to handle. Since FO documents usually have text the - SVG document will have a large number of text elements. - The font information for the text is obtained from the JVM in the - same way as for the AWT viewer. If the SVG is viewed on a - system where the fonts are different, such as another platform, - then the page may look wrong. -

-
-
-
- Wish list -

- Apache FOP is easily extensible and allows you to add new output formats to enhance FOP's functionality. There's a number of output formats - which are on our wish list. We're looking for volunteers to help us implement them. -

- -
- - -
- diff --git a/src/documentation/content/xdocs/0.93/pdfa.xml b/src/documentation/content/xdocs/0.93/pdfa.xml deleted file mode 100644 index 64bd5dc91..000000000 --- a/src/documentation/content/xdocs/0.93/pdfa.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - -
- PDF/A (ISO 19005) - $Revision$ - - - -
- -
- Overview - - Support for PDF/A is available beginning with version 0.92. - -

- PDF/A is a standard which turns PDF into an "electronic document file - format for long-term preservation". PDF/A-1 is the first part of the - standard and is documented in - ISO 19005-1:2005(E). - Work on PDF/A-2 is in progress at - AIIM. -

-

- Design documentation on PDF/A can be found on FOP's Wiki on the - PDFA1ConformanceNotes page. -

-
-
- Implementation Status -

- PDF/A-1b is implemented to the degree that FOP supports - the creation of the elements described in ISO 19005-1. -

-

- Tests have been performed against jHove and Adobe Acrobat 7.0.7 (Preflight function). - FOP does not validate completely against Apago's PDF Appraiser. Reasons unknown due to - lack of a full license to get a detailed error protocol. -

-

- PDF/A-1a is not implemented, yet. This is mostly because of the requirement - for tagged PDF which is not available in FOP, yet. -

-
-
- Usage (command line) -

- To activate PDF/A-1b from the command-line, specify "-pdfprofile PDF/A-1b" - as a parameter. If there is a violation of one of the validation rules for - PDF/A, an error message is presented and the processing stops. -

-
-
- Usage (embedded) -

- When FOP is embedded in another Java application you can set a special option - on the renderer options in the user agent to activate the PDF/A-1b profile. - Here's an example: -

- -

- If one of the validation rules of PDF/A is violated, an PDFConformanceException - (descendant of RuntimeException) is thrown. -

-
-
- PDF/A in Action -

- There are a number of things that must be looked after if you activate a PDF/A - profile. If you receive a PDFConformanceException, have a look at the following - list (not necessarily comprehensive): -

-
    -
  • - Make sure all (!) fonts are embedded. If you use base 14 fonts (like Helvetica) - you need to obtain a license for them and embed them like any other font. -
  • -
  • - Don't use PDF encryption. PDF/A doesn't allow it. -
  • -
  • - Don't use CMYK images without an ICC color profile. PDF/A doesn't allow mixing - color spaces and FOP currently only properly supports the sRGB color space. Please - note that FOP embeds a standard sRGB ICC profile (sRGB IEC61966-2.1) as the - primary output intent for the PDF if no other output intent has been specified - in the configuration. -
  • -
  • - Don't use non-RGB colors in SVG images. Same issue as with CMYK images. -
  • -
  • - Don't use EPS graphics with fo:external-graphic. Embedding EPS graphics in PDF - is deprecated since PDF 1.4 and prohibited by PDF/A. -
  • -
  • - PDF is forced to version 1.4 if PDF/A-1 is activated. -
  • -
  • - No filter must be specified explicitely for metadata objects. Metadata must be - embedded in clear text so non-PDF-aware applications can extract the XMP metadata. -
  • -
-
-
- PDF profile compatibility -

- The PDF profiles "PDF/X-3:2003" and "PDF/A-1b" are compatible and can both be - activated at the same time. -

-
- -
diff --git a/src/documentation/content/xdocs/0.93/pdfencryption.xml b/src/documentation/content/xdocs/0.93/pdfencryption.xml deleted file mode 100644 index f68eae437..000000000 --- a/src/documentation/content/xdocs/0.93/pdfencryption.xml +++ /dev/null @@ -1,234 +0,0 @@ - - - - - -
- PDF encryption. - $Revision$ - - - - -
- -
- Overview - - PDF Encryption is available in Release 0.20.5 and later. The comments on this page do - not apply to releases earlier than 0.20.5. - -

- FOP supports encryption of PDF output, thanks to Patrick - C. Lankswert. This feature is commonly used to prevent - unauthorized viewing, printing, editing, copying text from the - document and doing annotations. It is also possible to ask the - user for a password in order to view the contents. Note that - there already exist third party applications which can decrypt - an encrypted PDF without effort and allow the aforementioned - operations, therefore the degree of protection is limited. -

-

- For further information about features and restrictions regarding PDF - encryption, look at the documentation coming with Adobe Acrobat or the - technical documentation on the Adobe web site. -

-
-
- Usage (command line) -

- Encryption is enabled by supplying any of the encryption related - options. -

-

- An owner password is set with the -o option. This - password is actually used as encryption key. Many tools for - PDF processing ask for this password to disregard any - restriction imposed on the PDF document. -

-

- If no owner password has been supplied but FOP was asked to apply some - restrictions, a random password is used. In this case it is obviously - impossiible to disregard restrictions in PDF processing tools. -

-

- A user password, supplied with the -u option, will - cause the PDF display software to ask the reader for this password in - order to view the contents of the document. If no user password was - supplied, viewing the content is not restricted. -

-

- Further restrictions can be imposed by using the -noprint, - -nocopy, -noedit and - -noannotations options, which disable printing, copying - text, editing in Adobe Acrobat and making annotations, respectively. -

-
-
- Usage (embedded) -

- When FOP is embedded in another Java application you need to set an - options map on the renderer. These are the supported options: -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionDescriptionValuesDefault
ownerPasswordThe owner passwordString -
userPasswordThe user passwordString -
allowPrintAllows/disallows printing of the PDF"TRUE" or "FALSE""TRUE"
allowCopyContentAllows/disallows copy/paste of content"TRUE" or "FALSE""TRUE"
allowEditContentAllows/disallows editing of content"TRUE" or "FALSE""TRUE"
allowEditAnnotationsAllows/disallows editing of annotations"TRUE" or "FALSE""TRUE"
- - Encryption is enabled as soon as one of these options is set. - -

- An example to enable PDF encryption in Java code: -

- -

- The parameters for the constructor of PDFEncryptionParams are: -

-
    -
  1. userPassword: String, may be null
  2. -
  3. ownerPassword: String, may be null
  4. -
  5. allowPrint: true if printing is allowed
  6. -
  7. allowCopyContent: true if copying content is allowed
  8. -
  9. allowEditContent: true if editing content is allowed
  10. -
  11. allowEditAnnotations: true if editing annotations is allowed
  12. -
-

- Alternatively, you can set each value separately in the Map provided by - FOUserAgent.getRendererOptions() by using the following keys: -

-
    -
  1. user-password: String
  2. -
  3. owner-password: String
  4. -
  5. noprint: Boolean or "true"/"false"
  6. -
  7. nocopy: Boolean or "true"/"false"
  8. -
  9. noedit: Boolean or "true"/"false"
  10. -
  11. noannotations: Boolean or "true"/"false"
  12. -
-
-
- Environment -

- In order to use PDF encryption, FOP has to be compiled with - cryptography support. Currently, only JCE - is supported. JCE is part of JDK 1.4. For earlier JDKs, it can - be installed separately. The build process automatically - detects JCE presence and installs PDF encryption support if - possible, otherwise a stub is compiled in. -

-

- Cryptography support must also be present at run time. In particular, a - provider for the RC4 cipher is needed. Unfortunately, the sample JCE - provider in Sun's JDK 1.4 does not provide RC4. If you - get a message saying -

- "Cannot find any provider supporting RC4" -

- then you don't have the needed infrastructure. -

-

- There are several commercial and a few Open Source packages which - provide RC4. A pure Java implementation is produced by The Legion of the Bouncy - Castle. Mozilla - JSS is an interface to a native implementation. -

-
-
- Installing a crypto provider -

- The pure Java implementation from Bouncy Castle is easy to - install. -

-
    -
  1. - Download the binary distribution for your JDK version. If you have JDK - 1.3 or earlier you must also download a JCE from the same page. -
  2. -
  3. - Unpack the distribution. Add the jar file to your classpath. A - convenient way to use the jar on Linux is to simply drop it into the - FOP lib directory, it will be automatically picked up by - fop.sh. If you have JDK 1.3 or earlier don't forget to - install the JCE as well. -
  4. -
  5. - Open the java.security file and add
    - security.provider.6=org.bouncycastle.jce.provider.BouncyCastleProvider,
    - preferably at the end of the block defining the other crypto - providers. For JDK 1.4 this is detailed on Sun's web site. -
  6. -
-

- If you have any experience with Mozilla JSS or any other - cryptography provider, please post it to the fop-user list. -

-
- -
diff --git a/src/documentation/content/xdocs/0.93/pdfx.xml b/src/documentation/content/xdocs/0.93/pdfx.xml deleted file mode 100644 index cf796c74d..000000000 --- a/src/documentation/content/xdocs/0.93/pdfx.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - -
- PDF/X (ISO 15930) - $Revision$ - - - -
- -
- Overview - - Support for PDF/X is available beginning with version 0.93. This feature is new and - may not be 100% complete, yet. Feedback is welcome. - -

- PDF/X is a standard which faciliates prepress digital data exchange using PDF. - Currently, only PDF/X-3:2003 is implemented out of the many different flavours of PDF/X - profiles. PDF/X-3:2003 is documented in - ISO 15930-6:2003(E). - More info on PDF/X can be found on the - PDF/X info site. -

-
-
- Implementation Status -

- PDF/X-3:2003 is implemented to the degree that FOP supports - the creation of the elements described in ISO 15930-6. -

-

- An important restriction of the current implementation is that all normal - RGB colors specified in XSL-FO and SVG are left unchanged in the sRGB color - space (XSL-FO and SVG both use sRGB as their default color space). - There's no conversion to a CMYK color space. Although sRGB is a - calibrated color space, its color space has a different size than a CMYK - color space which makes the conversion a lossy conversion and can lead to - unwanted results. Although the use of the calibrated sRGB has been promoted - for years, print shops usually prefer to convert an sRGB PDF to CMYK prior - to production. Until there's full CMYK support in FOP you will have to - work closely with your print service provider to make sure you get the - intended result. -

-

- Tests have been performed against Adobe Acrobat 7.0.7 (Preflight function). - Note that there are bugs in Adobe Acrobat which cause false alarms if both - PDF/A-1b and PDF/X-3:2003 are activated at the same time. -

-
-
- Usage (command line) -

- To activate PDF/X-3:2003 from the command-line, specify "-pdfprofile PDF/X-3:2003" - as a parameter. If there is a violation of one of the validation rules for - PDF/X, an error message is presented and the processing stops. -

-
-
- Usage (embedded) -

- When FOP is embedded in another Java application you can set a special option - on the renderer options in the user agent to activate the PDF/A-1b profile. - Here's an example: -

- -

- If one of the validation rules of PDF/X is violated, an PDFConformanceException - (descendant of RuntimeException) is thrown. -

-
-
- PDF/X in Action -

- There are a number of things that must be looked after if you activate a PDF/X - profile. If you receive a PDFConformanceException, have a look at the following - list (not necessarily comprehensive): -

-
    -
  • - Make sure all (!) fonts are embedded. If you use base 14 fonts (like Helvetica) - you need to obtain a license for them and embed them like any other font. -
  • -
  • - Don't use PDF encryption. PDF/X doesn't allow it. -
  • -
  • - Don't use CMYK images without an ICC color profile. PDF/X doesn't allow mixing - color spaces and FOP currently only properly supports the sRGB color space. However, - you will need to specify an - output device profile - (usually a CMYK profile) in the configuration. sRGB won't work here since it's a - display device profile, not an output device profile. -
  • -
  • - Don't use non-RGB colors in SVG images. Same issue as with CMYK images. -
  • -
  • - Don't use EPS graphics with fo:external-graphic. Embedding EPS graphics in PDF - is deprecated since PDF 1.4 and prohibited by PDF/X-3:2003. -
  • -
  • - PDF is forced to version 1.4 if PDF/X-3:2003 is activated. -
  • -
-
-
- PDF profile compatibility -

- The PDF profiles "PDF/X-3:2003" and "PDF/A-1b" are compatible and can both be - activated at the same time. -

-
- -
diff --git a/src/documentation/content/xdocs/0.93/running.xml b/src/documentation/content/xdocs/0.93/running.xml deleted file mode 100644 index 3e852ea98..000000000 --- a/src/documentation/content/xdocs/0.93/running.xml +++ /dev/null @@ -1,349 +0,0 @@ - - - - - -
- Running Apache FOP - $Revision$ -
- - -
- System Requirements -

The following software must be installed:

- -

The following software is optional, depending on your needs:

- -

In addition, the following system requirements apply:

-
    -
  • - If you will be using FOP to process SVG, you must do so in a graphical environment. - See FOP: Graphics (Batik) for details. -
  • -
-
-
- Installation -
- Instructions -

- Basic FOP installation consists of first unzipping the .gz file that is the - distribution medium, then unarchiving the resulting .tar file in a - directory/folder that is convenient on your system. Please consult your operating system - documentation or Zip application software documentation for instructions specific to your - site. -

-
-
- Problems -

- Some Mac OSX users have experienced filename truncation problems using Stuffit to unzip - and unarchive their distribution media. This is a legacy of older Mac operating systems, - which had a 31-character pathname limit. Several Mac OSX users have recommended that - Mac OSX users use the shell command tar -xzf instead. -

-
-
-
- Starting FOP as a Standalone Application -
- Using the fop script or batch file -

- The usual and recommended practice for starting FOP from the command line is to run the - batch file fop.bat (Windows) or the shell script fop (Unix/Linux). - These scripts require that the environment variable JAVA_HOME be - set to a path pointing to the appropriate Java installation on your system. Macintosh OSX - includes a Java environment as part of its distribution. We are told by Mac OSX users that - the path to use in this case is /Library/Java/Home. Caveat: - We suspect that, as Apple releases new Java environments and as FOP upgrades the minimum - Java requirements, the two will inevitably not match on some systems. Please see - Java on Mac OSX FAQ for information as - it becomes available. -

- - [OPTIONS] - -d debug mode - -x dump configuration settings - -q quiet mode - -c cfg.xml use additional configuration file cfg.xml - -l lang the language to use for user information - -r relaxed/less strict validation (where available) - -dpi xxx target resolution in dots per inch (dpi) where xxx is a number - -s for area tree XML, down to block areas only - -v to show FOP version being used - - -o [password] PDF file will be encrypted with option owner password - -u [password] PDF file will be encrypted with option user password - -noprint PDF file will be encrypted without printing permission - -nocopy PDF file will be encrypted without copy content permission - -noedit PDF file will be encrypted without edit content permission - -noannotations PDF file will be encrypted without edit annotation permission - -pdfprofile prof PDF file will be generated with the specified profile - (Examples for prof: PDF/A-1b or PDF/X-3:2003) - - [INPUT] - infile xsl:fo input file (the same as the next) - -fo infile xsl:fo input file - -xml infile xml input file, must be used together with -xsl - -atin infile area tree input file - -xsl stylesheet xslt stylesheet - - -param name value to use for parameter in xslt stylesheet - (repeat '-param name value' for each parameter) - - [OUTPUT] - outfile input will be rendered as PDF into outfile - -pdf outfile input will be rendered as PDF (outfile req'd) - -pdfa1b outfile input will be rendered as PDF/A-1b compliant PDF - (outfile req'd, same as "-pdf outfile -pdfprofile PDF/A-1b") - -awt input will be displayed on screen - -rtf outfile input will be rendered as RTF (outfile req'd) - -pcl outfile input will be rendered as PCL (outfile req'd) - -ps outfile input will be rendered as PostScript (outfile req'd) - -afp outfile input will be rendered as AFP (outfile req'd) - -tiff outfile input will be rendered as TIFF (outfile req'd) - -png outfile input will be rendered as PNG (outfile req'd) - -txt outfile input will be rendered as plain text (outfile req'd) - -at [mime] out representation of area tree as XML (outfile req'd) - specify optional mime output to allow AT to be converted - to final format later - -print input file will be rendered and sent to the printer - see options with "-print help" - -out mime outfile input will be rendered using the given MIME type - (outfile req'd) Example: "-out application/pdf D:\out.pdf" - (Tip: "-out list" prints the list of supported MIME types) - -mif outfile input will be rendered as MIF (FrameMaker) (outfile req'd) - Experimental feature - requires additional fop-sandbox.jar. - -svg outfile input will be rendered as an SVG slides file (outfile req'd) - Experimental feature - requires additional fop-sandbox.jar. - - -foout outfile input will only be XSL transformed. The intermediate - XSL-FO file is saved and no rendering is performed. - (Only available if you use -xml and -xsl parameters) - - - [Examples] - Fop foo.fo foo.pdf - Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line) - Fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf - Fop -xml foo.xml -xsl foo.xsl -foout foo.fo - Fop foo.fo -mif foo.mif - Fop foo.fo -rtf foo.rtf - Fop foo.fo -print or Fop -print foo.fo - Fop foo.fo -awt]]> -

- PDF encryption is only available if FOP was compiled with encryption support - and if compatible encryption support is availabe at run time. - Currently, only the JCE is supported. Check the Details. -

-
-
- Writing your own script -

FOP's entry point for your own scripts is the class -org.apache.fop.cli.Main. The general pattern for the - command line is: java -classpath <CLASSPATH> - org.apache.fop.cli.Main <arguments>. The arguments - consist of the options and infile and outfile specifications - as shown above for the standard scripts. You may wish to review - the standard scripts to make sure that - you get your environment properly configured. -

-
-
- Running with java's <code>-jar</code> option -

- As an alternative to the start scripts you can run java - -jar path/to/build/fop.jar <arguments>, relying on - FOP to build the classpath for running FOP dynamically, see below. If you use hyphenation, - you must put fop-hyph.jar in the lib - directory. -

- -

You can also run java -jar path/to/fop.jar - <arguments>, relying on the Class-Path - entry in the manifest file. This works if you put - fop.jar and all jar files from the lib - directory in a single directory. If you use hyphenation, you - must also put fop-hyph.jar in that directory.

- -

In both cases the arguments consist of the options and - infile and outfile specifications as shown above for the - standard scripts.

-
-
- FOP's dynamical classpath construction - -

If FOP is started without a proper classpath, it tries to - add its dependencies dynamically. FOP uses the current working - directory as the base directory for its search. If the base - directory is called build, then its parent - directory becomes the base directory.

- -

FOP expects to find fop.jar in the - build subdirectory of the base directory, and - adds it to the classpath. Subsequently FOP adds all - jar files in the lib directory to the - classpath. The lib directory is either the lib - subdirectory of the base directory, or, if that does not - exist, the base directory itself.

- -

If the system property fop.optional.lib - contains the name of a directory, then all jar - files in that directory are also added to the classpath. See - the methods getJARList and - checkDependencies in - org.apache.fop.cli.Main.

- -
-
-
- Using Xalan to Check XSL-FO Input -

- FOP sessions that use -xml and -xsl input instead of -fo input are actually - controlling two distinct conversions: Tranforming XML to XSL-FO, then formatting - the XSL-FO to PDF (or another FOP output format). - Although FOP controls both of these processes, the first is included merely as - a convenience and for performance reasons. - Only the second is part of FOP's core processing. - If a user has a problem running FOP, it is important to determine which of these - two processes is causing the problem. - If the problem is in the first process, the user's stylesheet is likely the cause. - The FOP development team does not have resources to help with stylesheet issues, - although we have included links to some useful - Specifications and - Books/Articles. - If the problem is in the second process, FOP may have a bug or an unimplemented - feature that does require attention from the FOP development team. -

- The user is always responsible to provide correct XSL-FO code to FOP. -

- In the case of using -xml and -xsl input, although the user is responsible for - the XSL-FO code that is FOP's input, it is not visible to the user. To make the - intermediate FO file visible, the FOP distribution includes the "-foout" option - which causes FOP to run only the first (transformation) step, and write the - results to a file. (See also the Xalan command-line below) -

- - When asking for help on the FOP mailing lists, never attach XML and - XSL to illustrate the issue. Always run the XSLT step (-foout) and send the - resulting XSL-FO file instead. Of course, be sure that the XSL-FO file is - correct before sending it. - -

- The -foout option works the same way as if you would call the - Xalan command-line: -

-

- java org.apache.xalan.xslt.Process -IN xmlfile -XSL file -OUT outfile -

-

- Note that there are some subtle differences between the FOP and Xalan command-lines. -

-
-
- Memory Usage -

- FOP can consume quite a bit of memory, even though this has been continually improved. - This is partly inherent to the formatting process and partly caused by implementation choices. - All FO processors currently on the market have memory problems with certain layouts. -

-

- If you are running out of memory when using FOP, here are some ideas that may help: -

-
    -
  • - Increase memory available to the JVM. See - the -Xmx option - for more information. - - It is usually unwise to increase the memory allocated to the JVM beyond the amount of - physical RAM, as this will generally cause significantly slower performance. - -
  • -
  • - Avoid forward references. - Forward references are references to some later part of a document. - Examples include page number citations which refer to pages which follow the citation, - tables of contents at the beginning of a document, and page numbering schemes that - include the total number of pages in the document - ("page N of TOTAL"). - Forward references cause all subsequent pages to be held in memory until the reference - can be resolved, i.e. until the page with the referenced element is encountered. - Forward references may be required by the task, but if you are getting a memory - overflow, at least consider the possibility of eliminating them. - A table of contents could be replaced by PDF bookmarks instead or moved to the end of - the document (reshuffle the paper could after printing). -
  • -
  • - Avoid large images, especially if they are scaled down. - If they need to be scaled, scale them in another application upstream from FOP. - For many image formats, memory consumption is driven mainly by the size of the image - file itself, not its dimensions (width*height), so increasing the compression rate - may help. -
  • -
  • - Use multiple page sequences. - FOP starts rendering after the end of a page sequence is encountered. - While the actual rendering is done page-by-page, some additional memory is - freed after the page sequence has been rendered. - This can be substantial if the page sequence contains lots of FO elements. -
  • -
-

- One of FOP's stated design goals is to be able to process input of arbitrary size. - Addressing this goal is one of the prime motivations behind the - FOP Redesign. -

-
-
- Problems -

If you have problems running FOP, please see the "How to get Help" page.

-
- -
diff --git a/src/documentation/content/xdocs/0.93/servlets.xml b/src/documentation/content/xdocs/0.93/servlets.xml deleted file mode 100644 index cecbcaa60..000000000 --- a/src/documentation/content/xdocs/0.93/servlets.xml +++ /dev/null @@ -1,260 +0,0 @@ - - - - - -
- Servlets - How to use Apache FOP in a Servlet - $Revision$ -
- -
- Overview -

- This page discusses topic all around using Apache FOP in a servlet environment. -

-
-
- Example Servlets in the FOP distribution -

- In the directory {fop-dir}/src/java/org/apache/fop/servlet, you'll find a working example - of a FOP-enabled servlet. -

-

- The servlet is automatically built when you build Apache FOP using the supplied Ant script. After building - the servlet, drop fop.war into the webapps directory of Apache Tomcat (or any other web container). Then, you can use - URLs like the following to generate PDF files: -

-
    -
  • http://localhost:8080/fop/fop?fo=/home/path/to/fofile.fo
  • -
  • http://localhost:8080/fop/fop?xml=/home/path/to/xmlfile.xml&xsl=/home/path/to/xslfile.xsl
  • -
-

-

The source code for the servlet can be found under {fop-dir}/src/java/org/apache/fop/servlet/FopServlet.java.

- - This example servlet should not be used on a public web server connected to the Internet as it does not contain - any measures to prevent Denial-of-Service-Attacks. It is provided as an example and as a starting point for - your own servlet. - -
-
- Create your own Servlet - - This section assumes you are familiar with embedding FOP. - -
- A minimal Servlet -

- Here is a minimal code snippet to demonstrate the basics: -

- private FopFactory fopFactory = FopFactory.newInstance(); -private TransformerFactory tFactory = TransformerFactory.newInstance(); - -public void doGet(HttpServletRequest request, - HttpServletResponse response) throws ServletException { - try { - response.setContentType("application/pdf"); - Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, response.getOutputStream()); - Transformer transformer = tFactory.newTransformer(); - Source src = new StreamSource("foo.fo"); - Result res = new SAXResult(fop.getDefaultHandler()); - transformer.transform(src, res); - } catch (Exception ex) { - throw new ServletException(ex); - } -} - - There are numerous problems with the code snippet above. - Its purpose is only to demonstrate the basic concepts. - See below for details. - -
-
- Adding XSL tranformation (XSLT) -

- A common requirement is to transform an XML source to - XSL-FO using an XSL transformation. It is recommended to use - JAXP for this task. The following snippet shows the basic - code: -

- private FopFactory fopFactory = FopFactory.newInstance(); -private TransformerFactory tFactory = TransformerFactory.newInstance(); - -public void init() throws ServletException { - //Optionally customize the FopFactory and TransformerFactory here -} - -[..] - - //Setup a buffer to obtain the content length - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - //Setup FOP - Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out); - - //Setup Transformer - Source xsltSrc = new StreamSource(new File("foo-xml2fo.xsl")); - Transformer transformer = tFactory.newTransformer(xsltSrc); - - //Make sure the XSL transformation's result is piped through to FOP - Result res = new SAXResult(fop.getDefaultHandler()); - - //Setup input - Source src = new StreamSource(new File("foo.xml")); - - //Start the transformation and rendering process - transformer.transform(src, res); - - //Prepare response - response.setContentType("application/pdf"); - response.setContentLength(out.size()); - - //Send content to Browser - response.getOutputStream().write(out.toByteArray()); - response.getOutputStream().flush(); - - Buffering the generated PDF in a ByteArrayOutputStream is done to avoid potential - problems with the Acrobat Reader Plug-in in Microsoft Internet Explorer. - -

- The Source instance used above is simply an - example. If you have to read the XML from a string, supply - a new StreamSource(new - StringReader(xmlstring)). Constructing and reparsing - an XML string is generally less desirable than using a - SAXSource if you generate your XML. You can alternatively - supply a DOMSource as well. You may also use dynamically - generated XSL if you like. -

-

- Because you have an explicit Transformer object, you can also use it to - explicitely set parameters for the transformation run. -

-
-
- Custom configuration -

- You can easily set up your own FOUserAgent as demonstrated on the Embedding page. -

-
-
- Improving performance -

- There are several options to consider: -

-
    -
  • - Instead of java.io.ByteArrayOutputStream consider using the ByteArrayOutputStream - implementation from the Jakarta Commons IO project which allocates less memory. - The full class name is: org.apache.commons.io.output.ByteArrayOutputStream -
  • -
  • - In certain cases it can help to write the generated PDF to a temporary file so - you can quickly reuse the file. This is especially useful, if Internet Explorer - calls the servlet multiple times with the same request or if you often generate - equal PDFs. -
  • -
-

- Of course, the - performance hints from the Embedding page - apply here, too. -

-
-
-
- Notes on Microsoft Internet Explorer -

- Some versions of Internet Explorer will not automatically show the PDF or call the servlet multiple times. - These are well-known limitations of Internet Explorer and are not a problem of the servlet. - However, Internet Explorer can still be used to download the PDF so that it can be viewed later. - Here are some suggestions in this context: -

-
    -
  • - Use an URL ending in .pdf, like - http://myserver/servlet/stuff.pdf. Yes, the servlet can - be configured to handle this. If the URL has to contain parameters, - try to have both the base URL as well as the last parameter end in - .pdf, if necessary append a dummy parameter, like - http://myserver/servlet/stuff.pdf?par1=a&par2=b&d=.pdf. The - effect may depend on IEx version. -
  • -
  • - Give IEx the opportunity to cache. In particular, ensure the - server does not set any headers causing IEx not to cache the - content. This may be a real problem if the document is sent - over HTTPS, because most IEx installations will by default - not cache any content retrieved over HTTPS. - Setting the Expires header entry may help in - this case:
    response.setDateHeader("Expires", - System.currentTimeMillis() + cacheExpiringDuration * - 1000);
    Consult your server manual and the - relevant RFCs for further details on HTTP headers and - caching. -
  • -
  • - Cache in the server. It may help to include a parameter in - the URL which has a timestamp as the value min order to - decide whether a request is repeated. IEx is reported to - retrieve a document up to three times, but never more often. -
  • -
-
-
- Servlet Engines -

- When using a servlet engine, there are potential CLASSPATH issues, and potential conflicts - with existing XML/XSLT libraries. Servlet containers also often use their own classloaders - for loading webapps, which can cause bugs and security problems. -

-
- Tomcat -

- Check Tomcat's documentation for detailed instructions about installing FOP and Cocoon. - There are known bugs that must be addressed, particularly for Tomcat 4.0.3. -

-
-
- WebSphere 3.5 -

- Put a copy of a working parser in some directory where WebSphere can access it. - For example, if /usr/webapps/yourapp/servlets is the CLASSPATH for your servlets, - copy the Xerces jar into it (any other directory would also be fine). - Do not add the jar to the servlet CLASSPATH, but add it to the CLASSPATH of the - application server which contains your web application. - In the WebSphere administration console, click on the "environment" button in the - "general" tab. In the "variable name" box, enter "CLASSPATH". - In the "value" box, enter the correct path to the parser jar file - (/usr/webapps/yourapp/servlets/Xerces.jar in our example here). - Press "OK", then apply the change and restart the application server. -

-
-
-
- Handling complex use cases -

- Sometimes the requirements for a servlet get quite sophisticated: SQL data sources, - multiple XSL transformations, merging of several datasources etc. In such a case - consider using Apache Cocoon instead - of a custom servlet to accomplish your goal. -

-
- -
\ No newline at end of file diff --git a/src/documentation/content/xdocs/0.93/upgrading.xml b/src/documentation/content/xdocs/0.93/upgrading.xml deleted file mode 100644 index 0f04e63b2..000000000 --- a/src/documentation/content/xdocs/0.93/upgrading.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - -
- Upgrading from an Earlier Version of Apache FOP - $Revision$ -
- -
- Important! -

- If you're planning to upgrade to the latest FOP version there are a few very important things - to consider: -

-
    -
  • - More than half of the codebase has been rewritten over the last three years. With version 0.93 the code has reached production level. -
  • -
  • - The API of FOP has changed considerably and is not - backwards-compatible with versions 0.20.5 and - 0.91beta. Version 0.92 introduced the new stable - API. -
  • -
  • - Since version 0.92 some deprecated methods which were part - of the old API have been removed. If you upgrade from 0.91 - beta, you will need to adjust your Java code. Similarly if - you upgrade from 0.92 and use deprecated methods. -
  • -
  • - If you are using a configuration file for version 0.20.5, you have to rebuild it in the new format. The format - of the configuration files has changed since version 0.20.5. See conf/fop.xconf for - an example configuration file. A XML Schema file can be found under - src/foschema/fop-configuration.xsd. -
  • -
  • - If you are using font metrics files for version 0.20.5 or - 0.92 or earlier, you have to regenerate them in the new - format. The new format is characterized by a version - attribute on the top-level font-metrics element, whose value - is 2.0. The absence of a version attribute will be - interpreted as version 1.0, and such metrics files will no - longer be parsed. -
  • -
  • -

    - The new code is much more strict about the interpretation of the XSL-FO 1.0 specification. - Things that worked fine in version 0.20.5 might start to produce warnings or even errors - now. FOP 0.20.5 contains many bugs which have been corrected in the new code. -

    - - While FOP 0.20.5 allowed you to have empty fo:table-cell elements, the new code - will complain about that (unless relaxed validation is enabled) because the specification - demands at least one block-level element ((%block;)+, see - XSL-FO 1.0, 6.7.10) - inside an fo:table-cell element. - -
  • -
  • - Extensions and Renderers written for version 0.20.5 will not work with the new code! The new FOP - extension for Barcode4J will be available in - January 2007. -
  • -
  • - The PCL Renderer and the MIF Handler have not been resurrected, yet! They are currently non-functional - and hope for someone to step up and reimplement them. -
  • -
  • - By looking at the Compliance page you might get the impression - that the new code is much more advanced than version 0.20.5. That's true but there may still - be a few things that may not be handled as gracefully by the new code as by version 0.20.5. -
  • -
-
-
- What you need to know when you upgrade! -

- When you use your existing FO files or XML/XSL files which work fine with FOP version - 0.20.5 against this FOP version some things may not work as expected. The following - list will hopefully help you to identify and correct those problems. -

-
    -
  • - Check the Compliance page for the feature causing - trouble. It may contain the necessary information to understand and resolve the problem. -
  • -
  • - Not all 0.20.5 output formats are supported. PDF and Postscript should be fully supported. - See Output Targets for a more complete description. -
  • -
  • - As stated above empty table cells <fo:table-cell></fo:table-cell> - are not allowed by the specification. The same applies to empty static-content - and block-container elements, for example. -
  • -
  • - 0.20.5 is not XSL-FO compliant with respect to sizing images (external-graphic) - or instream-foreign-object - objects. If images or SVGs are sized differently in your outputs with the new FOP version - check Bug 37136 - as it contains some hints on what to do. The file - - "examples/fo/basic/images.fo" has - a number of good examples that show the new, more correct behaviour. -
  • -
  • - The fox:outline extension is not implemented in this version anymore. - It has been superseded by the new bookmark elements from XSL-FO 1.1. -
  • -
  • - The fox:destination extension is also not implemented in this version - although it may be added in the future. See also - Bug 37157. -
  • -
-
- -
diff --git a/src/documentation/content/xdocs/0.94/index.xml b/src/documentation/content/xdocs/0.94/index.xml index ba5b1af15..9bf46ccf5 100644 --- a/src/documentation/content/xdocs/0.94/index.xml +++ b/src/documentation/content/xdocs/0.94/index.xml @@ -32,7 +32,7 @@

This fifth release contains many bug fix release and new features compared - to 0.92beta. To see what has changed since the last release, please visit the + to 0.93. To see what has changed since the last release, please visit the Changes Page and the Release Notes.

diff --git a/src/documentation/content/xdocs/0.95/anttask.xml b/src/documentation/content/xdocs/0.95/anttask.xml new file mode 100644 index 000000000..44550c3d7 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/anttask.xml @@ -0,0 +1,197 @@ + + + + + +
+ Ant task + $Revision$ +
+ +

+ Apache FOP provides an Ant task for automating the document build process. +

+
+ Description +

+ The FOP Ant task will convert XSL-FO documents to PDF, PS, PCL etc. output + (see Output formats for available formats). +

+

+ To call FOP tasks within Ant, first add a FOP task definition to your Ant build file. + One method of defining the task is as follows: +

+ + + + + + + + + + + + + + ]]> +

+ Then create FOP tasks within your Ant build file, using the FOP task parameters listed below.

+
+ +
Parameters for FOP Ant task + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameters specified as attributes
AttributeDescriptionRequired
fofileXSL-FO file to be renderedYes, if no fileset nested element is used
outfileOutput filenameYes, when fofile is used. (This attribute is not valid for filesets.)
formatPossible output formats:
+ application/X-fop-awt-preview
+ application/X-fop-print
+ application/X-fop-areatree
+ application/pdf
+ application/postscript
+ application/mif
+ application/rtf, + text/richtext, + text/rtf
+ application/x-pcl, + application/vnd.hp-PCL
+ application/x-afp, + application/vnd.ibm.modcap
+ text/plain
+ image/svg+xml
+ image/gif
+ image/png
+ image/tiff
+
No, defaults to application/pdf
outdirOutput directoryRequired if a fileset is used to specify the files to render; optional for fofile. (Can alternatively specify the full path in the fofile value.)
forceRecreate target files, even if they are newer than their corresponding + source files. Note: This attribute is available in post-0.20.5 + versions (0.20.x nightly build and 1.0dev) only; target files are + always generated (i.e., force=true) in 0.20.5 release. + No, default is false
basedirBase directory to resolve relative references (e.g., graphics files) within the + FO document. + No, for single FO File entry, default is to use the location + of that FO file. +
relativebaseFor fileset usage only. A value of true specifies using the location + of each .fo file as the base directory for resolving relative file references located + within that .fo file. A value of false specifies using the value of + basedir for all files within the fileset, or just the current working directory + if basedir is not specified. + No, default is false. +
userconfigUser configuration file (same as the FOP "-c" command line option).No
messagelevelLogging level
+ Possible values: error, warn, info, verbose, debug. Currently doesn't work in FOP Trunk!!!
No, defaults to verbose
logFilesControls whether the names of the files that are processed are logged + (true) or not (false). Currently doesn't work in FOP Trunk!!!No, default is true
+

+ + + + + + + + + + + +
Parameters specified as nested elements
AttributeDescriptionRequired
filesetFileSets + are used to specify multiple XSL-FO files to be rendered.Yes, if no fofile attribute is supplied
+

+
+ Examples +

+ The following example converts a single XSL-FO file to a PDF document: +

+ + + + + ]]> +

+ This example converts all XSL-FO files within an entire directory to PostScript: +

+ + + + + + + + ]]> +
+ +
+ diff --git a/src/documentation/content/xdocs/0.95/compiling.xml b/src/documentation/content/xdocs/0.95/compiling.xml new file mode 100644 index 000000000..57761429f --- /dev/null +++ b/src/documentation/content/xdocs/0.95/compiling.xml @@ -0,0 +1,141 @@ + + + + + +
+ Apache FOP: Building from Source Code + $Revision$ +
+ +
+ Do You Need To Build? +

+ FOP distributions are either pre-compiled binary or source. + If you are using a binary distribution, it is already built and there is no need to build it again. + See the Download Instructions for information about whether a + binary or source distribution is best for your needs. +

+

+ If you got the source code from a repository snapshot or via Subversion you will need to build FOP + in any case. +

+
+
+ Set Up Your Environment +
+ JDK +

+ Building FOP requires a minimum Java Development Kit (JDK/SDK) of 1.4 + (A Java Runtime Environment is not sufficient). +

+
+
+ CLASSPATH +

+ There is generally no need to setup a classpath. All libraries needed to compile FOP are included + in the source distribution and are referenced by the build script. + You will only need to adjust the classpath if you build FOP in some other way. See the build + script build.xml for details. +

+
+
+ JAVA_HOME +

+ The build script uses Apache Ant, a popular + Java-based build tool, which usually requires that the environment variable JAVA_HOME point to + your local JDK root directory. This is true even if you use JDK 1.4 or above, which normally + does not need this setting. +

+
+
+ Apache Ant +

+ Apache Ant must be installed in order to + build FOP. Following best practices we don't include Ant with FOP anymore. You can find the + instructions to install Ant in the Ant manual on the web. +

+
+
+
+ Run the Build Script +

+ Change to the FOP root directory and build FOP by executing the build script (build.xml) + using the "ant" command. +

+ + The "ant" command is only available on your system if you've properly + installed Apache Ant and added Ant's location to the PATH + environment variable. + +

+ The file build.xml in the FOP root directory is the blueprint that Ant uses for the build. It + contains information for numerous build targets, many of which are building blocks to more + useful target, and others which are primarily used by the FOP developers. + You may benefit from looking through this file to learn more about the various build targets. + To obtain a complete list of useful build targets: +

+ ant -projecthelp +

The most useful targets are:

+
    +
  • + package: Generates the JAR files (default). This is the normal build that + produces a jar file usable for running FOP. +
  • +
  • + clean : Cleans the build directory. This is useful for making sure that + any build errors are cleaned up before starting a new build. It should not ordinarily be + needed, but may be helpful if you are having problems with the build process itself. +
  • +
  • + javadocs: Creates the FOP API documentation. + A minimum JDK version of 1.4.2 is required for generating the javadocs. +
  • +
+

To run the build:

+ ant [target ...] +

For example to do a normal build for the "all" target (which is the default):

+ ant +

OR

+ ant all +

To clean the build directory first:

+ ant clean all + + If you want to shorten the build time you can just call the "package" target which + doesn't perform any automated tests during the build. + +
+
+ Troubleshooting +

If you have problems building FOP, please try the following:

+
    +
  • Run the build with the target of "clean", then rerun the build.
  • +
  • Delete the build directory completely, then rerun the build.
  • +
  • + Make sure you do not have a non-FOP version of xerces.jar, xalan.jar, batik.jar, + or another dependency product somewhere in your CLASSPATH. +
  • +
  • + If the build still fails, see the Getting Help + page for further help. +
  • +
+
+ +
+ diff --git a/src/documentation/content/xdocs/0.95/configuration.xml b/src/documentation/content/xdocs/0.95/configuration.xml new file mode 100644 index 000000000..e82a6e862 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/configuration.xml @@ -0,0 +1,394 @@ + + + + + +
+ Apache FOP: Configuration + $Revision$ +
+ + +
+ Configuration File Basics +

+ The FOP configuration file is an XML file containing a variety of settings that are useful + for controlling FOP's behavior, and for helping it find resources that you wish it to use. +

+

+ The easiest way to get started using a FOP configuration file is to copy the sample found + at {fop-dir}/conf/fop.xconf to a location of your choice, and then to + edit it according to your needs. + It contains templates for the various configuration options, most of which are commented + out. Remove the comments and change the settings for entries that you wish to use. + Be sure to follow any instructions, including comments which specify the value range. + Also, since the configuration file is XML, be sure to keep it well-formed. +

+
+ Making Configuration Available to FOP +

After creating your configuration file, you must tell FOP how to find it:

+ +

+ See Setting the Configuration Programmatically + for instructions on how to do so in an embedded environment. +

+
+
+
+ Summary of the General Configuration Options + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ElementData Type (for the value)DescriptionDefault Value
baseURL or directorySpecifies the base URL based on which relative URL will be resolved.current directory
font-baseURL or directorySpecifies the base URL based on which relative font URLs will be resolved. + base URL/directory (above)
hyphenation-baseURL or directorySpecifies the base URL based on which relative URLs to hyphenation pattern + files will be resolved. If not specified, support for user-supplied hyphenation + patterns remains disabled. + disabled
source-resolutionInteger, dpi + Resolution in dpi (dots per inch) which is used internally to determine the pixel + size for SVG images and bitmap images without resolution information. + 72 dpi
target-resolutionInteger, dpi + Resolution in dpi (dots per inch) used to specify the output resolution for bitmap + images generated by bitmap renderers (such as the TIFF renderer) and by bitmaps + generated by Apache Batik for filter effects and such. + 72 dpi
strict-configurationBoolean (true, false) + Setting this option to 'true' will cause FOP to strictly verify the contents of the + FOP configuration file to ensure that defined resources (such as fonts and base + URLs/directories) are valid and available to FOP. Any errors found will cause FOP to + immediately raise an exception.false
strict-validationBoolean (true, false) + Setting this option to 'false' causes FOP to be more forgiving about XSL-FO validity, + for example, you're allowed to specify a border on a region-body which is supported + by some FO implementations but is non-standard. Note that such a border would + currently have no effect in Apache FOP.true
break-indent-inheritanceBoolean (true, false) + Setting this option to 'true' causes FOP to use an alternative rule set to determine + text indents specified through margins, start-indent and end-indent. Many commercial + FO implementations have chosen to break the XSL specification in this aspect. This + option tries to mimic their behaviour. Please note that Apache FOP may still not + behave exactly like those implementations either because FOP has not fully matched + the desired behaviour and because the behaviour among the commercial implementations + varies. The default for this option (i.e. false) is to behave exactly like the + specification describes.false
default-page-settingsn/a + Specifies the default width and height of a page if "auto" is specified + for either or both values. Use "height" and "width" attributes on the + default-page-settings element to specify the two values."height" 11 inches, "width" 8.26 inches
use-cacheboolean (true, false)All fonts information that has been gathered as a result of "directory" + or "auto-detect" font configurations will be cached for future rendering runs. + This setting should improve performance on systems where + fonts have been configured using the "directory" or "auto-detect" tag mechanisms. + By default this option is switched on.true
cache-fileStringThis options specifies the file/directory path of the fop cache file. + This option can also be specified on the command-line using the -cache option. + This file is currently only used to cache font triplet information for future reference.${base}/conf/fop.cache
renderers(see text below)Contains the configuration for each renderer. See below.N/A
+

+ This is an excerpt from the example configuration file coming with FOP: +

+ + + + true + + + true + + + ./ + + + ./ + + + 72 + + 72 + + + + + +]]> +
+
+ Renderer configuration +

+ Each Renderer has its own configuration section which is identified by the + MIME type the Renderer is written for, ex. "application/pdf" for the PDF Renderer. +

+

+ The configuration for the PDF Renderer could look like this: +

+ + + + + flate + + + + + + + + + + + + + + + ]]> +

+ The details on the font configuration can be found on the separate Fonts page. + Note especially the section entitled Register Fonts with FOP. +

+
+ Special Settings for the PDF Renderer +

+ The configuration element for the PDF renderer contains two elements. One is for the font configuration + (please follow the link above) and one is for the "filter list". The filter list controls how the + individual objects in a PDF file are encoded. By default, all objects get "flate" encoded (i.e. simply + compressed with the same algorithm that is also used in ZIP files). Most users don't need to change that + setting. For debugging purposes, it may be desired not to compress the internal objects at all so the + generated PDF commands can be read. In that case, you can simply use the following filter list. The + second filter list (type="image") ensures that all images still get compressed but also ASCII-85 encoded + so the produced PDF file is still easily readable in a text editor. +

+ + + null + + + flate + ascii-85 + + + ]]> +

+ Another (optional) setting specific to the PDF Renderer is an output color profile, an ICC + color profile which indicates the target color space the PDF file is generated for. This + setting is mainly used in conjunction with the PDF/X feature. + An example: +

+ + C:\FOP\Color\EuropeISOCoatedFOGRA27.icc + + ]]> +

+ Some people don't have high requirements on color fidelity but instead want the smallest + PDF file sizes possible. In this case it's possible to disable the default sRGB color space + which XSL-FO requires. This will cause RGB colors to be generated as device-specific RGB. + Please note that this option is unavailable (and will cause an error) if you enable + PDF/A or PDF/X functionality or if you specify an output profile. This setting will make the + PDF about 4KB smaller. To disable the sRGB color space add the following setting: +

+ + true + + ]]> +
+
+ Special Settings for the PostScript Renderer +

+ Besides the normal font configuration (the same "fonts" element as for the PDF renderer) the PostScript + renderer has an additional setting to force landscape pages to be rotated to fit on a page inserted into + the printer in portrait mode. Set the value to "true" to activate this feature. The default is "false". + Example: +

+ + true + + + + + + + + + + + + ]]> +
+
+ Special Settings for the PCL Renderer +

+ Non-standard fonts for the PCL renderer are made available through the Java2D subsystem which means that + you don't have to do any custom font configuration in this case but you have to use the font names + offered by Java. +

+

+ Additionally, there are certain settings that control how the renderer handles various elements. +

+ + quality + bitmap +]]> +

+ The default value for the "rendering" setting is "speed" which causes borders + to be painted as plain rectangles. In this mode, no special borders (dotted, + dashed etc.) are available. If you want support for all border modes, set the + value to "quality" as indicated above. This will cause the borders to be painted + as bitmaps. +

+

+ The default value for the "text-rendering" setting is "auto" which paints the + base fonts using PCL fonts. Non-base fonts are painted as bitmaps through Java2D. + If the mix of painting methods results in unwelcome output, you can set this + to "bitmap" which causes all text to be rendered as bitmaps. +

+
+
+ +
+ When it does not work + +

FOP searches the configuration file for the information it +expects, at the position it expects. When that information is not +present, FOP will not complain, it will just continue. When there is +other information in the file, FOP will not complain, it will just +ignore it. That means that when your configuration information is in +the file but in a different XML element, or in a different XML path, +than FOP expects, it will be silently ignored.

+ +

Check the following possibilities:

+ +
    +
  • The format of the configuration file has changed +considerably between FOP 0.20.5 and FOP 1.0 and its beta versions. Did +you convert your file to the new format?
  • + +
  • The FOP distribution contains a schema for configuration +files, at src/foschema/fop-configuration.xsd. Did you validate your +configuration file against it? Add the following schema location to +the schema element: + +]]> + + +and run the configuration file through a validating schema +parser. Note that the schema cannot detect all errors, and that it is +stricter about the order of some elements than FOP itself is.
  • + +
  • Run FOP in debug mode (command line option +-d). This makes FOP report which configuration +information it finds. Check if FOP finds what you expect.
  • + +
+ +
+ +
+ diff --git a/src/documentation/content/xdocs/0.95/embedding.xml b/src/documentation/content/xdocs/0.95/embedding.xml new file mode 100644 index 000000000..b2c802db7 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/embedding.xml @@ -0,0 +1,689 @@ + + + + + + +
+ Apache FOP: Embedding + How to Embed FOP in a Java application + $Revision$ +
+ + +
+ Overview +

+ Review Running FOP for important information that applies + to embedded applications as well as command-line use, such as options and performance. +

+

+ To embed Apache FOP in your application, first create a new + org.apache.fop.apps.FopFactory instance. This object can be used to launch multiple + rendering runs. For each run, create a new org.apache.fop.apps.Fop instance through + one of the factory methods of FopFactory. In the method call you specify which output + format (i.e. Renderer) to use and, if the selected renderer requires an OutputStream, + which OutputStream to use for the results of the rendering. You can customize FOP's + behaviour in a rendering run by supplying your own FOUserAgent instance. The + FOUserAgent can, for example, be used to set your own Renderer instance (details + below). Finally, you retrieve a SAX DefaultHandler instance from the Fop object and + use that as the SAXResult of your transformation. +

+ + We recently changed FOP's outer API to what we consider the final API. This might require + some changes in your application. The main reasons for these changes were performance + improvements due to better reuse of reusable objects and reduced use of static variables + for added flexibility in complex environments. + +
+
+ Basic Usage Pattern +

+ Apache FOP relies heavily on JAXP. It uses SAX events exclusively to receive the XSL-FO + input document. It is therefore a good idea that you know a few things about JAXP (which + is a good skill anyway). Let's look at the basic usage pattern for FOP... +

+

Here is the basic pattern to render an XSL-FO file to PDF: +

+ +

+ Let's discuss these 5 steps in detail: +

+
    +
  • + Step 1: You create a new FopFactory instance. The FopFactory instance holds + references to configuration information and cached data. It's important to reuse this + instance if you plan to render multiple documents during a JVM's lifetime. +
  • +
  • + Step 2: You set up an OutputStream that the generated document + will be written to. It's a good idea to buffer the OutputStream as demonstrated + to improve performance. +
  • +
  • + Step 3: You create a new Fop instance through one of the factory + methods on the FopFactory. You tell the FopFactory what your desired output format + is. This is done by using the MIME type of the desired output format (ex. "application/pdf"). + You can use one of the MimeConstants.* constants. The second parameter is the + OutputStream you've setup up in step 2. +
  • +
  • + Step 4 We recommend that you use JAXP Transformers even + if you don't do XSLT transformations to generate the XSL-FO file. This way + you can always use the same basic pattern. The example here sets up an + "identity transformer" which just passes the input (Source) unchanged to the + output (Result). You don't have to work with a SAXParser if you don't do any + XSLT transformations. +
  • +
  • + Step 5: Here you set up the input and output for the XSLT + transformation. The Source object is set up to load the "myfile.fo" file. + The Result is set up so the output of the XSLT transformation is sent to FOP. + The FO file is sent to FOP in the form of SAX events which is the most efficient + way. Please always avoid saving intermediate results to a file or a memory buffer + because that affects performance negatively. +
  • +
  • + Step 6: Finally, we start the XSLT transformation by starting + the JAXP Transformer. As soon as the JAXP Transformer starts to send its output + to FOP, FOP itself starts its processing in the background. When the + transform() method returns FOP will also have finished converting + the FO file to a PDF file and you can close the OutputStream. + + It's a good idea to enclose the whole conversion in a try..finally statement. If + you close the OutputStream in the finally section, this will make sure that the + OutputStream is properly closed even if an exception occurs during the conversion. + +
  • +
+

+ If you're not totally familiar with JAXP Transformers, please have a look at the + Embedding examples below. The section contains examples + for all sorts of use cases. If you look at all of them in turn you should be able + to see the patterns in use and the flexibility this approach offers without adding + too much complexity. +

+

+ This may look complicated at first, but it's really just the combination of an + XSL transformation and a FOP run. It's also easy to comment out the FOP part + for debugging purposes, for example when you're tracking down a bug in your + stylesheet. You can easily write the XSL-FO output from the XSL transformation + to a file to check if that part generates the expected output. An example for that + can be found in the Embedding examples (See "ExampleXML2FO"). +

+
+ Logging +

+ Logging is now a little different than it was in FOP 0.20.5. We've switched from + Avalon Logging to Jakarta Commons Logging. + While with Avalon Logging the loggers were directly given to FOP, FOP now retrieves + its logger(s) through a statically available LogFactory. This is similar to the + general pattern that you use when you work with Apache Log4J directly, for example. + We call this "static logging" (Commons Logging, Log4J) as opposed to "instance logging" + (Avalon Logging). This has a consequence: You can't give FOP a logger for each + processing run anymore. The log output of multiple, simultaneously running FOP instances + is sent to the same logger. +

+ + We know this may be an issue in multi-threaded server environments if you'd like to + know what's going on in every single FOP processing run. We're planning to add an + additional feedback facility to FOP which can be used to obtain all sorts of specific + feedback (validation messages, layout problems etc.). "Static logging" is mainly + interesting for a developer working on FOP and for advanced users who are debugging + FOP. We don't consider the logging output to be useful to normal FOP users. Please + have some patience until we can add this feature or jump in and help us build it. We've + set up a Wiki page + which documents what we're going to build. + +

+ By default, Jakarta Commons Logging uses + JDK logging (available in JDKs 1.4 or higher) as its backend. You can configure Commons + Logging to use an alternative backend, for example Log4J. Please consult the + documentation for Jakarta Commons Logging on + how to configure alternative backends. +

+
+ +
+ Processing XSL-FO +

+ Once the Fop instance is set up, call getDefaultHandler() to obtain a SAX + DefaultHandler instance to which you can send the SAX events making up the XSL-FO + document you'd like to render. FOP processing starts as soon as the DefaultHandler's + startDocument() method is called. Processing stops again when the + DefaultHandler's endDocument() method is called. Please refer to the basic + usage pattern shown above to render a simple XSL-FO document. +

+
+ +
+ Processing XSL-FO generated from XML+XSLT +

+ If you want to process XSL-FO generated from XML using XSLT we recommend + again using standard JAXP to do the XSLT part and piping the generated SAX + events directly through to FOP. The only thing you'd change to do that + on the basic usage pattern above is to set up the Transformer differently: +

+ +
+
+
+ Input Sources +

+ The input XSL-FO document is always received by FOP as a SAX stream (see the + Parsing Design Document for the rationale). +

+

+ However, you may not always have your input document available as a SAX stream. + But with JAXP it's easy to convert different input sources to a SAX stream so you + can pipe it into FOP. That sounds more difficult than it is. You simply have + to set up the right Source instance as input for the JAXP transformation. + A few examples: +

+
    +
  • + URL: Source src = new StreamSource("http://localhost:8080/testfile.xml"); +
  • +
  • + File: Source src = new StreamSource(new File("C:/Temp/myinputfile.xml")); +
  • +
  • + String: Source src = new StreamSource(new StringReader(myString)); // myString is a String +
  • +
  • + InputStream: Source src = new StreamSource(new MyInputStream(something)); +
  • +
  • + Byte Array: Source src = new StreamSource(new ByteArrayInputStream(myBuffer)); // myBuffer is a byte[] here +
  • +
  • + DOM: Source src = new DOMSource(myDocument); // myDocument is a Document or a Node +
  • +
  • + Java Objects: Please have a look at the Embedding examples which contain an example for this. +
  • +
+

+ There are a variety of upstream data manipulations possible. + For example, you may have a DOM and an XSL stylesheet; or you may want to + set variables in the stylesheet. Interface documentation and some cookbook + solutions to these situations are provided in + Xalan Basic Usage Patterns. +

+
+
+ Configuring Apache FOP Programmatically +

+ Apache FOP provides two levels on which you can customize FOP's + behaviour: the FopFactory and the user agent. +

+
+ Customizing the FopFactory +

+ The FopFactory holds configuration data and references to objects which are reusable over + multiple rendering runs. It's important to instantiate it only once (except in special + environments) and reuse it every time to create new FOUserAgent and Fop instances. +

+

+ You can set all sorts of things on the FopFactory: +

+
    +
  • +

    + The font base URL to use when resolving relative URLs for fonts. Example: +

    + fopFactory.setFontBaseURL("file:///C:/Temp/fonts"); +
  • +
  • +

    + The hyphenation base URL to use when resolving relative URLs for + hyphenation patterns. Example: +

    + fopFactory.setHyphenBaseURL("file:///C:/Temp/hyph"); +
  • +
  • +

    + Disable strict validation. When disabled FOP is less strict about the rules + established by the XSL-FO specification. Example: +

    + fopFactory.setStrictValidation(false); +
  • +
  • +

    + Enable an alternative set of rules for text indents that tries to mimic the behaviour of many commercial + FO implementations, that chose to break the specification in this respect. The default of this option is + 'false', which causes Apache FOP to behave exactly as described in the specification. To enable the + alternative behaviour, call: +

    + fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary(true); +
  • +
  • +

    + Set the source resolution for the document. This is used internally to determine the pixel + size for SVG images and bitmap images without resolution information. Default: 72 dpi. Example: +

    + fopFactory.setSourceResolution(96); // =96dpi (dots/pixels per Inch) +
  • +
  • +

    + Manually add an ElementMapping instance. If you want to supply a special FOP extension + you can give the instance to the FOUserAgent. Normally, the FOP extensions can be automatically detected + (see the documentation on extension for more info). Example: +

    + fopFactory.addElementMapping(myElementMapping); // myElementMapping is a org.apache.fop.fo.ElementMapping +
  • +
  • +

    + Set a URIResolver for custom URI resolution. By supplying a JAXP URIResolver you can add + custom URI resolution functionality to FOP. For example, you can use + Apache XML Commons Resolver to make use of XCatalogs. Example: +

    + fopFactory.setURIResolver(myResolver); // myResolver is a javax.xml.transform.URIResolver + + Both the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FopFactory + is primarily used to resolve URIs on factory-level (hyphenation patterns, for example) and it is always used + if no other URIResolver (for example on the FOUserAgent) resolved the URI first. + +
  • +
+
+
+ Customizing the User Agent +

+ The user agent is the entity that allows you to interact with a single rendering run, i.e. the processing of a single + document. If you wish to customize the user agent's behaviour, the first step is to create your own instance + of FOUserAgent using the appropriate factory method on FopFactory and pass that + to the factory method that will create a new Fop instance: +

+ +

+ You can do all sorts of things on the user agent: +

+
    +
  • +

    + The base URL to use when resolving relative URLs. Example: +

    + userAgent.setBaseURL("file:///C:/Temp/"); +
  • +
  • +

    + Set the producer of the document. This is metadata information that can be used for certain output formats such as PDF. The default producer is "Apache FOP". Example: +

    + userAgent.setProducer("MyKillerApplication"); +
  • +
  • +

    + Set the creating user of the document. This is metadata information that can be used for certain output formats such as PDF. Example: +

    + userAgent.setCreator("John Doe"); +
  • +
  • +

    + Set the author of the document. This is metadata information that can be used for certain output formats such as PDF. Example: +

    + userAgent.setAuthor("John Doe"); +
  • +
  • +

    + Override the creation date and time of the document. This is metadata information that can be used for certain output formats such as PDF. Example: +

    + userAgent.setCreationDate(new Date()); +
  • +
  • +

    + Set the title of the document. This is metadata information that can be used for certain output formats such as PDF. Example: +

    + userAgent.setTitle("Invoice No 138716847"); +
  • +
  • +

    + Set the keywords of the document. This is metadata information that can be used for certain output formats such as PDF. Example: +

    + userAgent.setKeywords("XML XSL-FO"); +
  • +
  • +

    + Set the target resolution for the document. This is used to + specify the output resolution for bitmap images generated by bitmap renderers + (such as the TIFF renderer) and by bitmaps generated by Apache Batik for filter + effects and such. Default: 72 dpi. Example: +

    + userAgent.setTargetResolution(300); // =300dpi (dots/pixels per Inch) +
  • +
  • +

    + Set your own Renderer instance. If you want to supply your own renderer or + configure a Renderer in a special way you can give the instance to the FOUserAgent. Normally, + the Renderer instance is created by FOP. Example: +

    + userAgent.setRendererOverride(myRenderer); // myRenderer is an org.apache.fop.render.Renderer +
  • +
  • +

    + Set your own FOEventHandler instance. If you want to supply your own FOEventHandler or + configure an FOEventHandler subclass in a special way you can give the instance to the FOUserAgent. Normally, + the FOEventHandler instance is created by FOP. Example: +

    + userAgent.setFOEventHandlerOverride(myFOEventHandler); // myFOEventHandler is an org.apache.fop.fo.FOEventHandler +
  • +
  • +

    + Set a URIResolver for custom URI resolution. By supplying a JAXP URIResolver you can add + custom URI resolution functionality to FOP. For example, you can use + Apache XML Commons Resolver to make use of XCatalogs. Example: +

    + userAgent.setURIResolver(myResolver); // myResolver is a javax.xml.transform.URIResolver + + Both the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FOUserAgent is + used for resolving URIs which are document-related. If it's not set or cannot resolve a URI, the URIResolver + from the FopFactory is used. + +
  • +
+ + You should not reuse an FOUserAgent instance between FOP rendering runs although you can. Especially + in multi-threaded environment, this is a bad idea. + +
+
+
+ Using a Configuration File +

+ Instead of setting the parameters manually in code as shown above you can also set + many values from an XML configuration file: +

+ +

+ The layout of the configuration file is described on the Configuration page. +

+
+
+ Hints +
+ Object reuse +

+ Fop instances shouldn't (and can't) be reused. Please recreate + Fop and FOUserAgent instances for each rendering run using the FopFactory. + This is a cheap operation as all reusable information is held in the + FopFactory. That's why it's so important to reuse the FopFactory instance. +

+
+
+ AWT issues +

+ If your XSL-FO files contain SVG then Apache Batik will be used. When Batik is + initialised it uses certain classes in java.awt that + intialise the Java AWT classes. This means that a daemon thread + is created by the JVM and on Unix it will need to connect to a + DISPLAY. +

+

+ The thread means that the Java application may not automatically quit + when finished, you will need to call System.exit(). These + issues should be fixed in the JDK 1.4. +

+

+ If you run into trouble running FOP on a head-less server, please see the + notes on Batik. +

+
+
+ Getting information on the rendering process +

+ To get the number of pages that were rendered by FOP you can call + Fop.getResults(). This returns a FormattingResults object + where you can look up the number of pages produced. It also gives you the + page-sequences that were produced along with their id attribute and their + numbers of pages. This is particularly useful if you render multiple + documents (each enclosed by a page-sequence) and have to know the number of + pages of each document. +

+
+
+
+ Improving performance +

+ There are several options to consider: +

+
    +
  • + Whenever possible, try to use SAX to couple the individual components involved + (parser, XSL transformer, SQL datasource etc.). +
  • +
  • + Depending on the target OutputStream (in case of a FileOutputStream, but not + for a ByteArrayOutputStream, for example) it may improve performance considerably + if you buffer the OutputStream using a BufferedOutputStream: + out = new java.io.BufferedOutputStream(out); +
    + Make sure you properly close the OutputStream when FOP is finished. +
  • +
  • + Cache the stylesheet. If you use the same stylesheet multiple times + you can set up a JAXP Templates object and reuse it each time you do + the XSL transformation. (More information can be found + here.) +
  • +
  • + Use an XSLT compiler like XSLTC + that comes with Xalan-J. +
  • +
  • + Fine-tune your stylesheet to make the XSLT process more efficient and to create XSL-FO that can + be processed by FOP more efficiently. Less is more: Try to make use of property inheritance where possible. +
  • +
+
+
+ Multithreading FOP +

+ Apache FOP may currently not be completely thread safe. + The code has not been fully tested for multi-threading issues, yet. + If you encounter any suspicious behaviour, please notify us. +

+

+ There is also a known issue with fonts being jumbled between threads when using + the Java2D/AWT renderer (which is used by the -awt and -print output options). + In general, you cannot safely run multiple threads through the AWT renderer. +

+
+
+ Examples +

+ The directory "{fop-dir}/examples/embedding" contains several working examples. +

+
+ ExampleFO2PDF.java +

This + + example +demonstrates the basic usage pattern to transform an XSL-FO +file to PDF using FOP. +

+
+
+
+ ExampleXML2FO.java +

This + + example +has nothing to do with FOP. It is there to show you how an XML +file can be converted to XSL-FO using XSLT. The JAXP API is used to do the +transformation. Make sure you've got a JAXP-compliant XSLT processor in your +classpath (ex. Xalan). +

+
+
+
+ ExampleXML2PDF.java +

This + + example +demonstrates how you can convert an arbitrary XML file to PDF +using XSLT and XSL-FO/FOP. It is a combination of the first two examples +above. The example uses JAXP to transform the XML file to XSL-FO and FOP to +transform the XSL-FO to PDF. +

+
+

+The output (XSL-FO) from the XSL transformation is piped through to FOP using +SAX events. This is the most efficient way to do this because the +intermediate result doesn't have to be saved somewhere. Often, novice users +save the intermediate result in a file, a byte array or a DOM tree. We +strongly discourage you to do this if it isn't absolutely necessary. The +performance is significantly higher with SAX. +

+
+
+ ExampleObj2XML.java +

This + + example +is a preparatory example for the next one. It's an example that +shows how an arbitrary Java object can be converted to XML. It's an often +needed task to do this. Often people create a DOM tree from a Java object and +use that. This is pretty straightforward. The example here, however, shows how +to do this using SAX, which will probably be faster and not even more +complicated once you know how this works. +

+
+

+For this example we've created two classes: ProjectTeam and ProjectMember +(found in xml-fop/examples/embedding/java/embedding/model). They represent +the same data structure found in +xml-fop/examples/embedding/xml/xml/projectteam.xml. We want to serialize to XML a +project team with several members which exist as Java objects. +Therefore we created the two classes: ProjectTeamInputSource and +ProjectTeamXMLReader (in the same place as ProjectTeam above). +

+

+The XMLReader implementation (regard it as a special kind of XML parser) is +responsible for creating SAX events from the Java object. The InputSource +class is only used to hold the ProjectTeam object to be used. +

+

+Have a look at the source of ExampleObj2XML.java to find out how this is +used. For more detailed information see other resources on JAXP (ex. +An older JAXP tutorial). +

+
+
+ ExampleObj2PDF.java +

This + + example +combines the previous and the third to demonstrate +how you can transform a Java object to a PDF directly in one smooth run +by generating SAX events from the Java object that get fed to an XSL +transformation. The result of the transformation is then converted to PDF +using FOP as before. +

+
+
+
+ ExampleDOM2PDF.java +

This + + example +has FOP use a DOMSource instead of a StreamSource in order to +use a DOM tree as input for an XSL transformation. +

+
+
+ ExampleSVG2PDF.java (PDF Transcoder example) +

This + + example +shows the usage of the PDF Transcoder, a sub-application within FOP. +It is used to generate a PDF document from an SVG file. +

+
+
+ Final notes +

+These examples should give you an idea of what's possible. It should be easy +to adjust these examples to your needs. Also, if you have other examples that you +think should be added here, please let us know via either the fop-users or fop-dev +mailing lists. Finally, for more help please send your questions to the fop-users +mailing list. +

+
+
+ +
+ diff --git a/src/documentation/content/xdocs/0.95/extensions.xml b/src/documentation/content/xdocs/0.95/extensions.xml new file mode 100644 index 000000000..483866e61 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/extensions.xml @@ -0,0 +1,234 @@ + + + + + +
+ Standard FOP Extensions + $Revision$ +
+ +

+ By "extension", we mean any data that can be placed in the input XML document that + is not addressed by the XSL-FO standard. + By having a mechanism for supporting extensions, FOP is able to add features that + are not covered in the specification. +

+

+ The extensions documented here are included with FOP, and are automatically available + to you. If you wish to add an extension of your own to FOP, please see the + Developers' Extension Page. +

+ All extensions require the correct use of an appropriate namespace in your input document. +
+ SVG +

+ Please see the SVG documentation for more details. +

+
+
+ FO Extensions +
+ Namespace +

+ By convention, FO extensions in FOP use the "fox" namespace prefix. + To use any of the FO extensions, add a namespace entry for + http://xml.apache.org/fop/extensions to the root element: +

+ ]]> +
+
+ PDF Bookmarks +

+ In previous versions of Apache FOP there was a fox:outline element + which was used to create outlines in PDF files. The redesigned code makes use + of the new bookmark feature defined in the latest XSL 1.1 working draft. +

+
+
+ Anchors or Named Destinations +

Use the fox:destination element to define "named destinations" inside a PDF document. +These are useful as fragment identifiers, e.g. "http://server/document.pdf#anchor-name". +fox:destination elements can be placed almost anywhere in the fo document, including a child of +root, a block-level element, or an inline-level element. +For the destination to actually work, it must correspond to an "id" attribute on some fo element +within the document. In other words, the "id" attribute actually creates the "view" within the +PDF document. The fox:destination simply gives that view an independent name. +

+ +... +Table of Contents]]> + It is possible that in some future release of FOP, all elements with +"id" attributes will generate named-destinations, which will eliminate the need for +fox:destination. +
+
+ Table Continuation Label +

This extension element hasn't been reimplemented for the redesigned code, yet.

+ +
+
+ fox:orphan-content-limit and fox:widow-content-limit +

+ The two proprietary extension properties, fox:orphan-content-limit and + fox:widow-content-limit, are used to improve the layout of list-blocks and tables. + If you have a table with many entries, you don't want a single row to be left over + on a page. You will want to make sure that at least two or three lines are kept + together. The properties take an absolute length which specifies the area at the + beginning (fox:widow-content-limit) or at the end (fox:orphan-content-limit) of a + table or list-block. The properties are inherited and only have an effect on fo:table + and fo:list-block. An example: fox:widow-content-limit="3 * 1.2em" would make sure + the you'll have at least three lines (assuming line-height="1.2") together on a table + or list-block. +

+
+
+ fox:external-document + + This feature is incomplete. Support for multi-page documents will be added shortly. + At the moment, only single-page images will work. And this will not work with RTF output. + +

+ This is a proprietary extension element which allows to add whole images as pages to + an FO document. For example, if you have a scanned document or a fax as multi-page TIFF + file, you can append or insert this document using the fox:external-document + element. Each page of the external document will create one full page in the target + format. +

+

+ The fox:external-document element is structurally a peer to + fo:page-sequence, so wherever you can put an fo:page-sequence + you could also place a fox:external-document. + Therefore, the specified contents for fo:root change to: +

+

+ + (layout-master-set, declarations?, bookmark-tree?, (page-sequence|page-sequence-wrapper|fox:external-document|fox:destination)+) + +

+
+ Specification +

+ The fox:external-document extension formatting object is used to specify + how to create a (sub-)sequence of pages within a document. The content of these pages + comes from the individual subimages/pages of an image or paged document (for example: + multi-page TIFF in the form of faxes or scanned documents, or PDF files). The + formatting object creates the necessary areas to display one image per page. +

+

+ In terms of page numbers, the behaviour is the same as for + fo:page-sequence. The placement of the image inside the page is similar + to that of fo:external-graphic or fo:instream-foreign-object, + i.e. the viewport (and therefore the page size) is defined by either the intrinsic + size of the image or by the size properties that apply to this formatting object. +

+

Content: EMPTY

+

The following properties apply to this formatting object:

+
    +
  • (Common Accessibility Properties) (not implemented, yet)
  • +
  • (Common Aural Properties) (not implemented, yet)
  • +
  • block-progression-dimension
  • +
  • content-height
  • +
  • content-type
  • +
  • content-width
  • +
  • display-align
  • +
  • height
  • +
  • id
  • +
  • inline-progression-dimension
  • +
  • overflow
  • +
  • pages: <page-set> (see below) (not implemented, yet)
  • +
  • reference-orientation
  • +
  • scaling
  • +
  • scaling-method
  • +
  • src
  • +
  • text-align
  • +
  • width
  • +
+

+ Datatype "page-set": Value: auto | <integer-range>, + Default: "auto" which means all pages/subimages of the document. + <integer-range> allows values such as "7" or "1-3" +

+ + fox:external-document is not suitable for concatenating FO documents. + For this, XInclude is recommended. + +
+
+
+ Free-form Transformation for fo:block-container +

+ For fo:block-container elements whose absolute-position set to + "absolute" or "fixed" you can use the extension attribute fox:transform + to apply a free-form transformation to the whole block-container. The content of the + fox:transform attribute is the same as for + SVG's transform attribute. + The transformation specified here is performed in addition to other implicit + transformations of the block-container (resulting from top, left and other properties) + and after them. +

+

+ Examples: fox:transform="rotate(45)" would rotate the block-container + by 45 degrees clock-wise around its upper-left corner. + fox:transform="translate(10000,0)" would move the block-container to the + right by 10 points (=10000 millipoints, FOP uses millipoints internally!). +

+ + This extension attribute doesn't work for all output formats! It's currently only + supported for PDF, PS and Java2D-based renderers. + +
+
+ Color functions +

+ XSL-FO supports specifying color using the rgb(), rgb-icc() and system-color() functions. + Apache FOP provides additional color functions for special use cases. Please note that + using these functions compromises the interoperability of an FO document. +

+
+ cmyk() +

color cmyk(numeric, numeric, numeric, numeric)

+

+ This function will construct a color in device-specific CMYK color space. The numbers + must be between 0.0 and 1.0. For output formats that don't support device-specific + color space the CMYK value is converted to an sRGB value. +

+
+
+ +
+ +
+ diff --git a/src/documentation/content/xdocs/0.95/fonts.xml b/src/documentation/content/xdocs/0.95/fonts.xml new file mode 100644 index 000000000..423eaad11 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/fonts.xml @@ -0,0 +1,410 @@ + + + + + +
+ Apache FOP: Fonts + $Revision$ + + + + + + +
+ +
+ Summary +

The following table summarizes the font capabilities of the various FOP renderers:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RendererBase-14AWT/OSCustomCustom Embedding
PDFyesnoyesyes
PostScriptyesnoyesyes
PCLyes (modified)yes (painted as bitmaps)yes (painted as bitmaps)no
AFPnonoyesyes
Java2D/AWT/Bitmapif available from OSyesyesn/a (display only)
Printif available from OSyesyescontrolled by OS printer driver
RTFn/a (font metrics not needed)n/an/an/a
TXTyes (used for layout but not for output)noyes (used for layout but not for output)no
XMLyesnoyesn/a
+
+
+ Base-14 Fonts +

+ The Adobe PostScript and PDF Specification specify a set of 14 fonts that must be + available to every PostScript interpreter and PDF reader: + Helvetica (normal, bold, italic, bold italic), + Times (normal, bold, italic, bold italic), + Courier (normal, bold, italic, bold italic), + Symbol and ZapfDingbats. +

+

+ Please note that recent versions of Adobe Acrobat Reader replace + "Helvetica" with "Arial" and "Times" with "Times New Roman" internally. + GhostScript replaces "Helvetica" with "Nimbus Sans L" and "Times" with + "Nimbus Roman No9 L". Other document viewers may do similar font + substitutions. If you need to make sure that there are no such + substitutions, you need to specify an explicit font and embed it in + the target document. +

+
+
+ Missing Fonts +

+ When FOP does not have a specific font at its disposal (because it's + not installed in the operating system or set up in FOP's configuration), + the font is replaced with "any". "any" is internally mapped to the + Base-14 font "Times" (see above). +

+
+
+ Java2D/AWT/Operating System Fonts +

+ The Java2D family of renderers (Java2D, AWT, Print, TIFF, PNG), use the + Java AWT subsystem for font metric information. Through operating system + registration, the AWT subsystem knows what fonts are available on the system, + and the font metrics for each one. +

+

+ When working with one of these output formats and you're missing a font, just + install it in your operating system and they should be available for these + renderers. Please note that this is not true for other output formats such as + PDF or PostScript. +

+
+ +
+ Custom Fonts +

+ Support for custom fonts is highly output format dependent (see above table). + This section shows how to add Type 1 and TrueType fonts to the PDF, PostScript and + Java2D-based renderers. Other renderers (like AFP) support other font formats. Details + in this case can be found on the page about output formats. +

+

+ Prior to FOP version 0.94, it was always necessary to create an XML font metrics file + if you wanted to add a custom font. This unconvenient step has been removed and in + addition to that, FOP supports auto-registration of fonts, i.e. FOP can find fonts + installed in your operating system or can scan user-specified directories for fonts. + Font registration via XML font metrics file is still supported and is still necessary + if you want to use a TrueType Collection (*.ttc). Direct support for TrueType + collections may be added later. Furthermore, the XML font metrics files are still + required if you don't want to embed, but only reference a font. +

+

+ Basic information about fonts can be found at: +

+ +
+ +
+ Basic font configuration +

+ If you want FOP to use custom fonts, you need to tell it where to find them. This + is done in the configuration file and once per renderer (because each output format + is a little different). In the basic form, you can either tell FOP to find your + operating system fonts or you can specify directories that it will search for + support fonts. These fonts will then automatically be registered. +

+ + + C:\MyFonts1 + + + C:\MyFonts2 + + + +]]> + + Review the documentation for FOP Configuration + for instructions on making the FOP configuration available to FOP when it runs. + Otherwise, FOP has no way of finding your custom font information. It is currently + not possible to easily configure fonts from Java code. + +
+ +
+ Advanced font configuration +

+ The instructions found above should be sufficient for most users. Below are some + additional instructions in case the basic font configuration doesn't lead to + the desired results. +

+
+ Type 1 Font Metrics +

FOP includes PFMReader, which reads the PFM file that normally comes with a Type 1 font, and generates an appropriate font metrics file for it. + To use it, run the class org.apache.fop.fonts.apps.PFMReader:

+

Windows:

+ java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar + org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file +

Unix:

+ java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar + org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file +

PFMReader [options]:

+
    +
  • -fn <fontname> By default, FOP uses the fontname from the + .pfm file when embedding the font. Use the "-fn" option to override this name with one you have + chosen. This may be useful in some cases to ensure that applications using the output document + (Acrobat Reader for example) use the embedded font instead of a local font with the same + name.
  • +
+ The classpath in the above example has been simplified for readability. + You will have to adjust the classpath to the names of the actual JAR files in the lib directory. + xml-apis.jar, xercesImpl.jar, xalan.jar and serializer.jar are not necessary for JDK version 1.4 or later. + The tool will construct some values (FontBBox, StemV and ItalicAngle) based on assumptions and calculations which are only an approximation to the real values. + FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file. + The PFMReader tool does not yet interpret PFB or AFM files, so if you want to be correct, you may have to adjust the values in the XML file manually. + The constructed values however appear to have no visible influence. +
+
+ TrueType Font Metrics +

FOP includes TTFReader, which reads the TTF file and generates an appropriate font metrics file for it. + Use it in a similar manner to PFMReader. + For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf:

+ java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar + org.apache.fop.fonts.apps.TTFReader [options] + C:\myfonts\cmr10.ttf ttfcm.xml +

TTFReader [options]:

+
    +
  • -d <DEBUG | INFO > Sets the debug level (default is + INFO).
  • +
  • -fn <fontname> Same as for PFMReader.
  • +
  • -ttcname <fontname> If you're reading data from a + TrueType Collection (.ttc file) you must specify which font from the collection you will read + metrics from. + If you read from a .ttc file without this option, the fontnames will be listed for you.
  • +
  • -enc ansi Creates a WinAnsi-encoded font metrics file. + Without this option, a CID-keyed font metrics file is created. + The table below summarizes the differences between these two encoding options as currently + used within FOP. + Please note that this information only applies to TrueType fonts and TrueType collections:
  • +
+ + + + + + + + + + + + + + + + +
IssueWinAnsiCID-keyed
Usable Character SetLimited to WinAnsi character set, which is roughly equivalent to iso-8889-1.Limited only by the characters in the font itself.
Embedding the FontOptional.Mandatory. Not embedding the font produces invalid PDF documents.
+ + You may experience failures with certain TrueType fonts, especially if they don't contain + the so-called Unicode "cmap" table. TTFReader can currently not deal with font like this. + +
+
+ TrueType Collections Font Metrics +

TrueType collections (.ttc files) contain more than one font. + To create metrics files for these fonts, you must specify which font in the collection should be generated, by using the "-ttcname" option with the TTFReader.

+

To get a list of the fonts in a collection, just start the TTFReader as if it were a normal TrueType file (without the -ttcname option). + It will display all of the font names and exit with an Exception.

+

Here is an example of generating a metrics file for a .ttc file:

+ java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar + org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho" + msmincho.ttc msminch.xml +
+
+ Register Fonts with FOP +

You must tell FOP how to find and use the font metrics files by registering them in the FOP Configuration. Add entries for your custom fonts, regardless of font type, to the configuration file in a manner similar to the following:

+ + + + + + + + C:\MyFonts1 + + + C:\MyFonts2 + + + +]]> +
    +
  • + URLs are used to access the font metric and font files. + Relative URLs are resolved relative to the font-base property (or base) if available. + See FOP: Configuration for more information. +
  • +
  • The "metrics-url" attribute is generally not necessary except if you run into problems with certain fonts.
  • +
  • Either an "embed-url" or a "metrics-url" must be specified for font tag configurations.
  • +
  • The font "kerning" attribute is optional. Default is "true".
  • +
  • If embedding is off (i.e. embed-url is not set), the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.
  • +
  • When setting the "embed-url" attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.
  • +
  • The fonts "directory" tag can be used to register fonts contained within a single or list of directory paths. The "recursive" attribute can be specified to recursively add fonts from all sub directories.
  • +
  • The fonts "auto-detect" tag can be used to automatically register fonts that are found to be installed on the native operating system.
  • +
  • Fonts registered with "font" tag configurations override fonts found by means of "directory" tag definitions.
  • +
  • Fonts found as a result of a "directory" tag configuration override fonts found as a result of the "auto-detect" tag being specified.
  • +
  • + If relative URLs are specified, they are evaluated relative to the value of the + "font-base" setting. If there is no "font-base" setting, the fonts are evaluated + relative to the base directory. +
  • +
+ +
+
+ Auto-Detect and auto-embedd feature +

When the "auto-detect" flag is set in the configuration, FOP will automatically search for fonts in the default paths for your operating system.

+

FOP will also auto-detect fonts which are available in the classpath, if they are described as "application/x-font" in the MANIFEST.MF file. For example, if your .jar file contains font/myfont.ttf:

+ Manifest-Version: 1.0 + + Name: font/myfont.ttf + Content-Type: application/x-font +

This feature allows you to create JAR files containing fonts. The JAR files can be added to fop by providem them in the classpath, e.g. copying them into the lib/ directory.

+
+
+ Embedding + The PostScript renderer does not yet support TrueType fonts, but can embed Type 1 fonts. + The font is simply embedded into the PDF file, it is not converted. +

Font embedding is enabled in the userconfig.xml file and controlled by the embed-url attribute. + If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.

+ + Omitting the embed-url attribute for CID-encoded TrueType fonts will currently produce invalid + PDF files! If you create the XML font metric file using the "-enc ansi" option, you can omit + the embed-url attribute for TrueType fonts but you're restricted to the WinAnsi character set. + +

When FOP embeds a font, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font. + This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.

+

When embedding PostScript fonts, the entire font is always embedded.

+

When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the + original font, containing only the glyphs used, is embedded in the output document.

+
+ +
+ +
diff --git a/src/documentation/content/xdocs/0.95/fotree/disabled-testcases.xml b/src/documentation/content/xdocs/0.95/fotree/disabled-testcases.xml new file mode 100644 index 000000000..f6f78dcf7 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/fotree/disabled-testcases.xml @@ -0,0 +1,26 @@ + + + + + + Markers and core function evaluation + from-table-column_marker.fo + The code currently evaluates this function according to the column in which the + marker appears in the source document, rather than the column it is retrieved in. + + diff --git a/src/documentation/content/xdocs/0.95/graphics.xml b/src/documentation/content/xdocs/0.95/graphics.xml new file mode 100644 index 000000000..31e54d8fd --- /dev/null +++ b/src/documentation/content/xdocs/0.95/graphics.xml @@ -0,0 +1,551 @@ + + + + + +
+ Apache FOP: Graphics Formats + $Revision$ +
+ +
+ Introduction +

+ After the Apache FOP 0.94 release, the image handling subsystem has been rewritten in + order to improve the range of supported images and image subtypes, to lower the + overall memory consumption when handling images, to produce smaller output files and to + increase the performance in certain areas. Of course, this causes a few changes most of + which the user will probably not notice. The most important changes are: +

+
    +
  • + The image libraries Jimi and JAI are no longer supported. Instead, Apache FOP uses the + Image I/O API that was introduced with Java 1.4 for all bitmap codecs. +
  • +
  • + Some bitmap images are no longer converted to a standardized 24 bit RGB image but are + instead handled in their native format. +
  • +
  • + A plug-in mechanism offers a possibility to add support for new formats without changing + the FOP's source code. +
  • +
+

+ The actual image loading framework + no longer resides in Apache FOP, but was instead placed in + XML Graphics Commons. +

+
+
+ Overview of Graphics Support +

+ The table below summarizes the theoretical support for graphical formats + within FOP. In other words, within the constraints of the limitations listed here, + these formats should work. However, many of them have not been tested, + and there may be limitations that have not yet been discovered or documented. + The packages needed to support some formats are not included in the FOP distribution + and must be installed separately. Follow the links in the "Support Through" columns + for more details. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FormatTypeSupport Through
Apache FOP (native)Apache BatikImage I/O
BMP (Microsoft Windows Bitmap)bitmapX [1]
EMF (Windows Enhanced Metafile)vector (with embedded bitmaps)(X)
EPS (Encapsulated PostScript)metafile (both bitmap and vector), most frequently used for vector drawings(X)
GIF (Graphics Interchange Format)bitmapX
JPEG (Joint Photographic Experts Group)bitmap(X)X
PNG (Portable Network Graphic)bitmapX
SVG (Scalable Vector Graphics)vector (with embedded bitmaps)X
TIFF (Tag Image Format File)bitmap(X)X [1]
WMF (Windows Metafile)vector (with embedded bitmaps)(X)
+

+ Legend: +

+
    +
  • "(X)" means restricted support. Please see the details below.
  • +
  • + [1]: Requires the presence of JAI Image I/O Tools + (or an equivalent Image I/O compatible codec) in the classpath. JAI Image I/O Tools also + adds support for JPEG 2000, WBMP, RAW and PNM. Other Image I/O codecs may provide + support for additional formats. +
  • +
+ + JAI Image I/O Tools is not the same as the + JAI library! The + former simply exposes JAI's codecs using the Image I/O API but does not include all + the image manipulation functionality. + +
+ Map of supported image formats by output format +

+ Not all image formats are supported for all output formats! For example, while you can + use EPS (Encapsulated PostScript) files when you generate PostScript output, this format + will not be supported by any other output format. Here's an overview of which image + formats are supported by which output format: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Image FormatPDFPostScriptJava2D, PNG, TIFF, AWTPCLAFPRTF
BMP (Microsoft Windows Bitmap)XXXXXX
EMF (Windows Enhanced Metafile)X [1]
EPS (Encapsulated PostScript)X [1]
GIF (Graphics Interchange Format)XXXXXX
JPEG (Joint Photographic Experts Group)X [1]X [1]XXX [1]X
PNG (Portable Network Graphic)XXXXXX
SVG (Scalable Vector Graphics)XXXXXX
TIFF (Tag Image Format File)X [2]X [2]XXX [2]X
WMF (Windows Metafile)XXXXXX
+

+ Legend: +

+
    +
  • + [1]: Supported without the need to decode the image. +
  • +
  • + [2]: Supported without the need to decode the image, but only for certain subtypes. +
  • +
+
+
+
+ Graphics Packages +
+ XML Graphics Commons Native +

+ XML Graphics Commons supports a number + of graphic file formats natively as basic functionality: all bitmap formats for which + there are Image I/O codecs available (JPEG, PNG, GIF, TIFF, etc.), EPS and EMF. +

+
+
+ FOP Native +

+ FOP has no native image plug-ins for the image loading framework of its own but currently + hosts the Batik-dependent SVG and WMF plug-ins until they can be moved to + Apache Batik. +

+
+
+ Apache Batik +

+ Apache Batik will later receive the + SVG and WMF plug-ins for the image loading framework that are currently hosted inside + FOP. +

+

+ Current FOP distributions include a distribution of the + Apache Batik. + Because Batik's API changes frequently, it is highly recommended that you use the + version that ships with FOP, at least when running FOP. +

+ Batik must be run in a graphical environment. +

+ Batik must be run in a graphical environment. + It uses AWT classes for rendering SVG, which in turn require an X server on Unixish + systems. If you run a server without X, or if you can't connect to the X server due to + security restrictions or policies (a so-called "headless" environment), SVG rendering + will fail. +

+

Here are some workarounds:

+
    +
  • + Start Java with the -Djava.awt.headless=true command line option. +
  • +
  • + Install an X server which provides an in-memory framebuffer without actually using a + screen device or any display hardware. One example is Xvfb. +
  • +
  • + Install a toolkit which emulates AWT without the need for an underlying X server. One + example is the PJA toolkit, which is free + and comes with detailed installation instructions. +
  • +
+
+
+
+ Details on image formats +
+ BMP +

+ BMP images are supported through an Image I/O codec. There may be limitations of the + codec which are outside the control of Apache FOP. +

+
+
+ EMF +

+ Windows Enhanced Metafiles (EMF) are only supported in RTF output where they are + embedded without decoding. +

+
+
+ EPS +

Apache FOP allows to use EPS files when generating PostScript output only.

+

+ Other output targets can't be supported at the moment because + FOP lacks a PostScript interpreter. Furthermore, FOP is currently not able + to parse the preview bitmaps sometimes contained in EPS files. +

+
+
+ GIF +

+ GIF images are supported through an Image I/O codec. Transparency is supported but + not guaranteed to work with every output format. +

+
+
+ JPEG +

+ FOP native support (i.e. the handling of undecoded images) of JPEG does not include all + variants, especially those containing unusual color lookup tables and color profiles. + If you have trouble with a JPEG image in FOP, try opening it with an image processing + program (such as Photoshop or Gimp) and then saving it. Specifying 24-bit color output + may also help. For the PDF and PostScript renderers most JPEG images can be passed + through without decompression. User reports indicate that grayscale, RGB, and + CMYK color spaces are all rendered properly. However, for other output formats, the + JPEG images have to be decompressed. Tests have shown that there are some limitation + in some Image I/O codecs concerning images in the CMYK color space. Work-arounds are + in place but may not always work as expected. +

+
+
+ PNG +

+ PNG images are supported through an Image I/O codec. Transparency is supported but + not guaranteed to work with every output format. +

+
+
+ SVG +
+ Introduction +

FOP uses Apache Batik for SVG support. + This format can be handled as an fo:instream-foreign-object or in a separate + file referenced with fo:external-graphic.

+ + Batik's SVG Rasterizer utility may also be used to convert standalone SVG + documents into PDF. For more information please see the + SVG Rasterizer documentation + on the Batik site. + +
+
+ Placing SVG Graphics into PDF +

+ The SVG is rendered into PDF by using PDF commands to draw and fill + lines and curves. This means that the graphical objects created with + this remain as vector graphics. The same applies to PostScript output. + For other output formats the SVG graphic may be converted to a bitmap + image. +

+

+ There are a number of SVG things that cannot be converted directly into + PDF. Parts of the graphic such as effects, patterns and images are inserted + into the PDF as a raster graphic. The resolution of these raster images can + be controlled through the "target resolution" setting in the + configuration.

+

+ Currently transparency is limited in PDF so many SVG images that + contain effects or graphics with transparent areas may not be displayed + correctly. +

+
+
+ Placing SVG Text into PDF and PostScript +

If possible, Batik will use normal PDF or PostScript text when inserting text. It does + this by checking if the text can be drawn normally and the font is + supported. This example svg text.svg / + text.pdf + shows how various types and effects with text are handled. + Note that tspan and outlined text are not yet implemented.

+

+ Otherwise, text is converted and drawn as a set of shapes by Batik, using the + stroking text painter. This means that a typical character will + have about 10 curves (each curve consists of at least 20 characters). + This can make the output files large and when it is viewed the + viewer may not normally draw those fine curves very well (In Adobe Acrobat, turning on + "Smooth Line Art" in the preferences will fix this). Copy/paste functionality + will not be supported in this case. + If the text is inserted into the output file using the inbuilt text commands + it will use a single character. +

+

+ Note that because SVG text can be rendered as either text or a vector graphic, you + may need to consider settings in your viewer for both. The Acrobat viewer has both + "smooth line art" and "smooth text" settings that may need to be set for SVG images + to be displayed nicely on your screen (see Edit / Preferences / Display). + This setting will not affect the printing of your document, which should be OK in + any case, but will only affect the quality of the screen display.

+
+
+ Scaling +

+ Currently, SVG images are rendered with the dimensions specified in the SVG + file, within the viewport specified in the fo:external-graphic element. + For everything to work properly, the two should be equal. The SVG standard leaves + this issue as an implementation detail. Additional scaling options are available + through XSL-FO means. +

+

+ If you use pixels to specify the size of an SVG graphic the "source resolution" setting + in the configuration will be used to determine the + size of a pixel. The use of pixels to specify sizes is discouraged as they may + be interpreted differently in different environments. +

+
+
+ Known Problems +
    +
  • + Soft mask transparency is combined with white so that it looks better + on PDF 1.3 viewers but this causes the soft mask to be slightly lighter + or darker on PDF 1.4 viewers. +
  • +
  • + There is some problem with a gradient inside a pattern which may cause a PDF + error when viewed in Acrobat 5. +
  • +
  • + Text is not always handled correctly, it may select the wrong font + especially if characters have multiple fonts in the font list. +
  • +
  • + Uniform transparency for images and other SVG elements that are converted + into a raster graphic are not drawn properly in PDF. The image is opaque. +
  • +
+
+
+
+ TIFF +

+ FOP can embed TIFF images without decompression into PDF, PostScript and AFP if they + have either CCITT T.4, CCITT T.6, or JPEG compression. Otherwise, a TIFF-capable + Image I/O codec is necessary for decoding the image. +

+

+ There may be some limitation concerning images in the CMYK color space. +

+
+
+ WMF +

+ Windows Metafiles (WMF) are supported through classes in + Apache Batik. At the moment, support + for this format is experimental and may not always work as expected. +

+
+
+
+ Graphics Resolution +

+ Some bitmapped image file formats store a dots-per-inch (dpi) or other resolution + values. FOP tries to use this resolution information whenever possible to determine + the image's intrinsic size. This size is used during the layout process when it is not + superseded by an explicit size on fo:external-graphic (content-width and content-height + properties). +

+

+ Please note that not all images contain resolution information. If it's not available + the source resolution set on the FopFactory (or through the user configuration XML) is used. + The default here is 72 dpi. +

+

+ Bitmap images are generally embedded into the output format at their original resolution + (as is). No resampling of the image is performed. Explicit resampling is on our wishlist, + but hasn't been implemented, yet. Bitmaps included in SVG graphics may be resampled to + the resolution specified in the "target resolution" setting in the + configuration if SVG filters are applied. This can be + used as a work-around to resample images in FO documents. +

+
+
+ Page selection for multi-page formats +

+ Some image formats such as TIFF support multiple pages/sub-images per file. You can + select a particular page using a special URI fragment in the form: + <uri>#page=<nr> + (for example: http://localhost/images/myimage.tiff#page=3) +

+
+
+ Image caching +

+ FOP caches images between runs. There is one cache per FopFactory instance. The URI is + used as a key to identify images which means that when a particular URI appears again, + the image is taken from the cache. If you have a servlet that generates a different + image each time it is called with the same URI you need to use a constantly + changing dummy parameter on the URI to avoid caching. +

+

+ The image cache has been improved considerably in the redesigned code. Therefore, a + resetCache() method like in earlier versions of FOP has become unnecessary. If you + still experience OutOfMemoryErrors, please notify us. +

+
+ +
diff --git a/src/documentation/content/xdocs/0.95/hyphenation.xml b/src/documentation/content/xdocs/0.95/hyphenation.xml new file mode 100644 index 000000000..ed97c6868 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/hyphenation.xml @@ -0,0 +1,237 @@ + + + + + +
+ Apache FOP: Hyphenation + $Revision$ +
+ +
+ Hyphenation Support +
+ Introduction +

FOP uses Liang's hyphenation algorithm, well known from TeX. It needs + language specific pattern and other data for operation.

+

Because of licensing issues (and for + convenience), all hyphenation patterns for FOP are made available through + the Objects For + Formatting Objects project.

+ If you have made improvements to an existing FOP hyphenation pattern, + or if you have created one from scratch, please consider contributing these + to OFFO so that they can benefit other FOP users as well. + Please inquire on the FOP User + mailing list. +
+
+ License Issues +

Many of the hyphenation files distributed with TeX and its offspring are + licenced under the LaTeX + Project Public License (LPPL), which prevents them from being + distributed with Apache software. The LPPL puts restrictions on file names + in redistributed derived works which we feel can't guarantee. Some + hyphenation pattern files have other or additional restrictions, for + example against use for commercial purposes.

+

Although Apache FOP cannot redistribute hyphenation pattern files that do + not conform with its license scheme, that does not necessarily prevent users + from using such hyphenation patterns with FOP. However, it does place on + the user the responsibility for determining whether the user can rightly use + such hyphenation patterns under the hyphenation pattern license.

+ The user is responsible to settle license issues for hyphenation + pattern files that are obtained from non-Apache sources. +
+
+ Sources of Custom Hyphenation Pattern Files +

The most important source of hyphenation pattern files is the + CTAN TeX + Archive.

+
+
+ Installing Custom Hyphenation Patterns +

To install a custom hyphenation pattern for use with FOP:

+
    +
  1. Convert the TeX hyphenation pattern file to the FOP format. The FOP + format is an xml file conforming to the DTD found at + {fop-dir}/hyph/hyphenation.dtd.
  2. +
  3. Name this new file following this schema: + languageCode_countryCode.xml. The country code is + optional, and should be used only if needed. For example: +
      +
    • en_US.xml would be the file name for American + English hyphenation patterns.
    • +
    • it.xml would be the file name for Italian + hyphenation patterns.
    • +
    + The language and country codes must match the XSL-FO input, which + follows ISO + 639 (languages) and ISO + 3166 (countries). NOTE: The ISO 639/ISO 3166 convention is that + language names are written in lower case, while country codes are written + in upper case. FOP does not check whether the language and country specified + in the FO source are actually from the current standard, but it relies + on it being two letter strings in a few places. So you can make up your + own codes for custom hyphenation patterns, but they should be two + letter strings too (patches for proper handling extensions are welcome)
  4. +
  5. There are basically three ways to make the FOP-compatible hyphenation pattern + file(s) accessible to FOP: +
      +
    • Download the precompiled JAR from OFFO + and place it either in the {fop-dir}/lib directory, or + in a directory of your choice (and append the full path to the JAR to + the environment variable FOP_HYPHENATION_PATH).
    • +
    • Download the desired FOP-compatible hyphenation pattern file(s) from + OFFO, + and/or take your self created hyphenation pattern file(s), +
        +
      • place them in the directory {fop-dir}/hyph,
      • +
      • or place them in a directory of your choice and set the Ant variable + user.hyph.dir to point to that directory (in + build-local.properties),
      • +
      + and run Ant with build target + jar-hyphenation. This will create a JAR containing the + compiled patterns in {fop-dir}/build that will be added to the + classpath on the next run. + (When FOP is built from scratch, and there are pattern source file(s) + present in the directory pointed to by the + user.hyph.dir variable, this JAR will automatically + be created from the supplied pattern(s)).
    • +
    • Put the pattern source file(s) into a directory of your choice and + configure FOP to look for custom patterns in this directory, by setting the + <hyphenation-base> + configuration option.
    • +
    +
  6. +
+ + Either of these three options will ensure hyphenation is working when using + FOP from the command-line. If FOP is being embedded, remember to add the location(s) + of the hyphenation JAR(s) to the CLASSPATH (option 1 and 2) or to set the + <hyphenation-dir> + configuration option programmatically (option 3). + +
+
+
+ Hyphenation Patterns +

If you would like to build your own hyphenation pattern files, or modify + existing ones, this section will help you understand how to do so. Even + when creating a pattern file from scratch, it may be beneficial to start + with an existing file and modify it. See + OFFO's Hyphenation page for examples. + Here is a brief explanation of the contents of FOP's hyphenation patterns:

+ The remaining content of this section should be considered "draft" + quality. It was drafted from theoretical literature, and has not been + tested against actual FOP behavior. It may contain errors or omissions. + Do not rely on these instructions without testing everything stated here. + If you use these instructions, please provide feedback on the + FOP User mailing list, either + confirming their accuracy, or raising specific problems that we can + address. +
    +
  • The root of the pattern file is the <hyphenation-info> element.
  • +
  • <hyphen-char>: its attribute "value" contains the character signalling + a hyphen in the <exceptions> section. It has nothing to do with the + hyphenation character used in FOP, use the XSLFO hyphenation-character + property for defining the hyphenation character there. At some points + a dash U+002D is hardwired in the code, so you'd better use this too + (patches to rectify the situation are welcome). There is no default, + if you declare exceptions with hyphenations, you must declare the + hyphen-char too.
  • +
  • <hyphen-min> contains two attributes: +
      +
    • before: the minimum number of characters in a word allowed to exist + on a line immediately preceding a hyphenated word-break.
    • +
    • after: the minimum number of characters in a word allowed to exist + on a line immediately after a hyphenated word-break.
    • +
    + This element is unused and not even read. It should be considered a + documentation for parameters used during pattern generation. +
  • +
  • <classes> contains whitespace-separated character sets. The members + of each set should be treated as equivalent for purposes of hyphenation, + usually upper and lower case of the same character. The first character + of the set is the canonical character, the patterns and exceptions + should only contain these canonical representation characters (except + digits for weight, the period (.) as word delimiter in the patterns and + the hyphen char in exceptions, of course).
  • +
  • <exceptions> contains whitespace-separated words, each of which + has either explicit hyphen characters to denote acceptable breakage + points, or no hyphen characters, to indicate that this word should + never be hyphenated, or contain explicit <hyp> elements for specifying + changes of spelling due to hyphenation (like backen -> bak-ken or + Stoffarbe -> Stoff-farbe in the old german spelling). Exceptions override + the patterns described below. Explicit <hyp> declarations don't work + yet (patches welcome). Exceptions are generally a bit brittle, test + carefully.
  • +
  • <patterns> includes whitespace-separated patterns, which are what + drive most hyphenation decisions. The characters in these patterns are + explained as follows: +
      +
    • non-numeric characters represent characters in a sub-word to be + evaluated
    • +
    • the period character (.) represents a word boundary, i.e. either + the beginning or ending of a word
    • +
    • numeric characters represent a scoring system for indicating the + acceptability of a hyphen in this location. Odd numbers represent an + acceptable location for a hyphen, with higher values overriding lower + inhibiting values. Even numbers indicate an unacceptable location, with + higher values overriding lower values indicating an acceptable position. + A value of zero (inhibiting) is implied when there is no number present. + Generally patterns are constructed so that valuse greater than 4 are rare. + Due to a bug currently patterns with values of 8 and greater don't + have an effect, so don't wonder.
    • +
    + Here are some examples from the English patterns file: +
      +
    • Knuth (The TeXBook, Appendix H) uses the example hach4, which indicates that it is extremely undesirable to place a hyphen after the substring "hach", for example in the word "toothach-es".
    • +
    • .leg5e indicates that "leg-e", when it occurs at the beginning of a word, is a very good place to place a hyphen, if one is needed. Words like "leg-end" and "leg-er-de-main" fit this pattern.
    • +
    + Note that the algorithm that uses this data searches for each of the word's substrings in the patterns, and chooses the highest value found for letter combination. +
  • +
+

If you want to convert a TeX hyphenation pattern file, you have to undo + the TeX encoding for non-ASCII text. FOP uses Unicode, and the patterns + must be proper Unicode too. You should be aware of the XML encoding issues, + preferably use a good Unicode editor.

+

Note that FOP does not do Unicode character normalization. If you use + combining chars for accents and other character decorations, you must + declare character classes for them, and use the same sequence of base character + and combining marks in the XSLFO source, otherwise the pattern wouldn't match. + Fortunately, Unicode provides precomposed characters for all important cases + in common languages, until now nobody run seriously into this issue. Some dead + languages and dialects, especially ancient ones, may pose a real problem + though.

+

If you want to generate your own patterns, an open-source utility called + patgen is available on many Unix/Linux distributions and every TeX + distribution which can be used to assist in + creating pattern files from dictionaries. Pattern creation for languages like + english or german is an art. If you can, read Frank Liang's original paper + "Word Hy-phen-a-tion by Com-pu-ter" (yes, with hyphens). It is not available + online. The original patgen.web source, included in the TeX source distributions, + contains valuable comments, unfortunately technical details obscure often the + high level issues. Another important source is + The + TeX Book, appendix H (either read the TeX source, or run it through + TeX to typeset it). Secondary articles, for example the works by Petr Sojka, + may also give some much needed insight into problems arising in automated + hyphenation.

+
+ +
diff --git a/src/documentation/content/xdocs/0.95/index.xml b/src/documentation/content/xdocs/0.95/index.xml new file mode 100644 index 000000000..3bc718b34 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/index.xml @@ -0,0 +1,54 @@ + + + + + +
+ Apache FOP Version 0.95 + $Revision$ +
+ +
+ Introduction +

+ The Apache FOP team is proud to present to you this production quality release. + We're still in the process of adding new features. We welcome any feedback you + might have and even more, any other form of help to get the project forward. +

+

+ This sixth release contains many bug fix release and new features compared + to 0.94. To see what has changed since the last release, please visit the + Changes Page and the + Release Notes. +

+
+
+ Upgrading from an earlier version +

+ If you're upgrading to this version from an earlier version of FOP, please read the + information contained on the Upgrading page! +

+
+
+ Download +

+ To download this version, please visit the download page. +

+
+ +
diff --git a/src/documentation/content/xdocs/0.95/intermediate.xml b/src/documentation/content/xdocs/0.95/intermediate.xml new file mode 100644 index 000000000..4744185aa --- /dev/null +++ b/src/documentation/content/xdocs/0.95/intermediate.xml @@ -0,0 +1,146 @@ + + + + + +
+ Intermediate Format + $Revision$ +
+ + + Please note that the intermediate format is an advanced feature and can be ignored by most + users of Apache FOP. + +
+ Introduction +

+ The intermediate format (IF) is a proprietary XML format that represents the area tree + generated by the layout engine. The area tree is conceptually defined in the + XSL-FO specification in chapter 1.1.2. + The IF can be generated through the area tree XML Renderer (the XMLRenderer). +

+

+ The intermediate format can be used to generate intermediate documents that are modified + before they are finally rendered to their ultimate output format. Modifications include + adjusting and changing trait values, adding or modifying area objects, inserting prefabricated + pages, overlays, imposition (n-up, rotation, scaling etc.). Multiple IF files can be combined + to a single output file. +

+
+
+ Usage of the Intermediate Format +

+ As already mentioned, the IF is generated by using the XMLRenderer (MIME type: + application/X-fop-areatree). So, you basically set the right MIME type for + the output format and process your FO files as if you would create a PDF file. However, there + is an important detail to consider: The various Renderers don't all use the same font sources. + To be able to create the right area tree for the ultimate output file, you need to create + the IF file using the right font setup. This is achieved by telling the XMLRenderer to mimic + another renderer. This is done by calling the XMLRenderer's mimicRenderer() method with an + instance of the ultimate target renderer as the single parameter. This has a consequence: An + IF file rendered with the Java2DRenderer may not look as expected when it was actually generated + for the PDF renderer. For renderers that use the same font setup, this restriction does not + apply (PDF and PS, for example). Generating the intermediate format file is the first step. +

+

+ The second step is to reparse the IF file using the AreaTreeParser which is + found in the org.apache.fop.area package. The pages retrieved from the IF file are added to an + AreaTreeModel instance from where they are normally rendered using one of the available Renderer + implementations. You can find examples for the IF processing in the + examples/embedding + directory in the FOP distribution +

+

+ The basic pattern to parse the IF format looks like this: +

+ +

+ This example simply reads an IF file and renders it to a PDF file. Please note, that in normal + FOP operation you're shielded from having to instantiate the FontInfo object yourself. This + is normally a task of the AreaTreeHandler which is not present in this scenario. The same + applies to the AreaTreeModel instance, in this case an instance of a subclass called + RenderPagesModel. RenderPagesModel is ideal in this case as it has very little overhead + processing the individual pages. An important line in the example is the call to + endDocument() on the AreaTreeModel. This lets the Renderer know that the processing + is now finished. +

+

+ The intermediate format can also be used from the command-line + by using the "-atin" parameter for specifying the area tree XML as input file. You can also + specify a "mimic renderer" by inserting a MIME type between "-at" and the output file. +

+
+ Concatenating Documents +

+ This initial example is obviously not very useful. It would be faster to create the PDF file + directly. As the ExampleConcat.java + example shows you can easily parse multiple IF files in a row and add the parsed pages to the + same AreaTreeModel instance which essentially concatenates all the input document to one single + output document. +

+
+
+ Modifying Documents +

+ One of the most important use cases for the intermediate format is obviously modifying the area + tree XML before finally rendering it to the target format. You can easily use XSLT to process + the IF file according to your needs. Please note, that we will currently not formally describe + the intermediate format. You need to have a good understanding its structure so you don't + create any non-parseable files. We may add an XML Schema and more detailed documentation at a + later time. You're invited to help us with that. +

+
+
+ Advanced Use +

+ The generation of the intermediate format as well as it parsing process has been designed to allow + for maximum flexibility and optimization. Please note that you can call setTransformerHandler() on + XMLRenderer to give the XMLRenderer your own TransformerHandler instance in case you would like to + do custom serialization (to a W3C DOM, for example) and/or to directly modify the area tree using + XSLT. The AreaTreeParser on the other side allows you to retrieve a ContentHandler instance where + you can manually send SAX events to to start the parsing process (see getContentHandler()). +

+
+
+ +
diff --git a/src/documentation/content/xdocs/0.95/known-issues.xml b/src/documentation/content/xdocs/0.95/known-issues.xml new file mode 100644 index 000000000..6e28e3fb7 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/known-issues.xml @@ -0,0 +1,70 @@ + + + + + + MIF and SVG output support have not been restored, yet. + + + Auto table layout is not implemented, yet. + + + Footnotes may overlap with text of the region-body in multi-column + documents. + + + Space resolution does not work between footnote regions. + + + There's a problem involving nested block-containers and + reference-orientation 180/-180 (Bugzilla #36391) + + + block-containers with no height currently don't create a fence for + spaces as they should (they behave like a normal block). + + + Preserved linefeeds in fo:character are not handled correctly. + + + An empty block currently produces a fence for stacking constraints + which it shouldn't. + + + There are several small problems around white space handling. + + + leaders with leader-pattern="use-content" may not work as expected. + + + If two consecutive pages don't have the same available width, the + content currently isn't properly fit into the available space on + the new page. + + + background-images on page-number-citations are not placed correctly. + + + Not all FO elements can be referenced by their "id", most notably: + table-body, table-header, table-footer and table-row. + + + Column balancing in multi-column documents may not work as expected + (Bugzilla #36356) + + diff --git a/src/documentation/content/xdocs/0.95/knownissues_overview.xml b/src/documentation/content/xdocs/0.95/knownissues_overview.xml new file mode 100644 index 000000000..7247e6b79 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/knownissues_overview.xml @@ -0,0 +1,70 @@ + + + + + +
+ Apache FOP: Known Issues + $Revision$ +
+ +
+ Known issues +

+ This page lists currently known issues in the current release. +

+ +

+ For additional information on known issues in Apache FOP, please have a look at the following pages, too: +

+ +
+

+ Apache FOP has an extensive automated testing infrastructure. Parts of this infrastructure are several + sets of test cases. When a test case is listed in disabled-testcases.xml it is disabled in the JUnit + tests during the normal build process. This indicates a problem in the current codebase. When a bug is + fixed or a missing feature is added the entry for the relevant test case(s) are removed. +

+
+ FO Tree +

+ This section lists disabled test cases in the test suite for the FO tree tests, at the time + of the release. +

+ +
+
+ Layout Engine +

+ This section lists disabled test cases in the test suite for the layout engine tests, at the + time of the release. +

+ +
+
+ Other known issues +

This section lists other known issues.

+ +
+
+ +
+ diff --git a/src/documentation/content/xdocs/0.95/layoutengine/disabled-testcases.xml b/src/documentation/content/xdocs/0.95/layoutengine/disabled-testcases.xml new file mode 100644 index 000000000..b4de16ef4 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/layoutengine/disabled-testcases.xml @@ -0,0 +1,260 @@ + + + + + + + + External link around an SVG not properly sized + basic-link_external-destination_2.xml + The bpd trait of the inlineparent area for the basic-link + is not sized correctly if it wraps an image that is higher than the + nominal line. + + + Auto-height block-containers produce fences + block-container_space-before_space-after_3.xml + Block-containers with no height currently don't + create a fence for spaces as they should (they behave like a + normal block). + + + font-stretch NYI + block_font-stretch.xml + Font-stretch is not implemented, yet. + + + Hyphenation with preserved linefeeds + block_hyphenation_linefeed_preserve.xml + When hyphenation is enabled and linefeeds are preserved, + the text is output multiple times. + + + linefeed-treatment + block_linefeed-treatment.xml + Preserved linefeeds in a fo:character are not handled + correctly. + + + white-space-treatment + block_white-space-treatment_3.xml + White space handling incorrectly stops at fo:inline + boundaries when it comes to formatter generated line breaks. + + + Empty blocks produce fences + block_space-before_space-after_8.xml + An empty block currently produces a fence for + stacking constraints which it shouldn't. + + + block white-space nbsp 2 + block_white-space_nbsp_2.xml + The nbsp given as an fo:character is not adjustable and therefore + the justification does not work in this case. + + + block word-spacing + block_word-spacing.xml + Word-spacing may not work as expected. + + + block word-spacing text-align justify + block_word-spacing_text-align_justify.xml + Word-spacing may not work as expected. + + + external-graphic don't shrink + external-graphic_oversized.xml + Images currently don't shrink so they fit on a page + when they are too big and shrinking is allowed to + happen (min/opt/max). + + + Test case with HTTP URL + external-graphic_src_uri.xml + Doesn't work behind a proxy which requires + authorization. + + + Space Resolution in foot note area + footnote_space-resolution.xml + Space resolution does not work between footnote + regions. + + + Footnotes swallowed in lists + footnote_in_list.xml + Element lists for lists are created by combining the + element lists from list-item-label and list-item-body. The + footnotes contained in the KnuthBlockBoxes are not propagated to + the combined element list. + http://issues.apache.org/bugzilla/show_bug.cgi?id=37579 + + + Footnotes swallowed in tables + footnote_in_table.xml + Element lists for tables are created by combining the + element lists from the individual table-cells. The footnotes + contained in the KnuthBlockBoxes are not propagated to the combined + element list. + http://issues.apache.org/bugzilla/show_bug.cgi?id=37579 + + + NPE for table inside an inline + inline_block_nested_3.xml + Placing a table as a child of an fo:inline produces a + NullPointerException. + + + inline-container is not implemented, yet. + inline-container_block_nested.xml + inline-container is not implemented, yet. Content of an + inline-container will get swallowed. The test case contains no checks. + + + inline-container is not implemented, yet. + inline-container_border_padding.xml + inline-container is not implemented, yet. Content of an + inline-container will get swallowed. + + + inline letter-spacing + inline_letter-spacing.xml + Letter-spacing may not work as + expected within fo:inline. + + + inline word-spacing + inline_word-spacing.xml + Word-spacing may not work as expected within + fo:inline. + + + inline word-spacing text-align justify + inline_word-spacing_text-align_justify.xml + + + + leader-alignment NYI + leader-alignment.xml + Leader-alignment is not yet + implemented. + + + leader-pattern="use-content": Problem with line height + leader_leader-pattern_use-content_bug.xml + Line height is not correctly calculated for + use-content leaders whose height is larger than the rest of the + line. + http://www.nabble.com/leaders-with-leader-pattern%3D%22use-content%22-t546244.html + + + keep-with-previous doesn't work in lists + list-block_keep-with-previous.xml + Keep-with-previous doesn't work inside tables and + lists, yet. + + + keep-with-previous doesn't work in lists + list-item_block_keep-with-previous.xml + Keep-with-previous doesn't work inside tables and + lists, yet. + + + Page breaking doesn't deal with IPD changes + page-breaking_4.xml + Page breaking currently doesn't support changing available IPD + between pages of a single page-sequence. Element list generation has to be reset to + redetermine line breaks in this case. + + + Overflow handing is incomplete + page-breaking_6.xml + Line breaking is not 100% correct when there's too little space. + Overflows are not detected and warned. + + + Indefinite page height handling is imcomplete + page-height_indefinite_simple.xml + A RuntimeException is thrown for a page of indefinite height. Lots of warnings. + + + page-number-citation: Problem with background-image + page-number-citation_background-image.xml + Background-images on page-number-citations are not + placed correctly. + + + page-number-citation-last: FOs spanning multiple pages are not properly handled. + page-number-citation-last_basic.xml + Resolution of forward references does not wait until an FO is fully finished when an FO spans multiple pages. + + + IDs are not working on all FO elements + page-number-citation_complex_1.xml + The "id" attributes are not properly handled for all block-level FO elements. + + + IDs are not working on all FO elements + page-number-citation_complex_2.xml + The "id" attributes are not properly handled for all inline-level FO elements. + + + Footnotes in multi-column documents + region-body_column-count_footnote.xml + Footnotes may overlap with text of the region-body in + multi-column documents. + + + Column Balancing problems + region-body_column-count_balance_4col.xml + Situation in a 4-column document where the column balancing doesn't work and even causes some + content to disappear. + + + Column Balancing problems + region-body_column-count_bug36356.xml + Column balancing doesn't work as expected. + + + table-cell empty area with marker.xml + table-cell_empty_area_with_marker.xml + A table-cell producing an empty area does currently not add any markers to a page. + See TODO entry in AreaAdditionUtil. + + + Border conditionality on table + table_border-width_conditionality.xml + The code should be ok, but the test case uses shorthands and therefore + is probably not expressing the indended outcome according to the spec. The test + case should be revisited. + + + fo:wrapper around block-level content (with id) + wrapper_block_id.xml + "id" attributes on fo:wrapper around block-level content don't get + added to the area tree. + + + Soft hyphen with normal hyphenation enabled + block_shy_linebreaking_hyph.xml + A soft hyphen should be a preferred as break compared to a + normal hyphenation point but is not. + + diff --git a/src/documentation/content/xdocs/0.95/output.xml b/src/documentation/content/xdocs/0.95/output.xml new file mode 100644 index 000000000..628df1248 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/output.xml @@ -0,0 +1,888 @@ + + + + + + +
+ Apache FOP Output Formats + $Revision$ + + + + +
+ + +

+ FOP supports multiple output formats by using a different renderer for each format. + The renderers do not all have the same set of capabilities, sometimes because of + the output format itself, sometimes because some renderers get more development + attention than others. +

+
+ General Information +
+ Fonts +

+ Most FOP renderers use a FOP-specific system for font registration. + However, the Java2D/AWT and print renderers use the Java AWT package, which gets its + font information from the operating system registration. + This can result in several differences, including actually using different fonts, + and having different font metrics for the same font. + The net effect is that the layout of a given FO document can be quite different between + renderers that do not use the same font information. +

+

+ Theoretically, there's some potential to make the output of the PDF/PS renderers match + the output of the Java2D-based renderers. If FOP used the font metrics from its own + font subsystem but still used Java2D for text painting in the Java2D-based renderers, + this could probably be achieved. However, this approach hasn't been implemented, yet. +

+

+ With a work-around, it is possible to match the PDF/PS output in a Java2D-based + renderer pretty closely. The clue is to use the + intermediate format. The trick is to layout the + document using FOP's own font subsystem but then render the document using Java2D. + Here are the necessary steps (using the command-line): +

+
    +
  1. + Produce an IF file: fop -fo myfile.fo -at application/pdf myfile.at.xml
    + Specifying "application/pdf" for the "-at" parameter causes FOP to use FOP's own + font subsystem (which is used by the PDF renderer). Note that no PDF file is created + in this step. +
  2. +
  3. Render to a PDF file: fop -atin myfile.at.xml -pdf myfile.pdf
  4. +
  5. Render to a Java2D-based renderer: +
      +
    • fop -atin myfile.at.xml -print
    • +
    • fop -atin myfile.at.xml -awt
    • +
    • fop -atin myfile.at.xml -tiff myfile.tiff
    • +
    +
  6. +
+
+
+ Output to a Printer or Other Device +

+ The most obvious way to print your document is to use the FOP + print renderer, which uses the Java2D API (AWT). + However, you can also send output from the Postscript renderer directly to a Postscript + device, or output from the PCL renderer directly to a PCL device. +

+

+ Here are Windows command-line examples for Postscript and PCL: +

+ + +

+ Here is some Java code to accomplish the task in UNIX: +

+ +

+ Set the output MIME type to "application/x-pcl" (MimeConstants.MIME_PCL) and + it happily sends the PCL to the UNIX printer queue. +

+
+
+
+ PDF +

+ PDF is the best supported output format. It is also the most accurate + with text and layout. This creates a PDF document that is streamed out + as each page is rendered. This means that the internal page index + information is stored near the end of the document. + The PDF version supported is 1.4. PDF versions are forwards/backwards + compatible. +

+

+ Note that FOP does not currently support "tagged PDF" or PDF/A-1a. + Support for PDF/A-1b and PDF/X has recently been added, however. +

+
+ Fonts +

+ PDF has a set of fonts that are always available to all PDF viewers; + to quote from the PDF Specification: + + "PDF prescribes a set of 14 standard fonts that can be used without prior + definition. + These include four faces each of three Latin text typefaces (Courier, + Helvetica, and Times), as well as two symbolic fonts (Symbol and ITC Zapf + Dingbats). These fonts, or suitable substitute fonts with the same metrics, are + guaranteed to be available in all PDF viewer applications." +

+
+
+ Post-processing +

+ FOP does not currently support several desirable PDF features: watermarks and signatures. + One workaround is to use Adobe Acrobat (the full version, not the Reader) to process + the file manually or with scripting that it supports. +

+

+ Another popular post-processing tool is iText, + which has tools for adding security features, document properties, watermarks, and many + other features to PDF files. +

+ + Caveat: iText may swallow PDF bookmarks. But + Jens Stavnstrup tells us + that this doesn't happen if you use iText's PDFStamper. + +

+ Here is some sample code that uses iText to encrypt a FOP-generated PDF. (Note that FOP now + supports PDF encryption. However the principles for using + iText for other PDF features are similar.) +

+ +

+ Check the iText tutorial and documentation for setting access flags, password, + encryption strength and other parameters. +

+
+
+ Watermarks +

+ In addition to the PDF Post-processing options, consider the following workarounds: +

+
    +
  • + Use a background image for the body region. +
  • +
  • + (submitted by Trevor Campbell) Place an image in a + region that overlaps the flowing text. For example, make + region-before large enough to contain your image. Then include a + block (if necessary, use an absolutely positioned block-container) + containing the watermark image in the static-content for the + region-before. Note that the image will be drawn on top of the + normal content. +
  • +
+
+
+
+ PostScript +

+ The PostScript renderer has been brought up to a similar quality as the + PDF renderer, but may still be missing certain features. It provides good + support for most text and layout. + Images and SVG are not fully supported, yet. Currently, the PostScript + renderer generates PostScript Level 3 with most DSC comments. Actually, + the only Level 3 features used are the FlateDecode and DCTDecode + filter (the latter is used for 1:1 embedding of JPEG images), everything + else is Level 2. +

+
+ Configuration +

+ The PostScript renderer configuration currently allows the following settings: +

+ + false + 3 + false + false + true +]]> +

+ The default value for the "auto-rotate-landscape" setting is "false". Setting it + to "true" will automatically rotate landscape pages and will mark them as landscape. +

+

+ The default value for the "language-level" setting is "3". This setting specifies + the PostScript language level which should be used by FOP. Set this to "2" + only if you don't have a Level 3 capable interpreter. +

+

+ The default value for the "optimize-resources" setting is "false". Setting it + to "true" will produce the PostScript file in two steps. A temporary file will be + written first which will then be processed to add only the fonts which were really + used and images are added to the stream only once as PostScript forms. This will + reduce file size but can potentially increase the memory needed in the interpreter + to process. +

+

+ The default value for the "safe-set-page-device" setting is "false". Setting it + to "true" will cause the renderer to invoke a postscript macro which guards against + the possibility of invalid/unsupported postscript key/values being issued to the + implementing postscript page device. +

+

+ The default value for the "dsc-compliant" setting is "true". Setting it + to "false" will break DSC compliance by minimizing the number of setpagedevice + calls in the postscript document output. This feature may be useful when unwanted + blank pages are experienced in your postscript output. This problem is caused by + the particular postscript implementation issuing unwanted postscript subsystem + initgraphics/erasepage calls on each setpagedevice call. +

+
+
+ Limitations +
    +
  • Images and SVG may not be displayed correctly. SVG support is far from being complete. No image transparency is available.
  • +
  • Only Type 1 fonts are supported.
  • +
  • Multibyte characters are not supported.
  • +
  • PPD support is still missing.
  • +
+
+
+
+ PCL +

+ This format is for the Hewlett-Packard PCL printers and other printers + supporting PCL. It should produce output as close to identical as possible + to the printed output of the PDFRenderer within the limitations of the + renderer, and output device. +

+

+ The output created by the PCLRenderer is generic PCL 5, HP GL/2 and PJL. + This should allow any device fully supporting PCL 5 to be able to + print the output generated by the PCLRenderer. PJL is used to control the + print job and switch to the PCL language. PCL 5 is used for text, raster + graphics and rectangular fill graphics. HP GL/2 is used for more complex + painting operations. Certain painting operations are done off-screen and + rendered to PCL as bitmaps because of limitations in PCL 5. +

+
+ References + +
+
+ Limitations +
    +
  • + Text or graphics outside the left or top of the printable area are not + rendered properly. This is a limitation of PCL, not FOP. In general, + things that should print to the left of the printable area are shifted + to the right so that they start at the left edge of the printable area. +
  • +
  • + The Helvetica and Times fonts are not well supported among PCL printers + so Helvetica is mapped to Arial and Times is mapped to Times New. This + is done in the PCLRenderer, no changes are required in the FO's. The + metrics and appearance for Helvetica/Arial and Times/Times New are + nearly identical, so this has not been a problem so far. +
  • +
  • For the non-symbol fonts, the ISO 8859-1 symbol set is used (PCL set "0N").
  • +
  • + All fonts available to the Java2D subsystem are usable. The texts are + painted as bitmap much like the Windows PCL drivers do. +
  • +
  • Multibyte characters are not supported.
  • +
  • + At the moment, only monochrome output is supported. PCL5c color extensions + will only be implemented on demand. Color and grayscale images are converted + to monochrome bitmaps (1-bit). Dithering only occurs if the JAI image library + is available. +
  • +
  • + Images are scaled up to the next resolution level supported by PCL (75, + 100, 150, 200, 300, 600 dpi). For color and grayscale images an even + higher PCL resolution is selected to give the dithering algorithm a chance + to improve the bitmap quality. +
  • +
  • + Currently, there's no support for clipping and image transparency, largely + because PCL 5 has certain limitations. +
  • +
+
+
+ Configuration +

+ The PCL renderer configuration currently allows the following settings: +

+ + quality + bitmap + false +]]> +

+ The default value for the "rendering" setting is "speed" which causes borders + to be painted as plain rectangles. In this mode, no special borders (dotted, + dashed etc.) are available. If you want support for all border modes, set the + value to "quality" as indicated above. This will cause the borders to be painted + as bitmaps. +

+

+ The default value for the "text-rendering" setting is "auto" which paints the + base fonts using PCL fonts. Non-base fonts are painted as bitmaps through Java2D. + If the mix of painting methods results in unwelcome output, you can set this + to "bitmap" which causes all text to be rendered as bitmaps. +

+

+ The default value for the "disable-pjl" setting is "false". This means that + the PCL renderer usually generates PJL commands before and after the document + in order to switch a printer into PCL language. PJL commands can be disabled + if you set this value to "true". +

+

+ You can control the output resolution for the PCL using the "target resolution" + setting on the FOUserAgent. The actual value will be rounded up to the next + supported PCL resolution. Currently, only 300 and 600 dpi are supported which + should be enough for most use cases. Note that this setting directly affects + the size of the output file and the print quality. +

+
+
+ Extensions +

The PCL Renderer supports some PCL specific extensions which can be embedded + into the input FO document. To use the extensions the appropriate namespace must + be declared in the fo:root element like this:

+ +]]> +
+ Page Source (Tray selection) +

+ The page-source extension attribute on fo:simple-page-master allows to + select the paper tray the sheet for a particular simple-page-master is + to be taken from. Example: +

+ + + ... + + +]]> +

+ Note: the tray number is a positive integer and the value depends on + the target printer. Not all PCL printers support the same paper trays. + 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. +

+
+
+
+
+ AFP + The AFP Renderer is a new addition (27-Apr-2006) to the sandbox and as such not yet fully tested or feature complete. +

+ The FOP AFP Renderer deals with creating documents conforming to the IBM AFP document architecture + also refered to as MO:DCA (Mixed Object Document Content Architecture). +

+
+ References + +
+
+ Limitations +

This list is most likely badly incomplete.

+
    +
  • + Clipping of text and graphics is not supported. +
  • +
  • + Only IBM outline and raster fonts and to a limited extend the original fonts built into FOP are supported. + Support for TrueType fonts may be added later. +
  • +
+
+
+ Configuration +
+ Fonts +

The AFP Renderer requires special configuration particularly related to fonts. + AFP Render configuration is done through the normal FOP configuration file. The MIME type + for the AFP Renderer is application/x-afp which means the AFP Renderer section in the FOP configuration file + looks like:

+ + + ... +]]> +

There are 3 font configuration variants supported:

+
    +
  1. IBM Raster fonts
  2. +
  3. IBM Outline fonts
  4. +
  5. FOP built-in Base14 fonts
  6. +
+

A typical raster font configuration looks like:

+ + + + + + + + + + + + + + + + + + + + + + + + ]]> +

An outline font configuration is simpler as the individual font size entries are not required. + However, the characterset definition is now required within the afp-font element.

+ + + + + + +]]> +

Experimentation has shown that the font metrics for the FOP built-in Base14 fonts are actually + very similar to some of the IBM outline and raster fonts. In cases were the IBM font files are not + available the path attribute in the afp-font element can be replaced by a base14-font attribute + giving the name of the matching Base14 font. In this case the AFP Renderer will take the + font metrics from the built-in font.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> +
+
+ Output Resolution +

By default the AFP Renderer creates output with a resolution of 240 dpi. + This can be overridden by the <renderer-resolution/> configuration element. Example:

+ 240]]> +
+
+ Images +

By default the AFP Renderer converts all images to 8 bit grey level. + This can be overridden by the <images> configuration element. Example:

+ +]]> +

This will put images as RGB images into the AFP output stream. The default setting is:

+ +]]> +

Only the values "color" and "b+w" are allowed for the mode attribute. The bits-per-pixel + attribute is ignored if mode is "color". For "b+w" mode is must be 1, 4, or 8.

+
+
+
+ Extensions +

The AFP Renderer supports some AFP specific extensions which can be embedded into the input + fo document. To use the extensions the appropriate namespace must be declared in the fo:root element like this:

+ +]]> +
+ Page Overlay Extension +

The include-page-overlay extension element allows to define on a per simple-page-master basis a page overlay resource. Example:

+ + + + ... + + +]]> +

The mandatory name attribute must refer to an 8 character (space padded) resource name that + must be known in the AFP processing environment.

+
+
+ Page Segment Extension +

The include-page-segment extension element allows to define resource substitution for fo:external-graphics elements. + Example:

+ + + + + + + +]]> +

The include-page-segment extension element can only occur within a simple-page-master. + Multiple include-page-segment extension elements within a simple-page-master are allowed. + The mandatory name attribute must refer to an 8 character + (space padded) resource name that must be known in the AFP processing environment. + The value of the mandatory src attribute is compared against the value of the src attribute in + fo:external-graphic elements and if it is identical (string matching is used) in the generated + AFP the external graphic is replaced by a reference to the given resource. +

+
+
+ Tag Logical Element Extension +

The tag-logical-element extension element allows to injects TLEs into the AFP output stream. Example:

+ + + + + + + +]]> +

The tag-logical-element extension element can only occur within a simple-page-master. + Multiple tag-logical-element extension elements within a simple-page-master are allowed. + The name and value attributes are mandatory. +

+
+
+ No Operation Extension +

The no-operation extension provides the ability to carry up to 32K of comments or any other type + of unarchitected data into the AFP output stream. Example:

+ + + + insert up to 32k of character data here! + + +]]> +

The no-operation extension element can only occur within a simple-page-master. + Multiple no-operation extension elements within a simple-page-master are allowed. + The name attribute is mandatory. +

+
+
+
+
+ RTF +

+ JFOR, an open source XSL-FO to RTF converter has been integrated into Apache FOP. + This will create an RTF (rich text format) document that will + attempt to contain as much information from the XSL-FO document as + possible. It should be noted that is not possible (due to RTF's limitations) to map all + XSL-FO features to RTF. For complex documents, the RTF output will never reach the feature + level from PDF, for example. Thus, using RTF output is only recommended for simple documents + such as letters. +

+

+ The RTF output follows Microsoft's RTF specifications + and produces best results on Microsoft Word. +

+ RTF output is currently unmaintained and lacks many features compared to other output + formats. Using other editable formats like Open Document Format, instead of producing XSL-FO + then RTF through FOP, might give better results. +
+
+ XML (Area Tree XML) +

+ This is primarily for testing and verification. The XML created is simply + a representation of the internal area tree put into XML. We use that to verify + the functionality of FOP's layout engine. +

+

+ The other use case of the Area Tree XML is as FOP's "intermediate format". More information + on that can be found on the page dedicated to the Intermediate Format. +

+
+
+ Java2D/AWT +

+ The Java2DRenderer provides the basic functionality for all + Java2D-based output formats (AWT viewer, direct print, PNG, TIFF). +

+

+ The AWT viewer shows a window with the pages displayed inside a + Java graphic. It displays one page at a time. + The fonts used for the formatting and viewing depend on the fonts + available to your JRE. +

+
+
+ Print +

+ It is possible to directly print the document from the command line. + This is done with the same code that renders to the Java2D/AWT renderer. +

+
+
+ Bitmap (TIFF/PNG) +

+ It is possible to directly create bitmap images from the individual + pages generated by the layout engine. + This is done with the same code that renders to the Java2D/AWT renderer. +

+

+ Currently, two output formats are supported: PNG and TIFF. TIFF produces + one file with multiple pages, while PNG output produces one file per + page. The quality of the bitmap depends on the target resolution setting + on the FOUserAgent. +

+
+ Configuration +

+ The TIFF and PNG renderer configuration currently allows the following settings: +

+ + true + +]]> +

+ The default value for the "transparent-page-background" setting is "false" which + paints an opaque, white background for the whole image. If you set this to true, + no such background will be painted and you will get a transparent image if + an alpha channel is available in the output format. +

+
+
+ TIFF-specific Configuration +

+ In addition to the above values the TIFF renderer configuration allows some additional + settings: +

+ + true + CCITT T.6 + +]]> +

+ The default value for the "compression" setting is "PackBits" which + which is a widely supported RLE compression scheme for TIFF. The set of compression + names to be used here matches the set that the Image I/O API uses. Note that + not all compression schemes may be available during runtime. This depends on the + actual codecs being available. Here is a list of possible values: +

+
    +
  • NONE (no compression)
  • +
  • PackBits (RLE, run-length encoding)
  • +
  • JPEG
  • +
  • Deflate
  • +
  • LZW
  • +
  • ZLib
  • +
  • CCITT T.4 (Fax Group 3)
  • +
  • CCITT T.6 (Fax Group 4)
  • +
+ + If you want to use CCITT compression, please make sure you've got a J2SE 1.4 or later and + + Java Advanced Imaging Image I/O Tools + + in your classpath. The Sun JRE doesn't come with a TIFF codec built in, so it has to be + added separately. The internal TIFF codec from XML Graphics Commons only supports PackBits, + Deflate and JPEG compression for writing. + +
+
+
+ TXT +

+ The text renderer produces plain ASCII text output + that attempts to match the output of the PDFRenderer as closely as + possible. This was originally developed to accommodate an archive system + that could only accept plain text files, and is primarily useful for getting + a quick-and-dirty view of the document text. The renderer is very limited, + so do not be surprised if it gives unsatisfactory results. +

+

+ The Text renderer works with a fixed size page buffer. The size of this + buffer is controlled with the textCPI and textLPI public variables. + The textCPI is the effective horizontal characters per inch to use. + The textLPI is the vertical lines per inch to use. From these values + and the page width and height the size of the buffer is calculated. + The formatting objects to be rendered are then mapped to this grid. + Graphic elements (lines, borders, etc) are assigned a lower priority + than text, so text will overwrite any graphic element representations. +

+

+ Because FOP lays the text onto a grid during layout, there are frequently + extra or missing spaces between characters and lines, which is generally + unsatisfactory. + Users have reported that the optimal settings to avoid such spacing problems are: +

+
    +
  • font-family="Courier"
  • +
  • font-size="7.3pt"
  • +
  • line-height="10.5pt"
  • +
+
+
+ Output Formats in the Sandbox +

+ Due to the state of certain renderers we moved some of them to a "sandbox" area until + they are ready for more serious use. The renderers and FOEventHandlers in the sandbox + can be found under src/sandbox and are compiled into build/fop-sandbox.jar during the + main build. The output formats in the sandbox are marked as such below. +

+
+ MIF + The MIF handler is in the sandbox and not yet functional in FOP Trunk!!! Please help us ressurrect this feature. +

+ This format is the Maker Interchange Format which is used by + Adobe Framemaker. +

+
+
+ SVG + The SVG renderer is in the sandbox and may not work as expected in FOP Trunk!!! Please help us improve this feature. +

+ This format creates an SVG document that has links between the pages. + This is primarily for slides and creating svg images of pages. + Large documents will create SVG files that are far too large for + an SVG viewer to handle. Since FO documents usually have text the + SVG document will have a large number of text elements. + The font information for the text is obtained from the JVM in the + same way as for the AWT viewer. If the SVG is viewed on a + system where the fonts are different, such as another platform, + then the page may look wrong. +

+
+
+
+ Wish list +

+ Apache FOP is easily extensible and allows you to add new output formats to enhance FOP's functionality. There's a number of output formats + which are on our wish list. We're looking for volunteers to help us implement them. +

+ +
+ + +
+ + diff --git a/src/documentation/content/xdocs/0.95/pdfa.xml b/src/documentation/content/xdocs/0.95/pdfa.xml new file mode 100644 index 000000000..1b3b75561 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/pdfa.xml @@ -0,0 +1,159 @@ + + + + + +
+ PDF/A (ISO 19005) + $Revision$ + + + +
+ +
+ Overview + + Support for PDF/A is available beginning with version 0.92. + +

+ PDF/A is a standard which turns PDF into an "electronic document file + format for long-term preservation". PDF/A-1 is the first part of the + standard and is documented in + ISO 19005-1:2005(E). + Work on PDF/A-2 is in progress at + AIIM. +

+

+ Design documentation on PDF/A can be found on FOP's Wiki on the + PDFA1ConformanceNotes page. +

+
+
+ Implementation Status +

+ PDF/A-1b is implemented to the degree that FOP supports + the creation of the elements described in ISO 19005-1. +

+

+ Tests have been performed against jHove and Adobe Acrobat 7.0.7 (Preflight function). + FOP does not validate completely against Apago's PDF Appraiser. Reasons unknown due to + lack of a full license to get a detailed error protocol. +

+

+ PDF/A-1a is not implemented, yet. This is mostly because of the requirement + for tagged PDF which is not available in FOP, yet. +

+
+
+ Usage (command line) +

+ To activate PDF/A-1b from the command-line, specify "-pdfprofile PDF/A-1b" + as a parameter. If there is a violation of one of the validation rules for + PDF/A, an error message is presented and the processing stops. +

+
+
+ Usage (embedded) +

+ When FOP is embedded in another Java application you can set a special option + on the renderer options in the user agent to activate the PDF/A-1b profile. + Here's an example: +

+ +

+ If one of the validation rules of PDF/A is violated, an PDFConformanceException + (descendant of RuntimeException) is thrown. +

+
+
+ PDF/A in Action +

+ There are a number of things that must be looked after if you activate a PDF/A + profile. If you receive a PDFConformanceException, have a look at the following + list (not necessarily comprehensive): +

+
    +
  • + Make sure all (!) fonts are embedded. If you use base 14 fonts (like Helvetica) + you need to obtain a license for them and embed them like any other font. +
  • +
  • + Don't use PDF encryption. PDF/A doesn't allow it. +
  • +
  • + Don't use CMYK images without an ICC color profile. PDF/A doesn't allow mixing + color spaces and FOP currently only properly supports the sRGB color space. Please + note that FOP embeds a standard sRGB ICC profile (sRGB IEC61966-2.1) as the + primary output intent for the PDF if no other output intent has been specified + in the configuration. +
  • +
  • + Don't use non-RGB colors in SVG images. Same issue as with CMYK images. +
  • +
  • + Don't use EPS graphics with fo:external-graphic. Embedding EPS graphics in PDF + is deprecated since PDF 1.4 and prohibited by PDF/A. +
  • +
  • + PDF is forced to version 1.4 if PDF/A-1 is activated. +
  • +
  • + No filter must be specified explicitely for metadata objects. Metadata must be + embedded in clear text so non-PDF-aware applications can extract the XMP metadata. +
  • +
+
+
+ PDF profile compatibility +

+ The PDF profiles "PDF/X-3:2003" and "PDF/A-1b" are compatible and can both be + activated at the same time. +

+
+
+ Interoperability +

+ There has been some confusion about the namespace for the PDF/A indicator in the XMP + metadata. At least three variants have been seen in the wild: +

+ + + + + + + + + + + + + +
http://www.aiim.org/pdfa/ns/id.htmlobsolete, from an early draft of ISO-19005-1, used by Adobe Acrobat 7.x
http://www.aiim.org/pdfa/ns/idobsolete, found in the original ISO 19005-1:2005 document
http://www.aiim.org/pdfa/ns/id/correct, found in the technical corrigendum 1 of ISO 19005-1:2005
+

+ If you get an error validating a PDF/A file in Adobe Acrobat 7.x it doesn't mean that + FOP did something wrong. It's Acrobat that is at fault. This is fixed in Adobe Acrobat 8.x + which uses the correct namespace as described in the technical corrigendum 1. +

+
+ +
diff --git a/src/documentation/content/xdocs/0.95/pdfencryption.xml b/src/documentation/content/xdocs/0.95/pdfencryption.xml new file mode 100644 index 000000000..cda301aab --- /dev/null +++ b/src/documentation/content/xdocs/0.95/pdfencryption.xml @@ -0,0 +1,225 @@ + + + + + +
+ PDF encryption. + $Revision$ + + + + +
+ +
+ Overview +

+ FOP supports encryption of PDF output, thanks to Patrick + C. Lankswert. This feature is commonly used to prevent + unauthorized viewing, printing, editing, copying text from the + document and doing annotations. It is also possible to ask the + user for a password in order to view the contents. Note that + there already exist third party applications which can decrypt + an encrypted PDF without effort and allow the aforementioned + operations, therefore the degree of protection is limited. +

+

+ For further information about features and restrictions regarding PDF + encryption, look at the documentation coming with Adobe Acrobat or the + technical documentation on the Adobe web site. +

+
+
+ Usage (command line) +

+ Encryption is enabled by supplying any of the encryption related + options. +

+

+ An owner password is set with the -o option. This + password is actually used as encryption key. Many tools for + PDF processing ask for this password to disregard any + restriction imposed on the PDF document. +

+

+ If no owner password has been supplied but FOP was asked to apply some + restrictions, a random password is used. In this case it is obviously + impossiible to disregard restrictions in PDF processing tools. +

+

+ A user password, supplied with the -u option, will + cause the PDF display software to ask the reader for this password in + order to view the contents of the document. If no user password was + supplied, viewing the content is not restricted. +

+

+ Further restrictions can be imposed by using the -noprint, + -nocopy, -noedit and + -noannotations options, which disable printing, copying + text, editing in Adobe Acrobat and making annotations, respectively. +

+
+
+ Usage (embedded) +

+ When FOP is embedded in another Java application you need to set an + options map on the renderer. These are the supported options: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionDescriptionValuesDefault
ownerPasswordThe owner passwordString +
userPasswordThe user passwordString +
allowPrintAllows/disallows printing of the PDF"TRUE" or "FALSE""TRUE"
allowCopyContentAllows/disallows copy/paste of content"TRUE" or "FALSE""TRUE"
allowEditContentAllows/disallows editing of content"TRUE" or "FALSE""TRUE"
allowEditAnnotationsAllows/disallows editing of annotations"TRUE" or "FALSE""TRUE"
+ + Encryption is enabled as soon as one of these options is set. + +

+ An example to enable PDF encryption in Java code: +

+ +

+ The parameters for the constructor of PDFEncryptionParams are: +

+
    +
  1. userPassword: String, may be null
  2. +
  3. ownerPassword: String, may be null
  4. +
  5. allowPrint: true if printing is allowed
  6. +
  7. allowCopyContent: true if copying content is allowed
  8. +
  9. allowEditContent: true if editing content is allowed
  10. +
  11. allowEditAnnotations: true if editing annotations is allowed
  12. +
+

+ Alternatively, you can set each value separately in the Map provided by + FOUserAgent.getRendererOptions() by using the following keys: +

+
    +
  1. user-password: String
  2. +
  3. owner-password: String
  4. +
  5. noprint: Boolean or "true"/"false"
  6. +
  7. nocopy: Boolean or "true"/"false"
  8. +
  9. noedit: Boolean or "true"/"false"
  10. +
  11. noannotations: Boolean or "true"/"false"
  12. +
+
+
+ Environment +

+ In order to use PDF encryption, FOP has to be compiled with + cryptography support. Currently, only JCE + is supported. JCE is part of JDK 1.4. For earlier JDKs, it can + be installed separately. The build process automatically + detects JCE presence and installs PDF encryption support if + possible, otherwise a stub is compiled in. +

+

+ Cryptography support must also be present at run time. In particular, a + provider for the RC4 cipher is needed. Unfortunately, the sample JCE + provider in Sun's JDK 1.4 does not provide RC4. If you + get a message saying +

+ "Cannot find any provider supporting RC4" +

+ then you don't have the needed infrastructure. +

+

+ There are several commercial and a few Open Source packages which + provide RC4. A pure Java implementation is produced by The Legion of the Bouncy + Castle. Mozilla + JSS is an interface to a native implementation. +

+
+
+ Installing a crypto provider +

+ The pure Java implementation from Bouncy Castle is easy to + install. +

+
    +
  1. + Unpack the distribution. Add the jar file to your classpath. A + convenient way to use the jar on Linux is to simply drop it into the + FOP lib directory, it will be automatically picked up by + fop.sh. +
  2. +
  3. + Open the java.security file and add
    + security.provider.6=org.bouncycastle.jce.provider.BouncyCastleProvider,
    + preferably at the end of the block defining the other crypto + providers. For JDK 1.4 this is detailed on Sun's web site. +
  4. +
+

+ If you have any experience with Mozilla JSS or any other + cryptography provider, please post it to the fop-user list. +

+
+ +
diff --git a/src/documentation/content/xdocs/0.95/pdfx.xml b/src/documentation/content/xdocs/0.95/pdfx.xml new file mode 100644 index 000000000..cf796c74d --- /dev/null +++ b/src/documentation/content/xdocs/0.95/pdfx.xml @@ -0,0 +1,136 @@ + + + + + +
+ PDF/X (ISO 15930) + $Revision$ + + + +
+ +
+ Overview + + Support for PDF/X is available beginning with version 0.93. This feature is new and + may not be 100% complete, yet. Feedback is welcome. + +

+ PDF/X is a standard which faciliates prepress digital data exchange using PDF. + Currently, only PDF/X-3:2003 is implemented out of the many different flavours of PDF/X + profiles. PDF/X-3:2003 is documented in + ISO 15930-6:2003(E). + More info on PDF/X can be found on the + PDF/X info site. +

+
+
+ Implementation Status +

+ PDF/X-3:2003 is implemented to the degree that FOP supports + the creation of the elements described in ISO 15930-6. +

+

+ An important restriction of the current implementation is that all normal + RGB colors specified in XSL-FO and SVG are left unchanged in the sRGB color + space (XSL-FO and SVG both use sRGB as their default color space). + There's no conversion to a CMYK color space. Although sRGB is a + calibrated color space, its color space has a different size than a CMYK + color space which makes the conversion a lossy conversion and can lead to + unwanted results. Although the use of the calibrated sRGB has been promoted + for years, print shops usually prefer to convert an sRGB PDF to CMYK prior + to production. Until there's full CMYK support in FOP you will have to + work closely with your print service provider to make sure you get the + intended result. +

+

+ Tests have been performed against Adobe Acrobat 7.0.7 (Preflight function). + Note that there are bugs in Adobe Acrobat which cause false alarms if both + PDF/A-1b and PDF/X-3:2003 are activated at the same time. +

+
+
+ Usage (command line) +

+ To activate PDF/X-3:2003 from the command-line, specify "-pdfprofile PDF/X-3:2003" + as a parameter. If there is a violation of one of the validation rules for + PDF/X, an error message is presented and the processing stops. +

+
+
+ Usage (embedded) +

+ When FOP is embedded in another Java application you can set a special option + on the renderer options in the user agent to activate the PDF/A-1b profile. + Here's an example: +

+ +

+ If one of the validation rules of PDF/X is violated, an PDFConformanceException + (descendant of RuntimeException) is thrown. +

+
+
+ PDF/X in Action +

+ There are a number of things that must be looked after if you activate a PDF/X + profile. If you receive a PDFConformanceException, have a look at the following + list (not necessarily comprehensive): +

+
    +
  • + Make sure all (!) fonts are embedded. If you use base 14 fonts (like Helvetica) + you need to obtain a license for them and embed them like any other font. +
  • +
  • + Don't use PDF encryption. PDF/X doesn't allow it. +
  • +
  • + Don't use CMYK images without an ICC color profile. PDF/X doesn't allow mixing + color spaces and FOP currently only properly supports the sRGB color space. However, + you will need to specify an + output device profile + (usually a CMYK profile) in the configuration. sRGB won't work here since it's a + display device profile, not an output device profile. +
  • +
  • + Don't use non-RGB colors in SVG images. Same issue as with CMYK images. +
  • +
  • + Don't use EPS graphics with fo:external-graphic. Embedding EPS graphics in PDF + is deprecated since PDF 1.4 and prohibited by PDF/X-3:2003. +
  • +
  • + PDF is forced to version 1.4 if PDF/X-3:2003 is activated. +
  • +
+
+
+ PDF profile compatibility +

+ The PDF profiles "PDF/X-3:2003" and "PDF/A-1b" are compatible and can both be + activated at the same time. +

+
+ +
diff --git a/src/documentation/content/xdocs/0.95/running.xml b/src/documentation/content/xdocs/0.95/running.xml new file mode 100644 index 000000000..38e31cc6c --- /dev/null +++ b/src/documentation/content/xdocs/0.95/running.xml @@ -0,0 +1,350 @@ + + + + + +
+ Running Apache FOP + $Revision$ +
+ + +
+ System Requirements +

The following software must be installed:

+
    +
  • + Java 1.4.x or later Runtime Environment. +
      +
    • + Many JREs >=1.4 contain older JAXP implementations (which often contain bugs). It's + usually a good idea to replace them with a current implementation. +
    • +
    +
  • +
  • + Apache FOP. The FOP distribution includes all libraries that you will + need to run a basic FOP installation. These can be found in the [fop-root]/lib directory. These + libraries include the following: + +
  • +
+

The following software is optional, depending on your needs:

+
    +
  • + Graphics libraries. Generally, FOP contains direct support for the most important + bitmap image formats (including PNG, JPEG and GIF). See + FOP: Graphics Formats for details. +
  • +
  • + PDF encryption. See FOP: PDF Encryption for details. +
  • +
+

In addition, the following system requirements apply:

+
    +
  • + If you will be using FOP to process SVG, you must do so in a graphical environment. + See FOP: Graphics (Batik) for details. +
  • +
+
+
+ Installation +
+ Instructions +

+ Basic FOP installation consists of first unzipping the .gz file that is the + distribution medium, then unarchiving the resulting .tar file in a + directory/folder that is convenient on your system. Please consult your operating system + documentation or Zip application software documentation for instructions specific to your + site. +

+
+
+ Problems +

+ Some Mac OSX users have experienced filename truncation problems using Stuffit to unzip + and unarchive their distribution media. This is a legacy of older Mac operating systems, + which had a 31-character pathname limit. Several Mac OSX users have recommended that + Mac OSX users use the shell command tar -xzf instead. +

+
+
+
+ Starting FOP as a Standalone Application +
+ Using the fop script or batch file +

+ The usual and recommended practice for starting FOP from the command line is to run the + batch file fop.bat (Windows) or the shell script fop (Unix/Linux). + These scripts require that the environment variable JAVA_HOME be + set to a path pointing to the appropriate Java installation on your system. Macintosh OSX + includes a Java environment as part of its distribution. We are told by Mac OSX users that + the path to use in this case is /Library/Java/Home. Caveat: + We suspect that, as Apple releases new Java environments and as FOP upgrades the minimum + Java requirements, the two will inevitably not match on some systems. Please see + Java on Mac OSX FAQ for information as + it becomes available. +

+ + [OPTIONS] + -d debug mode + -x dump configuration settings + -q quiet mode + -c cfg.xml use additional configuration file cfg.xml + -l lang the language to use for user information + -r relaxed/less strict validation (where available) + -dpi xxx target resolution in dots per inch (dpi) where xxx is a number + -s for area tree XML, down to block areas only + -v to show FOP version being used + + -o [password] PDF file will be encrypted with option owner password + -u [password] PDF file will be encrypted with option user password + -noprint PDF file will be encrypted without printing permission + -nocopy PDF file will be encrypted without copy content permission + -noedit PDF file will be encrypted without edit content permission + -noannotations PDF file will be encrypted without edit annotation permission + -pdfprofile prof PDF file will be generated with the specified profile + (Examples for prof: PDF/A-1b or PDF/X-3:2003) + + [INPUT] + infile xsl:fo input file (the same as the next) + -fo infile xsl:fo input file + -xml infile xml input file, must be used together with -xsl + -atin infile area tree input file + -xsl stylesheet xslt stylesheet + + -param name value to use for parameter in xslt stylesheet + (repeat '-param name value' for each parameter) + + [OUTPUT] + outfile input will be rendered as PDF into outfile + -pdf outfile input will be rendered as PDF (outfile req'd) + -pdfa1b outfile input will be rendered as PDF/A-1b compliant PDF + (outfile req'd, same as "-pdf outfile -pdfprofile PDF/A-1b") + -awt input will be displayed on screen + -rtf outfile input will be rendered as RTF (outfile req'd) + -pcl outfile input will be rendered as PCL (outfile req'd) + -ps outfile input will be rendered as PostScript (outfile req'd) + -afp outfile input will be rendered as AFP (outfile req'd) + -tiff outfile input will be rendered as TIFF (outfile req'd) + -png outfile input will be rendered as PNG (outfile req'd) + -txt outfile input will be rendered as plain text (outfile req'd) + -at [mime] out representation of area tree as XML (outfile req'd) + specify optional mime output to allow AT to be converted + to final format later + -print input file will be rendered and sent to the printer + see options with "-print help" + -out mime outfile input will be rendered using the given MIME type + (outfile req'd) Example: "-out application/pdf D:\out.pdf" + (Tip: "-out list" prints the list of supported MIME types) + -mif outfile input will be rendered as MIF (FrameMaker) (outfile req'd) + Experimental feature - requires additional fop-sandbox.jar. + -svg outfile input will be rendered as an SVG slides file (outfile req'd) + Experimental feature - requires additional fop-sandbox.jar. + + -foout outfile input will only be XSL transformed. The intermediate + XSL-FO file is saved and no rendering is performed. + (Only available if you use -xml and -xsl parameters) + + + [Examples] + Fop foo.fo foo.pdf + Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line) + Fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf + Fop -xml foo.xml -xsl foo.xsl -foout foo.fo + Fop foo.fo -mif foo.mif + Fop foo.fo -rtf foo.rtf + Fop foo.fo -print or Fop -print foo.fo + Fop foo.fo -awt]]> +

+ PDF encryption is only available if FOP was compiled with encryption support + and if compatible encryption support is available at run time. + Currently, only the JCE is supported. Check the Details. +

+
+
+ Writing your own script +

FOP's entry point for your own scripts is the class +org.apache.fop.cli.Main. The general pattern for the + command line is: java -classpath <CLASSPATH> + org.apache.fop.cli.Main <arguments>. The arguments + consist of the options and infile and outfile specifications + as shown above for the standard scripts. You may wish to review + the standard scripts to make sure that + you get your environment properly configured. +

+
+
+ Running with java's <code>-jar</code> option +

+ As an alternative to the start scripts you can run java + -jar path/to/build/fop.jar <arguments>, relying on + FOP to build the classpath for running FOP dynamically, see below. If you use hyphenation, + you must put fop-hyph.jar in the lib + directory. +

+ +

You can also run java -jar path/to/fop.jar + <arguments>, relying on the Class-Path + entry in the manifest file. This works if you put + fop.jar and all jar files from the lib + directory in a single directory. If you use hyphenation, you + must also put fop-hyph.jar in that directory.

+ +

In both cases the arguments consist of the options and + infile and outfile specifications as shown above for the + standard scripts.

+
+
+ FOP's dynamical classpath construction + +

If FOP is started without a proper classpath, it tries to + add its dependencies dynamically. If the system property + fop.home contains the name of a directory, then + FOP uses that directory as the base directory for its + search. Otherwise the current working directory is the base + directory. If the base directory is called build, + then its parent directory becomes the base directory.

+ +

FOP expects to find fop.jar in the + build subdirectory of the base directory, and + adds it to the classpath. Subsequently FOP adds all + jar files in the lib directory to the + classpath. The lib directory is either the lib + subdirectory of the base directory, or, if that does not + exist, the base directory itself.

+ +

If the system property fop.optional.lib + contains the name of a directory, then all jar + files in that directory are also added to the classpath. See + the methods getJARList and + checkDependencies in + org.apache.fop.cli.Main.

+ +
+
+
+ Using Xalan to Check XSL-FO Input +

+ FOP sessions that use -xml and -xsl input instead of -fo input are actually + controlling two distinct conversions: Tranforming XML to XSL-FO, then formatting + the XSL-FO to PDF (or another FOP output format). + Although FOP controls both of these processes, the first is included merely as + a convenience and for performance reasons. + Only the second is part of FOP's core processing. + If a user has a problem running FOP, it is important to determine which of these + two processes is causing the problem. + If the problem is in the first process, the user's stylesheet is likely the cause. + The FOP development team does not have resources to help with stylesheet issues, + although we have included links to some useful + Specifications and + Books/Articles. + If the problem is in the second process, FOP may have a bug or an unimplemented + feature that does require attention from the FOP development team. +

+ The user is always responsible to provide correct XSL-FO code to FOP. +

+ In the case of using -xml and -xsl input, although the user is responsible for + the XSL-FO code that is FOP's input, it is not visible to the user. To make the + intermediate FO file visible, the FOP distribution includes the "-foout" option + which causes FOP to run only the first (transformation) step, and write the + results to a file. (See also the Xalan command-line below) +

+ + When asking for help on the FOP mailing lists, never attach XML and + XSL to illustrate the issue. Always run the XSLT step (-foout) and send the + resulting XSL-FO file instead. Of course, be sure that the XSL-FO file is + correct before sending it. + +

+ The -foout option works the same way as if you would call the + Xalan command-line: +

+

+ java org.apache.xalan.xslt.Process -IN xmlfile -XSL file -OUT outfile +

+

+ Note that there are some subtle differences between the FOP and Xalan command-lines. +

+
+
+ Memory Usage +

+ FOP can consume quite a bit of memory, even though this has been continually improved. + This is partly inherent to the formatting process and partly caused by implementation choices. + All FO processors currently on the market have memory problems with certain layouts. +

+

+ If you are running out of memory when using FOP, here are some ideas that may help: +

+
    +
  • + Increase memory available to the JVM. See + the -Xmx option + for more information. + + It is usually unwise to increase the memory allocated to the JVM beyond the amount of + physical RAM, as this will generally cause significantly slower performance. + +
  • +
  • + Avoid forward references. + Forward references are references to some later part of a document. + Examples include page number citations which refer to pages which follow the citation, + tables of contents at the beginning of a document, and page numbering schemes that + include the total number of pages in the document + ("page N of TOTAL"). + Forward references cause all subsequent pages to be held in memory until the reference + can be resolved, i.e. until the page with the referenced element is encountered. + Forward references may be required by the task, but if you are getting a memory + overflow, at least consider the possibility of eliminating them. + A table of contents could be replaced by PDF bookmarks instead or moved to the end of + the document (reshuffle the paper could after printing). +
  • +
  • + Avoid large images, especially if they are scaled down. + If they need to be scaled, scale them in another application upstream from FOP. + For many image formats, memory consumption is driven mainly by the size of the image + file itself, not its dimensions (width*height), so increasing the compression rate + may help. +
  • +
  • + Use multiple page sequences. + FOP starts rendering after the end of a page sequence is encountered. + While the actual rendering is done page-by-page, some additional memory is + freed after the page sequence has been rendered. + This can be substantial if the page sequence contains lots of FO elements. +
  • +
+
+
+ Problems +

If you have problems running FOP, please see the "How to get Help" page.

+
+ +
diff --git a/src/documentation/content/xdocs/0.95/servlets.xml b/src/documentation/content/xdocs/0.95/servlets.xml new file mode 100644 index 000000000..07c22312d --- /dev/null +++ b/src/documentation/content/xdocs/0.95/servlets.xml @@ -0,0 +1,325 @@ + + + + + +
+ Servlets + How to use Apache FOP in a Servlet + $Revision$ +
+ +
+ Overview +

+ This page discusses topic all around using Apache FOP in a servlet environment. +

+
+
+ Example Servlets in the FOP distribution +

+ In the directory {fop-dir}/src/java/org/apache/fop/servlet, you'll find a working example + of a FOP-enabled servlet. +

+

+ The servlet is automatically built when you build Apache FOP using the supplied Ant script. After building + the servlet, drop fop.war into the webapps directory of Apache Tomcat (or any other web container). Then, you can use + URLs like the following to generate PDF files: +

+
    +
  • http://localhost:8080/fop/fop?fo=/home/path/to/fofile.fo
  • +
  • http://localhost:8080/fop/fop?xml=/home/path/to/xmlfile.xml&xsl=/home/path/to/xslfile.xsl
  • +
+

+

The source code for the servlet can be found under {fop-dir}/src/java/org/apache/fop/servlet/FopServlet.java.

+ + This example servlet should not be used on a public web server connected to the Internet as it does not contain + any measures to prevent Denial-of-Service-Attacks. It is provided as an example and as a starting point for + your own servlet. + +
+
+ Create your own Servlet + + This section assumes you are familiar with embedding FOP. + +
+ A minimal Servlet +

+ Here is a minimal code snippet to demonstrate the basics: +

+ private FopFactory fopFactory = FopFactory.newInstance(); +private TransformerFactory tFactory = TransformerFactory.newInstance(); + +public void doGet(HttpServletRequest request, + HttpServletResponse response) throws ServletException { + try { + response.setContentType("application/pdf"); + Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, response.getOutputStream()); + Transformer transformer = tFactory.newTransformer(); + Source src = new StreamSource("foo.fo"); + Result res = new SAXResult(fop.getDefaultHandler()); + transformer.transform(src, res); + } catch (Exception ex) { + throw new ServletException(ex); + } +} + + There are numerous problems with the code snippet above. + Its purpose is only to demonstrate the basic concepts. + See below for details. + +
+
+ Adding XSL tranformation (XSLT) +

+ A common requirement is to transform an XML source to + XSL-FO using an XSL transformation. It is recommended to use + JAXP for this task. The following snippet shows the basic + code: +

+ private FopFactory fopFactory = FopFactory.newInstance(); +private TransformerFactory tFactory = TransformerFactory.newInstance(); + +public void init() throws ServletException { + //Optionally customize the FopFactory and TransformerFactory here +} + +[..] + + //Setup a buffer to obtain the content length + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + //Setup FOP + Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out); + + //Setup Transformer + Source xsltSrc = new StreamSource(new File("foo-xml2fo.xsl")); + Transformer transformer = tFactory.newTransformer(xsltSrc); + + //Make sure the XSL transformation's result is piped through to FOP + Result res = new SAXResult(fop.getDefaultHandler()); + + //Setup input + Source src = new StreamSource(new File("foo.xml")); + + //Start the transformation and rendering process + transformer.transform(src, res); + + //Prepare response + response.setContentType("application/pdf"); + response.setContentLength(out.size()); + + //Send content to Browser + response.getOutputStream().write(out.toByteArray()); + response.getOutputStream().flush(); + + Buffering the generated PDF in a ByteArrayOutputStream is done to avoid potential + problems with the Acrobat Reader Plug-in in Microsoft Internet Explorer. + +

+ The Source instance used above is simply an + example. If you have to read the XML from a string, supply + a new StreamSource(new + StringReader(xmlstring)). Constructing and reparsing + an XML string is generally less desirable than using a + SAXSource if you generate your XML. You can alternatively + supply a DOMSource as well. You may also use dynamically + generated XSL if you like. +

+

+ Because you have an explicit Transformer object, you can also use it to + explicitely set parameters for the transformation run. +

+
+
+ Custom configuration +

+ You can easily set up your own FOUserAgent as demonstrated on the Embedding page. +

+
+
+ Improving performance +

+ There are several options to consider: +

+
    +
  • + Instead of java.io.ByteArrayOutputStream consider using the ByteArrayOutputStream + implementation from the Jakarta Commons IO project which allocates less memory. + The full class name is: org.apache.commons.io.output.ByteArrayOutputStream +
  • +
  • + In certain cases it can help to write the generated PDF to a temporary file so + you can quickly reuse the file. This is especially useful, if Internet Explorer + calls the servlet multiple times with the same request or if you often generate + equal PDFs. +
  • +
+

+ Of course, the + performance hints from the Embedding page + apply here, too. +

+
+
+ Accessing resources in your web application +

+ Often, you will want to use resources (stylesheets, images etc.) which are bundled with + your web application. FOP provides a URIResolver implementation that lets you access + files via the Servlet's ServletContext. The class is called + org.apache.fop.servlet.ServletContextURIResolver. +

+

+ Here's how to set it up in your servlet. Instantiate a new instance in the servlet's + init() method: +

+ +

+ The ServletContextURIResolver reacts on URIs beginning with "servlet-context:". If you + want to access an image in a subdirectory of your web application, you could, for + example, use: "servlet-context:/images/myimage.png". Don't forget the leading slash + after the colon! +

+

+ Further down, you can use the URIResolver for various things: +

+
    +
  • + With the Transformer (JAXP/XSLT) so things like document() functions can resolver + "servlet-context:" URIs. +
  • +
  • + With the FopFactory so every resource FOP loads can be loaded using a "servlet-context:" + URI. +
  • +
  • + You can the ServletContextURIResolver yourself in your servlet code to access + stylesheets or XML files bundled with your web application. +
  • +
+

+ Here are some example snippets: +

+ +
+
+
+ Notes on Microsoft Internet Explorer +

+ Some versions of Internet Explorer will not automatically show the PDF or call the servlet multiple times. + These are well-known limitations of Internet Explorer and are not a problem of the servlet. + However, Internet Explorer can still be used to download the PDF so that it can be viewed later. + Here are some suggestions in this context: +

+
    +
  • + Use an URL ending in .pdf, like + http://myserver/servlet/stuff.pdf. Yes, the servlet can + be configured to handle this. If the URL has to contain parameters, + try to have both the base URL as well as the last parameter end in + .pdf, if necessary append a dummy parameter, like + http://myserver/servlet/stuff.pdf?par1=a&par2=b&d=.pdf. The + effect may depend on IEx version. +
  • +
  • + Give IEx the opportunity to cache. In particular, ensure the + server does not set any headers causing IEx not to cache the + content. This may be a real problem if the document is sent + over HTTPS, because most IEx installations will by default + not cache any content retrieved over HTTPS. + Setting the Expires header entry may help in + this case:
    response.setDateHeader("Expires", + System.currentTimeMillis() + cacheExpiringDuration * + 1000);
    Consult your server manual and the + relevant RFCs for further details on HTTP headers and + caching. +
  • +
  • + Cache in the server. It may help to include a parameter in + the URL which has a timestamp as the value min order to + decide whether a request is repeated. IEx is reported to + retrieve a document up to three times, but never more often. +
  • +
+
+
+ Servlet Engines +

+ When using a servlet engine, there are potential CLASSPATH issues, and potential conflicts + with existing XML/XSLT libraries. Servlet containers also often use their own classloaders + for loading webapps, which can cause bugs and security problems. +

+
+ Tomcat +

+ Check Tomcat's documentation for detailed instructions about installing FOP and Cocoon. + There are known bugs that must be addressed, particularly for Tomcat 4.0.3. +

+
+
+ WebSphere 3.5 +

+ Put a copy of a working parser in some directory where WebSphere can access it. + For example, if /usr/webapps/yourapp/servlets is the CLASSPATH for your servlets, + copy the Xerces jar into it (any other directory would also be fine). + Do not add the jar to the servlet CLASSPATH, but add it to the CLASSPATH of the + application server which contains your web application. + In the WebSphere administration console, click on the "environment" button in the + "general" tab. In the "variable name" box, enter "CLASSPATH". + In the "value" box, enter the correct path to the parser jar file + (/usr/webapps/yourapp/servlets/Xerces.jar in our example here). + Press "OK", then apply the change and restart the application server. +

+
+
+
+ Handling complex use cases +

+ Sometimes the requirements for a servlet get quite sophisticated: SQL data sources, + multiple XSL transformations, merging of several datasources etc. In such a case + consider using Apache Cocoon instead + of a custom servlet to accomplish your goal. +

+
+ +
\ No newline at end of file diff --git a/src/documentation/content/xdocs/0.95/upgrading.xml b/src/documentation/content/xdocs/0.95/upgrading.xml new file mode 100644 index 000000000..77925fbf8 --- /dev/null +++ b/src/documentation/content/xdocs/0.95/upgrading.xml @@ -0,0 +1,126 @@ + + + + + +
+ Upgrading from an Earlier Version of Apache FOP + $Revision$ +
+ +
+ Important! +

+ If you're planning to upgrade to the latest FOP version there are a few very important things + to consider: +

+
    +
  • + More than half of the codebase has been rewritten over the + last four years. With version 0.93 the code has reached + production level, and continues to improve with + version 0.94 and 0.95. +
  • +
  • + The API of FOP has changed considerably and is not + backwards-compatible with versions 0.20.5 and + 0.91beta. Version 0.92 introduced the new stable + API. +
  • +
  • + Since version 0.92 some deprecated methods which were part + of the old API have been removed. If you upgrade from 0.91 + beta, you will need to adjust your Java code. Similarly if + you upgrade from 0.92 and use deprecated methods. +
  • +
  • + If you are using a configuration file for version 0.20.5, you have to rebuild it in the new format. The format + of the configuration files has changed since version 0.20.5. See conf/fop.xconf for + an example configuration file. A XML Schema file can be found under + src/foschema/fop-configuration.xsd. +
  • +
  • + Beginning with version 0.94 you can skip the generation of + font metric files and remove the "font-metrics" attribute + in the font configuration. The font metrics files are, for + the moment, still required if you use a TrueType Collection (*.ttc) + and in that case you need to regenerate the font metrics file + if yours are from a FOP version before 0.93. +
  • +
  • +

    + The new code is much more strict about the interpretation of the XSL-FO 1.0 specification. + Things that worked fine in version 0.20.5 might start to produce warnings or even errors + now. FOP 0.20.5 contains many bugs which have been corrected in the new code. +

    + + While FOP 0.20.5 allowed you to have empty fo:table-cell elements, the new code + will complain about that (unless relaxed validation is enabled) because the specification + demands at least one block-level element ((%block;)+, see + XSL-FO 1.0, 6.7.10) + inside an fo:table-cell element. + +
  • +
  • + Extensions and Renderers written for version 0.20.5 will not work with the new code! The new FOP + extension for Barcode4J is available since + January 2007. +
  • +
  • + The SVG Renderer and the MIF Handler have not been resurrected, yet! They are currently non-functional + and hope for someone to step up and reimplement them. +
  • +
+
+
+ What you need to know when you upgrade! +

+ When you use your existing FO files or XML/XSL files which work fine with FOP version + 0.20.5 against this FOP version some things may not work as expected. The following + list will hopefully help you to identify and correct those problems. This does not mean + that the new FOP is at fault. Quite the opposite actually! See below: +

+
    +
  • + Check the Compliance page for the feature causing + trouble. It may contain the necessary information to understand and resolve the problem. +
  • +
  • + As stated above empty table cells <fo:table-cell></fo:table-cell> + are not allowed by the specification. The same applies to empty static-content + and block-container elements, for example. +
  • +
  • + 0.20.5 is not XSL-FO compliant with respect to sizing images (external-graphic) + or instream-foreign-object + objects. If images or SVGs are sized differently in your outputs with the new FOP version + check Bug 37136 + as it contains some hints on what to do. The file + + "examples/fo/basic/images.fo" has + a number of good examples that show the new, more correct behaviour. +
  • +
  • + The fox:outline extension is not implemented in this version anymore. + It has been superseded by the new bookmark elements from XSL-FO 1.1. So please + update your stylesheets accordingly. +
  • +
+
+ +
diff --git a/src/documentation/content/xdocs/compliance.ihtml b/src/documentation/content/xdocs/compliance.ihtml index 27ca74a63..2b25b89d7 100644 --- a/src/documentation/content/xdocs/compliance.ihtml +++ b/src/documentation/content/xdocs/compliance.ihtml @@ -1,5 +1,5 @@ +"http://www.w3.org/TR/html4/loose.dtd"> + Apache FOP Compliance Page - +

W3C XSL-FO 1.0 Standard

-

- One of FOP's design goals is conformance to the - W3C XSL-FO 1.0 standard, which specifies three levels - of "conformance": basic, extended, and complete. Although FOP does not currently conform to - any of these levels, it is nevertheless a useful work-in-progress for many applications. - The information presented here demonstrates FOP's progress toward the goal of conformance, - which progress consists of implementation of specific objects and properties in the standard. - The information presented is useful not only to the developers as a sort of "to do" list, - but also for setting proper expectations for users and potential users. -

-

- In the tables below, "yes" (green background) indicates conformance, "no" (red background) - indicates a lack of conformance, "partial" (greyish background) indicates partial conformance, - and "na" indicates that the item is "not applicable" to FOP usually because FOP supports only - visual media. -

+ +

One of FOP's design goals is conformance to the W3C XSL-FO 1.0 standard, which specifies three + levels of "conformance": basic, extended, and complete. Although FOP does not currently conform + to any of these levels, it is nevertheless a useful work-in-progress for many applications. The + information presented here demonstrates FOP's progress toward the goal of conformance, which + progress consists of implementation of specific objects and properties in the standard. The + information presented is useful not only to the developers as a sort of "to do" list, but also + for setting proper expectations for users and potential users.

+ +

In the tables below, "yes" (green background) indicates conformance, "no" (red background) + indicates a lack of conformance, "partial" (greyish background) indicates partial conformance, + and "na" indicates that the item is "not applicable" to FOP usually because FOP supports only + visual media.

+

XSL-FO Object Support

+ -

XSL-FO Property Support

- + +

XSL-FO Property Support

+ + +

XSL-FO Core Function Library Support

+ -

XSL-FO Object Support Table (§6)

-

- The following is a summary of FOP's current support for the standard XSL-FO objects. -

+ +

XSL-FO Object Support Table (§6)

+ +

The following is a summary of FOP's current support for the standard XSL-FO objects.

+ - - - - - + + + + + + + + + + - - - - + + + + + + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + - - - - - +
  • [0.94 and later] The page width may not change among pages of the same page-sequence + unless a forced break is inserted.
  • + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - +
  • [0.20.5] Only works as direct child of fo:flow.
  • + +
  • [0.20.5] For absolute positioning, use 'position="absolute"' (as + 'absolute-position="absolute"' is not implemented), and specify all four of "left", + "top", "width" and "height"
  • + +
  • [0.94 and later] No known restrictions.
  • + + + - - - - - - - - + + - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - -
    - Object Name - XSL-FO Conformance Level - Citation - Support in FOP - Comments Object NameXSL-FO Conformance LevelCitationSupport in FOPComments
    - 0.20.5 (previous) 0.93 (stable) - 0.94 (stable) - develop- ment 0.20.5 (ancient)0.94 (stable)0.95 (beta)develop- ment
    - Declarations and Pagination and Layout Formatting Objects (§6.4) Declarations and Pagination and Layout Formatting Objects + (§6.4)
    - root - Basic - §6.4.2 - yes yes - yes - yes  
    - declarations - Basic - §6.4.3 - no no - no - no  
    - color-profile - Extended - §6.4.4 - no no - no - no  
    - page-sequence - Basic - §6.4.5 - yes yes - yes - yes  
    - layout-master-set - Basic - §6.4.6 - yes yes - yes - yes  
    - page-sequence-master - Basic - §6.4.7 - yes yes - yes - yes  
    - single-page-master-reference - Basic - §6.4.8 - yes yes - yes - yes  
    - repeatable-page-master-reference - Basic - §6.4.9 - yes yes - yes - yes  
    - repeatable-page-master-alternatives - Extended - §6.4.10 - yes yes - yes - yes  
    - conditional-page-master-reference - Extended - §6.4.11 - yes yes - yes - yes  
    - simple-page-master - Basic - §6.4.12 - yes partial - partial - partial -
      -
    • - [0.93 and later] The page width may not change among pages of the same page-sequence - unless a forced break is inserted.
    • -
    rootBasic§6.4.2yesyesyesyes 
    - region-body - Basic - §6.4.13 - yes yes - yes - yes
    - region-before - Extended - §6.4.14 - yes yes - yes - yes  
    - region-after - Extended - §6.4.15 - yes yes - yes - yes  
    - region-start - Extended - §6.4.16 - yes yes - yes - yes  
    - region-end - Extended - §6.4.17 - yes yes - yes - yes  
    - flow - Basic - §6.4.18 - yes yes - yes - yes  
    - static-content - Extended - §6.4.19 - yes yes - yes - yes  
    - title - Extended - §6.4.20 - no no - no - no   declarationsBasic§6.4.3nononono 
    - Block Formatting Objects (§6.5) color-profileExtended§6.4.4nononono 
    - block - Basic - §6.5.2 - yes yes - yes - yes  
    - block-container - Extended - §6.5.3 - partial partial - partial - partial -
      -
    • - [0.20.5] Currently only works as direct child of fo:flow.
    • -
    • - [0.20.5] For absolute positioning, use 'position="absolute"' (as 'absolute-position="absolute"' is not implemented), and specify all four of "left", "top", "width" and "height"
    • -
    • - [0.93 and later] No known restrictions.
    • -
    page-sequenceBasic§6.4.5yesyesyesyes 
    - Inline Formatting Objects (§6.6) layout-master-setBasic§6.4.6yesyesyesyes 
    - bidi-override - Extended - §6.6.2 - no no - no - no  
    - character - Basic - §6.6.3 - yes yes - yes - yes  
    - initial-property-set - Extended - §6.6.4 - no no - no - no  
    - external-graphic - Basic - §6.6.5 - yes yes - yes - yes  
    - instream-foreign-object - Extended - §6.6.6 - yes yes - yes - yes -
      -
    • Built-in support for SVG only, additional namespaces through optional extensions.
    • -
    page-sequence-masterBasic§6.4.7yesyesyesyes 
    - inline - Basic - §6.6.7 - yes yes - yes - yes  
    - inline-container - Extended - §6.6.8 - no no - no - no  
    - leader - Basic - §6.6.9 - partial yes - yes - yes  
    - page-number - Basic - §6.6.10 - yes yes - yes - yes  
    - page-number-citation - Extended - §6.6.11 - partial partial - partial - partial -
      -
    • - [0.20.5] Only works for table of contents without any problems. The case where the page number doesn't fit on a line isn't handled, and any text on the same line and after the page-number might not appear exactly where you want it to.
    • -
    • - [0.93 and later] After the page number is known, no relayout is performed. The appearance may be suboptimal depending on the use case.
    • -
    single-page-master-referenceBasic§6.4.8yesyesyesyes 
    repeatable-page-master-referenceBasic§6.4.9yesyesyesyes 
    - Table Formatting Objects (§6.7) repeatable-page-master-alternativesExtended + §6.4.10yesyesyesyes 
    - table-and-caption - Basic - §6.7.2 - no no - no - no  
    - table - Basic - §6.7.3 - partial partial - partial - partial -
      -
    • [0.20.5–0.93] Only border-collapse="separate"
    • -
    • [All] No support for auto layout yet
    • -
    -
    conditional-page-master-referenceExtended + §6.4.11yesyesyesyes 
    - table-column - Basic simple-page-masterBasic§6.4.12yespartialpartialpartial - §6.7.4 - partial yes - yes - yes
      -
    • - [0.20.5] You must explicitly specify column widths.
    • -
    - table-caption - Extended - §6.7.5 - no no - no - no  
    - table-header - Basic - §6.7.6 - yes yes - yes - yes  
    - table-footer - Extended - §6.7.7 - yes yes - yes - yes  
    - table-body - Basic - §6.7.8 - yes yes - yes - yes  
    - table-row - Basic - §6.7.9 - yes yes - yes - yes  
    - table-cell - Basic - §6.7.10 - partial yes - yes - yes  
    - List Formatting Objects (§6.8) region-bodyBasic§6.4.13yesyesyesyes
    - list-block - Basic - §6.8.2 - yes yes - yes - yes  
    - list-item - Basic - §6.8.3 - yes yes - yes - yes  
    - list-item-body - Basic - §6.8.4 - yes yes - yes - yes  
    - list-item-label - Extended - §6.8.5 - yes yes - yes - yes   region-beforeExtended§6.4.14yesyesyesyes 
    - Link and Multi Formatting Objects (§6.9) region-afterExtended§6.4.15yesyesyesyes 
    - basic-link - Extended - §6.9.2 - yes yes - yes - yes -
      -
    • - both internal and external supported
    • -
    region-startExtended§6.4.16yesyesyesyes 
    - multi-switch - Extended - §6.9.3 - no no - no - no  
    - multi-case - Basic - §6.9.4 - no no - no - no  
    - multi-toggle - Extended - §6.9.5 - no no - no - no  
    - multi-properties - Extended - §6.9.6 - no no - no - no  
    - multi-property-set - Extended - §6.9.7 - no no - no - no   region-endExtended§6.4.17yesyesyesyes 
    - Formatting Objects for Bookmarks (§6.11 in XSL 1.1 WD) flowBasic§6.4.18yesyesyesyes 
    - bookmark-tree (since XSL 1.1) - Extended - §6.11.1 in XSL 1.1 WD - no yes - yes - yes -
      -
    • [0.20.5] Uses the proprietary fox:outline extension.
    • -
    static-contentExtended§6.4.19yesyesyesyes 
    - bookmark (since XSL 1.1) - Extended - §6.11.2 in XSL 1.1 WD - no yes - yes - yes -
      -
    • [0.20.5] Uses the proprietary fox:outline extension.
    • -
    titleExtended§6.4.20nononono 
    - bookmark-title (since XSL 1.1) - Extended - §6.11.3 in XSL 1.1 WD - no partial - partial - partial -
      -
    • [0.20.5] Uses the proprietary fox:outline extension.
    • -
    • [0.93 and later] color, font-style and font-weight are not supported, yet.
    • -
    Block Formatting Objects (§6.5)
    - Out-of-line Formatting Objects (§6.10) blockBasic§6.5.2yesyesyesyes 
    - float - Extended - §6.10.2 - no no - no - no  
    - footnote - Extended - §6.10.3 - yes partial - partial - partial block-containerExtended§6.5.3partialpartialpartialpartial
      -
    • [0.20.5] Footnotes sometimes overlap with the main content
    • -
    • [0.93 and later] Restrictions with multi-column documents.
    • -
    - footnote-body - Extended - §6.10.4 - yes yes - yes - yes  
    - Other Formatting Objects (§6.11)
    - wrapper - Basic - §6.11.2 - yes partial - partial - partial -
      -
    • [0.93 and later] Only works as expected with inline-level content.
    • -
    Inline Formatting Objects (§6.6)
    - marker - Extended - §6.11.3 - yes yes - yes - yes bidi-overrideExtended§6.6.2nononono 
    - retrieve-marker - Extended - §6.11.4 - yes yes - yes - yes  
    -

    XSL-FO Property Support Table (§7)

    -

    - The following is a summary of FOP's current support for the standard XSL-FO properties. -

    - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + - - - - - +
  • Built-in support for SVG only, additional namespaces through optional + extensions.
  • + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
  • [0.20.5] Only works for table of contents without any problems. The case where the + page number doesn't fit on a line isn't handled, and any text on the same line and after + the page-number might not appear exactly where you want it to.
  • + +
  • [0.94 and later] After the page number is known, no relayout is performed. The + appearance may be suboptimal depending on the use case.
  • + + + - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
  • [0.20.5] Only border-collapse="separate"
  • + +
  • [All] No support for auto layout yet
  • + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
  • [0.20.5] You must explicitly specify column widths.
  • + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • both internal and external supported
  • + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • [0.20.5] Uses the proprietary fox:outline extension.
  • + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • [0.20.5] Uses the proprietary fox:outline extension.
  • + +
  • [0.94 and later] color, font-style and font-weight are not supported, yet.
  • + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  • [0.20.5] Footnotes sometimes overlap with the main content
  • + +
  • [0.94 and later] Restrictions with multi-column documents.
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    - Property Name - XSL-FO Conformance Level - Citation - Support in FOP - Comments
    - 0.20.5 (previous) 0.93 (stable) - 0.94 (stable) - develop- ment
    - Common Accessibility Properties (§7.4) characterBasic§6.6.3yesyesyesyes 
    - source-document - Basic - §7.4.1 - na na - na - na  
    - role - Basic - §7.4.2 - na na - na - na   initial-property-setExtended§6.6.4nononono 
    - Common Absolute Position Properties (§7.5) external-graphicBasic§6.6.5yesyesyesyes 
    - absolute-position - Complete instream-foreign-objectExtended§6.6.6yesyesyesyes - §7.5.1 - no yes - yes - yes
      -
    • - [0.20.5] Use shorthand position="absolute" as a workaround.
    • -
    • - [0.93 and later] No restrictions. The 0.20.5 work-around is not supported.
    • -
    - top - Extended - §7.5.2 - yes yes - yes - yes  
    - right - Extended - §7.5.3 - yes yes - yes - yes  
    - bottom - Extended - §7.5.4 - yes yes - yes - yes  
    - left - Extended - §7.5.5 - yes yes - yes - yes   inlineBasic§6.6.7yesyesyesyes 
    - Common Aural Properties (§7.6) inline-containerExtended§6.6.8nononono 
    - azimuth - Basic - §7.6.1 - na na - na - na  
    - cue-after - Basic - §7.6.2 - na na - na - na  
    - cue-before - Basic - §7.6.3 - na na - na - na  
    - elevation - Basic - §7.6.4 - na na - na - na  
    - pause-after - Basic - §7.6.5 - na na - na - na  
    - pause-before - Basic - §7.6.6 - na na - na - na  
    - pitch - Basic - §7.6.7 - na na - na - na  
    - pitch-range - Basic - §7.6.8 - na na - na - na  
    - play-during - Basic - §7.6.9 - na na - na - na  
    - richness - Basic - §7.6.10 - na na - na - na  
    - speak - Basic - §7.6.11 - na na - na - na  
    - speak-header - Basic - §7.6.12 - na na - na - na  
    - speak-numeral - Basic - §7.6.13 - na na - na - na  
    - speak-punctuation - Basic - §7.6.14 - na na - na - na  
    - speech-rate - Basic - §7.6.15 - na na - na - na  
    - stress - Basic - §7.6.16 - na na - na - na  
    - voice-family - Basic - §7.6.17 - na na - na - na  
    - volume - Basic - §7.6.18 - na na - na - na   leaderBasic§6.6.9partialyesyesyes 
    - Common Border, Padding, and Background Properties (§7.7) page-numberBasic§6.6.10yesyesyesyes 
    - background-attachment - Extended - §7.7.1 - no no - no - no  
    - background-color - Basic - §7.7.2 - yes partial - partial - partial page-number-citationExtended§6.6.11partialpartialpartialpartial
      -
    • - [0.93 and later] not yet implemented for table-column, table-body, table-header and table-footer.
    • -
    - background-image - Extended - §7.7.3 - yes partial - partial - partial -
      -
    • - [0.93 and later] not yet implemented for table-column, table-body, table-header and table-footer.
    • -
    Table Formatting Objects (§6.7)
    - background-repeat - Extended - §7.7.4 - no yes - yes - yes  
    - background-position-horizontal - Extended - §7.7.5 - no yes - yes - yes  
    - background-position-vertical - Extended - §7.7.6 - no yes - yes - yes  
    - border-before-color - Basic - §7.7.7 - yes yes - yes - yes  
    - border-before-style - Basic - §7.7.8 - partial yes - yes - yes -
      -
    • - [0.20.5] only "solid" works
    • -
    table-and-captionBasic§6.7.2nononono 
    - border-before-width - Basic - §7.7.9 - yes yes - yes - yes  
    - border-after-color - Basic - §7.7.10 - yes yes - yes - yes  
    - border-after-style - Basic - §7.7.11 - partial yes - yes - yes tableBasic§6.7.3partialpartialpartialpartial
      -
    • - [0.20.5] only "solid" works
    • -
    - border-after-width - Basic - §7.7.12 - yes yes - yes - yes  
    - border-start-color - Basic - §7.7.13 - yes yes - yes - yes  
    - border-start-style - Basic - §7.7.14 - partial yes - yes - yes table-columnBasic§6.7.4partialyesyesyes
      -
    • - [0.20.5] only "solid" works
    • -
    - border-start-width - Basic - §7.7.15 - yes yes - yes - yes  
    - border-end-color - Basic - §7.7.16 - yes yes - yes - yes  
    - border-end-style - Basic - §7.7.17 - partial yes - yes - yes -
      -
    • - [0.20.5] only "solid" works
    • -
    table-captionExtended§6.7.5nononono 
    - border-end-width - Basic - §7.7.18 - yes yes - yes - yes  
    - border-top-color - Basic - §7.7.19 - yes yes - yes - yes  
    - border-top-style - Basic - §7.7.20 - partial yes - yes - yes -
      -
    • - [0.20.5] only "solid" works
    • -
    table-headerBasic§6.7.6yesyesyesyes 
    - border-top-width - Basic - §7.7.21 - yes yes - yes - yes  
    - border-bottom-color - Basic - §7.7.22 - yes yes - yes - yes  
    - border-bottom-style - Basic - §7.7.23 - partial yes - yes - yes -
      -
    • - [0.20.5] only "solid" works
    • -
    table-footerExtended§6.7.7yesyesyesyes 
    - border-bottom-width - Basic - §7.7.24 - yes yes - yes - yes  
    - border-left-color - Basic - §7.7.25 - yes yes - yes - yes  
    - border-left-style - Basic - §7.7.26 - partial yes - yes - yes -
      -
    • - [0.20.5] only "solid" works
    • -
    table-bodyBasic§6.7.8yesyesyesyes 
    - border-left-width - Basic - §7.7.27 - yes yes - yes - yes  
    - border-right-color - Basic - §7.7.28 - yes yes - yes - yes  
    - border-right-style - Basic - §7.7.29 - partial yes - yes - yes -
      -
    • - [0.20.5] only "solid" works
    • -
    table-rowBasic§6.7.9yesyesyesyes 
    - border-right-width - Basic - §7.7.30 - yes yes - yes - yes  
    - padding-before - Basic - §7.7.31 - partial yes - yes - yes -
      -
    • - [0.20.5] only one value allowed
    • -
    • - [0.20.5] only implemented for blocks
    • -
    • - [0.20.5] can't be used to make extra space (use indents + spaces instead)
    • -
    • - [0.20.5] can be used to control how much the background-color extends beyond the content rectangle
    • -
    - padding-after - Basic - §7.7.32 - partial yes - yes - yes -
      -
    • - [0.20.5] same limitations as padding-before
    • -
    table-cellBasic§6.7.10partialyesyesyes 
    - padding-start - Basic - §7.7.33 - partial yes - yes - yes List Formatting Objects (§6.8)
    list-blockBasic§6.8.2yesyesyesyes 
    list-itemBasic§6.8.3yesyesyesyes 
    list-item-bodyBasic§6.8.4yesyesyesyes 
    list-item-labelExtended§6.8.5yesyesyesyes 
    Link and Multi Formatting Objects (§6.9)
    basic-linkExtended§6.9.2yesyesyesyes
      -
    • - [0.20.5] same limitations as padding-before
    • -
    - padding-end - Basic - §7.7.34 - partial yes - yes - yes multi-switchExtended§6.9.3nononono 
    multi-caseBasic§6.9.4nononono 
    multi-toggleExtended§6.9.5nononono 
    multi-propertiesExtended§6.9.6nononono 
    multi-property-setExtended§6.9.7nononono 
    Formatting Objects for Bookmarks (§6.11 in XSL 1.1 WD)
    bookmark-tree (since + XSL 1.1)Extended§6.11.1 in XSL + 1.1 WDnoyesyesyes
      -
    • - [0.20.5] same limitations as padding-before
    • -
    - padding-top - Basic - §7.7.35 - partial yes - yes - yes bookmark (since XSL 1.1)Extended§6.11.2 in XSL 1.1 + WDnoyesyesyes +
      +
    • [0.20.5] Uses the proprietary fox:outline extension.
    • +
    +
    bookmark-title + (since XSL 1.1)Extended§6.11.3 in + XSL 1.1 WDnopartialpartialpartial
      -
    • - [0.20.5] same limitations as padding-before
    • -
    Out-of-line Formatting Objects (§6.10)
    - padding-bottom - Basic - §7.7.36 - partial yes - yes - yes floatExtended§6.10.2nononono 
    footnoteExtended§6.10.3yespartialpartialpartial
      -
    • - [0.20.5] same limitations as padding-before
    • -
    footnote-bodyExtended§6.10.4yesyesyesyes 
    Other Formatting Objects (§6.11)
    wrapperBasic§6.11.2yespartialpartialpartial +
      +
    • [0.94 and later] Only works as expected with inline-level content.
    • +
    +
    markerExtended§6.11.3yesyesyesyes 
    retrieve-markerExtended§6.11.4yesyesyesyes 
    + +

    XSL-FO Property Support Table + (§7)

    + +

    The following is a summary of FOP's current support for the standard XSL-FO properties.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + +
  • [0.94 and later] Some small limitations
  • + + + - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
  • [0.20.5] "percentage" not implemented. Workaround is to use the XSL-FO + "proportional-column-width" function.
  • + + + - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - + + + + + + - - - + + + + + + + + + - - - - + + + + + + + + + + + + - - - + + + - + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + - - - + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
  • [0.94 and later] IDs on table-header, table-footer, table-body, table-row, + table-and-caption, table-caption, inline-container and bidi-override are not available, + yet.
  • + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
  • [0.20.5] only "solid" works
  • + + + - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
  • [0.94 and later] Enum values other than "inherit" not yet supported.
  • + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
  • [0.20.5] only on pages and regions
  • + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
  • [0.20.5] "inherit" not handled
  • + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + +
    Property NameXSL-FO Conformance LevelCitationSupport in FOPComments
    0.20.5 (ancient)0.94 (stable)0.95 (beta)develop- ment
    Common Accessibility Properties (§7.4)
    source-documentBasic§7.4.1nananana 
    roleBasic§7.4.2nananana 
    Common Absolute Position Properties (§7.5)
    absolute-positionComplete§7.5.1noyesyesyes +
      +
    • [0.20.5] Use shorthand position="absolute" as a workaround.
    • + +
    • [0.94 and later] No restrictions. The 0.20.5 work-around is not supported.
    • +
    +
    topExtended§7.5.2yesyesyesyes 
    rightExtended§7.5.3yesyesyesyes 
    bottomExtended§7.5.4yesyesyesyes 
    leftExtended§7.5.5yesyesyesyes 
    Common Aural Properties (§7.6)
    azimuthBasic§7.6.1nananana 
    cue-afterBasic§7.6.2nananana 
    cue-beforeBasic§7.6.3nananana 
    elevationBasic§7.6.4nananana 
    pause-afterBasic§7.6.5nananana 
    pause-beforeBasic§7.6.6nananana 
    pitchBasic§7.6.7nananana 
    pitch-rangeBasic§7.6.8nananana 
    play-duringBasic§7.6.9nananana 
    richnessBasic§7.6.10nananana 
    speakBasic§7.6.11nananana 
    speak-headerBasic§7.6.12nananana 
    speak-numeralBasic§7.6.13nananana 
    speak-punctuationBasic§7.6.14nananana 
    speech-rateBasic§7.6.15nananana 
    stressBasic§7.6.16nananana 
    voice-familyBasic§7.6.17nananana 
    volumeBasic§7.6.18nananana 
    Common Border, Padding, and Background Properties + (§7.7)
    background-attachmentExtended§7.7.1nononono 
    background-colorBasic§7.7.2yespartialyesyes +
      +
    • [0.94] not yet implemented for table-column, table-body, table-header and + table-footer.
    • +
    +
    background-imageExtended§7.7.3yespartialyesyes +
      +
    • [0.94] not yet implemented for table-column, table-body, table-header and + table-footer.
    • +
    +
    background-repeatExtended§7.7.4noyesyesyes 
    background-position-horizontalExtended§7.7.5nopartialpartialpartial[0.94 and later] Ignored when background-repeat set to + "repeat" or "repeat-x"
    background-position-verticalExtended§7.7.6nopartialpartialpartial[0.94 and later] Ignored when background-repeat set to + "repeat" or "repeat-y"
    border-before-colorBasic§7.7.7yesyesyesyes 
    border-before-styleBasic§7.7.8partialyesyesyes +
      +
    • [0.20.5] only "solid" works
    • +
    +
    border-before-widthBasic§7.7.9yespartialyesyes +
      +
    • [0.94] .conditionality not supported on fo:table-cell
    • +
    +
    border-after-colorBasic§7.7.10yesyesyesyes 
    border-after-styleBasic§7.7.11partialyesyesyes +
      +
    • [0.20.5] only "solid" works
    • +
    +
    border-after-widthBasic§7.7.12yespartialyesyes +
      +
    • [0.94] .conditionality not supported on fo:table-cell
    • +
    +
    border-start-colorBasic§7.7.13yesyesyesyes 
    border-start-styleBasic§7.7.14partialyesyesyes +
      +
    • [0.20.5] only "solid" works
    • +
    +
    border-start-widthBasic§7.7.15yesyesyesyes 
    border-end-colorBasic§7.7.16yesyesyesyes 
    border-end-styleBasic§7.7.17partialyesyesyes +
      +
    • [0.20.5] only "solid" works
    • +
    +
    border-end-widthBasic§7.7.18yesyesyesyes 
    border-top-colorBasic§7.7.19yesyesyesyes 
    border-top-styleBasic§7.7.20partialyesyesyes +
      +
    • [0.20.5] only "solid" works
    • +
    +
    border-top-widthBasic§7.7.21yesyesyesyes 
    border-bottom-colorBasic§7.7.22yesyesyesyes 
    border-bottom-styleBasic§7.7.23partialyesyesyes +
      +
    • [0.20.5] only "solid" works
    • +
    +
    border-bottom-widthBasic§7.7.24yesyesyesyes 
    border-left-colorBasic§7.7.25yesyesyesyes 
    border-left-styleBasic§7.7.26partialyesyesyes +
      +
    • [0.20.5] only "solid" works
    • +
    +
    border-left-widthBasic§7.7.27yesyesyesyes 
    border-right-colorBasic§7.7.28yesyesyesyes 
    border-right-styleBasic§7.7.29partialyesyesyes +
      +
    • [0.20.5] only "solid" works
    • +
    +
    border-right-widthBasic§7.7.30yesyesyesyes 
    padding-beforeBasic§7.7.31partialyesyesyes +
      +
    • [0.20.5] only one value allowed
    • + +
    • [0.20.5] only implemented for blocks
    • + +
    • [0.20.5] can't be used to make extra space (use indents + spaces instead)
    • + +
    • [0.20.5] can be used to control how much the background-color extends beyond the + content rectangle
    • +
    +
    padding-afterBasic§7.7.32partialyesyesyes +
      +
    • [0.20.5] same limitations as padding-before
    • +
    +
    padding-startBasic§7.7.33partialyesyesyes +
      +
    • [0.20.5] same limitations as padding-before
    • +
    +
    padding-endBasic§7.7.34partialyesyesyes +
      +
    • [0.20.5] same limitations as padding-before
    • +
    +
    padding-topBasic§7.7.35partialyesyesyes +
      +
    • [0.20.5] same limitations as padding-before
    • +
    +
    padding-bottomBasic§7.7.36partialyesyesyes +
      +
    • [0.20.5] same limitations as padding-before
    • +
    +
    padding-leftBasic§7.7.37partialyesyesyes +
      +
    • [0.20.5] same limitations as padding-before
    • +
    +
    padding-rightBasic§7.7.38partialyesyesyes +
      +
    • [0.20.5] same limitations as padding-before
    • +
    +
    Common Font Properties (§7.8)
    font-familyBasic§7.8.2partialpartialpartialpartial +
      +
    • [0.20.5] font-family lists are not supported, use a single font-family name
    • + +
    • [0.94 and later] font-family lists are allowed but glyph based font selection is not + supported
    • +
    +
    font-selection-strategyComplete§7.8.3nononono 
    font-sizeBasic§7.8.4partialyesyesyes +
      +
    • [0.20.5] "smaller" and "larger" not implemented
    • +
    +
    font-stretchExtended§7.8.5nononono 
    font-size-adjustExtended§7.8.6nononono 
    font-styleBasic§7.8.7partialyesyesyes +
      +
    • [0.20.5] "normal" is not supported
    • +
    +
    font-variantBasic§7.8.8yesnonono 
    font-weightBasic§7.8.9partialpartialpartialpartial +
      +
    • [0.20.5] "normal", "bolder" and "lighter" are not supported
    • + +
    • [0.94 and later] TODO <relative> font weights
    • +
    +
    Common Hyphenation Properties (§7.9)
    countryExtended§7.9.1yesyesyesyes +
      +
    • [0.94 and earlier] Only used for controlling hyphenation.
    • + +
    • [trunk] For PDF output: Only 2-letter codes from ISO 3166 are supported properly to + identify the natural language!
    • +
    +
    languageExtended§7.9.2yesyesyesyes +
      +
    • [0.94 and earlier] Only used for controlling hyphenation.
    • + +
    • [trunk] For PDF output: Only 2-letter codes from ISO 639 are supported properly to + identify the natural language!
    • +
    +
    scriptExtended§7.9.3nononono 
    hyphenateExtended§7.9.4yesyesyesyes 
    hyphenation-characterExtended§7.9.5yesyesyesyes 
    hyphenation-push-character-countExtended§7.9.6yesyesyesyes 
    hyphenation-remain-character-countExtended§7.9.7yesyesyesyes 
    Common Margin Properties - Block (§7.10)
    margin-topBasic§7.10.1partialyesyesyes +
      +
    • [0.20.5] only on pages and regions
    • +
    +
    margin-bottomBasic§7.10.2partialyesyesyes +
      +
    • [0.20.5] only on pages and regions
    • +
    +
    margin-leftBasic§7.10.3partialyesyesyes +
      +
    • [0.20.5] only on pages and regions
    • +
    +
    margin-rightBasic§7.10.4partialyesyesyes +
      +
    • [0.20.5] only on pages and regions
    • +
    +
    space-beforeBasic§7.10.5partialpartialpartialpartial +
      +
    • [0.20.5] space-before.optimum supported
    • + +
    • [0.94 and later] Space adjustment may not fully work everywhere, yet.
    • +
    +
    space-afterBasic§7.10.6partialpartialpartialpartial +
      +
    • [0.20.5] space-after.optimum supported
    • + +
    • [0.94 and later] Space adjustment may not fully work everywhere, yet.
    • +
    +
    start-indentBasic§7.10.7yesyesyesyes 
    end-indentBasic§7.10.8yesyesyesyes 
    Common Margin Properties - Inline (§7.11)
    space-endBasic§7.11.1nononono 
    space-startBasic§7.11.2nononono 
    Common Relative Position Properties (§7.12)
    relative-positionExtended§7.12.1nononono 
    Area Alignment Properties (§7.13)
    alignment-adjustBasic§7.13.1noyesyesyes 
    alignment-baselineBasic§7.13.2noyesyesyes 
    baseline-shiftBasic§7.13.3partialyesyesyes +
      +
    • [0.20.5] Only values "super" and "sub" have been implemented.
    • +
    +
    display-alignExtended§7.13.4partialpartialpartialpartial +
      +
    • [0.20.5] Implemented only for table-cell and block-container.
    • + +
    • [0.20.5] For table-cell, the "height" attribute must be set for the parent table-row; + setting the height of the table or the table-cell results in vertical centering having no + effect.
    • + +
    • [0.94 and later] TODO Check e-g, i-f-o.
    • +
    +
    dominant-baselineBasic§7.13.5noyesyesyes 
    relative-alignExtended§7.13.6nononono 
    Area Dimension Properties (§7.14)
    block-progression-dimensionBasic§7.14.1noyesyesyes 
    content-heightExtended§7.14.2noyesyesyes 
    content-widthExtended§7.14.3noyesyesyes 
    heightBasic§7.14.4yesyesyesyes 
    inline-progression-dimensionBasic§7.14.5noyesyesyes 
    max-heightComplete§7.14.6nononono 
    max-widthComplete§7.14.7nononono 
    min-heightComplete§7.14.8nononono 
    min-widthComplete§7.14.9nononono 
    scalingExtended§7.14.10noyesyesyes 
    scaling-methodExtended§7.14.11nononono 
    widthBasic§7.14.12yesyesyesyes 
    Block and Line-related Properties (§7.15)
    hyphenation-keepExtended§7.15.1nononono 
    hyphenation-ladder-countExtended§7.15.2noyesyesyes 
    last-line-end-indentExtended§7.15.3noyesyesyes 
    line-heightBasic§7.15.4yesyesyesyes 
    line-height-shift-adjustmentExtended§7.15.5noyesyesyes 
    line-stacking-strategyBasic§7.15.6nopartialpartialpartial +
      +
    • [0.94 and later] value "line-height" not supported
    • +
    +
    linefeed-treatmentExtended§7.15.7noyesyesyes 
    white-space-treatmentExtended§7.15.8nopartialpartialpartial +
      +
    • [0.94 and later] inline elements may interfere with correct handling of this property + in some cases
    • +
    +
    text-alignBasic§7.15.9partialpartialpartialpartial +
      +
    • Only start, end, center and justify are supported
    • +
    +
    text-align-lastExtended§7.15.10partialpartialpartialpartial +
      +
    • Only start, end, center and justify are supported
    • +
    +
    text-indentBasic§7.15.11yesyesyesyes 
    white-space-collapseExtended§7.15.12yesyesyesyes 
    wrap-optionBasic§7.15.13yespartialpartialpartial +
      +
    • [0.94 and later] Only supported on fo:block.
    • +
    +
    Character Properties (§7.16)
    characterBasic§7.16.1yesyesyesyes 
    letter-spacingExtended§7.16.2yesyesyesyes 
    suppress-at-line-breakExtended§7.16.3nononono 
    text-decorationExtended§7.16.4yesyesyesyes 
    text-shadowExtended§7.16.5nononono 
    text-transformExtended§7.16.6noyesyesyes 
    treat-as-word-spaceExtended§7.16.7nononono 
    word-spacingExtended§7.16.8noyesyesyes 
    Color-related Properties (§7.17)
    colorBasic§7.17.1yesyesyesyes 
    color-profile-nameExtended§7.17.2nononono 
    rendering-intentExtended§7.17.3nononono 
    Float-related Properties (§7.18)
    clearExtended§7.18.1nononono 
    floatExtended§7.18.2nononono 
    intrusion-displaceExtended§7.18.3nononono 
    Keeps and Breaks Properties (§7.19)
    break-afterBasic§7.19.1yespartialyesyes +
      +
    • [0.94] Doesn't work on the last row of a table
    • +
    +
    break-beforeBasic§7.19.2yespartialyesyes +
      +
    • [0.94] Doesn't work on the first row of a table
    • +
    • [0.94] When set on the first child of an fo:table-cell, + the border-before is still painted on the previous page
    • +
    +
    keep-togetherExtended§7.19.3partialpartialpartialpartial +
      +
    • [0.20.5] works only in table rows
    • + +
    • [0.94 and later] <integer> values are not supported.
    • +
    +
    keep-with-nextBasic§7.19.4partialpartialpartialpartial +
      +
    • [0.20.5] works only in table rows
    • + +
    • [0.94 and later] works on all implemented block-level FOs, but not on inline-level + FOs.
    • + +
    • [0.94 and later] <integer> values are not supported.
    • +
    +
    keep-with-previousBasic§7.19.5partialpartialpartialpartial +
      +
    • [0.20.5] works only in table rows
    • + +
    • [0.94] works on all implemented FOs, except list- and table-related and + inline-level FOs.
    • + +
    • [0.95] works on all implemented FOs, except list- and inline-level + FOs.
    • + +
    • [0.94 and later] <integer> values are not supported.
    • +
    +
    orphansBasic§7.19.6noyesyesyes 
    widowsBasic§7.19.7noyesyesyes 
    Layout-related Properties (§7.20)
    clipExtended§7.20.1nononono 
    overflowBasic§7.20.2noyesyesyes 
    reference-orientationExtended§7.20.3noyesyesyes +
      +
    • [0.20.5] Workaround for page-orientation (portrait vs. landscape) is to swap the + page-width and page-height properties.
    • + +
    • [0.20.5] Workaround for block-container is to use SVG.
    • +
    +
    spanExtended§7.20.4yesyesyesyes 
    Leader and Rule Properties (§7.21)
    leader-alignmentExtended§7.21.1partialnonono +
      +
    • [0.20.5] not value "page"
    • + +
    • [0.94 and later] Not supported
    • +
    +
    leader-patternBasic§7.21.2partialyesyesyes +
      +
    • [0.20.5] not value "use-content"
    • + +
    • [0.94 and later] Value "use-content" does not work in all circumstances.
    • +
    +
    leader-pattern-widthExtended§7.21.3yesyesyesyes 
    leader-lengthBasic§7.21.4partialyesyesyes +
      +
    • [0.20.5] leader-length.minimum is not used at all
    • +
    +
    rule-styleBasic§7.21.5yesyesyesyes 
    rule-thicknessBasic§7.21.6yesyesyesyes 
    Properties for Dynamic Effects Formatting Objects + (§7.22)
    active-stateExtended§7.22.1nononono 
    auto-restoreExtended§7.22.2nononono 
    case-nameExtended§7.22.3nononono 
    case-titleExtended§7.22.4nononono 
    destination-placement-offsetExtended§7.22.5nononono 
    external-destinationBasic§7.22.6yesyesyesyes 
    indicate-destinationExtended§7.22.7nononono 
    internal-destinationExtended§7.22.8yesyesyesyes 
    show-destinationExtended§7.22.9nononono 
    starting-stateExtended§7.22.10nopartialpartialpartial +
      +
    • [0.94 and later] support for starting-state on fo:bookmark
    • +
    +
    switch-toExtended§7.22.11nononono 
    target-presentation-contextExtended§7.22.12nononono 
    target-processing-contextExtended§7.22.13nononono 
    target-stylesheetExtended§7.22.14nononono 
    Properties for Markers (§7.23)
    marker-class-nameExtended§7.23.1noyesyesyes 
    retrieve-class-nameExtended§7.23.2noyesyesyes 
    retrieve-positionExtended§7.23.3noyesyesyes 
    retrieve-boundaryExtended§7.23.4noyesyesyes 
    Properties for Number to String Conversion (§7.24)
    formatBasic§7.24.1noyesyesyes 
    grouping-separatorExtended§7.24.2nononono 
    grouping-sizeExtended§7.24.3nononono 
    letter-valueBasic§7.24.4nononono 
    Pagination and Layout Properties (§7.25)
    blank-or-not-blankExtended§7.25.1yesyesyesyes 
    column-countExtended§7.25.2yesyesyesyes 
    column-gapExtended§7.25.3yesyesyesyes 
    extentExtended§7.25.4yesyesyesyes 
    flow-nameBasic§7.25.5yesyesyesyes 
    force-page-countExtended§7.25.6noyesyesyes 
    initial-page-numberBasic§7.25.7yesyesyesyes 
    master-nameBasic§7.25.8yesyesyesyes 
    master-referenceBasic§7.25.9yesyesyesyes 
    maximum-repeatsExtended§7.25.10yesyesyesyes 
    media-usageExtended§7.25.11nononono 
    odd-or-evenExtended§7.25.12yesyesyesyes 
    page-heightBasic§7.25.13yesyesyesyes 
    page-positionExtended§7.25.14partialyesyesyes +
      +
    • [0.20.5] "last" isn't implemented!
    • +
    +
    page-widthBasic§7.25.15yesyesyesyes 
    precedenceExtended§7.25.16noyesyesyes 
    region-nameBasic§7.25.17yesyesyesyes 
    Table Properties (§7.26)
    border-after-precedenceBasic§7.26.1nononono 
    border-before-precedenceBasic§7.26.2nononono 
    - padding-left - Basic - §7.7.37 - partial yes - yes - yes border-collapseExtended§7.26.3partialyesyesyes
      -
    • - [0.20.5] same limitations as padding-before
    • -
    - padding-right - Basic - §7.7.38 - partial yes - yes - yes -
      -
    • - [0.20.5] same limitations as padding-before
    • -
    border-end-precedenceBasic§7.26.4nononono 
    - Common Font Properties (§7.8) border-separationExtended§7.26.5noyesyesyes 
    - font-family - Basic - §7.8.2 - partial partial - partial - partial -
      -
    • - [0.20.5] font-family lists are not supported, use a single font-family name
    • -
    • - [0.93 and later] font-family lists are allowed but glyph based font selection is not supported
    • -
    border-start-precedenceBasic§7.26.6nononono 
    - font-selection-strategy - Complete - §7.8.3 - no no - no - no  
    - font-size - Basic - §7.8.4 - partial yes - yes - yes -
      -
    • - [0.20.5] "smaller" and "larger" not implemented
    • -
    caption-sideComplete§7.26.7nononono 
    - font-stretch - Extended - §7.8.5 - no no - no - no  
    - font-size-adjust - Extended - §7.8.6 - no no - no - no  
    - font-style - Basic - §7.8.7 - partial yes - yes - yes -
      -
    • - [0.20.5] "normal" is not supported
    • -
    column-numberBasic§7.26.8noyesyesyes 
    - font-variant - Basic - §7.8.8 - yes no - no - no  
    - font-weight - Basic - §7.8.9 - partial partial - partial - partial column-widthBasic§7.26.9partialyesyesyes
      -
    • - [0.20.5] "normal", "bolder" and "lighter" are not supported
    • -
    • - [0.93 and later] TODO <relative> font weights
    • -
    - Common Hyphenation Properties (§7.9) empty-cellsExtended§7.26.10nononono 
    - country - Extended - §7.9.1 - yes yes - yes - yes -
      -
    • - [0.94 and earlier] Only used for controlling hyphenation.
    • -
    • - [trunk] For PDF output: Only 2-letter codes from ISO 3166 are supported properly to identify the natural language!
    • -
    -
    ends-rowExtended§7.26.11noyesyesyes 
    - language - Extended - §7.9.2 - yes yes - yes - yes -
      -
    • - [0.94 and earlier] Only used for controlling hyphenation.
    • -
    • - [trunk] For PDF output: Only 2-letter codes from ISO 639 are supported properly to identify the natural language!
    • -
    -
    number-columns-repeatedBasic§7.26.12noyesyesyes 
    - script - Extended - §7.9.3 - no no - no - no  
    - hyphenate - Extended - §7.9.4 - yes yes - yes - yes  
    - hyphenation-character - Extended - §7.9.5 - yes yes - yes - yes  
    - hyphenation-push-character-count - Extended - §7.9.6 - yes yes - yes - yes  
    - hyphenation-remain-character-count - Extended - §7.9.7 - yes yes - yes - yes   number-columns-spannedBasic§7.26.13yesyesyesyes 
    - Common Margin Properties - Block (§7.10) number-rows-spannedBasic§7.26.14yesyesyesyes 
    - margin-top - Basic - §7.10.1 - partial yes - yes - yes -
      -
    • - [0.20.5] only on pages and regions
    • -
    starts-rowExtended§7.26.15noyesyesyes 
    - margin-bottom - Basic - §7.10.2 - partial yes - yes - yes -
      -
    • - [0.20.5] only on pages and regions
    • -
    table-layoutExtended§7.26.16nononono 
    - margin-left - Basic - §7.10.3 - partial yes - yes - yes -
      -
    • - [0.20.5] only on pages and regions
    • -
    table-omit-footer-at-breakExtended§7.26.17yesyesyesyes 
    - margin-right - Basic - §7.10.4 - partial yes - yes - yes -
      -
    • - [0.20.5] only on pages and regions
    • -
    table-omit-header-at-breakExtended§7.26.18yesyesyesyes 
    - space-before - Basic - §7.10.5 - partial partial - partial - partial -
      -
    • - [0.20.5] space-before.optimum supported
    • -
    • - [0.93 and later] Space adjustment may not fully work everywhere, yet.
    • -
    Writing-mode-related Properties (§7.27)
    - space-after - Basic - §7.10.6 - partial partial - partial - partial -
      -
    • - [0.20.5] space-after.optimum supported
    • -
    • - [0.93 and later] Space adjustment may not fully work everywhere, yet.
    • -
    directionBasic§7.27.1nononono 
    - start-indent - Basic - §7.10.7 - yes yes - yes - yes  
    - end-indent - Basic - §7.10.8 - yes yes - yes - yes   glyph-orientation-horizontalExtended§7.27.2nononono 
    - Common Margin Properties - Inline (§7.11) glyph-orientation-verticalExtended§7.27.3nononono 
    - space-end - Basic - §7.11.1 - no text-altitudeExtended§7.27.4no - no - no   nonono 
    - space-start - Basic - §7.11.2 - no text-depthExtended§7.27.5nononono - no - no    
    - Common Relative Position Properties (§7.12) unicode-bidiExtended§7.27.6nononono 
    - relative-position - Extended - §7.12.1 - no writing-modeBasic§7.27.7nononono - no - no    
    - Area Alignment Properties (§7.13) Miscellaneous Properties (§7.28)
    - alignment-adjust - Basic - §7.13.1 - no yes - yes - yes  
    - alignment-baseline - Basic - §7.13.2 - no yes - yes - yes  
    - baseline-shift - Basic - §7.13.3 - partial yes - yes - yes -
      -
    • - [0.20.5] Only values "super" and "sub" have been implemented.
    • -
    content-typeExtended§7.28.1nononono 
    - display-align - Extended - §7.13.4 - partial partial - partial - partial idBasic§7.28.2yespartialpartialpartial
      -
    • - [0.20.5] Implemented only for table-cell and block-container.
    • -
    • - [0.20.5] For table-cell, the "height" attribute must be set for the parent table-row; setting the height of the table or the table-cell results in vertical centering having no effect.
    • -
    • - [0.93 and later] TODO Check e-g, i-f-o.
    • -
    - dominant-baseline - Basic - §7.13.5 - no yes - yes - yes  
    - relative-align - Extended - §7.13.6 - no no - no - no  
    - Area Dimension Properties (§7.14)
    - block-progression-dimension - Basic - §7.14.1 - no yes - yes - yes  
    - content-height - Extended - §7.14.2 - no yes - yes - yes  
    - content-width - Extended - §7.14.3 - no yes - yes - yes  
    - height - Basic - §7.14.4 - yes yes - yes - yes  
    - inline-progression-dimension - Basic - §7.14.5 - no yes - yes - yes  
    - max-height - Complete - §7.14.6 - no no - no - no  
    - max-width - Complete - §7.14.7 - no no - no - no  
    - min-height - Complete - §7.14.8 - no no - no - no  
    - min-width - Complete - §7.14.9 - no no - no - no  
    - scaling - Extended - §7.14.10 - no yes - yes - yes  
    - scaling-method - Extended - §7.14.11 - no no - no - no  
    - width - Basic - §7.14.12 - yes yes - yes - yes  
    - Block and Line-related Properties (§7.15)
    - hyphenation-keep - Extended - §7.15.1 - no no - no - no  
    - hyphenation-ladder-count - Extended - §7.15.2 - no yes - yes - yes  
    - last-line-end-indent - Extended - §7.15.3 - no yes - yes - yes  
    - line-height - Basic - §7.15.4 - yes yes - yes - yes  
    - line-height-shift-adjustment - Extended - §7.15.5 - no no - no - yes  
    - line-stacking-strategy - Basic - §7.15.6 - no partial - partial - partial -
      -
    • - [0.93 and later] value "line-height" not supported
    • -
    provisional-label-separationBasic§7.28.3yesyesyesyes 
    - linefeed-treatment - Extended - §7.15.7 - no yes - yes - yes  
    - white-space-treatment - Extended - §7.15.8 - no partial - partial - partial -
      -
    • - [0.93 and later] inline elements may interfere with correct handling of this property - in some cases
    • -
    provisional-distance-between-startsBasic§7.28.4yesyesyesyes 
    - text-align - Basic - §7.15.9 - partial partial - partial - partial -
      -
    • - Only start, end, center and justify are supported
    • -
    ref-idExtended§7.28.5yesyesyesyes 
    - text-align-last - Extended - §7.15.10 - partial partial - partial - partial -
      -
    • - Only start, end, center and justify are supported
    • -
    score-spacesExtended§7.28.6nononono 
    - text-indent - Basic - §7.15.11 - yes yes - yes - yes  
    - white-space-collapse - Extended - §7.15.12 - yes yes - yes - yes  
    - wrap-option - Basic - §7.15.13 - yes partial - partial - partial -
      -
    • - [0.93 and later] Only supported on fo:block.
    • -
    srcBasic§7.28.7yesyesyesyes 
    - Character Properties (§7.16) visibilityExtended§7.28.8nononono 
    - character - Basic - §7.16.1 - yes yes - yes - yes  
    - letter-spacing - Extended - §7.16.2 - yes yes - yes - yes  
    - suppress-at-line-break - Extended - §7.16.3 - no no - no - no  
    - text-decoration - Extended - §7.16.4 - yes yes - yes - yes  
    - text-shadow - Extended - §7.16.5 - no no - no - no  
    - text-transform - Extended - §7.16.6 - no yes - yes - yes  
    - treat-as-word-space - Extended - §7.16.7 - no no - no - no  
    - word-spacing - Extended - §7.16.8 - no yes - yes - yes   z-indexExtended§7.28.9nononono 
    - Color-related Properties (§7.17) Shorthand Properties (§7.29)
    - color - Basic - §7.17.1 - yes yes - yes - yes  
    - color-profile-name - Extended - §7.17.2 - no no - no - no  
    - rendering-intent - Extended - §7.17.3 - no no - no - no   backgroundComplete§7.29.1nononono 
    - Float-related Properties (§7.18) background-positionComplete§7.29.2noyesyesyes 
    - clear - Extended - §7.18.1 - no no - no - no  
    - float - Extended - §7.18.2 - no no - no - no  
    - intrusion-displace - Extended - §7.18.3 - no no - no - no   borderComplete§7.29.3noyesyesyes 
    - Keeps and Breaks Properties (§7.19) border-bottomComplete§7.29.4yesyesyesyes 
    - break-after - Basic - §7.19.1 - yes yes - yes - yes  
    - break-before - Basic - §7.19.2 - yes yes - yes - yes  
    - keep-together - Extended - §7.19.3 - partial partial - partial - partial border-colorComplete§7.29.5partialyesyesyes
      -
    • - [0.20.5] works only in table rows
    • -
    • - [0.93] works on all implemented block-level FOs, but not on inline-level FOs.
    • -
    • - [0.93 and later] <integer> values are not supported. -
    • +
    • [0.20.5] only one value allowed
    - keep-with-next - Basic - §7.19.4 - partial partial - partial - partial -
      -
    • - [0.20.5] works only in table rows
    • -
    • - [0.93 and later] works on all implemented block-level FOs, but not on inline-level FOs.
    • -
    • - [0.93 and later] <integer> values are not supported.
    • -
    - keep-with-previous - Basic - §7.19.5 - partial partial - partial - partial -
      -
    • [0.20.5] works only in table rows
    • -
    • [0.93 and later] works on all implemented FOs, except list- and - table-related and inline-level FOs.
    • -
    • [0.93 and later] <integer> values are not supported.
    • -
    - orphans - Basic - §7.19.6 - no yes - yes - yes  
    - widows - Basic - §7.19.7 - no yes - yes - yes   border-leftComplete§7.29.6yesyesyesyes 
    - Layout-related Properties (§7.20) border-rightComplete§7.29.7yesyesyesyes 
    - clip - Extended - §7.20.1 - no no - no - no  
    - overflow - Basic - §7.20.2 - no yes - yes - yes  
    - reference-orientation - Extended - §7.20.3 - no yes - yes - yes border-styleComplete§7.29.8partialyesyesyes
      -
    • - [0.20.5] Workaround for page-orientation (portrait vs. landscape) is to swap the page-width and page-height properties.
    • -
    • - [0.20.5] Workaround for block-container is to use SVG.
    • -
    - span - Extended - §7.20.4 - yes yes - yes - yes   border-spacingComplete§7.29.9noyesyesyes 
    - Leader and Rule Properties (§7.21) border-topComplete§7.29.10yesyesyesyes 
    - leader-alignment - Extended - §7.21.1 - partial no - no - no -
      -
    • - [0.20.5] not value "page"
    • -
    • - [0.93 and later] Not supported
    • -
    border-widthComplete§7.29.11yesyesyesyes 
    - leader-pattern - Basic - §7.21.2 - partial yes - yes - yes -
      -
    • - [0.20.5] not value "use-content"
    • -
    • - [0.93 and later] Value "use-content" does not work in all circumstances.
    • -
    cueComplete§7.29.12nananana 
    - leader-pattern-width - Extended - §7.21.3 - yes yes - yes - yes  
    - leader-length - Basic fontComplete§7.29.13nopartialpartialpartial - §7.21.4 - partial yes - yes - yes
      -
    • - [0.20.5] leader-length.minimum is not used at all
    • -
    - rule-style - Basic - §7.21.5 - yes yes - yes - yes  
    - rule-thickness - Basic - §7.21.6 - yes yes - yes - yes  
    - Properties for Dynamic Effects Formatting Objects (§7.22)
    - active-state - Extended - §7.22.1 - no no - no - no  
    - auto-restore - Extended - §7.22.2 - no no - no - no  
    - case-name - Extended - §7.22.3 - no no - no - no  
    - case-title - Extended - §7.22.4 - no no - no - no  
    - destination-placement-offset - Extended - §7.22.5 - no no - no - no  
    - external-destination - Basic - §7.22.6 - yes yes - yes - yes  
    - indicate-destination - Extended - §7.22.7 - no no - no - no  
    - internal-destination - Extended - §7.22.8 - yes yes - yes - yes  
    - show-destination - Extended - §7.22.9 - no no - no - no  
    - starting-state - Extended - §7.22.10 - no partial - partial - partial marginComplete§7.29.14partialyesyesyes
      -
    • [0.93 and later] support for starting-state on fo:bookmark
    • -
    - switch-to - Extended - §7.22.11 - no no - no - no  
    - target-presentation-context - Extended - §7.22.12 - no no - no - no  
    - target-processing-context - Extended - §7.22.13 - no no - no - no  
    - target-stylesheet - Extended - §7.22.14 - no no - no - no  
    - Properties for Markers (§7.23) paddingComplete§7.29.15partialyesyesyes +
      +
    • [0.20.5] only one value allowed
    • + +
    • [0.20.5] only implemented for blocks
    • + +
    • [0.20.5] can't be used to make extra space (use indents + spaces instead)
    • + +
    • [0.20.5] can be used to control how much the background-color extends beyond the + content rectangle
    • +
    +
    - marker-class-name - Extended - §7.23.1 - no yes - yes - yes  
    - retrieve-class-name - Extended - §7.23.2 - no yes - yes - yes  
    - retrieve-position - Extended - §7.23.3 - no yes - yes - yes  
    - retrieve-boundary - Extended - §7.23.4 - no yes - yes - yes   page-break-afterComplete§7.29.16noyesyesyes 
    - Properties for Number to String Conversion (§7.24) page-break-beforeComplete§7.29.17noyesyesyes 
    - format - Basic - §7.24.1 - no yes - yes - yes  
    - grouping-separator - Extended - §7.24.2 - no no - no - no  
    - grouping-size - Extended - §7.24.3 - no no - no - no  
    - letter-value - Basic - §7.24.4 - no no - no - no   page-break-insideComplete§7.29.18noyesyesyes 
    - Pagination and Layout Properties (§7.25) pauseComplete§7.29.19nananana 
    - blank-or-not-blank - Extended - §7.25.1 - yes yes - yes - yes  
    - column-count - Extended - §7.25.2 - yes yes - yes - yes  
    - column-gap - Extended - §7.25.3 - yes yes - yes - yes  
    - extent - Extended - §7.25.4 - yes yes - yes - yes  
    - flow-name - Basic - §7.25.5 - yes yes - yes - yes  
    - force-page-count - Extended - §7.25.6 - no yes - yes - yes  
    - initial-page-number - Basic - §7.25.7 - yes yes - yes - yes  
    - master-name - Basic - §7.25.8 - yes yes - yes - yes  
    - master-reference - Basic - §7.25.9 - yes yes - yes - yes  
    - maximum-repeats - Extended - §7.25.10 - yes yes - yes - yes  
    - media-usage - Extended - §7.25.11 - no no - no - no  
    - odd-or-even - Extended - §7.25.12 - yes yes - yes - yes  
    - page-height - Basic - §7.25.13 - yes yes - yes - yes  
    - page-position - Extended - §7.25.14 - partial yes - yes - yes positionComplete§7.29.20partialyesyesyes
      -
    • - [0.20.5] "last" isn't implemented!
    • -
    - page-width - Basic - §7.25.15 - yes yes - yes - yes  
    - precedence - Extended - §7.25.16 - no yes - yes - yes  
    - region-name - Basic - §7.25.17 - yes yes - yes - yes  
    - Table Properties (§7.26) sizeComplete§7.29.21nononono 
    - border-after-precedence - Basic - §7.26.1 - no no - no - no  
    - border-before-precedence - Basic - §7.26.2 - no no - no - no  
    - border-collapse - Extended - §7.26.3 vertical-alignComplete§7.29.22partialnoyesyespartialpartialpartial
      -
    • [0.94 and later] Some small limitations
    • +
    • [0.20.5] Only works as a shorthand for baseline-shift property.
    • + +
    • [0.94 and later] Percentages are not supported, yet.
    - border-end-precedence - Basic - §7.26.4 - no no - no - no  
    - border-separation - Extended - §7.26.5 - no yes - yes - yes  
    - border-start-precedence - Basic - §7.26.6 - no no - no - no  
    - caption-side - Complete - §7.26.7 - no no - no - no  
    - column-number - Basic - §7.26.8 - no yes - yes - yes  
    - column-width - Basic - §7.26.9 - partial yes - yes - yes -
      -
    • - [0.20.5] "percentage" not implemented. Workaround is to use the XSL-FO "proportional-column-width" function.
    • -
    white-spaceComplete§7.29.23noyesyesyes 
    - empty-cells - Extended - §7.26.10 - no yes - yes - yes  
    - ends-row - Extended - §7.26.11 - no yes - yes - yes  
    - number-columns-repeated - Basic - §7.26.12 - no yes - yes - yes  
    - number-columns-spanned - Basic - §7.26.13 - yes yes - yes - yes  
    - number-rows-spanned - Basic - §7.26.14 - yes yes - yes - yes  
    - starts-row - Extended - §7.26.15 - no yes - yes - yes  
    - table-layout - Extended - §7.26.16 - no no - no - no  
    - table-omit-footer-at-break - Extended - §7.26.17 - yes yes - yes - yes  
    - table-omit-header-at-break - Extended - §7.26.18 - yes yes - yes - yes   xml:langComplete§7.29.24noyesyesyes[0.95] Very basic parsing; no validation of the specified value.
    + +

    XSL-FO Core + Function Library Support Table (§5.10)

    + +

    The following is a summary of FOP's current support for the XSL-FO Core Function Library.

    + + + + + + + + + + + + + - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + -
    Function NameXSL-FO Conformance LevelCitationSupport in FOPComments
    - Writing-mode-related Properties (§7.27) 0.20.5 (ancient)0.94 (stable)0.95 (beta)develop- ment
    - direction - Basic - §7.27.1 - no no - no - no  
    - glyph-orientation-horizontal - Extended - §7.27.2 - no no - no - no  
    - glyph-orientation-vertical - Extended - §7.27.3 - no no - no - no  
    - text-altitude - Extended - §7.27.4 - no no - no - no  
    - text-depth - Extended - §7.27.5 - no no - no - no  
    - unicode-bidi - Extended - §7.27.6 - no no - no - no  
    - writing-mode - Basic - §7.27.7 - no no - no - no   Number Functions (§5.10.1)
    - Miscellaneous Properties (§7.28) floorBasic§5.10.1yesyesyesyes 
    - content-type - Extended - §7.28.1 - no no - no - no  
    - id - Basic - §7.28.2 - yes partial - partial - partial -
      -
    • [0.93 and later] IDs on table-header, table-footer, table-body, table-row, table-and-caption, table-caption, inline-container and bidi-override are not available, yet.
    • -
    ceilingBasic§5.10.1yesyesyesyes 
    - provisional-label-separation - Basic - §7.28.3 - yes yes - yes - yes  
    - provisional-distance-between-starts - Basic - §7.28.4 - yes yes - yes - yes  
    - ref-id - Extended - §7.28.5 - yes yes - yes - yes  
    - score-spaces - Extended - §7.28.6 - no no - no - no  
    - src - Basic - §7.28.7 - yes yes - yes - yes  
    - visibility - Extended - §7.28.8 - no no - no - no  
    - z-index - Extended - §7.28.9 - no no - no - no   roundBasic§5.10.1yesyesyesyes 
    - Shorthand Properties (§7.29) minBasic§5.10.1yesyesyesyes 
    - background - Complete - §7.29.1 - no no - no - no  
    - background-position - Complete - §7.29.2 - no yes - yes - yes  
    - border - Complete - §7.29.3 - no yes - yes - yes  
    - border-bottom - Complete - §7.29.4 - yes yes - yes - yes  
    - border-color - Complete - §7.29.5 - partial yes - yes - yes -
      -
    • - [0.20.5] only one value allowed
    • -
    maxBasic§5.10.1yesyesyesyes 
    - border-left - Complete - §7.29.6 - yes yes - yes - yes  
    - border-right - Complete - §7.29.7 - yes yes - yes - yes  
    - border-style - Complete - §7.29.8 - partial yes - yes - yes -
      -
    • - [0.20.5] only "solid" works
    • -
    absBasic§5.10.1yesyesyesyes 
    - border-spacing - Complete - §7.29.9 - no yes - yes - yes  
    - border-top - Complete - §7.29.10 - yes yes - yes - yes  
    - border-width - Complete - §7.29.11 - yes yes - yes - yes  
    - cue - Complete - §7.29.12 - na na - na - na  
    - font - Complete - §7.29.13 - no partial - partial - partial -
      -
    • - [0.93 and later] Enum values other than "inherit" not yet supported.
    • -
    Color Functions (§5.10.2)
    - margin - Complete - §7.29.14 - partial yes - yes - yes -
      -
    • - [0.20.5] only on pages and regions
    • -
    rgbBasic§5.10.2yesyesyesyes 
    - padding - Complete - §7.29.15 - partial yes - yes - yes -
      -
    • - [0.20.5] only one value allowed
    • -
    • - [0.20.5] only implemented for blocks
    • -
    • - [0.20.5] can't be used to make extra space (use indents + spaces instead)
    • -
    • - [0.20.5] can be used to control how much the background-color extends beyond the content rectangle
    • -
    - page-break-after - Complete - §7.29.16 - no yes - yes - yes  
    - page-break-before - Complete - §7.29.17 - no yes - yes - yes  
    - page-break-inside - Complete - §7.29.18 - no yes - yes - yes  
    - pause - Complete - §7.29.19 - na na - na - na  
    - position - Complete - §7.29.20 - partial yes - yes - yes -
      -
    • - [0.20.5] "inherit" not handled
    • -
    rgb-iccBasic§5.10.2noyesyesyes 
    - size - Complete - §7.29.21 - no no - no - no  
    - vertical-align - Complete - §7.29.22 - partial partial - partial - partial -
      -
    • - [0.20.5] Only works as a shorthand for baseline-shift property.
    • -
    • - [0.93 and later] Percentages are not supported, yet.
    • -
    system-colorBasic§5.10.2noyesyesyes 
    - white-space - Complete - §7.29.23 - no yes - yes - yes  
    - xml:lang - Complete - §7.29.24 - no no - no - yes [dev] Very basic parsing; no validation of the specified value.Font Functions (§5.10.3)
    -

    XSL-FO Core Function Library Support Table (§5.10)

    -

    - The following is a summary of FOP's current support for the XSL-FO Core Function Library. -

    - + - - - - - + + + + + + + + + + + + + + + + - - - - + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - + + + + + + - - + + + + + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
    - Function Name - XSL-FO Conformance Level - Citation - Support in FOP - Comments system-fontBasic§5.10.3nononono 
    - 0.20.5 (previous) - 0.93 (stable) 0.94 (stable) - develop- ment Property Value Functions (§5.10.4)
    - Number Functions (§5.10.1) inherited-property-valueBasic + §5.10.4yesyesyesyes 
    - floor - Basic - §5.10.1 - yes - yes yes - yes  
    - ceiling - Basic - §5.10.1 - yes - yes yes - yes  
    - round - Basic - §5.10.1 - yes - yes yes - yes  
    - min - Basic - §5.10.1 - yes - yes yes - yes  
    - max - Basic - §5.10.1 - yes - yes yes - yes  
    - abs - Basic - §5.10.1 - yes - yes yes - yes   label-endBasic + §5.10.4yesyesyesyes 
    - Color Functions (§5.10.2) body-startBasic + §5.10.4yesyesyesyes 
    - rgb - Basic - §5.10.2 - yes - yes yes - yes  
    - rgb-icc - Basic - §5.10.2 - no - yes yes - yes  
    - system-color - Basic - §5.10.2 - no - yes yes - yes   from-parentBasic + §5.10.4yesyesyesyes 
    - Font Functions (§5.10.3) from-nearest-specified-valueBasic + §5.10.4yesyesyesyes 
    - system-font - Basic - §5.10.3 - no - no from-table-columnBasic + §5.10.4no - no   yesyesyes 
    - Property Value Functions (§5.10.4) proportional-column-widthBasic + §5.10.4yesyesyesyes 
    - inherited-property-value - Basic - §5.10.4 - yes - yes yes - yes  
    - label-end - Basic - §5.10.4 - yes - yes yes - yes  
    - body-start - Basic - §5.10.4 - yes - yes yes - yes  
    - from-parent - Basic - §5.10.4 - yes - yes yes - yes  
    - from-nearest-specified-value - Basic - §5.10.4 - yes - yes yes - yes  
    - from-table-column - Basic - §5.10.4 - no - yes yes - yes  
    - proportional-column-width - Basic - §5.10.4 - yes - yes yes - yes  
    - merge-property-values - Basic - §5.10.4 - no - no no - no   merge-property-valuesBasic + §5.10.4nononono 
    diff --git a/src/documentation/content/xdocs/dev/doc.xml b/src/documentation/content/xdocs/dev/doc.xml index a9d054316..4fd6bce78 100644 --- a/src/documentation/content/xdocs/dev/doc.xml +++ b/src/documentation/content/xdocs/dev/doc.xml @@ -97,9 +97,9 @@ Maintenance branch releases either copy the trunk content to the maintenance bra Step-by-step instructions for the deployment process again:

    - Please make sure you use Forrest from the 0.7 branch for the time being. You will need + Please make sure you use Forrest from the Trunk (revision 632959 or later) for the time being. You will need to download it directly from SVN: - http://svn.apache.org/repos/asf/forrest/branches/forrest_07_branch + http://svn.apache.org/repos/asf/forrest/trunk
    • Modify the sources of the website and check locally with Forrest (run "forrest run" or just "forrest").
    • diff --git a/src/documentation/content/xdocs/dev/release.xml b/src/documentation/content/xdocs/dev/release.xml index fa4dbfa37..641758d78 100644 --- a/src/documentation/content/xdocs/dev/release.xml +++ b/src/documentation/content/xdocs/dev/release.xml @@ -73,7 +73,7 @@ The purpose of documenting it here is to facilitate consistency, ensure that the fop-hyph.jar to lib/ (e.g. from http://sourceforge.net/projects/offo
    • Alternatively, create a build-local.properties file that points to the above libs.
    • -
    • Run build[.sh] dist. Do this once using Sun JDK 1.3.1_15 or later and once with Sun JDK 1.4.2_08 or later. A Forrest installation is needed.
    • +
    • Run build[.sh] dist. Do this using Sun JDK 1.4.2_08 or later. A Forrest installation is needed.
    • Create signatures. Don't forget to upload your KEY: gpg -a -b --force-v3-sigs fop-0.94-src.tar.gz etc.
    • Upload the dist and signature files to your web directory diff --git a/src/documentation/content/xdocs/download.xml b/src/documentation/content/xdocs/download.xml index 40e42236b..f0a2a0a61 100644 --- a/src/documentation/content/xdocs/download.xml +++ b/src/documentation/content/xdocs/download.xml @@ -84,7 +84,7 @@

      - + @@ -102,6 +102,25 @@ + + + + + + + + + + + diff --git a/src/documentation/content/xdocs/faq.xml b/src/documentation/content/xdocs/faq.xml index d488a1f3c..a75cd41e0 100644 --- a/src/documentation/content/xdocs/faq.xml +++ b/src/documentation/content/xdocs/faq.xml @@ -645,6 +645,21 @@ Check the following:

      + + Why is the output of Java2D/AWT-based renderers different than, for example, PDF or PS? + +

      + If you render the same document once to a PNG or TIFF and once into a PDF, the output + may not be the same, i.e. line breaks are different or lines may have different heights. + The reason for this: The Java2D-based renderers use the font subsystem of Java2D/AWT. The + PDF and PS renderers use FOP's own font subsystem which provides much better font metrics + than Java2D. These can lead to different layout decisions when the same document is + rendered with different renderers. An alternative approach to fix this problem might be + available but it hasn't been tested, yet. See also the + notes on fonts in the various output formats. +

      +
      +
      Embedding FOP. Using FOP in a servlet. diff --git a/src/documentation/content/xdocs/index.xml b/src/documentation/content/xdocs/index.xml index b0f44fac3..9ed040184 100644 --- a/src/documentation/content/xdocs/index.xml +++ b/src/documentation/content/xdocs/index.xml @@ -29,14 +29,15 @@

      Apache FOP (Formatting Objects Processor) is a print formatter driven by XSL formatting objects (XSL-FO) and an output independent formatter. It is a Java application that reads a formatting object (FO) tree and renders the resulting - pages to a specified output. Output formats + pages to a specified output. Output formats currently supported include PDF, PS, PCL, AFP, XML (area tree representation), Print, AWT and PNG, and to a lesser extent, RTF and TXT. The primary output target is PDF.

      - The latest stable version of FOP (0.94) is the second - stable release after a large redesign effort and implements a large subset of the + A beta release of the latest version of FOP (0.95) is now + available. After a short testing period it will become the third + stable release after the large redesign effort and will implement a large subset of the XSL-FO Version 1.1 W3C Recommendation.

      diff --git a/src/documentation/content/xdocs/quickstartguide.xml b/src/documentation/content/xdocs/quickstartguide.xml new file mode 100644 index 000000000..ca205f5a2 --- /dev/null +++ b/src/documentation/content/xdocs/quickstartguide.xml @@ -0,0 +1,124 @@ + + + + + +
      + FOP: Quick Start Guide + Everything you need to start using and appreciating Apache FOP quickly. + $Revision: 627324 $ +
      + +
      + FOP Essentials +

      The goal of this Quick Start Guide is to help novice users get Apache FOP up and running quickly. Typically, you'll need to:

      +
        +
      1. Download FOP
      2. +
      3. Build FOP (you can skip this step if you download the binary distribution!)
      4. +
      5. Configure FOP
      6. +
      7. Run FOP
      8. +
      +

      Here are some links to help you find out what FOP can do, as well as how and where to get help:

      +
        +
      • Calling FOP from a Java Application
      • +
      • Using FOP in Servlets
      • +
      • Using FOP in an 'Ant' Build Script
      • +
      • XSL-FO Compliance (what FOP supports and what it doesn't)
      • +
      • FAQs
      • +
      • Getting Help
      • +
      • Mailing Lists
      • +
      +

      + Once you've familiarized yourself with the basics, you can get more detailed information, + in the detailed FOP product documentation. +

      +
      + +
      + Hello World with FOP +

      + This section walks you through a "Hello World!" page with Apache FOP. We're assuming you + download the binary distribution and that you have a Java Runtime Environment (version 1.4 + or later) installed. +

      +
        +
      1. + Unpack the downloaded binary distribution to a directory of your choice (for example, + C:\FOP if you're on Windows). Let's call that + directory <fop-home>. +
      2. +
      3. + Get a command prompt in the <fop-home> directory and write:
        + Windows: fop -fo examples/fo/basic/readme.fo -awt
        + Unix: ./fop.sh -fo examples/fo/basic/readme.fo -awt
        +
      4. +
      5. + If all went well, this should open a window showing you a "readme"-style document. + This is just to verify that FOP runs correctly. +
      6. +
      7. + Now, take your favorite XML editor and create a small XML file like the following. Replace + "Frank" with your own first name to make it a bit more personal and save it as + name.xml:
        + Frank]]> +
      8. +
      9. + To produce a PDF file from this XML file, we need an XSLT stylesheet that converts the + XML to XSL-FO. This is the first step in the processing chain. The second step will be + done by FOP when it reads the generated XSL-FO document and formats it to a PDF document. + You can copy the following minimal XSLT stylesheet, which takes your first name and + produces a "Hello World!"-style document (save it as name2fo.xsl):
        + + + + + + + + + + + + + + Hello, ! + + + + + +]]> + +
      10. +
      11. + Finally, let's put the previous two steps together: Go back to the command prompt and + enter the following command:
        + Windows: fop -xml name.xml -xsl name2fo.xsl -pdf name.pdf
        + Unix: ./fop.sh -xml name.xml -xsl name2fo.xsl -pdf name.pdf
        +
      12. +
      13. + You've produced your first PDF with Apache FOP! Please open name.pdf + in your favorite PDF viewer. +
      14. +
      +
      + +
      diff --git a/src/documentation/content/xdocs/site.xml b/src/documentation/content/xdocs/site.xml index 7914d5ef2..18716903c 100644 --- a/src/documentation/content/xdocs/site.xml +++ b/src/documentation/content/xdocs/site.xml @@ -15,6 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. --> + - @@ -57,12 +58,12 @@ --> - + - - + + @@ -89,16 +90,16 @@ - + - - + + @@ -125,9 +126,9 @@ - + diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index cb2c4aa0b..fa3e2e643 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -27,13 +27,13 @@
      Status -

      [last updated 9 January 2007]

      +

      [last updated 4 March 2008]

      This is the development status of Apache FOP. Development on the maintenance branch where FOP 0.20.5 came from has been halted. The code base has been largely redesigned. The new - code base has reached release 0.94. + code base has reached release 0.95.

      @@ -44,7 +44,7 @@ handle large documents.

      The redesign of the code base has largely been completed. The new code reached production quality with release 0.93. In the - course of 2007 we plan to release version 1.0.

      + course of 2008 or 2009 we hope to release version 1.0.

      If you're looking for a long-term road-map we have to disappoint you. This is Open Source and we're mostly volunteers working in their free time. What we have @@ -122,7 +122,7 @@

      - + diff --git a/src/documentation/content/xdocs/tabs.xml b/src/documentation/content/xdocs/tabs.xml index bb2fd7e72..a42fc9bd7 100644 --- a/src/documentation/content/xdocs/tabs.xml +++ b/src/documentation/content/xdocs/tabs.xml @@ -21,14 +21,8 @@ - + - - diff --git a/src/documentation/content/xdocs/team.xml b/src/documentation/content/xdocs/team.xml index 23cb87708..bd9f72fde 100644 --- a/src/documentation/content/xdocs/team.xml +++ b/src/documentation/content/xdocs/team.xml @@ -31,7 +31,6 @@ Active CommittersPlease don't write to any developer directly if you need help on using FOP. Only if you submit questions to the FOP User Mailing List will other FOP users be able to profit from answers given to your question. Another point is that a developer may have gone inactive or is on holidays in which case you may not get an answer in time.
        -
      • Finn Bock (FB)
      • Chris Bowditch (CB) is a Java/VB Programmer from England.
      • Jay Bryant (JB) is a @@ -51,10 +50,6 @@
      • Vincent Hennebert (VH), a Java developer from France; with an interest in typography, and in using Fop as a pdf renderer for book-like documents.
      • -
      • Peter Herweg (PH) is helping to - integrate the jfor project's RTF support into the upcoming FOP 1.0 version. - Born in 1978, he has been serving as an application developer for a small - industrial company in Germany since 1999.
      • Clay Leeds (CL) is a web/WAP/Palm developer from Laguna Beach, California, USA. A recent XML/XSL-FO convert, he has been nit-picking FAQs & assorted web @@ -78,7 +73,11 @@ from the TeX/LaTeX world. See his home page for some of his private projects.
      • Jörg Pietschmann (JP)
      • -
      • Oleg Tkachenko (OT)
      • +
      • Max Berger (MB) is currently a + PostDoc pursuing an academic career in computer science. His main interest in FOP is to + improve the DocBook to PDF tool-chain to produce high quality output, while still + conforming to given style-guides. See his home + page for more information.
      • Max Berger (MB) is currently a PostDoc pursuing an academic career in computer science. His main interest in FOP is to improve the DocBook to PDF tool-chain to produce high quality output, while still @@ -109,11 +108,16 @@
        Inactive Committers
          +
        • Finn Bock (FB)
        • Kelly Campbell
        • Steven Coffman
        • Bertrand Delacretaz
        • Tore Engvig
        • Stanislav Gorkhover
        • +
        • Peter Herweg (PH)
        • Fotis Jannidis
        • Karen Lease
        • Keiron Liddle
        • @@ -122,6 +126,7 @@
        • Jordan Naftolin
        • Arved Sandstrom
        • Eric Schaeffer
        • +
        • Oleg Tkachenko (OT)
        • Art Welch
        • Peter B. West
        @@ -264,7 +269,7 @@
      + + + ../../resources/images/bgimg72dpi.jpg + ../../resources/images/fop-logo-color-24bit.png + ../../../examples/fo/graphics/asf-logo.png + ../../../examples/fo/graphics/asf-logo.png +
      ../../resources/images/box1.png
      + + + + + + + + + + + + Before the table. + + + + + + Header 1.1 + Header 1.1 + Header 1.1 + Header 1.1 + Header 1.1 + + + Header 1.2 + Header 1.2 + Header 1.2 + Header 1.2 + Header 1.2 + + + + + Footer 1.1 + Footer 1.1 + + + Footer 1.2 + Footer 1.2 + + + + + + Cell 1.1 + Cell 1.1 + Cell 1.1 + Cell 1.1 + + + Cell 1.2 + Cell 1.2 + + + + + Cell 2.2 + + + + + Cell 3.1 + Cell 3.1 + + + + + Cell 4.1 + Cell 4.1 + + + Cell 4.2 + + + + + + + Cell 5.1 + Cell 5.1 + Cell 5.1 + Cell 5.1 + Cell 5.1 Line 5 + Cell 5.1 + Cell 5.1 + Cell 5.1 + Cell 5.1 + Cell 5.1 Line 10 + Cell 5.1 + + + Cell 5.2 + Cell 5.2 + Cell 5.2 + Cell 5.2 + + + + + Cell 6.2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/layoutengine/standard-testcases/table_backgrounds_2.xml b/test/layoutengine/standard-testcases/table_backgrounds_2.xml new file mode 100644 index 000000000..300d54234 --- /dev/null +++ b/test/layoutengine/standard-testcases/table_backgrounds_2.xml @@ -0,0 +1,113 @@ + + + + + +

      + This test checks background painting for fo:table-row, fo:table-body and fo:table-column + when the cells use padding. +

      +
      + + + + + + + + + + + + + + + background on cell + + + background on cell + + + + + background on row + + + background on row + + + + + + + background on body + + + background on body + + + + + + + + + + background on column + + + background on column + + + + + + + + + + background on table + + + background on table + + + + + + + + + + + + + + + + + + + + + + + + +
      diff --git a/test/layoutengine/standard-testcases/table_border-collapse_collapse_1.xml b/test/layoutengine/standard-testcases/table_border-collapse_collapse_1.xml deleted file mode 100644 index 052eaa1c9..000000000 --- a/test/layoutengine/standard-testcases/table_border-collapse_collapse_1.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - -

      - This test checks tables with collapse border model. Simple cell borders to start with. -

      -
      - - - - - - - - - - - block before table - - normal border here - - - - - - - - - - - - - cell1 cell1 cell1 cell1 cell1 cell1 cell1 - - - cell2 cell2 cell2 cell2 cell2 cell2 cell2 - - - - - cell3 - - - cell4 - - - - - block after table - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      diff --git a/test/layoutengine/standard-testcases/table_border-collapse_collapse_2.xml b/test/layoutengine/standard-testcases/table_border-collapse_collapse_2.xml deleted file mode 100644 index cd2575822..000000000 --- a/test/layoutengine/standard-testcases/table_border-collapse_collapse_2.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - -

      - This test checks tables with collapse border model. Simple cell borders to start with. -

      -
      - - - - - - - - - - block before table - - - - - - - cell1 - - - cell2 - - - - - spanned - - - - - cell4 - - - cell5 - - - - - block after table - - - - - - - -
      diff --git a/test/layoutengine/standard-testcases/table_border-collapse_separate_1.xml b/test/layoutengine/standard-testcases/table_border-collapse_separate_1.xml index d0b11c1b0..8a9370a5c 100644 --- a/test/layoutengine/standard-testcases/table_border-collapse_separate_1.xml +++ b/test/layoutengine/standard-testcases/table_border-collapse_separate_1.xml @@ -31,7 +31,7 @@ - + diff --git a/test/layoutengine/standard-testcases/table_border_padding.xml b/test/layoutengine/standard-testcases/table_border_padding.xml index 7099d5dd1..385242903 100644 --- a/test/layoutengine/standard-testcases/table_border_padding.xml +++ b/test/layoutengine/standard-testcases/table_border_padding.xml @@ -66,8 +66,8 @@ - - + + @@ -95,7 +95,7 @@ - + @@ -106,7 +106,7 @@ - + @@ -121,19 +121,27 @@ - + + + - + - + + - + + + - + + + + 3 - + diff --git a/test/layoutengine/standard-testcases/table_bug44621.xml b/test/layoutengine/standard-testcases/table_bug44621.xml new file mode 100644 index 000000000..b4b9edbd0 --- /dev/null +++ b/test/layoutengine/standard-testcases/table_bug44621.xml @@ -0,0 +1,105 @@ + + + + + +

      + This is a testcase for bug #44621: when the width of the after border of a cell, in the + trailing case, is bigger than in the normal case, a wrong sequence of Knuth elements was + generated, leading to some content being swallowed. +

      +
      + + + + + + + + + + The after borders of the body’s cells, in the trailing case, + are thicker than in the normal case. + + + + + Footer 1.1 + + + Footer 1.2 + + + + + + Cell 1.1 + + + Cell 1.2 + + + + + Cell 2.1 + + + Cell 2.2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + + + + + 3 + + +
      diff --git a/test/layoutengine/standard-testcases/table_row-delay_fixed-row-height.xml b/test/layoutengine/standard-testcases/table_row-delay_fixed-row-height.xml index 70990de62..0c6ed10eb 100644 --- a/test/layoutengine/standard-testcases/table_row-delay_fixed-row-height.xml +++ b/test/layoutengine/standard-testcases/table_row-delay_fixed-row-height.xml @@ -144,9 +144,9 @@ 3 - - - + + + diff --git a/test/layoutengine/standard-testcases/table_row-height_break.xml b/test/layoutengine/standard-testcases/table_row-height_break.xml new file mode 100644 index 000000000..b6c7d8d37 --- /dev/null +++ b/test/layoutengine/standard-testcases/table_row-height_break.xml @@ -0,0 +1,87 @@ + + + + + +

      + This test checks that a forced break is still taken into account when the minimal height of a + row is not reached yet. +

      +
      + + + + + + + + + + The first row of the following table has a fixed height, and a forced break + occurs before this height is reached. + + + + + Cell 1 + Should be on a new page + + + Cell 2 + + + + + Cell 3 + + + Cell 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      -- 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/pdf') 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 7c637cc8f0a1f0ff305f6a2fa68018d50ee52170 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Mon, 21 Apr 2008 09:51:21 +0000 Subject: Merged revisions 649657,650050 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r649657 | spepping | 2008-04-18 20:07:57 +0100 (Fri, 18 Apr 2008) | 4 lines An implementation of a positive integer property maker. It implements convertProperty, which is the correct method to implement if one wants to add to the make process. This fixes bug 44619. ........ r650050 | jeremias | 2008-04-21 09:32:02 +0100 (Mon, 21 Apr 2008) | 1 line Partially reverted my revision 641827: The yellow tint of certain JPEG images came from badly extracted ICC color profiles. This is fixed in XML Graphics Commons Trunk (revision 650048). ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@650069 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FOPropertyMapping.java | 14 ++++----- .../org/apache/fop/fo/flow/table/TableFObj.java | 20 +------------ .../apache/fop/fo/properties/NumberProperty.java | 34 ++++++++++++++++++++++ .../apache/fop/render/pdf/ImageRawJPEGAdapter.java | 17 ----------- status.xml | 5 ---- 5 files changed, 42 insertions(+), 48 deletions(-) (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 539648f5a..db19d6515 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -1095,13 +1095,13 @@ public final class FOPropertyMapping implements Constants { addPropertyMaker("hyphenation-character", m); // hyphenation-push-character-count - m = new NumberProperty.Maker(PR_HYPHENATION_PUSH_CHARACTER_COUNT); + m = new NumberProperty.PositiveIntegerMaker(PR_HYPHENATION_PUSH_CHARACTER_COUNT); m.setInherited(true); m.setDefault("2"); addPropertyMaker("hyphenation-push-character-count", m); // hyphenation-remain-character-count - m = new NumberProperty.Maker(PR_HYPHENATION_REMAIN_CHARACTER_COUNT); + m = new NumberProperty.PositiveIntegerMaker(PR_HYPHENATION_REMAIN_CHARACTER_COUNT); m.setInherited(true); m.setDefault("2"); addPropertyMaker("hyphenation-remain-character-count", m); @@ -2137,7 +2137,7 @@ public final class FOPropertyMapping implements Constants { addPropertyMaker("blank-or-not-blank", m); // column-count - m = new NumberProperty.Maker(PR_COLUMN_COUNT); + m = new NumberProperty.PositiveIntegerMaker(PR_COLUMN_COUNT); m.setInherited(false); m.setDefault("1"); addPropertyMaker("column-count", m); @@ -2175,7 +2175,7 @@ public final class FOPropertyMapping implements Constants { addPropertyMaker("force-page-count", m); // initial-page-number - m = new NumberProperty.Maker(PR_INITIAL_PAGE_NUMBER); + m = new NumberProperty.PositiveIntegerMaker(PR_INITIAL_PAGE_NUMBER); m.setInherited(false); m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); m.addEnum("auto-odd", getEnumProperty(EN_AUTO_ODD, "AUTO_ODD")); @@ -2359,19 +2359,19 @@ public final class FOPropertyMapping implements Constants { addPropertyMaker("ends-row", m); // number-columns-repeated - m = new NumberProperty.Maker(PR_NUMBER_COLUMNS_REPEATED); + m = new NumberProperty.PositiveIntegerMaker(PR_NUMBER_COLUMNS_REPEATED); m.setInherited(false); m.setDefault("1"); addPropertyMaker("number-columns-repeated", m); // number-columns-spanned - m = new NumberProperty.Maker(PR_NUMBER_COLUMNS_SPANNED); + m = new NumberProperty.PositiveIntegerMaker(PR_NUMBER_COLUMNS_SPANNED); m.setInherited(false); m.setDefault("1"); addPropertyMaker("number-columns-spanned", m); // number-rows-spanned - m = new NumberProperty.Maker(PR_NUMBER_ROWS_SPANNED); + m = new NumberProperty.PositiveIntegerMaker(PR_NUMBER_ROWS_SPANNED); m.setInherited(false); m.setDefault("1"); addPropertyMaker("number-rows-spanned", m); 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 24528f622..9b60de740 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java +++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.java @@ -117,7 +117,7 @@ public abstract class TableFObj extends FObj { * PropertyMaker subclass for the column-number property * */ - public static class ColumnNumberPropertyMaker extends NumberProperty.Maker { + public static class ColumnNumberPropertyMaker extends NumberProperty.PositiveIntegerMaker { /** * Constructor @@ -153,24 +153,6 @@ public abstract class TableFObj extends FObj { = (ColumnNumberManagerHolder) propertyList.getParentFObj(); 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());*/ - 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);*/ - p = NumberProperty.getInstance(columnIndex); - } - } - int colSpan = propertyList.get(Constants.PR_NUMBER_COLUMNS_SPANNED) .getNumeric().getValue(); int i = -1; diff --git a/src/java/org/apache/fop/fo/properties/NumberProperty.java b/src/java/org/apache/fop/fo/properties/NumberProperty.java index 6f8d8a1d2..58400d76e 100644 --- a/src/java/org/apache/fop/fo/properties/NumberProperty.java +++ b/src/java/org/apache/fop/fo/properties/NumberProperty.java @@ -68,6 +68,40 @@ public final class NumberProperty extends Property implements Numeric { } + public static class PositiveIntegerMaker extends PropertyMaker { + + /** + * Constructor for NumberProperty.PositiveIntegerMaker + * @param propId the id of the property for which a PositiveIntegerMaker should be created + */ + public PositiveIntegerMaker(int propId) { + super(propId); + } + + /** + * If the value is not positive, return a property with value 1 + * + * {@inheritDoc} + */ + public Property convertProperty(Property p, + PropertyList propertyList, FObj fo) + throws PropertyException { + if (p instanceof EnumProperty) { + return EnumNumber.getInstance(p); + } + Number val = p.getNumber(); + if (val != null) { + int i = val.intValue(); + if (i <= 0) { + i = 1; + } + return getInstance(i); + } + return convertPropertyDatatype(p, propertyList, fo); + } + + } + /** cache holding all canonical NumberProperty instances */ private static final PropertyCache cache = new PropertyCache(); diff --git a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java index 1c8fceb50..1e505daed 100644 --- a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java +++ b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java @@ -18,7 +18,6 @@ /* $Id$ */ package org.apache.fop.render.pdf; -import java.awt.color.ICC_Profile; import java.io.DataInput; import java.io.IOException; import java.io.InputStream; @@ -36,7 +35,6 @@ import org.apache.fop.pdf.PDFDeviceColorSpace; import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFFilter; import org.apache.fop.pdf.PDFFilterList; -import org.apache.fop.util.ColorProfileUtil; /** * PDFImage implementation for the PDF renderer which handles raw JPEG images. @@ -81,21 +79,6 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter { return toPDFColorSpace(getImageColorSpace()); } - /** {@inheritDoc} */ - protected ICC_Profile getEffectiveICCProfile() { - ICC_Profile profile = super.getEffectiveICCProfile(); - if (profile != null - && profile.getNumComponents() == 3 - && !ColorProfileUtil.isDefaultsRGB(profile)) { - //RGB profiles which are not sRGB don't seem to work. - //Without this override, the image drifts into yellow for an unknown reason. - //TODO Find out why this happens. - //Test using a JPEG images with, for example, "Adobe RGB 1998" color profile. - profile = null; - } - return profile; - } - /** {@inheritDoc} */ public int getBitsPerComponent() { return 8; diff --git a/status.xml b/status.xml index 009c827c9..df47e25da 100644 --- a/status.xml +++ b/status.xml @@ -82,11 +82,6 @@ When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. - - Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which - are not sRGB. The images drifted into yellow. The color profile is simply disabled in this - case. Please let us know if you know what the problem could be. - Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. -- cgit v1.2.3 From 7a70e99012aece4d8c53121d11b454b43e432994 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Fri, 25 Apr 2008 13:12:30 +0000 Subject: Merged revisions 651575 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r651575 | adelmelle | 2008-04-25 12:27:19 +0100 (Fri, 25 Apr 2008) | 3 lines Bugzilla 44634: Added partial implementation for show-destination. Only works for PDF output, when the PDF is opened in a standalone viewer, and for links that point to destinations in another PDF document. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@651599 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/compliance.ihtml | 11 +- src/java/org/apache/fop/area/AreaTreeParser.java | 4 +- src/java/org/apache/fop/area/Trait.java | 192 +++++++++------------ src/java/org/apache/fop/fo/Constants.java | 8 +- src/java/org/apache/fop/fo/FOPropertyMapping.java | 11 +- src/java/org/apache/fop/fo/flow/BasicLink.java | 62 ++++--- .../layoutmgr/inline/BasicLinkLayoutManager.java | 14 +- .../fop/layoutmgr/inline/InlineLayoutManager.java | 11 +- src/java/org/apache/fop/pdf/PDFFactory.java | 38 ++-- src/java/org/apache/fop/pdf/PDFGoToRemote.java | 34 +++- .../org/apache/fop/render/pdf/PDFRenderer.java | 21 ++- status.xml | 5 + .../basic-link_external-destination.xml | 4 +- 13 files changed, 221 insertions(+), 194 deletions(-) (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/documentation/content/xdocs/compliance.ihtml b/src/documentation/content/xdocs/compliance.ihtml index 2b25b89d7..2c1af46c3 100644 --- a/src/documentation/content/xdocs/compliance.ihtml +++ b/src/documentation/content/xdocs/compliance.ihtml @@ -5276,9 +5276,16 @@
      - + - + diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index 19edd3d5e..d48221c0a 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -1018,7 +1018,7 @@ public class AreaTreeParser { Trait.IS_REFERENCE_AREA, Trait.IS_VIEWPORT_AREA}; private void setTraits(Attributes attributes, Area area, Object[] traitSubset) { - for (int i = 0, c = traitSubset.length; i < c; i++) { + for (int i = traitSubset.length; --i >= 0;) { Object trait = traitSubset[i]; String traitName = Trait.getTraitName(trait); String value = attributes.getValue(traitName); @@ -1044,6 +1044,8 @@ public class AreaTreeParser { } } else if (cl == InternalLink.class) { area.addTrait(trait, new InternalLink(value)); + } else if (cl == Trait.ExternalLink.class) { + area.addTrait(trait, Trait.ExternalLink.makeFromTraitValue(value)); } else if (cl == Background.class) { Background bkg = new Background(); try { diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index 98bed098c..9599d8833 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -194,7 +194,7 @@ public class Trait implements Serializable { public static final Integer OVERLINE_COLOR = new Integer(35); /** Trait for color of linethrough decorations when rendering inline parent. */ public static final Integer LINETHROUGH_COLOR = new Integer(36); - + /** Maximum value used by trait keys */ public static final int MAX_TRAIT_KEY = 36; @@ -226,7 +226,7 @@ public class Trait implements Serializable { // Create a hashmap mapping trait code to name for external representation //put(ID_LINK, new TraitInfo("id-link", String.class)); put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class)); - put(EXTERNAL_LINK, new TraitInfo("external-link", String.class)); + put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class)); put(FONT, new TraitInfo("font", FontTriplet.class)); put(FONT_SIZE, new TraitInfo("font-size", Integer.class)); put(COLOR, new TraitInfo("color", Color.class)); @@ -277,7 +277,7 @@ public class Trait implements Serializable { new TraitInfo("is-reference-area", Boolean.class)); put(IS_VIEWPORT_AREA, new TraitInfo("is-viewport-area", Boolean.class)); - + } /** @@ -290,25 +290,6 @@ public class Trait implements Serializable { return TRAIT_INFO[((Integer)traitCode).intValue()].getName(); } - /** - * Get the trait code for a trait name. - * - * @param sTraitName the name of the trait to find - * @return the trait code object - */ - /* - public static Object getTraitCode(String sTraitName) { - Iterator iter = TRAIT_INFO.entrySet().iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - TraitInfo ti = (TraitInfo) entry.getValue(); - if (ti != null && ti.getName().equals(sTraitName)) { - return entry.getKey(); - } - } - return null; - }*/ - /** * Get the data storage class for the trait. * @@ -319,99 +300,6 @@ public class Trait implements Serializable { return TRAIT_INFO[((Integer)traitCode).intValue()].getClazz(); } - /** - * The type of trait for an area. - */ - private Object propType; - - /** - * The data value of the trait. - */ - private Object data; - - /** - * Create a new empty trait. - */ - public Trait() { - this.propType = null; - this.data = null; - } - - /** - * Create a trait with the value and type. - * - * @param propType the type of trait - * @param data the data value - */ - public Trait(Object propType, Object data) { - this.propType = propType; - this.data = data; - } - - /** - * Returns the trait data value. - * @return the trait data value - */ - public Object getData() { - return this.data; - } - - /** - * Returns the property type. - * @return the property type - */ - public Object getPropType() { - return this.propType; - } - - /** - * Return the string for debugging. - * {@inheritDoc} - */ - public String toString() { - return data.toString(); - } - - /** - * Make a trait value. - * - * @param oCode trait code - * @param sTraitValue trait value as String - * @return the trait value as object - */ - /* - public static Object makeTraitValue(Object oCode, String sTraitValue) { - // Get the code from the name - // See what type of object it is - // Convert string value to an object of that type - Class tclass = getTraitClass(oCode); - if (tclass == null) { - return null; - } - if (tclass.equals(String.class)) { - return sTraitValue; - } - if (tclass.equals(Integer.class)) { - return new Integer(sTraitValue); - } - // See if the class has a constructor from string or can read from a string - try { - Object o = tclass.newInstance(); - //return o.fromString(sTraitValue); - } catch (IllegalAccessException e1) { - log.error("Can't create instance of " - + tclass.getName()); - return null; - } catch (InstantiationException e2) { - log.error("Can't create instance of " - + tclass.getName()); - return null; - } - - - return null; - }*/ - /** * Class for internal link traits. * Stores PageViewport key and producer ID @@ -547,6 +435,80 @@ public class Trait implements Serializable { } } + /** + * External Link trait structure + */ + public static class ExternalLink implements Serializable { + + private String destination; + private boolean newWindow; + + /** + * Constructs an ExternalLink object with the given destination + * + * @param destination target of the link + * @param newWindow true if the target should be opened in a new window + */ + public ExternalLink(String destination, boolean newWindow) { + this.destination = destination; + this.newWindow = newWindow; + } + + /** + * Create an ExternalLink from a trait value/attribute value in the + * area tree + * @param traitValue the value to use (should match the result of {@link #toString()} + * @return an ExternalLink instance corresponding to the given value + */ + protected static ExternalLink makeFromTraitValue(String traitValue) { + if (traitValue.indexOf(ExternalLink.class.getName()) == -1 + || traitValue.indexOf("dest=") == -1) { + throw new IllegalArgumentException( + "Malformed trait value for Trait.ExternalLink: " + traitValue); + } + int startIndex = traitValue.indexOf("dest=") + 5; + int endIndex = traitValue.indexOf(',', startIndex); + if (endIndex == -1) { + endIndex = traitValue.indexOf(']'); + } + String dest = traitValue.substring(startIndex, endIndex); + startIndex = traitValue.indexOf("newWindow=", endIndex) + 10; + endIndex = traitValue.indexOf(']', startIndex); + boolean newWindow = Boolean.parseBoolean( + traitValue.substring(startIndex, endIndex)); + return new ExternalLink(dest, newWindow); + } + + /** + * Get the target/destination of the link + * @return the destination of the link + */ + public String getDestination() { + return this.destination; + } + + /** + * Check if the target has to be displayed in a new window + * @return true if the target has to be displayed in a new window + */ + public boolean newWindow() { + return this.newWindow; + } + + /** + * Return a String representation of the object. + * @return a String of the form + * "org.apache.fop.area.Trait.ExternalLink[dest=someURL,newWindow=false]" + */ + public String toString() { + StringBuffer sb = new StringBuffer(64); + sb.append(super.toString()); + sb.append("[dest=").append(this.destination); + sb.append(",newWindow=").append(newWindow).append("]"); + return sb.toString(); + } + } + /** * Background trait structure. * Used for storing back trait information which are related. diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java index edfa68c1a..25c2fe371 100644 --- a/src/java/org/apache/fop/fo/Constants.java +++ b/src/java/org/apache/fop/fo/Constants.java @@ -1092,7 +1092,11 @@ public interface Constants { /** Enumeration constant -- for instream-foreign-object and external-graphic, XSL 1.1 */ 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; + int EN_SCALE_UP_TO_FIT = 188; + /** Enumeration constant -- for fo:basic-link show-destination */ + int EN_REPLACE = 189; + /** Enumeration constant -- for fo:basic-link show-destination */ + int EN_NEW = 190; /** Number of enumeration constants defined */ - int ENUM_COUNT = 188; + int ENUM_COUNT = 190; } diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index db19d6515..5d4185d68 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -258,7 +258,7 @@ public final class FOPropertyMapping implements Constants { /** * Return a (possibly cached) enum property based in the enum value. - * @param enum A enum value from Constants.java. + * @param enumValue A enum value from Constants.java. * @param text the text value by which this enum property is known * @return An EnumProperty instance. */ @@ -371,9 +371,8 @@ public final class FOPropertyMapping implements Constants { || ((id & Constants.PROPERTY_MASK) == 0)) { return (String) s_htPropIds.get(new Integer(id)); } else { - return (String) s_htPropIds.get(new Integer( - id & Constants.PROPERTY_MASK)) + "." + s_htPropIds.get( - new Integer(id & Constants.COMPOUND_MASK)); + return s_htPropIds.get(new Integer(id & Constants.PROPERTY_MASK)) + + "." + s_htPropIds.get(new Integer(id & Constants.COMPOUND_MASK)); } } @@ -2019,8 +2018,10 @@ public final class FOPropertyMapping implements Constants { addPropertyMaker("internal-destination", m); // show-destination - m = new ToBeImplementedProperty.Maker(PR_SHOW_DESTINATION); + m = new EnumProperty.Maker(PR_SHOW_DESTINATION); m.setInherited(false); + m.addEnum("new", getEnumProperty(EN_NEW, "NEW")); + m.addEnum("replace", getEnumProperty(EN_REPLACE, "REPLACE")); m.setDefault("replace"); addPropertyMaker("show-destination", m); diff --git a/src/java/org/apache/fop/fo/flow/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java index b3ef48012..82d0134bd 100644 --- a/src/java/org/apache/fop/fo/flow/BasicLink.java +++ b/src/java/org/apache/fop/fo/flow/BasicLink.java @@ -27,19 +27,21 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; /** - * Class modelling the fo:basic-link object. + * Class modelling the + * 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 * reference). */ public class BasicLink extends Inline { + // The value of properties relevant for fo:basic-link. // private ToBeImplementedProperty destinationPlacementOffset; private String externalDestination; // private ToBeImplementedProperty indicateDestination; private String internalDestination; - // private ToBeImplementedProperty showDestination; + private int showDestination; // private ToBeImplementedProperty targetProcessingContext; // private ToBeImplementedProperty targetPresentationContext; // private ToBeImplementedProperty targetStylesheet; @@ -51,22 +53,23 @@ public class BasicLink extends Inline { private boolean blockOrInlineItemFound = false; /** - * @param parent FONode that is the parent of this object + * 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) { super(parent); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void bind(PropertyList pList) throws FOPException { super.bind(pList); // destinationPlacementOffset = pList.get(PR_DESTINATION_PLACEMENT_OFFSET); externalDestination = pList.get(PR_EXTERNAL_DESTINATION).getString(); // indicateDestination = pList.get(PR_INDICATE_DESTINATION); internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString(); - // showDestination = pList.get(PR_SHOW_DESTINATION); + showDestination = pList.get(PR_SHOW_DESTINATION).getEnum(); // targetProcessingContext = pList.get(PR_TARGET_PROCESSING_CONTEXT); // targetPresentationContext = pList.get(PR_TARGET_PRESENTATION_CONTEXT); // targetStylesheet = pList.get(PR_TARGET_STYLESHEET); @@ -80,26 +83,19 @@ public class BasicLink extends Inline { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); getFOEventHandler().startLink(this); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endLink(); } - /** - * {@inheritDoc} String, String) - * XSL Content Model: marker* (#PCDATA|%inline;|%block;)* - */ + /** {@inheritDoc} */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { if (FO_URI.equals(nsURI)) { @@ -116,39 +112,61 @@ public class BasicLink extends Inline { } /** - * @return the "internal-destination" property. + * Get the value of the internal-destination property. + * + * @return the "internal-destination" property */ public String getInternalDestination() { return internalDestination; } /** - * @return the "external-destination" property. + * Get the value of the external-destination property. + * + * @return the "external-destination" property */ public String getExternalDestination() { return externalDestination; } /** - * @return whether or not this basic link has an internal destination or not + * Convenience method to check if this instance has an internal destination. + * + * @return true if this basic link has an internal destination; + * false otherwise */ public boolean hasInternalDestination() { return internalDestination != null && internalDestination.length() > 0; } /** - * @return whether or not this basic link has an external destination or not + * Convenience method to check if this instance has an external destination + * + * @return true if this basic link has an external destination; + * false otherwise */ public boolean hasExternalDestination() { return externalDestination != null && externalDestination.length() > 0; } + /** + * Get the value of the show-destination property. + * + * @return the "show-destination" property + */ + public int getShowDestination() { + return this.showDestination; + } + /** {@inheritDoc} */ public String getLocalName() { return "basic-link"; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @return {@link org.apache.fop.fo.Constants#FO_BASIC_LINK} + */ public int getNameId() { return FO_BASIC_LINK; } diff --git a/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java index e7339034c..b8979e187 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java @@ -21,7 +21,7 @@ package org.apache.fop.layoutmgr.inline; import org.apache.fop.datatypes.URISpecification; import org.apache.fop.fo.flow.BasicLink; -import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.fo.Constants; import org.apache.fop.layoutmgr.PageSequenceLayoutManager; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.Trait; @@ -31,7 +31,6 @@ import org.apache.fop.area.LinkResolver; * LayoutManager for the fo:basic-link formatting object */ public class BasicLinkLayoutManager extends InlineLayoutManager { - private BasicLink fobj; /** * Create an fo:basic-link layout manager. @@ -40,23 +39,22 @@ public class BasicLinkLayoutManager extends InlineLayoutManager { */ public BasicLinkLayoutManager(BasicLink node) { super(node); - fobj = node; } /** {@inheritDoc} */ protected InlineArea createArea(boolean bInlineParent) { InlineArea area = super.createArea(bInlineParent); - setupBasicLinkArea(parentLM, area); + setupBasicLinkArea(area); return area; } /* * Detect internal or external link and add it as an area trait * - * @param parentLM the parent LayoutManager * @param area the basic-link's area */ - private void setupBasicLinkArea(LayoutManager parentLM, InlineArea area) { + private void setupBasicLinkArea(InlineArea area) { + BasicLink fobj = (BasicLink) this.fobj; // internal destinations take precedence: if (fobj.hasInternalDestination()) { String idref = fobj.getInternalDestination(); @@ -70,8 +68,10 @@ public class BasicLinkLayoutManager extends InlineLayoutManager { } } else if (fobj.hasExternalDestination()) { String url = URISpecification.getURL(fobj.getExternalDestination()); + boolean newWindow = (fobj.getShowDestination() == Constants.EN_NEW); if (url.length() > 0) { - area.addTrait(Trait.EXTERNAL_LINK, url); + area.addTrait(Trait.EXTERNAL_LINK, + new Trait.ExternalLink(url, newWindow)); } } } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java index f3bb66022..b59f0466a 100755 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java @@ -68,8 +68,6 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { */ private static Log log = LogFactory.getLog(InlineLayoutManager.class); - private InlineLevel fobj; - private CommonMarginInline inlineProps = null; private CommonBorderPaddingBackground borderProps = null; @@ -105,7 +103,6 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { // The node should be FObjMixed public InlineLayoutManager(InlineLevel node) { super(node); - fobj = node; } private Inline getInlineFO() { @@ -114,6 +111,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { /** {@inheritDoc} */ public void initialize() { + InlineLevel fobj = (InlineLevel) this.fobj; + int padding = 0; FontInfo fi = fobj.getFOEventHandler().getFontInfo(); FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); @@ -555,7 +554,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { if (returnList instanceof BlockKnuthSequence) { return; } - CommonBorderPaddingBackground borderAndPadding = fobj.getCommonBorderPaddingBackground(); + CommonBorderPaddingBackground borderAndPadding = + ((InlineLevel)fobj).getCommonBorderPaddingBackground(); if (borderAndPadding != null) { int ipStart = borderAndPadding.getBorderStartWidth(false) + borderAndPadding.getPaddingStart(false, this); @@ -579,7 +579,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { if (returnList instanceof BlockKnuthSequence) { return; } - CommonBorderPaddingBackground borderAndPadding = fobj.getCommonBorderPaddingBackground(); + CommonBorderPaddingBackground borderAndPadding = + ((InlineLevel)fobj).getCommonBorderPaddingBackground(); if (borderAndPadding != null) { int ipEnd = borderAndPadding.getBorderEndWidth(false) + borderAndPadding.getPaddingEnd(false, this); diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index f4474331f..02f0c2cdb 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -724,6 +724,7 @@ public class PDFFactory { * @param theColors the list of colors for the gradient * @param theBounds the list of bounds associated with the colors * @param theCoords the coordinates for the gradient + * @param theMatrix the coordinate-transformation matrix * @return the PDF pattern that was created */ public PDFPattern makeGradient(PDFResourceContext res, boolean radial, @@ -737,7 +738,7 @@ public class PDFFactory { List theCone; PDFPattern myPattern; //PDFColorSpace theColorSpace; - double interpolation = (double)1.000; + double interpolation = 1.000; List theFunctions = new ArrayList(); int currentPosition; @@ -874,7 +875,8 @@ public class PDFFactory { */ public PDFDests makeDests(List destinationList) { PDFDests dests; - + + //TODO: Check why the below conditional branch is needed. Condition is always true... final boolean deep = true; //true for a "deep" structure (one node per entry), true for a "flat" structure if (deep) { @@ -961,7 +963,7 @@ public class PDFFactory { } /** - * make a link object + * Make a {@link PDFLink} object * * @param rect the clickable rectangle * @param destination the destination file @@ -976,7 +978,7 @@ public class PDFFactory { PDFLink link = new PDFLink(rect); if (linkType == PDFLink.EXTERNAL) { - link.setAction(getExternalAction(destination)); + link.setAction(getExternalAction(destination, false)); } else { // linkType is internal String goToReference = getGoToReference(destination, yoffset); @@ -999,9 +1001,11 @@ public class PDFFactory { * * @param target The external target. This may be a PDF file name * (optionally with internal page number or destination) or any type of URI. + * @param newWindow boolean indicating whether the target should be + * displayed in a new window * @return the PDFAction thus created or found */ - public PDFAction getExternalAction(String target) { + public PDFAction getExternalAction(String target, boolean newWindow) { int index; String targetLo = target.toLowerCase(); // HTTP URL? @@ -1009,17 +1013,17 @@ public class PDFFactory { return new PDFUri(target); // Bare PDF file name? } else if (targetLo.endsWith(".pdf")) { - return getGoToPDFAction(target, null, -1); + return getGoToPDFAction(target, null, -1, newWindow); // PDF file + page? } else if ((index = targetLo.indexOf(".pdf#page=")) > 0) { String filename = target.substring(0, index + 4); int page = Integer.parseInt(target.substring(index + 10)); - return getGoToPDFAction(filename, null, page); + return getGoToPDFAction(filename, null, page, newWindow); // PDF file + destination? } else if ((index = targetLo.indexOf(".pdf#dest=")) > 0) { String filename = target.substring(0, index + 4); String dest = target.substring(index + 10); - return getGoToPDFAction(filename, dest, -1); + return getGoToPDFAction(filename, dest, -1, newWindow); // None of the above? Default to URI: } else { return new PDFUri(target); @@ -1069,9 +1073,11 @@ public class PDFFactory { * @param file the pdf file name * @param dest the remote name destination, may be null * @param page the remote page number, -1 means not specified + * @param newWindow boolean indicating whether the target should be + * displayed in a new window * @return the pdf goto remote object */ - private PDFGoToRemote getGoToPDFAction(String file, String dest, int page) { + private PDFGoToRemote getGoToPDFAction(String file, String dest, int page, boolean newWindow) { getDocument().getProfile().verifyActionAllowed(); PDFFileSpec fileSpec = new PDFFileSpec(file); PDFFileSpec oldspec = getDocument().findFileSpec(fileSpec); @@ -1083,11 +1089,11 @@ public class PDFFactory { PDFGoToRemote remote; if (dest == null && page == -1) { - remote = new PDFGoToRemote(fileSpec); + remote = new PDFGoToRemote(fileSpec, newWindow); } else if (dest != null) { - remote = new PDFGoToRemote(fileSpec, dest); + remote = new PDFGoToRemote(fileSpec, dest, newWindow); } else { - remote = new PDFGoToRemote(fileSpec, page); + remote = new PDFGoToRemote(fileSpec, page, newWindow); } PDFGoToRemote oldremote = getDocument().findGoToRemote(remote); if (oldremote == null) { @@ -1197,8 +1203,7 @@ public class PDFFactory { PDFFontDescriptor pdfdesc = makeFontDescriptor(descriptor); PDFFont font = null; - font = (PDFFont)PDFFont.createFont(fontname, fonttype, - basefont, encoding); + font = PDFFont.createFont(fontname, fonttype, basefont, encoding); getDocument().registerObject(font); if (fonttype == FontType.TYPE0) { @@ -1298,6 +1303,7 @@ public class PDFFactory { /** * Creates a PDFEncoding instance from a CodePointMapping instance. * @param encoding the code point mapping (encoding) + * @param fontNameHint ... * @return the PDF Encoding dictionary (or a String with the predefined encoding) */ public Object createPDFEncoding(SingleByteEncoding encoding, String fontNameHint) { @@ -1458,6 +1464,7 @@ public class PDFFactory { try { in = new java.net.URL(source.getSystemId()).openStream(); } catch (MalformedURLException e) { + //TODO: Why construct a new exception here, when it is not thrown? new FileNotFoundException( "File not found. URL could not be resolved: " + e.getMessage()); @@ -1514,7 +1521,7 @@ public class PDFFactory { log.error( "Failed to embed font [" + desc + "] " + desc.getEmbedFontName(), ioe); - return (PDFStream) null; + return null; } } @@ -1563,7 +1570,6 @@ public class PDFFactory { /** * Create a PDFICCStream * @see PDFImageXObject - * @see org.apache.fop.image.JpegImage * @see org.apache.fop.pdf.PDFDeviceColorSpace * @return the new PDF ICC stream object */ diff --git a/src/java/org/apache/fop/pdf/PDFGoToRemote.java b/src/java/org/apache/fop/pdf/PDFGoToRemote.java index 71cae5ba6..2cd937df3 100644 --- a/src/java/org/apache/fop/pdf/PDFGoToRemote.java +++ b/src/java/org/apache/fop/pdf/PDFGoToRemote.java @@ -20,7 +20,7 @@ package org.apache.fop.pdf; /** - * class representing a /GoToR object. + * Class representing a /GoToR object. */ public class PDFGoToRemote extends PDFAction { @@ -30,17 +30,21 @@ public class PDFGoToRemote extends PDFAction { private PDFFileSpec pdfFileSpec; private int pageReference = 0; private String destination = null; + private boolean newWindow = false; /** - * create an GoToR object. + * Create an GoToR object. * * @param pdfFileSpec the fileSpec associated with the action + * @param newWindow boolean indicating whether the target should be + * displayed in a new window */ - public PDFGoToRemote(PDFFileSpec pdfFileSpec) { + public PDFGoToRemote(PDFFileSpec pdfFileSpec, boolean newWindow) { /* generic creation of object */ super(); this.pdfFileSpec = pdfFileSpec; + this.newWindow = newWindow; } /** @@ -48,13 +52,16 @@ public class PDFGoToRemote extends PDFAction { * * @param pdfFileSpec the fileSpec associated with the action * @param page a page reference within the remote document + * @param newWindow boolean indicating whether the target should be + * displayed in a new window */ - public PDFGoToRemote(PDFFileSpec pdfFileSpec, int page) { + public PDFGoToRemote(PDFFileSpec pdfFileSpec, int page, boolean newWindow) { /* generic creation of object */ super(); this.pdfFileSpec = pdfFileSpec; this.pageReference = page; + this.newWindow = newWindow; } /** @@ -62,13 +69,16 @@ public class PDFGoToRemote extends PDFAction { * * @param pdfFileSpec the fileSpec associated with the action * @param dest a named destination within the remote document + * @param newWindow boolean indicating whether the target should be + * displayed in a new window */ - public PDFGoToRemote(PDFFileSpec pdfFileSpec, String dest) { + public PDFGoToRemote(PDFFileSpec pdfFileSpec, String dest, boolean newWindow) { /* generic creation of object */ super(); this.pdfFileSpec = pdfFileSpec; this.destination = dest; + this.newWindow = newWindow; } /** @@ -86,12 +96,18 @@ public class PDFGoToRemote extends PDFAction { public String toPDFString() { StringBuffer sb = new StringBuffer(64); sb.append(getObjectID()); - sb.append("<<\n/S /GoToR\n/F " + pdfFileSpec.referencePDF() + "\n"); + sb.append("<<\n/S /GoToR\n/F "); + sb.append(pdfFileSpec.referencePDF()); + sb.append("\n"); if (destination != null) { - sb.append("/D (" + this.destination + ")"); + sb.append("/D (").append(this.destination).append(")"); } else { - sb.append("/D [ " + this.pageReference + " /XYZ null null null ]"); + sb.append("/D [ ").append(this.pageReference).append(" /XYZ null null null ]"); + } + + if (newWindow) { + sb.append("/NewWindow true"); } sb.append(" \n>>\nendobj\n"); @@ -142,7 +158,7 @@ public class PDFGoToRemote extends PDFAction { } } - return true; + return (this.newWindow == remote.newWindow); } } diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index d2c8446eb..eae961e9b 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -837,7 +837,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * @param value the value * @return the formatted value */ - protected static final String format(float value) { + protected static String format(float value) { return PDFNumber.doubleOut(value); } @@ -1134,9 +1134,11 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * (i.e. if the area qualifies as a link target). * Otherwise, or if the area has no id, null is returned. * - * NOTE : area must be on currentPageViewport, otherwise result may be wrong! + * NOTE: area must be on currentPageViewport, otherwise result may be wrong! * * @param area the area for which to return the id + * @return the area's id (null if the area has no id or + * other preceding areas have the same id) */ protected String getTargetableID(Area area) { String id = (String) area.getTrait(Trait.PROD_ID); @@ -1374,11 +1376,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { // no INTERNAL_LINK, look for EXTERNAL_LINK if (!linkTraitFound) { - String extDest = (String) ip.getTrait(Trait.EXTERNAL_LINK); - if (extDest != null && extDest.length() > 0) { - linkTraitFound = true; - if (annotsAllowed) { - action = factory.getExternalAction(extDest); + Trait.ExternalLink extLink = (Trait.ExternalLink) ip.getTrait(Trait.EXTERNAL_LINK); + if (extLink != null) { + String extDest = extLink.getDestination(); + if (extDest != null && extDest.length() > 0) { + linkTraitFound = true; + if (annotsAllowed) { + action = factory.getExternalAction(extDest, extLink.newWindow()); + } } } } @@ -1610,7 +1615,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced. * @param uri URL of the bitmap * @param pos Position of the bitmap - * @deprecated Use {@link @putImage(String, Rectangle2D, Map)} instead. + * @deprecated Use {@link #putImage(String, Rectangle2D, Map)} instead. */ protected void putImage(String uri, Rectangle2D pos) { putImage(uri, pos, null); diff --git a/status.xml b/status.xml index 0b2b2ac38..7d813f6f8 100644 --- a/status.xml +++ b/status.xml @@ -53,11 +53,16 @@ + + + Add partial support for the "show-destination" property on fo:basic-link + (PDF output only; see limitations on the compliance page) Added minimal support for integer keep values on the various keep properties on block-level diff --git a/test/layoutengine/standard-testcases/basic-link_external-destination.xml b/test/layoutengine/standard-testcases/basic-link_external-destination.xml index 6f7ba77d6..690248d19 100644 --- a/test/layoutengine/standard-testcases/basic-link_external-destination.xml +++ b/test/layoutengine/standard-testcases/basic-link_external-destination.xml @@ -38,7 +38,7 @@ - - + + -- cgit v1.2.3 From d5fb8b71ba22f39d1e5e311104e8a47d597bc214 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Fri, 4 Jul 2008 13:21:43 +0000 Subject: Merged revisions 672833,674039,674043 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r672833 | adelmelle | 2008-06-30 18:34:41 +0100 (Mon, 30 Jun 2008) | 2 lines Added check for the case where column-number is specified on something other than a fo:table-cell or fo:table-column (strictly not an error) ........ r674039 | acumiskey | 2008-07-04 14:13:29 +0100 (Fri, 04 Jul 2008) | 2 lines Minor readability improvement. ........ r674043 | acumiskey | 2008-07-04 14:17:06 +0100 (Fri, 04 Jul 2008) | 3 lines The pdf StringBuffer is only used on these two lines and doesn't seem to do anything... Very strange... :-S ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@674045 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/render/pdf/PDFRenderer.java | 3 --- test/fotree/testcases/column-number_cells_rows.fo | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index eae961e9b..0723d62f0 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -1415,7 +1415,6 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { updateColor(ct, true); beginTextObject(); - StringBuffer pdf = new StringBuffer(); String fontName = getInternalFontNameForArea(text); int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); @@ -1434,8 +1433,6 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { textutil.writeTextMatrix(new AffineTransform(1, 0, 0, -1, rx / 1000f, bl / 1000f)); - currentStream.add(pdf.toString()); - super.renderText(text); textutil.writeTJ(); diff --git a/test/fotree/testcases/column-number_cells_rows.fo b/test/fotree/testcases/column-number_cells_rows.fo index 2d48e8ceb..90486d5fb 100644 --- a/test/fotree/testcases/column-number_cells_rows.fo +++ b/test/fotree/testcases/column-number_cells_rows.fo @@ -181,6 +181,10 @@ + + + Test column-number when specified on fo:block + -- cgit v1.2.3 From ccb0ccb674eb0cdd014a0ca236403a640bb57fdf Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Mon, 7 Jul 2008 12:48:50 +0000 Subject: Merged revisions 674245,674267,674269,674272-674273,674276,674325,674468,674470-674471 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r674245 | adelmelle | 2008-07-05 23:53:58 +0100 (Sat, 05 Jul 2008) | 1 line Fixed ClassCastException when specifying column-number on something other than a fo:table-column or fo:table-cell... ........ r674267 | adelmelle | 2008-07-06 08:50:23 +0100 (Sun, 06 Jul 2008) | 1 line Switch AreaTreeParser to use a java.nio.CharBuffer, and ignore characters events for all elements other than , or ........ r674269 | adelmelle | 2008-07-06 09:15:50 +0100 (Sun, 06 Jul 2008) | 1 line Remove deprecated Character area class ........ r674272 | adelmelle | 2008-07-06 09:44:54 +0100 (Sun, 06 Jul 2008) | 1 line Redo changes made in r674056... ........ r674273 | adelmelle | 2008-07-06 09:46:50 +0100 (Sun, 06 Jul 2008) | 1 line Simplified implementation of Area.getTraitAsBoolean() ........ r674276 | adelmelle | 2008-07-06 10:17:14 +0100 (Sun, 06 Jul 2008) | 3 lines Extracted conversion methods for String to int[] or double[] to a utility class. Made AreaTreeParser.getAttributeAsXXX() methods static to stress their utility character, and removed the private parseRect() in favor of getAttributeAsRectangle2D(). ........ r674325 | adelmelle | 2008-07-06 19:19:48 +0100 (Sun, 06 Jul 2008) | 1 line Fixed error; inadvertently switched the condition with r674272... ........ r674468 | acumiskey | 2008-07-07 13:36:57 +0100 (Mon, 07 Jul 2008) | 1 line Possible NullPointerException avoided ........ r674470 | acumiskey | 2008-07-07 13:38:04 +0100 (Mon, 07 Jul 2008) | 1 line Added new set accessor method for EncryptionParams. ........ r674471 | acumiskey | 2008-07-07 13:42:12 +0100 (Mon, 07 Jul 2008) | 1 line Added PDF encryption parameter support in configuration. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@674476 13f79535-47bb-0310-9956-ffa450edef68 --- .../content/xdocs/trunk/configuration.xml | 21 +++ src/java/org/apache/fop/area/Area.java | 8 +- src/java/org/apache/fop/area/AreaTreeParser.java | 169 +++++++++------------ src/java/org/apache/fop/area/inline/Character.java | 62 -------- .../org/apache/fop/fo/flow/table/TableFObj.java | 114 ++++++++------ src/java/org/apache/fop/pdf/PDFDocument.java | 6 +- .../org/apache/fop/render/AbstractRenderer.java | 22 +-- .../org/apache/fop/render/pdf/PDFRenderer.java | 8 + .../fop/render/pdf/PDFRendererConfigurator.java | 48 +++++- src/java/org/apache/fop/util/ConversionUtils.java | 110 ++++++++++++++ status.xml | 3 + 11 files changed, 339 insertions(+), 232 deletions(-) delete mode 100644 src/java/org/apache/fop/area/inline/Character.java create mode 100644 src/java/org/apache/fop/util/ConversionUtils.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/documentation/content/xdocs/trunk/configuration.xml b/src/documentation/content/xdocs/trunk/configuration.xml index e27ae94df..81b4d40ac 100644 --- a/src/documentation/content/xdocs/trunk/configuration.xml +++ b/src/documentation/content/xdocs/trunk/configuration.xml @@ -294,6 +294,27 @@ ]]> + +

      FOP supports encryption of PDF output, thanks to Patrick C. Lankswert. + This feature is commonly used to prevent unauthorized viewing, printing, editing, copying text + from the document and doing annotations. It is also possible to ask the user for a password in + order to view the contents. Note that there already exist third party applications which can + decrypt an encrypted PDF without effort and allow the aforementioned operations, therefore the + degree of protection is limited. For further information about features and restrictions + regarding PDF encryption, look at the documentation coming with Adobe Acrobat or the technical + documentation on the Adobe web site.

      + + + testuserpass + testownerpass + + + + + + ]]> +
      Special Settings for the PostScript Renderer diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java index 9c0fc8db6..ab9590685 100644 --- a/src/java/org/apache/fop/area/Area.java +++ b/src/java/org/apache/fop/area/Area.java @@ -417,17 +417,11 @@ public class Area extends AreaTreeObject implements Serializable { /** * Get a boolean trait from this area. - * * @param oTraitCode the trait key * @return the trait value */ public boolean getTraitAsBoolean(Object oTraitCode) { - final Object obj = getTrait(oTraitCode); - if (obj instanceof Boolean) { - return ((Boolean)obj).booleanValue(); - } else { - return false; - } + return Boolean.TRUE.equals(getTrait(oTraitCode)); } /** diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index d48221c0a..6d9fd4f32 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Set; import java.util.Stack; import java.util.StringTokenizer; +import java.nio.CharBuffer; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -56,7 +57,6 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.area.Trait.Background; import org.apache.fop.area.Trait.InternalLink; import org.apache.fop.area.inline.AbstractTextArea; -import org.apache.fop.area.inline.Character; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.Image; import org.apache.fop.area.inline.InlineArea; @@ -78,6 +78,7 @@ import org.apache.fop.traits.BorderProps; import org.apache.fop.util.ColorUtil; import org.apache.fop.util.ContentHandlerFactory; import org.apache.fop.util.ContentHandlerFactoryRegistry; +import org.apache.fop.util.ConversionUtils; import org.apache.fop.util.DefaultErrorListener; /** @@ -132,8 +133,10 @@ public class AreaTreeParser { private ElementMappingRegistry elementMappingRegistry; private Attributes lastAttributes; - private StringBuffer content = new StringBuffer(); + 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: @@ -176,7 +179,6 @@ public class AreaTreeParser { makers.put("text", new TextMaker()); makers.put("word", new WordMaker()); makers.put("space", new SpaceMaker()); - makers.put("char", new CharMaker()); makers.put("leader", new LeaderMaker()); makers.put("viewport", new ViewportMaker()); makers.put("image", new ImageMaker()); @@ -186,15 +188,6 @@ public class AreaTreeParser { makers.put("destination", new DestinationMaker()); } - private static Rectangle2D parseRect(String rect) { - StringTokenizer tokenizer = new StringTokenizer(rect, " "); - return new Rectangle2D.Double( - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken())); - } - private Area findAreaType(Class clazz) { if (areaStack.size() > 0) { int pos = areaStack.size() - 1; @@ -261,7 +254,10 @@ public class AreaTreeParser { boolean handled = true; if ("".equals(uri)) { Maker maker = (Maker)makers.get(localName); + content.clear(); + ignoreCharacters = true; if (maker != null) { + ignoreCharacters = maker.ignoreCharacters(); maker.startElement(attributes); } else if ("extension-attachments".equals(localName)) { //TODO implement me @@ -311,11 +307,12 @@ public class AreaTreeParser { Maker maker = (Maker)makers.get(localName); if (maker != null) { maker.endElement(); + content.clear(); } + ignoreCharacters = true; } else { //log.debug("Ignoring " + localName + " in namespace: " + uri); } - content.setLength(0); //Reset text buffer (see characters()) } } @@ -324,6 +321,7 @@ public class AreaTreeParser { private static interface Maker { void startElement(Attributes attributes) throws SAXException; void endElement(); + boolean ignoreCharacters(); } private abstract class AbstractMaker implements Maker { @@ -335,6 +333,10 @@ public class AreaTreeParser { public void endElement() { //nop } + + public boolean ignoreCharacters() { + return true; + } } private class AreaTreeMaker extends AbstractMaker { @@ -384,7 +386,7 @@ public class AreaTreeParser { if (currentPageViewport != null) { throw new IllegalStateException("currentPageViewport must be null"); } - Rectangle2D viewArea = parseRect(attributes.getValue("bounds")); + Rectangle2D viewArea = getAttributeAsRectangle2D(attributes, "bounds"); int pageNumber = getAttributeAsInteger(attributes, "nr", -1); String key = attributes.getValue("key"); String pageNumberString = attributes.getValue("formatted-nr"); @@ -420,7 +422,7 @@ public class AreaTreeParser { if (rv != null) { throw new IllegalStateException("Current RegionViewport must be null"); } - Rectangle2D viewArea = parseRect(attributes.getValue("rect")); + Rectangle2D viewArea = getAttributeAsRectangle2D(attributes, "rect"); rv = new RegionViewport(viewArea); transferForeignObjects(attributes, rv); rv.setClip(getAttributeAsBoolean(attributes, "clipped", false)); @@ -444,7 +446,7 @@ public class AreaTreeParser { public void endElement() { assertObjectOfClass(areaStack.pop(), RegionReference.class); - } + } } private class RegionAfterMaker extends AbstractMaker { @@ -455,7 +457,7 @@ public class AreaTreeParser { public void endElement() { assertObjectOfClass(areaStack.pop(), RegionReference.class); - } + } } private class RegionStartMaker extends AbstractMaker { @@ -466,7 +468,7 @@ public class AreaTreeParser { public void endElement() { assertObjectOfClass(areaStack.pop(), RegionReference.class); - } + } } private class RegionEndMaker extends AbstractMaker { @@ -477,7 +479,7 @@ public class AreaTreeParser { public void endElement() { assertObjectOfClass(areaStack.pop(), RegionReference.class); - } + } } private class RegionBodyMaker extends AbstractMaker { @@ -575,7 +577,7 @@ public class AreaTreeParser { public void endElement() { assertObjectOfClass(areaStack.pop(), BeforeFloat.class); - } + } } private class BlockMaker extends AbstractMaker { @@ -627,7 +629,7 @@ public class AreaTreeParser { public void endElement() { assertObjectOfClass(areaStack.pop(), Block.class); - } + } } private class LineAreaMaker extends AbstractMaker { @@ -735,47 +737,37 @@ public class AreaTreeParser { public void endElement() { assertObjectOfClass(areaStack.pop(), TextArea.class); - } + } } private class WordMaker extends AbstractMaker { - private int[] toIntArray(String s) { - if (s == null || s.length() == 0) { - return null; - } - StringTokenizer tokenizer = new StringTokenizer(s, " "); - List values = new java.util.ArrayList(); - while (tokenizer.hasMoreTokens()) { - values.add(new Integer(tokenizer.nextToken())); - } - int[] res = new int[values.size()]; - for (int i = 0, c = res.length; i < c; i++) { - res[i] = ((Integer)values.get(i)).intValue(); - } - return res; - } - public void endElement() { int offset = getAttributeAsInteger(lastAttributes, "offset", 0); - int[] letterAdjust = toIntArray(lastAttributes.getValue("letter-adjust")); - String txt = content.toString(); - WordArea word = new WordArea(txt, offset, letterAdjust); + int[] letterAdjust + = ConversionUtils.toIntArray( + lastAttributes.getValue("letter-adjust"), "\\s"); + content.flip(); + WordArea word = new WordArea(content.toString().trim(), offset, letterAdjust); AbstractTextArea text = getCurrentText(); 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); - String txt = content.toString(); //TODO the isAdjustable parameter is currently not used/implemented - if (txt.length() > 0) { + if (content.position() > 0) { + content.flip(); boolean adjustable = getAttributeAsBoolean(lastAttributes, "adj", true); - SpaceArea space = new SpaceArea(txt.charAt(0), offset, adjustable); + SpaceArea space = new SpaceArea(content.charAt(0), offset, adjustable); AbstractTextArea text = getCurrentText(); space.setParentArea(text); text.addChildArea(space); @@ -789,25 +781,11 @@ public class AreaTreeParser { Area parent = (Area)areaStack.peek(); parent.addChildArea(space); } - } - } - - private class CharMaker extends AbstractMaker { - - public void endElement() { - String txt = content.toString(); - Character ch = new Character(txt.charAt(0)); - transferForeignObjects(lastAttributes, ch); - setAreaAttributes(lastAttributes, ch); - setTraits(lastAttributes, ch, SUBSET_COMMON); - setTraits(lastAttributes, ch, SUBSET_BOX); - setTraits(lastAttributes, ch, SUBSET_COLOR); - setTraits(lastAttributes, ch, SUBSET_FONT); - ch.setOffset(getAttributeAsInteger(lastAttributes, "offset", 0)); - ch.setBaselineOffset(getAttributeAsInteger(lastAttributes, "baseline", 0)); - Area parent = (Area)areaStack.peek(); - parent.addChildArea(ch); - } + } + + public boolean ignoreCharacters() { + return false; + } } private class LeaderMaker extends AbstractMaker { @@ -830,9 +808,6 @@ public class AreaTreeParser { Area parent = (Area)areaStack.peek(); parent.addChildArea(leader); } - - public void endElement() { - } } private class ViewportMaker extends AbstractMaker { @@ -854,7 +829,7 @@ public class AreaTreeParser { public void endElement() { assertObjectOfClass(areaStack.pop(), Viewport.class); - } + } } private class ImageMaker extends AbstractMaker { @@ -1097,7 +1072,7 @@ public class AreaTreeParser { } } - private boolean getAttributeAsBoolean(Attributes attributes, String name, + private static boolean getAttributeAsBoolean(Attributes attributes, String name, boolean defaultValue) { String s = attributes.getValue(name); if (s == null) { @@ -1107,7 +1082,7 @@ public class AreaTreeParser { } } - private int getAttributeAsInteger(Attributes attributes, String name, + private static int getAttributeAsInteger(Attributes attributes, String name, int defaultValue) { String s = attributes.getValue(name); if (s == null) { @@ -1117,36 +1092,30 @@ public class AreaTreeParser { } } - private CTM getAttributeAsCTM(Attributes attributes, String name) { + private static CTM getAttributeAsCTM(Attributes attributes, String name) { String s = attributes.getValue(name).trim(); if (s.startsWith("[") && s.endsWith("]")) { s = s.substring(1, s.length() - 1); - StringTokenizer tokenizer = new StringTokenizer(s, " "); - double[] values = new double[] { - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken())}; + double[] values = ConversionUtils.toDoubleArray(s, "\\s"); + if (values.length != 6) { + throw new IllegalArgumentException("CTM must consist of 6 double values!"); + } return new CTM(values[0], values[1], values[2], values[3], values[4], values[5]); } else { - throw new IllegalArgumentException("CTM must be surrounded by square brackets"); + throw new IllegalArgumentException("CTM must be surrounded by square brackets!"); } } - private Rectangle2D getAttributeAsRectangle2D(Attributes attributes, String name) { + private static Rectangle2D getAttributeAsRectangle2D(Attributes attributes, String name) { String s = attributes.getValue(name).trim(); - StringTokenizer tokenizer = new StringTokenizer(s, " "); - double[] values = new double[] { - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken()), - Double.parseDouble(tokenizer.nextToken())}; + double[] values = ConversionUtils.toDoubleArray(s, "\\s"); + if (values.length != 4) { + throw new IllegalArgumentException("Rectangle must consist of 4 double values!"); + } return new Rectangle2D.Double(values[0], values[1], values[2], values[3]); } - private void transferForeignObjects(Attributes atts, AreaTreeObject ato) { + private static void transferForeignObjects(Attributes atts, AreaTreeObject ato) { for (int i = 0, c = atts.getLength(); i < c; i++) { String ns = atts.getURI(i); if (ns.length() > 0) { @@ -1163,11 +1132,25 @@ public class AreaTreeParser { public void characters(char[] ch, int start, int length) throws SAXException { if (delegate != null) { delegate.characters(ch, start, length); - } else { - content.append(ch, start, length); + } else if (!ignoreCharacters) { + int maxLength = this.content.capacity() - this.content.position(); + if (maxLength < length) { + // allocate a larger buffer and transfer content + CharBuffer newContent + = CharBuffer.allocate(this.content.position() + length); + this.content.flip(); + newContent.put(this.content); + this.content = newContent; + } + // make sure the full capacity is used + this.content.limit(this.content.capacity()); + // add characters to the buffer + this.content.put(ch, start, length); + // decrease the limit, if necessary + if (this.content.position() < this.content.limit()) { + this.content.limit(this.content.position()); + } } } - } - } diff --git a/src/java/org/apache/fop/area/inline/Character.java b/src/java/org/apache/fop/area/inline/Character.java deleted file mode 100644 index 6b6f9744f..000000000 --- a/src/java/org/apache/fop/area/inline/Character.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.inline; - -/** - * Single character inline area. - * This inline area holds a single character. - * @deprecated A TextArea with a single WordArea as its child should be used instead. - */ -public class Character extends AbstractTextArea { - // use a String instead of a character because if this character - // ends a syllable the hyphenation character must be added - private String character; - - /** - * Create a new character inline area with the given character. - * - * @param ch the character for this inline area - */ - public Character(char ch) { - character = new String() + ch; - } - - /** - * Get the character for this inline character area. - * - * @return the character - */ - public String getChar() { - return character; - } - - /** - * Add the hyphenation character and its length. - * - * @param hyphChar the hyphenation character - * @param hyphSize the size of the hyphenation character - */ - public void addHyphen(char hyphChar, int hyphSize) { - character += hyphChar; - this.setIPD(this.getIPD() + hyphSize); - } - -} - 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 370bb9de4..faf1f7aba 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableFObj.java +++ b/src/java/org/apache/fop/fo/flow/table/TableFObj.java @@ -55,9 +55,10 @@ public abstract class TableFObj extends FObj { CollapsingBorderModel collapsingBorderModel; /** - * Main constructor + * Create a TableFObj instance that is a child + * of the given {@link FONode} * - * @param parent the parent node + * @param parent the parent {@link FONode} */ public TableFObj(FONode parent) { super(parent); @@ -81,6 +82,8 @@ public abstract class TableFObj extends FObj { } /** + * Return the value for the "border-precedence" property + * for the given side. * * @param side the side for which to return the border precedence * @return the "border-precedence" value for the given side @@ -102,13 +105,13 @@ public abstract class TableFObj extends FObj { /** * Convenience method to returns a reference - * to the base Table instance + * to the base {@link Table} instance. * * @return the base table instance * */ public Table getTable() { - // Will be overridden in Table; for any other Table-node, recursive call to + // Overridden in Table; for any other Table-node, recursive call to // parent.getTable() return ((TableFObj) parent).getTable(); } @@ -119,13 +122,13 @@ public abstract class TableFObj extends FObj { public abstract CommonBorderPaddingBackground getCommonBorderPaddingBackground(); /** - * PropertyMaker subclass for the column-number property - * + * {@link PropertyMaker} subclass for the column-number property */ public static class ColumnNumberPropertyMaker extends PropertyMaker { /** * Constructor + * * @param propId the id of the property for which the maker should * be created */ @@ -144,46 +147,50 @@ public abstract class TableFObj extends FObj { /** + * {@inheritDoc} * Check the value of the column-number property. - * Return the parent's column index (initial value) in case - * of a negative or zero value - * - * @see org.apache.fop.fo.properties.PropertyMaker#make(PropertyList, String, FObj) */ public Property make(PropertyList propertyList, String value, FObj fo) throws PropertyException { + Property p = super.make(propertyList, value, fo); - ColumnNumberManagerHolder parent - = (ColumnNumberManagerHolder) propertyList.getParentFObj(); - ColumnNumberManager columnIndexManager = parent.getColumnNumberManager(); int columnIndex = p.getNumeric().getValue(); int colSpan = propertyList.get(Constants.PR_NUMBER_COLUMNS_SPANNED) .getNumeric().getValue(); - - int lastIndex = columnIndex - 1 + colSpan; - for (int i = columnIndex; i <= lastIndex; ++i) { - if (columnIndexManager.isColumnNumberUsed(i)) { - /* if column-number is already in use by another - * cell/column => error! - */ - TableEventProducer eventProducer = TableEventProducer.Provider.get( - fo.getUserAgent().getEventBroadcaster()); - eventProducer.cellOverlap(this, propertyList.getFObj().getName(), - i, fo.getLocator()); + + // only check whether the column-number is occupied in case it was + // specified on a fo:table-cell or fo:table-column + int foId = propertyList.getFObj().getNameId(); + if (foId == FO_TABLE_COLUMN || foId == FO_TABLE_CELL) { + ColumnNumberManagerHolder parent + = (ColumnNumberManagerHolder) propertyList.getParentFObj(); + ColumnNumberManager columnIndexManager = parent.getColumnNumberManager(); + int lastIndex = columnIndex - 1 + colSpan; + for (int i = columnIndex; i <= lastIndex; ++i) { + if (columnIndexManager.isColumnNumberUsed(i)) { + /* if column-number is already in use by another + * cell/column => error! + */ + TableEventProducer eventProducer + = TableEventProducer.Provider.get( + fo.getUserAgent().getEventBroadcaster()); + eventProducer.cellOverlap( + this, propertyList.getFObj().getName(), + i, propertyList.getFObj().getLocator()); + } } } - return p; } - + /** - * If the value is not positive, return a property whose value is the next column number - * * {@inheritDoc} + * If the value is not positive, return a property whose value + * is the next column number. */ - 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); @@ -191,15 +198,24 @@ public abstract class TableFObj extends FObj { Number val = p.getNumber(); if (val != null) { int i = Math.round(val.floatValue()); + int foId = propertyList.getFObj().getNameId(); if (i <= 0) { - ColumnNumberManagerHolder parent = - (ColumnNumberManagerHolder) propertyList.getParentFObj(); - ColumnNumberManager columnIndexManager = parent.getColumnNumberManager(); - i = columnIndexManager.getCurrentColumnNumber(); + if (foId == FO_TABLE_CELL || foId == FO_TABLE_COLUMN) { + ColumnNumberManagerHolder parent = + (ColumnNumberManagerHolder) propertyList.getParentFObj(); + ColumnNumberManager columnIndexManager = parent.getColumnNumberManager(); + i = columnIndexManager.getCurrentColumnNumber(); + } else { + /* very exceptional case: + * negative column-number specified on + * a FO that is not a fo:table-cell or fo:table-column + */ + i = 1; + } TableEventProducer eventProducer = TableEventProducer.Provider.get(fo.getUserAgent().getEventBroadcaster()); eventProducer.forceNextColumnNumber(this, propertyList.getFObj().getName(), - val, i, fo.getLocator()); + val, i, propertyList.getFObj().getLocator()); } return NumberProperty.getInstance(i); } @@ -233,26 +249,26 @@ public abstract class TableFObj extends FObj { /** * Creates a BorderSpecification from the border set on the given side. If no border * is set, a BorderSpecification with border-style none is created. - * + * * @param side one of CommonBorderPaddingBackground.BEFORE|AFTER|START|END */ private void createBorder(int side) { BorderSpecification borderSpec = new BorderSpecification( getCommonBorderPaddingBackground().getBorderInfo(side), getNameId()); switch (side) { - case CommonBorderPaddingBackground.BEFORE: - borderBefore = new ConditionalBorder(borderSpec, collapsingBorderModel); - break; - case CommonBorderPaddingBackground.AFTER: - borderAfter = new ConditionalBorder(borderSpec, collapsingBorderModel); - break; - case CommonBorderPaddingBackground.START: - borderStart = borderSpec; - break; - case CommonBorderPaddingBackground.END: - borderEnd = borderSpec; - break; - default: assert false; + case CommonBorderPaddingBackground.BEFORE: + borderBefore = new ConditionalBorder(borderSpec, collapsingBorderModel); + break; + case CommonBorderPaddingBackground.AFTER: + borderAfter = new ConditionalBorder(borderSpec, collapsingBorderModel); + break; + case CommonBorderPaddingBackground.START: + borderStart = borderSpec; + break; + case CommonBorderPaddingBackground.END: + borderEnd = borderSpec; + break; + default: assert false; } } } diff --git a/src/java/org/apache/fop/pdf/PDFDocument.java b/src/java/org/apache/fop/pdf/PDFDocument.java index bd44595fb..020a594b4 100644 --- a/src/java/org/apache/fop/pdf/PDFDocument.java +++ b/src/java/org/apache/fop/pdf/PDFDocument.java @@ -528,10 +528,10 @@ public class PDFDocument { public void setEncryption(PDFEncryptionParams params) { getProfile().verifyEncryptionAllowed(); this.encryption = PDFEncryptionManager.newInstance(++this.objectcount, params); - ((PDFObject)this.encryption).setDocument(this); if (encryption != null) { - /**@todo this cast is ugly. PDFObject should be transformed to an interface. */ - addTrailerObject((PDFObject)this.encryption); + PDFObject pdfObject = (PDFObject)encryption; + pdfObject.setDocument(this); + addTrailerObject(pdfObject); } else { log.warn( "PDF encryption is unavailable. PDF will be " diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 5c3e73ee0..ebff5323b 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -54,7 +54,6 @@ import org.apache.fop.area.RegionReference; import org.apache.fop.area.RegionViewport; import org.apache.fop.area.Span; import org.apache.fop.area.Trait; -import org.apache.fop.area.inline.Character; import org.apache.fop.area.inline.Container; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.Image; @@ -405,7 +404,7 @@ public abstract class AbstractRenderer for (int count = 0; count < spans.size(); count++) { span = (Span) spans.get(count); for (int c = 0; c < span.getColumnCount(); c++) { - NormalFlow flow = (NormalFlow) span.getNormalFlow(c); + NormalFlow flow = span.getNormalFlow(c); if (flow != null) { currentBPPosition = saveSpanBPPos; @@ -638,15 +637,6 @@ public abstract class AbstractRenderer } } - /** - * Render the given Character. - * @param ch the character to render - * @deprecated Only TextArea should be used. This method will be removed eventually. - */ - protected void renderCharacter(Character ch) { - currentIPPosition += ch.getAllocIPD(); - } - /** * Common method to render the background and borders for any inline area. * The all borders and padding are drawn outside the specified area. @@ -754,6 +744,8 @@ public abstract class AbstractRenderer renderContainer((Container) content); } else if (content instanceof ForeignObject) { renderForeignObject((ForeignObject) content, contpos); + } else if (content instanceof InlineBlockParent) { + renderInlineBlockParent((InlineBlockParent) content); } currentIPPosition += viewport.getAllocIPD(); currentBPPosition = saveBP; @@ -792,7 +784,7 @@ public abstract class AbstractRenderer * @param pos The target position of the foreign object * (todo) Make renderForeignObject() protected */ - public void renderForeignObject(ForeignObject fo, Rectangle2D pos) { + protected void renderForeignObject(ForeignObject fo, Rectangle2D pos) { // Default: do nothing. // Some renderers (ex. Text) don't support foreign objects. } @@ -817,8 +809,9 @@ public abstract class AbstractRenderer handler.handleXML(ctx, doc, namespace); } catch (Exception e) { // could not handle document - ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get( - ctx.getUserAgent().getEventBroadcaster()); + ResourceEventProducer eventProducer + = ResourceEventProducer.Provider.get( + ctx.getUserAgent().getEventBroadcaster()); eventProducer.foreignXMLProcessingError(this, doc, namespace, e); } } else { @@ -871,5 +864,4 @@ public abstract class AbstractRenderer matrix[5] = matrix[5] * 1000; return new AffineTransform(matrix); } - } diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 0723d62f0..ff0e64806 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -1842,5 +1842,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { public void setFilterMap(Map filterMap) { this.filterMap = filterMap; } + + /** + * Sets the encryption parameters used by the PDF renderer. + * @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 2fce8859a..51e13dde1 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java @@ -28,6 +28,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.pdf.PDFAMode; +import org.apache.fop.pdf.PDFEncryptionParams; import org.apache.fop.pdf.PDFFilterList; import org.apache.fop.pdf.PDFXMode; import org.apache.fop.render.PrintRendererConfigurator; @@ -78,13 +79,54 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { if (s != null) { pdfRenderer.setXMode(PDFXMode.valueOf(s)); } + Configuration encryptionParamsConfig = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false); + if (encryptionParamsConfig != null) { + PDFEncryptionParams encryptionParams = new PDFEncryptionParams(); + Configuration ownerPasswordConfig = encryptionParamsConfig.getChild( + PDFRenderer.OWNER_PASSWORD, false); + if (ownerPasswordConfig != null) { + String ownerPassword = ownerPasswordConfig.getValue(null); + if (ownerPassword != null) { + encryptionParams.setOwnerPassword(ownerPassword); + } + } + Configuration userPasswordConfig = encryptionParamsConfig.getChild( + PDFRenderer.USER_PASSWORD, false); + if (userPasswordConfig != null) { + String userPassword = userPasswordConfig.getValue(null); + if (userPassword != null) { + encryptionParams.setUserPassword(userPassword); + } + } + Configuration noPrintConfig = encryptionParamsConfig.getChild( + PDFRenderer.NO_PRINT, false); + if (noPrintConfig != null) { + encryptionParams.setAllowPrint(false); + } + Configuration noCopyContentConfig = encryptionParamsConfig.getChild( + PDFRenderer.NO_COPY_CONTENT, false); + if (noCopyContentConfig != null) { + encryptionParams.setAllowCopyContent(false); + } + Configuration noEditContentConfig = encryptionParamsConfig.getChild( + PDFRenderer.NO_EDIT_CONTENT, false); + if (noEditContentConfig != null) { + encryptionParams.setAllowEditContent(false); + } + Configuration noAnnotationsConfig = encryptionParamsConfig.getChild( + PDFRenderer.NO_ANNOTATIONS, false); + if (noAnnotationsConfig != null) { + encryptionParams.setAllowEditAnnotations(false); + } + pdfRenderer.setEncryptionParams(encryptionParams); + } s = cfg.getChild(PDFRenderer.KEY_OUTPUT_PROFILE, true).getValue(null); if (s != null) { pdfRenderer.setOutputProfileURI(s); } - Configuration child = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false); - if (child != null) { - pdfRenderer.disableSRGBColorSpace = child.getValueAsBoolean(false); + Configuration disableColorSpaceConfig = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false); + if (disableColorSpaceConfig != null) { + pdfRenderer.disableSRGBColorSpace = disableColorSpaceConfig.getValueAsBoolean(false); } } } diff --git a/src/java/org/apache/fop/util/ConversionUtils.java b/src/java/org/apache/fop/util/ConversionUtils.java new file mode 100644 index 000000000..e2d93fbd3 --- /dev/null +++ b/src/java/org/apache/fop/util/ConversionUtils.java @@ -0,0 +1,110 @@ +/* + * 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; + +/** + * This class contains utility methods for conversions, like + * a java.lang.String to an array of int or double. + */ +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 + * 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) + * @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 + * 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) + * @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/status.xml b/status.xml index 42996789e..6f22165c5 100644 --- a/status.xml +++ b/status.xml @@ -53,6 +53,9 @@ + + Added PDF encryption parameter support in configuration. + Allowing non-zero borders and padding on page regions when relaxed validation is turned on. -- cgit v1.2.3 From c0b3bda3b8ec533d8595c75a810df9ac19ab23d4 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Thu, 10 Jul 2008 10:59:39 +0000 Subject: * Created new AbstractState class that shares common properties and stack popping/pushing behaviour of and is now extended by AFPState and PDFState. * color, resolution and bitsPerPixel moved from AFPInfo to AFPState/AbstractState resulting in a more simplified AFPInfo and AFPSVGHandler. * Changed AFPRenderer, AFPDataStream, PresentationTextObject and PresentationTextData to use encapsulated AFPTextDataInfo instead of a chain of long parameter passing between objects. Also provided some formatting cleanup in PresentationTextData. * Use of X and Y offsets no longer used by AFPDataStream, setOffsets() is now deprecated and added setOrientation() accessor (which still remains relevant). * AFPRenderer no longer uses its own bespoke ViewPortPos mechanism and now uses the more standard state stack and AffineTransform mechanism enjoyed by the postscript and PDF Renderers. This means that there is now a proper implementation for startVParea(), endVParea(), saveGraphicsState(), restoreGraphicsState(), breakOutOfStateStack() and restoreStateStackAfterBreakOut() and it is no longer necessary to have a copy/pasted/tweaked renderBlockViewport() or renderRegionViewport(). As a result of this AFPRenderer is now much more compact (by some 500 lines) - similar work needs to be done in the PCL Renderer, any volunteers? * Added lots of helpful toString() methods for those mere mortals wishing to step through with a debugger :). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@675507 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 1 + src/java/org/apache/fop/pdf/PDFState.java | 321 +---- src/java/org/apache/fop/render/AbstractState.java | 376 ++++++ src/java/org/apache/fop/render/afp/AFPInfo.java | 62 +- .../org/apache/fop/render/afp/AFPRenderer.java | 1391 +++++++------------- .../render/afp/AFPRendererContextConstants.java | 6 - .../org/apache/fop/render/afp/AFPSVGHandler.java | 27 +- src/java/org/apache/fop/render/afp/AFPState.java | 436 +++--- .../org/apache/fop/render/afp/ObjectAreaInfo.java | 3 +- .../apache/fop/render/afp/modca/AFPDataStream.java | 89 +- .../fop/render/afp/modca/AbstractPageObject.java | 25 +- .../fop/render/afp/modca/PresentationTextData.java | 280 ++-- .../render/afp/modca/PresentationTextObject.java | 52 +- .../org/apache/fop/render/pdf/PDFRenderer.java | 7 +- 14 files changed, 1352 insertions(+), 1724 deletions(-) create mode 100644 src/java/org/apache/fop/render/AbstractState.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/build.xml b/build.xml index ff76686b6..b55cabb2f 100644 --- a/build.xml +++ b/build.xml @@ -593,6 +593,7 @@ RetroWeaver will be added here --> + diff --git a/src/java/org/apache/fop/pdf/PDFState.java b/src/java/org/apache/fop/pdf/PDFState.java index e453d7b51..4f7b23a80 100644 --- a/src/java/org/apache/fop/pdf/PDFState.java +++ b/src/java/org/apache/fop/pdf/PDFState.java @@ -19,14 +19,9 @@ package org.apache.fop.pdf; -import java.io.Serializable; -import java.util.List; import java.util.Iterator; - -import java.awt.Color; import java.awt.Paint; import java.awt.Shape; -import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.GeneralPath; @@ -47,144 +42,12 @@ import java.awt.geom.GeneralPath; * It is impossible to optimise the result without analysing the all * the possible combinations after completing. */ -public class PDFState { - - private Data data = new Data(); - - private List stateStack = new java.util.ArrayList(); +public class PDFState extends org.apache.fop.render.AbstractState { /** * PDF State for storing graphics state. */ public PDFState() { - - } - - /** - * Push the current state onto the stack. - * This call should be used when the q operator is used - * so that the state is known when popped. - */ - public void push() { - Data copy; - try { - copy = (Data)getData().clone(); - getData().resetTransform(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e.getMessage()); - } - stateStack.add(copy); - } - - /** - * @return the currently valid state - */ - public Data getData() { - return data; - } - - /** - * Pop the state from the stack and set current values to popped state. - * This should be called when a Q operator is used so - * the state is restored to the correct values. - * @return the restored state, null if the stack is empty - */ - public Data pop() { - if (getStackLevel() > 0) { - Data popped = (Data)stateStack.remove(stateStack.size() - 1); - - data = popped; - return popped; - } else { - return null; - } - } - - /** - * Get the current stack level. - * - * @return the current stack level - */ - public int getStackLevel() { - return stateStack.size(); - } - - /** - * Restore the state to a particular level. - * this can be used to restore to a known level without making - * multiple pop calls. - * - * @param stack the level to restore to - */ - /* - public void restoreLevel(int stack) { - int pos = stack; - while (stateStack.size() > pos + 1) { - stateStack.remove(stateStack.size() - 1); - } - if (stateStack.size() > pos) { - pop(); - } - }*/ - - /** - * Set the current line dash. - * Check if setting the line dash to the given values - * will make a change and then set the state to the new values. - * - * @param array the line dash array - * @param offset the line dash start offset - * @return true if the line dash has changed - */ - /* - public boolean setLineDash(int[] array, int offset) { - return false; - }*/ - - /** - * Set the current line width. - * @param width the line width in points - * @return true if the line width has changed - */ - public boolean setLineWidth(float width) { - if (getData().lineWidth != width) { - getData().lineWidth = width; - return true; - } else { - return false; - } - } - - /** - * Set the current color. - * Check if the new color is a change and then set the current color. - * - * @param col the color to set - * @return true if the color has changed - */ - public boolean setColor(Color col) { - if (!col.equals(getData().color)) { - getData().color = col; - return true; - } else { - return false; - } - } - - /** - * Set the current background color. - * Check if the background color will change and then set the new color. - * - * @param col the new background color - * @return true if the background color has changed - */ - public boolean setBackColor(Color col) { - if (!col.equals(getData().backcolor)) { - getData().backcolor = col; - return true; - } else { - return false; - } } /** @@ -195,13 +58,14 @@ public class PDFState { * @return true if the new paint changes the current paint */ public boolean setPaint(Paint p) { - if (getData().paint == null) { + Paint paint = ((PDFData)getData()).paint; + if (paint == null) { if (p != null) { - getData().paint = p; + ((PDFData)getData()).paint = p; return true; } - } else if (!data.paint.equals(p)) { - getData().paint = p; + } else if (!paint.equals(p)) { + ((PDFData)getData()).paint = p; return true; } return false; @@ -220,11 +84,12 @@ public class PDFState { * @return true if the clip will change the current clip. */ public boolean checkClip(Shape cl) { - if (getData().clip == null) { + Shape clip = ((PDFData)getData()).clip; + if (clip == null) { if (cl != null) { return true; } - } else if (!new Area(getData().clip).equals(new Area(cl))) { + } else if (!new Area(clip).equals(new Area(cl))) { return true; } //TODO check for clips that are larger than the current @@ -239,80 +104,23 @@ public class PDFState { * @param cl the new clip in the current state */ public void setClip(Shape cl) { - if (getData().clip != null) { - Area newClip = new Area(getData().clip); + Shape clip = ((PDFData)getData()).clip; + if (clip != null) { + Area newClip = new Area(clip); newClip.intersect(new Area(cl)); - getData().clip = new GeneralPath(newClip); + ((PDFData)getData()).clip = new GeneralPath(newClip); } else { - getData().clip = cl; + ((PDFData)getData()).clip = cl; } } /** - * Check the current transform. - * The transform for the current state is the combination of all - * transforms in the current state. The parameter is compared - * against this current transform. - * - * @param tf the transform the check against - * @return true if the new transform is different then the current transform - */ - public boolean checkTransform(AffineTransform tf) { - return !tf.equals(getData().transform); - } - - /** - * Set a new transform. - * This transform is appended to the transform of - * the current graphic state. - * - * @param tf the transform to concatonate to the current level transform - * @deprecated This method name is misleading. Use concatenate(AffineTransform) instead! - */ - public void setTransform(AffineTransform tf) { - concatenate(tf); - } - - /** - * Concatenates the given AffineTransform to the current one. - * @param tf the transform to concatenate to the current level transform - */ - public void concatenate(AffineTransform tf) { - getData().concatenate(tf); - } - - /** - * Get the current transform. - * This gets the combination of all transforms in the - * current state. - * - * @return the calculate combined transform for the current state - */ - public AffineTransform getTransform() { - AffineTransform tf; - AffineTransform at = new AffineTransform(); - for (Iterator iter = stateStack.iterator(); iter.hasNext();) { - Data d = (Data)iter.next(); - tf = d.transform; - at.concatenate(tf); - } - at.concatenate(getData().transform); - return at; - } - - /** - * Get a copy of the base transform for the page. Used to translate - * IPP/BPP values into X,Y positions when positioning is "fixed". + * Get the current stack level. * - * @return the base transform, or null if the state stack is empty + * @return the current stack level */ - public AffineTransform getBaseTransform() { - if (stateStack.size() == 0) { - return null; - } else { - Data baseData = (Data) stateStack.get(0); - return (AffineTransform) baseData.transform.clone(); - } + public int getStackLevel() { + return getStateStack().size(); } /** @@ -328,90 +136,67 @@ public class PDFState { PDFGState defaultState = PDFGState.DEFAULT; PDFGState state; - PDFGState newstate = new PDFGState(); - newstate.addValues(defaultState); - for (Iterator iter = stateStack.iterator(); iter.hasNext();) { - Data d = (Data)iter.next(); + PDFGState newState = new PDFGState(); + newState.addValues(defaultState); + for (Iterator iter = getStateStack().iterator(); iter.hasNext();) { + PDFData d = (PDFData)iter.next(); state = d.gstate; if (state != null) { - newstate.addValues(state); + newState.addValues(state); } } - if (getData().gstate != null) { - newstate.addValues(getData().gstate); + if (((PDFData)getData()).gstate != null) { + newState.addValues(((PDFData)getData()).gstate); } - - return newstate; + return newState; } - public class Data implements Cloneable, Serializable { + private class PDFData extends org.apache.fop.render.AbstractState.AbstractData { - public Color color = Color.black; - public Color backcolor = Color.black; - public Paint paint = null; - public Paint backPaint = null; - public int lineCap = 0; - public int lineJoin = 0; - public float lineWidth = 1; - public float miterLimit = 0; - public boolean text = false; - public int dashOffset = 0; - public int[] dashArray = new int[0]; - public AffineTransform transform = new AffineTransform(); - public float fontSize = 0; - public String fontName = ""; - public Shape clip = null; - public PDFGState gstate = null; - + private static final long serialVersionUID = 3527950647293177764L; + + private Paint paint = null; + private Paint backPaint = null; + private int lineCap = 0; + private int lineJoin = 0; + private float miterLimit = 0; + private boolean text = false; + private int dashOffset = 0; + private Shape clip = null; + private PDFGState gstate = null; /** {@inheritDoc} */ public Object clone() throws CloneNotSupportedException { - Data obj = new Data(); - obj.color = this.color; - obj.backcolor = this.backcolor; + PDFData obj = (PDFData)super.clone(); obj.paint = this.paint; obj.backPaint = this.paint; obj.lineCap = this.lineCap; obj.lineJoin = this.lineJoin; - obj.lineWidth = this.lineWidth; obj.miterLimit = this.miterLimit; obj.text = this.text; obj.dashOffset = this.dashOffset; - obj.dashArray = this.dashArray; - obj.transform = new AffineTransform(this.transform); - obj.fontSize = this.fontSize; - obj.fontName = this.fontName; obj.clip = this.clip; obj.gstate = this.gstate; return obj; } - /** - * Get the current Transform. - */ - public AffineTransform getTransform() { - return transform; - } - - public void resetTransform() { - transform = new AffineTransform(); - } - - /** - * Concatenate the given AffineTransform with the current thus creating - * a new viewport. Note that all concatenation operations are logged - * so they can be replayed if necessary (ex. for block-containers with - * "fixed" positioning. - * @param at Transformation to perform - */ - public void concatenate(AffineTransform at) { - transform.concatenate(at); - } - /** {@inheritDoc} */ public String toString() { - return super.toString() + ", " + this.transform; + return super.toString() + + ", paint=" + paint + + ", backPaint=" + backPaint + + ", lineCap=" + lineCap + + ", miterLimit=" + miterLimit + + ", text=" + text + + ", dashOffset=" + dashOffset + + ", clip=" + clip + + ", gstate=" + gstate; } } + + /** {@inheritDoc} */ + protected AbstractData instantiateData() { + return new PDFData(); + } } diff --git a/src/java/org/apache/fop/render/AbstractState.java b/src/java/org/apache/fop/render/AbstractState.java new file mode 100644 index 000000000..07595be7f --- /dev/null +++ b/src/java/org/apache/fop/render/AbstractState.java @@ -0,0 +1,376 @@ +/* + * 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.awt.Color; +import java.awt.geom.AffineTransform; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Stack; + +/** + * A base class which holds information about the current rendering state. + */ +public abstract class AbstractState { + private AbstractData currentData = null; + private Stack/**/ stateStack = null; + + /** + * Instantiates a new state data object + * @return a new state data object + */ + protected abstract AbstractData instantiateData(); + + /** + * @return the currently valid state + */ + public AbstractData getData() { + if (currentData == null) { + currentData = instantiateData(); + } + return currentData; + } + + /** + * Set the current color. + * Check if the new color is a change and then set the current color. + * + * @param col the color to set + * @return true if the color has changed + */ + public boolean setColor(Color col) { + if (!col.equals(getData().color)) { + getData().color = col; + return true; + } + return false; + } + + /** + * Get the color. + * @return the color + */ + public Color getColor() { + if (getData().color == null) { + getData().color = Color.black; + } + return getData().color; + } + + /** + * Get the background color. + * @return the background color + */ + public Color getBackColor() { + if (getData().backColor == null) { + getData().backColor = Color.white; + } + return getData().backColor; + } + + /** + * Set the current background color. + * Check if the new background color is a change and then set the current background color. + * + * @param col the background color to set + * @return true if the color has changed + */ + public boolean setBackColor(Color col) { + if (!col.equals(getData().backColor)) { + getData().backColor = col; + return true; + } + return false; + } + + /** + * Set the current font name + * @param internalFontName the internal font name + * @return true if the font name has changed + */ + public boolean setFontName(String internalFontName) { + if (!internalFontName.equals(getData().fontName)) { + getData().fontName = internalFontName; + return true; + } + return false; + } + + /** + * Gets the current font name + * @return the current font name + */ + public String getFontName() { + return getData().fontName; + } + + /** + * Gets the current font size + * @return the current font size + */ + public int getFontSize() { + return getData().fontSize; + } + + /** + * Set the current font size. + * Check if the font size is a change and then set the current font size. + * + * @param size the font size to set + * @return true if the font size has changed + */ + public boolean setFontSize(int size) { + if (size != getData().fontSize) { + getData().fontSize = size; + return true; + } + return false; + } + + /** + * Set the current line width. + * @param width the line width in points + * @return true if the line width has changed + */ + public boolean setLineWidth(float width) { + if (getData().lineWidth != width) { + getData().lineWidth = width; + return true; + } + return false; + } + + /** + * Gets the current line width + * @return the current line width + */ + public float getLineWidth() { + return getData().lineWidth; + } + + /** + * Sets the dash array (line type) for the current basic stroke + * @param dash the line dash array + * @return true if the dash array has changed + */ + public boolean setDashArray(float[] dash) { + if (!Arrays.equals(dash, getData().dashArray)) { + getData().dashArray = dash; + return true; + } + return false; + } + + /** + * Get the current transform. + * This gets the combination of all transforms in the + * current state. + * + * @return the calculate combined transform for the current state + */ + public AffineTransform getTransform() { + AffineTransform at = new AffineTransform(); + for (Iterator iter = getStateStack().iterator(); iter.hasNext();) { + AbstractData data = (AbstractData)iter.next(); + AffineTransform stackTrans = data.getTransform(); + at.concatenate(stackTrans); + } + AffineTransform currentTrans = getData().getTransform(); + at.concatenate(currentTrans); + return at; + } + + /** + * Check the current transform. + * The transform for the current state is the combination of all + * transforms in the current state. The parameter is compared + * against this current transform. + * + * @param tf the transform the check against + * @return true if the new transform is different then the current transform + */ + public boolean checkTransform(AffineTransform tf) { + return !tf.equals(getData().getTransform()); + } + + /** + * Get a copy of the base transform for the page. Used to translate + * IPP/BPP values into X,Y positions when positioning is "fixed". + * + * @return the base transform, or null if the state stack is empty + */ + public AffineTransform getBaseTransform() { + if (getStateStack().isEmpty()) { + return null; + } else { + AbstractData baseData = (AbstractData)getStateStack().get(0); + return (AffineTransform) baseData.getTransform().clone(); + } + } + + /** + * Concatenates the given AffineTransform to the current one. + * @param tf the transform to concatenate to the current level transform + */ + public void concatenate(AffineTransform tf) { + getData().concatenate(tf); + } + + /** + * Resets the current AffineTransform. + */ + public void resetTransform() { + getData().resetTransform(); + } + + /** + * Push the current state onto the stack. + * This call should be used when the Q operator is used + * so that the state is known when popped. + */ + public void push() { + AbstractData copy; + try { + copy = (AbstractData)getData().clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e.getMessage()); + } + getStateStack().push(copy); + } + + /** + * Pop the state from the stack and set current values to popped state. + * This should be called when a Q operator is used so + * the state is restored to the correct values. + * @return the restored state, null if the stack is empty + */ + public AbstractData pop() { + if (!getStateStack().isEmpty()) { + this.currentData = (AbstractData)getStateStack().pop(); + return this.currentData; + } else { + return null; + } + } + + /** + * Clears the state stack + */ + public void clear() { + getStateStack().clear(); + currentData = null; + } + + /** + * @return the state stack + */ + protected Stack/**/ getStateStack() { + if (stateStack == null) { + stateStack = new java.util.Stack/**/(); + } + return stateStack; + } + + /** {@inheritDoc} */ + public String toString() { + return "stateStack=" + stateStack + + ", currentData=" + currentData; + } + + /** + * A base state data holding object + */ + public abstract class AbstractData implements Cloneable, Serializable { + /** The current color */ + private Color color = null; + + /** The current background color */ + private Color backColor = null; + + /** The current font name */ + private String fontName = null; + + /** The current font size */ + private int fontSize = 0; + + /** The current line width */ + private float lineWidth = 0; + + /** The dash array for the current basic stroke (line type) */ + private float[] dashArray = null; + + /** The current transform */ + private AffineTransform transform = null; + + /** + * Concatenate the given AffineTransform with the current thus creating + * a new viewport. Note that all concatenation operations are logged + * so they can be replayed if necessary (ex. for block-containers with + * "fixed" positioning. + * @param at Transformation to perform + */ + public void concatenate(AffineTransform at) { + getTransform().concatenate(at); + } + + /** + * Get the current AffineTransform. + * @return the current transform + */ + public AffineTransform getTransform() { + if (transform == null) { + transform = new AffineTransform(); + } + return transform; + } + + /** + * Resets the current AffineTransform. + */ + public void resetTransform() { + transform = new AffineTransform(); + } + + /** {@inheritDoc} */ + public Object clone() throws CloneNotSupportedException { + AbstractData obj = instantiateData(); + obj.color = this.color; + obj.backColor = this.backColor; + obj.fontName = this.fontName; + obj.fontSize = this.fontSize; + obj.lineWidth = this.lineWidth; + obj.dashArray = this.dashArray; + obj.transform = new AffineTransform(this.transform); + return obj; + } + + /** {@inheritDoc} */ + public String toString() { + return "color=" + color + + ", backColor=" + backColor + + ", fontName=" + fontName + + ", fontSize=" + fontSize + + ", lineWidth=" + lineWidth + + ", dashArray=" + dashArray + + ", transform=" + transform; + } + } +} diff --git a/src/java/org/apache/fop/render/afp/AFPInfo.java b/src/java/org/apache/fop/render/afp/AFPInfo.java index 19e58d30f..b12a46cb2 100644 --- a/src/java/org/apache/fop/render/afp/AFPInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPInfo.java @@ -29,27 +29,27 @@ import org.apache.fop.render.afp.modca.AFPDataStream; public final class AFPInfo { /** see WIDTH */ private int width; + /** see HEIGHT */ private int height; + /** see XPOS */ private int x; + /** see YPOS */ private int y; + /** see HANDLER_CONFIGURATION */ private Configuration cfg; /** see AFP_FONT_INFO */ private FontInfo fontInfo; + /** See AFP_DATASTREAM */ private AFPDataStream afpDataStream; + /** See AFP_STATE */ private AFPState afpState; - /** see AFP_GRAYSCALE */ - private boolean color; - /** see AFP_RESOLUTION */ - private int resolution; - /** see AFP_BITS_PER_PIXEL */ - private int bitsPerPixel; /** * Returns the width. @@ -123,7 +123,7 @@ public final class AFPInfo { * @return true if supports color */ public boolean isColorSupported() { - return this.color; + return getState().isColorImages(); } /** @@ -144,14 +144,14 @@ public final class AFPInfo { * @return the resolution */ protected int getResolution() { - return resolution; + return getState().getResolution(); } /** * @return the number of bits per pixel to use */ protected int getBitsPerPixel() { - return bitsPerPixel; + return getState().getBitsPerPixel(); } /** @@ -170,14 +170,6 @@ public final class AFPInfo { this.y = y; } - /** - * Sets the current resolution - * @param resolution the current resolution - */ - protected void setResolution(int resolution) { - this.resolution = resolution; - } - /** * Sets the current font info * @param fontInfo the current font info @@ -196,25 +188,21 @@ public final class AFPInfo { /** * Sets the AFP datastream - * @param afpDataStream the AFP datastream - */ - public void setAFPDataStream(AFPDataStream afpDataStream) { - this.afpDataStream = afpDataStream; - } - - /** - * Sets if we are supporing color - * @param color true if color is supported - */ - public void setColor(boolean color) { - this.color = color; - } - - /** - * Sets the number of bits per pixel - * @param bitsPerPixel the number of bits per pixel - */ - public void setBitsPerPixel(int bitsPerPixel) { - this.bitsPerPixel = bitsPerPixel; + * @param dataStream the AFP datastream + */ + public void setAFPDataStream(AFPDataStream dataStream) { + this.afpDataStream = dataStream; + } + + /** {@inheritDoc} */ + public String toString() { + return "width=" + width + + ",height=" + height + + ",x=" + x + + ",y=" + y + + ",cfg=" + cfg + + ",fontInfo=" + fontInfo + + ",afpDatastream=" + afpDataStream + + ",afpState=" + afpState; } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 790732c12..c08da6ad9 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -23,7 +23,6 @@ import java.awt.Color; import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.AffineTransform; -import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.RenderedImage; import java.io.FileNotFoundException; @@ -50,18 +49,14 @@ import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.xmlgraphics.ps.ImageEncodingHelper; +import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; import org.apache.fop.area.Block; -import org.apache.fop.area.BlockViewport; -import org.apache.fop.area.BodyRegion; import org.apache.fop.area.CTM; import org.apache.fop.area.LineArea; -import org.apache.fop.area.NormalFlow; import org.apache.fop.area.OffDocumentItem; import org.apache.fop.area.PageViewport; -import org.apache.fop.area.RegionReference; -import org.apache.fop.area.RegionViewport; import org.apache.fop.area.Trait; import org.apache.fop.area.inline.Image; import org.apache.fop.area.inline.Leader; @@ -76,6 +71,7 @@ import org.apache.fop.fonts.base14.Courier; import org.apache.fop.fonts.base14.Helvetica; import org.apache.fop.fonts.base14.TimesRoman; import org.apache.fop.render.AbstractPathOrientedRenderer; +import org.apache.fop.render.AbstractState; import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.render.afp.extensions.AFPElementMapping; @@ -87,7 +83,6 @@ import org.apache.fop.render.afp.fonts.FopCharacterSet; import org.apache.fop.render.afp.fonts.OutlineFont; import org.apache.fop.render.afp.modca.AFPConstants; import org.apache.fop.render.afp.modca.AFPDataStream; -import org.apache.fop.render.afp.modca.ImageObject; import org.apache.fop.render.afp.modca.PageObject; /** @@ -146,123 +141,37 @@ import org.apache.fop.render.afp.modca.PageObject; */ public class AFPRenderer extends AbstractPathOrientedRenderer { - /** - * The default afp renderer output resolution - */ - public static final int DPI_240_RESOLUTION = 240; + private static final int X = 0; + + private static final int Y = 1; + + private static final int X1 = 0; - /** - * The afp factor for calculating resolutions (e.g. 72000/240 = 300) - */ - private static final int DPI_CONVERSION_FACTOR = 72000; + private static final int Y1 = 1; + + private static final int X2 = 2; + + private static final int Y2 = 3; /** * The afp data stream object responsible for generating afp data */ private AFPDataStream afpDataStream = null; - /** - * The map of afp root extensions - */ - // UNUSED - // private HashMap rootExtensionMap = null; /** * The map of page segments */ private Map/**/pageSegmentsMap = null; - /** - * The fonts on the current page - */ - private Map/**/getCurrentPageFonts() { - if (currentPageFontMap == null) { - this.currentPageFontMap = new java.util.HashMap/**/(); - } - return this.currentPageFontMap; - } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startRenderer(OutputStream outputStream) throws IOException { - this.currentColor = new Color(255, 255, 255); - getAFPDataStream().setPortraitRotation(portraitRotation); - getAFPDataStream().setLandscapeRotation(landscapeRotation); - getAFPDataStream().setOutputStream(outputStream); + currentState.setColor(new Color(255, 255, 255)); + getAFPDataStream().setPortraitRotation(currentState.getPortraitRotation()); + afpDataStream.setLandscapeRotation(currentState.getLandscapeRotation()); + afpDataStream.setOutputStream(outputStream); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void stopRenderer() throws IOException { getAFPDataStream().write(); afpDataStream = null; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startPageSequence(LineArea seqTitle) { getAFPDataStream().endPageGroup(); - getAFPDataStream().startPageGroup(); + afpDataStream.startPageGroup(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public boolean supportsOutOfOrder() { // return false; return true; } - /** - * Prepare a page for rendering. 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 pages can be rendered. The body of the page - * should not be rendered. The page will be rendered at a later time by the - * call to render page. - * - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void preparePage(PageViewport page) { - // initializeRootExtensions(page); - - // this.currentFontFamily = ""; - this.currentFontSize = 0; - this.pageFontCounter = 0; - this.currentPageFontMap = null; - // this.lineCache = new HashSet(); - - Rectangle2D bounds = page.getViewArea(); - - this.pageWidth = mpts2units(bounds.getWidth()); - this.pageHeight = mpts2units(bounds.getHeight()); - - // renderPageGroupExtensions(page); - final int pageRotation = 0; + int pageWidth = currentState.getPageWidth(); + int pageHeight = currentState.getPageHeight(); getAFPDataStream().startPage(pageWidth, pageHeight, pageRotation, getResolution(), getResolution()); renderPageObjectExtensions(page); + getPages().put(page, getAFPDataStream().savePage()); + } + + private Map/**/ getPages() { if (this.pages == null) { - this.pages = new java.util.HashMap(); + this.pages = new java.util.HashMap/**/(); } - this.pages.put(page, getAFPDataStream().savePage()); - + return this.pages; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void processOffDocumentItem(OffDocumentItem odi) { // TODO + log.debug("NYI processOffDocumentItem(" + odi + ")"); } /** {@inheritDoc} */ public Graphics2DAdapter getGraphics2DAdapter() { return new AFPGraphics2DAdapter(); } - - /** - * {@inheritDoc} - */ + + /** {@inheritDoc} */ public void startVParea(CTM ctm, Rectangle2D clippingRect) { - // dummy not used - } - - /** - * {@inheritDoc} - */ - public void endVParea() { - // dummy not used - } - - /** - * Renders a region viewport. - *

      - * - * The region may clip the area and it establishes a position from where the - * region is placed. - *

      - * - * @param port - * The region viewport to be rendered - */ - public void renderRegionViewport(RegionViewport port) { - if (port != null) { - Rectangle2D view = port.getViewArea(); - // The CTM will transform coordinates relative to - // this region-reference area into page coords, so - // set origin for the region to 0,0. - currentBPPosition = 0; - currentIPPosition = 0; - - RegionReference regionReference = port.getRegionReference(); - handleRegionTraits(port); - - /* - * _afpDataStream.startOverlay(mpts2units(view.getX()) , - * mpts2units(view.getY()) , mpts2units(view.getWidth()) , - * mpts2units(view.getHeight()) - * , rotation); - */ - - pushViewPortPos(new ViewPortPos(view, regionReference.getCTM())); - - if (regionReference.getRegionClass() == FO_REGION_BODY) { - renderBodyRegion((BodyRegion) regionReference); - } else { - renderRegion(regionReference); - } - /* - * _afpDataStream.endOverlay(); - */ - popViewPortPos(); + saveGraphicsState(); + if (ctm != null) { + AffineTransform at = ctm.toAffineTransform(); + concatenateTransformationMatrix(at); + } + if (clippingRect != null) { + clipRect((float)clippingRect.getX() / 1000f, + (float)clippingRect.getY() / 1000f, + (float)clippingRect.getWidth() / 1000f, + (float)clippingRect.getHeight() / 1000f); } } /** {@inheritDoc} */ - protected void renderBlockViewport(BlockViewport bv, List children) { - // clip and position viewport if necessary - - // save positions - int saveIP = currentIPPosition; - int saveBP = currentBPPosition; - - CTM ctm = bv.getCTM(); - int borderPaddingStart = bv.getBorderAndPaddingWidthStart(); - int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore(); - // This is the content-rect - float width = (float) bv.getIPD() / 1000f; - float height = (float) bv.getBPD() / 1000f; - - if (bv.getPositioning() == Block.ABSOLUTE - || bv.getPositioning() == Block.FIXED) { - - // For FIXED, we need to break out of the current viewports to the - // one established by the page. We save the state stack for - // restoration - // after the block-container has been painted. See below. - List breakOutList = null; - 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); - - // skipping fox:transform here - - // saveGraphicsState(); - // Viewport position - // concatenateTransformationMatrix(mptToPt(positionTransform)); - - // Background and borders - float bpwidth = (borderPaddingStart + bv - .getBorderAndPaddingWidthEnd()) / 1000f; - float bpheight = (borderPaddingBefore + bv - .getBorderAndPaddingWidthAfter()) / 1000f; - Point2D ptSrc = new Point(0, 0); - Point2D ptDst = positionTransform.transform(ptSrc, null); - Rectangle2D borderRect = new Rectangle2D.Double(ptDst.getX(), ptDst - .getY(), 1000 * (width + bpwidth), - 1000 * (height + bpheight)); - pushViewPortPos(new ViewPortPos(borderRect, new CTM( - positionTransform))); - drawBackAndBorders(bv, 0, 0, width + bpwidth, height + bpheight); - - // Shift to content rectangle after border painting - AffineTransform contentRectTransform = new AffineTransform(); - contentRectTransform.translate(borderPaddingStart, - borderPaddingBefore); - // concatenateTransformationMatrix(mptToPt(contentRectTransform)); - ptSrc = new Point(0, 0); - ptDst = contentRectTransform.transform(ptSrc, null); - Rectangle2D contentRect = new Rectangle2D.Double(ptDst.getX(), - ptDst.getY(), 1000 * width, 1000 * height); - pushViewPortPos(new ViewPortPos(contentRect, new CTM( - contentRectTransform))); - - // Clipping is not supported, yet - // Rectangle2D clippingRect = null; - // clippingRect = new Rectangle(0, 0, bv.getIPD(), bv.getBPD()); - - // saveGraphicsState(); - // Set up coordinate system for content rectangle - AffineTransform contentTransform = ctm.toAffineTransform(); - // concatenateTransformationMatrix(mptToPt(contentTransform)); - contentRect = new Rectangle2D.Double(0, 0, 1000 * width, - 1000 * height); - pushViewPortPos(new ViewPortPos(contentRect, new CTM( - contentTransform))); - - currentIPPosition = 0; - currentBPPosition = 0; - renderBlocks(bv, children); - - popViewPortPos(); - popViewPortPos(); - // restoreGraphicsState(); - popViewPortPos(); - // restoreGraphicsState(); - - if (breakOutList != null) { - restoreStateStackAfterBreakOut(breakOutList); - } - - currentIPPosition = saveIP; - currentBPPosition = saveBP; - } else { - - currentBPPosition += bv.getSpaceBefore(); - - // borders and background in the old coordinate system - handleBlockTraits(bv); - - // Advance to start of content area - currentIPPosition += bv.getStartIndent(); - - CTM tempctm = new CTM(containingIPPosition, currentBPPosition); - ctm = tempctm.multiply(ctm); - - // Now adjust for border/padding - currentBPPosition += borderPaddingBefore; - - Rectangle2D clippingRect = null; - clippingRect = new Rectangle(currentIPPosition, currentBPPosition, - bv.getIPD(), bv.getBPD()); - - // startVParea(ctm, clippingRect); - pushViewPortPos(new ViewPortPos(clippingRect, ctm)); - - currentIPPosition = 0; - currentBPPosition = 0; - renderBlocks(bv, children); - // endVParea(); - popViewPortPos(); - - currentIPPosition = saveIP; - currentBPPosition = saveBP; - - currentBPPosition += (int) (bv.getAllocBPD()); - } + public void endVParea() { + restoreGraphicsState(); } /** {@inheritDoc} */ - protected void renderReferenceArea(Block block) { - //TODO Remove this method once concatenateTransformationMatrix() is implemented - - // save position and offset - int saveIP = currentIPPosition; - int saveBP = currentBPPosition; - - //Establish a new coordinate system - AffineTransform at = new AffineTransform(); - at.translate(currentIPPosition, currentBPPosition); - at.translate(block.getXOffset(), block.getYOffset()); - at.translate(0, block.getSpaceBefore()); - - if (!at.isIdentity()) { - Rectangle2D contentRect - = new Rectangle2D.Double(at.getTranslateX(), at.getTranslateY(), - block.getAllocIPD(), block.getAllocBPD()); - pushViewPortPos(new ViewPortPos(contentRect, new CTM(at))); - } - - currentIPPosition = 0; - currentBPPosition = 0; - handleBlockTraits(block); - - List children = block.getChildAreas(); - if (children != null) { - renderBlocks(block, children); - } - + protected void concatenateTransformationMatrix(AffineTransform at) { if (!at.isIdentity()) { - popViewPortPos(); + currentState.concatenate(at); } - - // stacked and relative blocks effect stacking - currentIPPosition = saveIP; - currentBPPosition = saveBP; } - - /** {@inheritDoc} */ - protected void renderFlow(NormalFlow flow) { - // save position and offset - int saveIP = currentIPPosition; - int saveBP = currentBPPosition; - - //Establish a new coordinate system - AffineTransform at = new AffineTransform(); - at.translate(currentIPPosition, currentBPPosition); - - if (!at.isIdentity()) { - Rectangle2D contentRect - = new Rectangle2D.Double(at.getTranslateX(), at.getTranslateY(), - flow.getAllocIPD(), flow.getAllocBPD()); - pushViewPortPos(new ViewPortPos(contentRect, new CTM(at))); - } - currentIPPosition = 0; - currentBPPosition = 0; - super.renderFlow(flow); - - if (!at.isIdentity()) { - popViewPortPos(); - } - - // stacked and relative blocks effect stacking - currentIPPosition = saveIP; - currentBPPosition = saveBP; - } - - /** {@inheritDoc} */ - protected void concatenateTransformationMatrix(AffineTransform at) { - // Not used here since AFPRenderer defines its own renderBlockViewport() - // method. - throw new UnsupportedOperationException("NYI"); - } - - /** - * {@inheritDoc} - */ - public void renderPage(PageViewport pageViewport) { - - // initializeRootExtensions(page); - - // this.currentFontFamily = ""; - this.currentFontSize = 0; - this.pageFontCounter = 0; - this.currentPageFontMap = null; - // this.lineCache = new HashSet(); + public void renderPage(PageViewport pageViewport) throws IOException, FOPException { + currentState.clear(); Rectangle2D bounds = pageViewport.getViewArea(); + + AffineTransform basicPageTransform = new AffineTransform(); + int resolution = currentState.getResolution(); + double scale = (double)1 / (AFPConstants.DPI_72_MPTS / resolution); + basicPageTransform.scale(scale, scale); - this.pageWidth = mpts2units(bounds.getWidth()); - this.pageHeight = mpts2units(bounds.getHeight()); - - if (pages != null && pages.containsKey(pageViewport)) { + currentState.concatenate(basicPageTransform); + if (getPages().containsKey(pageViewport)) { getAFPDataStream().restorePage( - (PageObject) pages.remove(pageViewport)); - + (PageObject)getPages().remove(pageViewport)); } else { - // renderPageGroupExtensions(page); + int pageWidth + = (int)Math.round(bounds.getWidth() / (AFPConstants.DPI_72_MPTS / resolution)); + currentState.setPageWidth(pageWidth); + int pageHeight + = (int)Math.round(bounds.getHeight() / (AFPConstants.DPI_72_MPTS / resolution)); + currentState.setPageHeight(pageHeight); final int pageRotation = 0; getAFPDataStream().startPage(pageWidth, pageHeight, pageRotation, - getResolution(), getResolution()); + resolution, resolution); renderPageObjectExtensions(pageViewport); - } + + super.renderPage(pageViewport); - pushViewPortPos(new ViewPortPos()); - - renderPageAreas(pageViewport.getPage()); - - if (currentPageFontMap != null) { - Iterator iter = currentPageFontMap.values().iterator(); - while (iter.hasNext()) { - AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter - .next(); - - getAFPDataStream().createFont( - (byte) afpFontAttributes.getFontReference(), - afpFontAttributes.getFont(), - afpFontAttributes.getPointSize()); - } + AFPPageFonts pageFonts = currentState.getPageFonts(); + if (pageFonts != null && !pageFonts.isEmpty()) { + getAFPDataStream().addFontsToCurrentPage(pageFonts); } getAFPDataStream().endPage(); - - popViewPortPos(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void clip() { // TODO + log.debug("NYI clip()"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void clipRect(float x, float y, float width, float height) { // TODO + log.debug("NYI clipRect(x=" + x + ",y=" + y + ",width=" + width + ", height=" + height + ")"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void moveTo(float x, float y) { // TODO + log.debug("NYI moveTo(x=" + x + ",y=" + y + ")"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void lineTo(float x, float y) { // TODO + log.debug("NYI lineTo(x=" + x + ",y=" + y + ")"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void closePath() { // TODO + log.debug("NYI closePath()"); } - /** - * {@inheritDoc} - */ + private int[] mpts2units(float[] srcPts, float[] dstPts) { + return transformPoints(srcPts, dstPts, true); + } + + private int[] pts2units(float[] srcPts, float[] dstPts) { + return transformPoints(srcPts, dstPts, false); + } + + private int[] mpts2units(float[] srcPts) { + return transformPoints(srcPts, null, true); + } + + private int[] pts2units(float[] srcPts) { + return transformPoints(srcPts, null, false); + } + + /** {@inheritDoc} */ public void fillRect(float x, float y, float width, float height) { -// getAFPDataStream().createShading( -// pts2units(x), pts2units(y), pts2units(width), pts2units(height), -// currentColor); - getAFPDataStream().createLine(pts2units(x), pts2units(y), - pts2units(x + width), pts2units(y), pts2units(height), - currentColor); + float[] srcPts = new float[] {x * 1000, y * 1000}; + float[] dstPts = new float[srcPts.length]; + int[] coords = mpts2units(srcPts, dstPts); + int resolution = currentState.getResolution(); + int x2 = Math.round(dstPts[X] + ((width * 1000) / (AFPConstants.DPI_72_MPTS / resolution))); + int thickness = Math.round((height * 1000) / (AFPConstants.DPI_72_MPTS / resolution)); + getAFPDataStream().createLine( + coords[X], + coords[Y], + x2, + coords[Y], + thickness, + currentState.getColor()); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public 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; - if ((w < 0) || (h < 0)) { + float[] srcPts = new float[] {x1 * 1000, y1 * 1000, x2 * 1000, y2 * 1000}; + float[] dstPts = new float[srcPts.length]; + int[] coords = mpts2units(srcPts, dstPts); + + float width = dstPts[X2] - dstPts[X1]; + float height = dstPts[Y2] - dstPts[Y1]; + if ((width < 0) || (height < 0)) { log.error("Negative extent received. Border won't be painted."); return; } @@ -816,58 +446,91 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { switch (style) { case Constants.EN_DOUBLE: if (horz) { - float h3 = h / 3; - float ym1 = y1; - float ym2 = ym1 + h3 + h3; - getAFPDataStream().createLine(pts2units(x1), pts2units(ym1), - pts2units(x2), pts2units(ym1), pts2units(h3), col); - getAFPDataStream().createLine(pts2units(x1), pts2units(ym2), - pts2units(x2), pts2units(ym2), pts2units(h3), col); + float h3 = height / 3; + float ym2 = dstPts[Y1] + h3 + h3; + afpDataStream.createLine( + coords[X1], + coords[Y1], + coords[X2], + coords[Y1], + Math.round(h3), + col); + afpDataStream.createLine( + coords[X1], + Math.round(ym2), + coords[X2], + Math.round(ym2), + Math.round(h3), + col); } else { - float w3 = w / 3; - float xm1 = x1; - float xm2 = xm1 + w3 + w3; - getAFPDataStream().createLine(pts2units(xm1), pts2units(y1), - pts2units(xm1), pts2units(y2), pts2units(w3), col); - getAFPDataStream().createLine(pts2units(xm2), pts2units(y1), - pts2units(xm2), pts2units(y2), pts2units(w3), col); + float w3 = width / 3; + float xm2 = dstPts[X1] + w3 + w3; + afpDataStream.createLine( + coords[X1], + coords[Y1], + coords[X1], + coords[Y2], + Math.round(w3), + col); + afpDataStream.createLine( + Math.round(xm2), + coords[Y1], + Math.round(xm2), + coords[Y2], + Math.round(w3), + col); } break; case Constants.EN_DASHED: if (horz) { - float w2 = 2 * h; - while (x1 + w2 < x2) { - getAFPDataStream().createLine(pts2units(x1), pts2units(y1), - pts2units(x1 + w2), pts2units(y1), pts2units(h), + float w2 = 2 * height; + while (coords[X1] + w2 < coords[X2]) { + afpDataStream.createLine( + coords[X1], + coords[Y1], + coords[X1] + Math.round(w2), + coords[Y1], + Math.round(height), col); - x1 += 2 * w2; + coords[X1] += 2 * w2; } } else { - float h2 = 2 * w; - while (y1 + h2 < y2) { - getAFPDataStream().createLine(pts2units(x1), pts2units(y1), - pts2units(x1), pts2units(y1 + h2), pts2units(w), + float h2 = 2 * width; + while (coords[Y1] + h2 < coords[Y2]) { + afpDataStream.createLine( + coords[X1], + coords[Y2], + coords[X1], + coords[Y1] + Math.round(h2), + Math.round(width), col); - y1 += 2 * h2; + coords[Y1] += 2 * h2; } } break; case Constants.EN_DOTTED: if (horz) { - while (x1 + h < x2) { - getAFPDataStream() - .createLine(pts2units(x1), pts2units(y1), - pts2units(x1 + h), pts2units(y1), - pts2units(h), col); - x1 += 2 * h; + while (coords[X1] + height < coords[X2]) { + afpDataStream.createLine( + coords[X1], + coords[Y1], + coords[X1] + Math.round(height), + coords[Y1], + Math.round(height), + col + ); + coords[X1] += 2 * height; } } else { - while (y1 + w < y2) { - getAFPDataStream() - .createLine(pts2units(x1), pts2units(y1), - pts2units(x1), pts2units(y1 + w), - pts2units(w), col); - y1 += 2 * w; + while (y1 + width < y2) { + afpDataStream.createLine( + coords[X1], + coords[Y1], + coords[X1], + coords[Y1] + Math.round(width), + Math.round(width), + col); + coords[Y1] += 2 * width; } } break; @@ -877,29 +540,54 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { if (horz) { Color uppercol = lightenColor(col, -colFactor); Color lowercol = lightenColor(col, colFactor); - float h3 = h / 3; - float ym1 = y1; - getAFPDataStream().createLine(pts2units(x1), pts2units(ym1), - pts2units(x2), pts2units(ym1), pts2units(h3), uppercol); - getAFPDataStream().createLine(pts2units(x1), - pts2units(ym1 + h3), pts2units(x2), - pts2units(ym1 + h3), pts2units(h3), col); - getAFPDataStream().createLine(pts2units(x1), - pts2units(ym1 + h3 + h3), pts2units(x2), - pts2units(ym1 + h3 + h3), pts2units(h3), lowercol); + float h3 = height / 3; + afpDataStream.createLine( + coords[X1], + coords[Y1], + coords[X2], + coords[Y1], + Math.round(h3), + uppercol); + afpDataStream.createLine( + coords[X1], + Math.round(dstPts[Y1] + h3), + coords[X2], + Math.round(dstPts[Y1] + h3), + Math.round(h3), + col); + afpDataStream.createLine( + coords[X1], + Math.round(dstPts[Y1] + h3 + h3), + coords[X2], + Math.round(dstPts[Y1] + h3 + h3), + Math.round(h3), + lowercol); } else { Color leftcol = lightenColor(col, -colFactor); Color rightcol = lightenColor(col, colFactor); - float w3 = w / 3; - float xm1 = x1 + (w3 / 2); - getAFPDataStream().createLine(pts2units(xm1), pts2units(y1), - pts2units(xm1), pts2units(y2), pts2units(w3), leftcol); - getAFPDataStream().createLine(pts2units(xm1 + w3), - pts2units(y1), pts2units(xm1 + w3), pts2units(y2), - pts2units(w3), col); - getAFPDataStream().createLine(pts2units(xm1 + w3 + w3), - pts2units(y1), pts2units(xm1 + w3 + w3), pts2units(y2), - pts2units(w3), rightcol); + float w3 = width / 3; + float xm1 = dstPts[X1] + (w3 / 2); + afpDataStream.createLine( + Math.round(xm1), + coords[Y1], + Math.round(xm1), + coords[Y2], + Math.round(w3), + leftcol); + afpDataStream.createLine( + Math.round(xm1 + w3), + coords[Y1], + Math.round(xm1 + w3), + coords[Y2], + Math.round(w3), + col); + afpDataStream.createLine( + Math.round(xm1 + w3 + w3), + coords[Y1], + Math.round(xm1 + w3 + w3), + coords[Y2], + Math.round(w3), + rightcol); } break; } @@ -908,28 +596,24 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { case Constants.EN_INSET: case Constants.EN_OUTSET: default: - getAFPDataStream().createLine(pts2units(x1), pts2units(y1), - pts2units(horz ? x2 : x1), pts2units(horz ? y1 : y2), - pts2units(Math.abs(horz ? (y2 - y1) : (x2 - x1))), col); + afpDataStream.createLine( + coords[X1], + coords[Y1], + (horz ? coords[X2] : coords[X1]), + (horz ? coords[Y1] : coords[Y2]), + Math.abs(Math.round(horz ? height : width)), + col); } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected RendererContext createRendererContext(int x, int y, int width, int height, Map foreignAttributes) { RendererContext context; context = super.createRendererContext(x, y, width, height, foreignAttributes); - context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE, Boolean - .valueOf(!this.colorImages)); context.setProperty(AFPRendererContextConstants.AFP_FONT_INFO, this.fontInfo); - context.setProperty(AFPRendererContextConstants.AFP_RESOLUTION, - new Integer(this.resolution)); - context.setProperty(AFPRendererContextConstants.AFP_BITS_PER_PIXEL, - new Integer(this.bitsPerPixel)); context.setProperty(AFPRendererContextConstants.AFP_DATASTREAM, getAFPDataStream()); context.setProperty(AFPRendererContextConstants.AFP_STATE, getState()); @@ -944,17 +628,18 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) { uri = URISpecification.getURL(uri); - getState().setImageUri(uri); + currentState.setImageUri(uri); Rectangle posInt = new Rectangle((int) pos.getX(), (int) pos.getY(), (int) pos.getWidth(), (int) pos.getHeight()); Point origin = new Point(currentIPPosition, currentBPPosition); int x = origin.x + posInt.x; int y = origin.y + posInt.y; - + String name = (String)getPageSegments().get(uri); if (name != null) { - getAFPDataStream().createIncludePageSegment(name, mpts2units(x), - mpts2units(y)); + float[] srcPts = {x, y}; + int[] coords = mpts2units(srcPts); + getAFPDataStream().createIncludePageSegment(name, coords[X], coords[Y]); } else { ImageManager manager = getUserAgent().getFactory().getImageManager(); ImageInfo info = null; @@ -989,31 +674,41 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { ImageRawCCITTFax ccitt = (ImageRawCCITTFax) img; in = ccitt.createInputStream(); byte[] buf = IOUtils.toByteArray(in); - int afpx = mpts2units(posInt.x + currentIPPosition); - int afpy = mpts2units(posInt.y + currentBPPosition); - int afpw = mpts2units(posInt.getWidth()); - int afph = mpts2units(posInt.getHeight()); - int afpres = getResolution(); + float[] srcPts = new float[] { + posInt.x + currentIPPosition, + posInt.y + currentBPPosition, + (float)posInt.getWidth(), + (float)posInt.getHeight() + }; + int[] coords = mpts2units(srcPts); String mimeType = info.getMimeType(); // create image object parameters ImageObjectInfo imageObjectInfo = new ImageObjectInfo(); + imageObjectInfo.setBuffered(false); imageObjectInfo.setUri(uri); imageObjectInfo.setMimeType(mimeType); ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo(); - objectAreaInfo.setX(afpx); - objectAreaInfo.setY(afpy); - objectAreaInfo.setWidth(afpw); - objectAreaInfo.setHeight(afph); - objectAreaInfo.setWidthRes(afpres); - objectAreaInfo.setHeightRes(afpres); + objectAreaInfo.setX(coords[X]); + objectAreaInfo.setY(coords[Y]); + int resolution = currentState.getResolution(); + int w = Math.round( + ((float)posInt.getWidth() * 1000) + / (AFPConstants.DPI_72_MPTS / resolution)); + int h = Math.round( + ((float)posInt.getHeight() * 1000) + / (AFPConstants.DPI_72_MPTS / resolution)); + objectAreaInfo.setWidth(w); + objectAreaInfo.setHeight(h); + objectAreaInfo.setWidthRes(resolution); + objectAreaInfo.setHeightRes(resolution); imageObjectInfo.setObjectAreaInfo(objectAreaInfo); imageObjectInfo.setData(buf); imageObjectInfo.setDataHeight(ccitt.getSize().getHeightPx()); imageObjectInfo.setDataWidth(ccitt.getSize().getWidthPx()); - imageObjectInfo.setColor(colorImages); - imageObjectInfo.setBitsPerPixel(bitsPerPixel); + imageObjectInfo.setColor(currentState.isColorImages()); + imageObjectInfo.setBitsPerPixel(currentState.getBitsPerPixel()); imageObjectInfo.setCompression(ccitt.getCompression()); imageObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes); getAFPDataStream().createObject(imageObjectInfo); @@ -1079,15 +774,15 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * the x coordinate (in mpt) * @param y * the y coordinate (in mpt) - * @param w + * @param width * the width of the viewport (in mpt) - * @param h + * @param height * the height of the viewport (in mpt) * @param foreignAttributes * a mapping of foreign attributes */ public void drawBufferedImage(ImageInfo imageInfo, RenderedImage image, - int imageRes, int x, int y, int w, int h, Map foreignAttributes) { + int imageRes, int x, int y, int width, int height, Map foreignAttributes) { ByteArrayOutputStream baout = new ByteArrayOutputStream(); try { // Serialize image @@ -1111,129 +806,127 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo(); - objectAreaInfo.setX(mpts2units(x)); - objectAreaInfo.setY(mpts2units(y)); - objectAreaInfo.setWidth(mpts2units(w)); - objectAreaInfo.setHeight(mpts2units(h)); + + float[] srcPts = new float[] {x, y}; + int[] coords = mpts2units(srcPts); + objectAreaInfo.setX(coords[X]); + objectAreaInfo.setY(coords[Y]); + int resolution = currentState.getResolution(); + int w = Math.round( + (width * 1000) + / (AFPConstants.DPI_72_MPTS / resolution)); + int h = Math.round( + (height * 1000) + / (AFPConstants.DPI_72_MPTS / resolution)); + objectAreaInfo.setWidth(w); + objectAreaInfo.setHeight(h); + objectAreaInfo.setWidthRes(imageRes); objectAreaInfo.setHeightRes(imageRes); imageObjectInfo.setObjectAreaInfo(objectAreaInfo); - + imageObjectInfo.setData(baout.toByteArray()); imageObjectInfo.setDataHeight(image.getHeight()); imageObjectInfo.setDataWidth(image.getWidth()); - imageObjectInfo.setColor(colorImages); - imageObjectInfo.setBitsPerPixel(bitsPerPixel); + imageObjectInfo.setColor(currentState.isColorImages()); + imageObjectInfo.setBitsPerPixel(currentState.getBitsPerPixel()); imageObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes); getAFPDataStream().createObject(imageObjectInfo); } - /** - * Establishes a new foreground or fill color. {@inheritDoc} - */ + /** {@inheritDoc} */ public void updateColor(Color col, boolean fill) { if (fill) { - currentColor = col; + currentState.setColor(col); } } /** {@inheritDoc} */ - public List breakOutOfStateStack() { - log.debug("Block.FIXED --> break out"); - List breakOutList = new java.util.ArrayList(); - //Don't pop the last ViewPortPos (created by renderPage()) - while (this.viewPortPositions.size() > 1) { - breakOutList.add(0, popViewPortPos()); + public void restoreStateStackAfterBreakOut(List breakOutList) { + log.debug("Block.FIXED --> restoring context after break-out"); + AbstractState.AbstractData data; + Iterator it = breakOutList.iterator(); + while (it.hasNext()) { + data = (AbstractState.AbstractData)it.next(); + saveGraphicsState(); + concatenateTransformationMatrix(data.getTransform()); } - return breakOutList; } /** {@inheritDoc} */ - public void restoreStateStackAfterBreakOut(List breakOutList) { - log.debug("Block.FIXED --> restoring context after break-out"); - for (int i = 0, c = breakOutList.size(); i < c; i++) { - ViewPortPos vps = (ViewPortPos)breakOutList.get(i); - pushViewPortPos(vps); + protected List breakOutOfStateStack() { + log.debug("Block.FIXED --> break out"); + List breakOutList = new java.util.ArrayList(); + AbstractState.AbstractData data; + while (true) { + data = currentState.getData(); + if (currentState.pop() == null) { + break; + } + breakOutList.add(0, data); //Insert because of stack-popping } + return breakOutList; } - /** Saves the graphics state of the rendering engine. */ + /** {@inheritDoc} */ public void saveGraphicsState() { - + currentState.push(); } - /** Restores the last graphics state of the rendering engine. */ + /** {@inheritDoc} */ public void restoreGraphicsState() { - + currentState.pop(); } /** Indicates the beginning of a text object. */ public void beginTextObject() { - + //TODO maybe? + log.debug("NYI beginTextObject()"); } /** Indicates the end of a text object. */ public void endTextObject() { - + //TODO maybe? + log.debug("NYI endTextObject()"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void renderImage(Image image, Rectangle2D pos) { drawImage(image.getURL(), pos, image.getForeignAttributes()); } - /** - * {@inheritDoc} - */ - public void renderText(TextArea text) { + /** {@inheritDoc} */ + public void renderText(TextArea text) { + log.debug(text.getText()); renderInlineAreaBackAndBorders(text); String name = getInternalFontNameForArea(text); - this.currentFontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)) - .intValue(); - AFPFont font = (AFPFont) fontInfo.getFonts().get(name); - - Color col = (Color) text.getTrait(Trait.COLOR); - - int vsci = mpts2units(font.getWidth(' ', currentFontSize) / 1000 - + text.getTextWordSpaceAdjust() - + text.getTextLetterSpaceAdjust()); - - // word.getOffset() = only height of text itself - // currentBlockIPPosition: 0 for beginning of line; nonzero - // where previous line area failed to take up entire allocated space - int rx = currentIPPosition + text.getBorderAndPaddingWidthStart(); - int bl = currentBPPosition + text.getOffset() - + text.getBaselineOffset(); + int fontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); + currentState.setFontSize(fontSize); + AFPFont font = (AFPFont)fontInfo.getFonts().get(name); // Set letterSpacing // float ls = fs.getLetterSpacing() / this.currentFontSize; - String worddata = text.getText(); - // Create an AFPFontAttributes object from the current font details - AFPFontAttributes afpFontAttributes = new AFPFontAttributes(name, font, - currentFontSize); + AFPFontAttributes afpFontAttributes + = new AFPFontAttributes(name, font, fontSize); - if (!getCurrentPageFonts().containsKey(afpFontAttributes.getFontKey())) { + AFPPageFonts pageFonts = currentState.getPageFonts(); + if (!pageFonts.containsKey(afpFontAttributes.getFontKey())) { // Font not found on current page, so add the new one - this.pageFontCounter++; - afpFontAttributes.setFontReference(pageFontCounter); - getCurrentPageFonts().put(afpFontAttributes.getFontKey(), - afpFontAttributes); + afpFontAttributes.setFontReference(currentState.incrementPageFontCount()); + pageFonts.put(afpFontAttributes.getFontKey(), afpFontAttributes); } else { // Use the previously stored font attributes - afpFontAttributes = (AFPFontAttributes) currentPageFontMap - .get(afpFontAttributes.getFontKey()); + afpFontAttributes = (AFPFontAttributes) pageFonts.get(afpFontAttributes.getFontKey()); } // Try and get the encoding to use for the font String encoding = null; try { - encoding = font.getCharacterSet(currentFontSize).getEncoding(); + encoding = font.getCharacterSet(fontSize).getEncoding(); } catch (Throwable ex) { encoding = AFPConstants.EBCIDIC_ENCODING; log.warn("renderText():: Error getting encoding for font '" @@ -1241,19 +934,50 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { + encoding); } + byte[] data = null; try { - getAFPDataStream().createText(afpFontAttributes.getFontReference(), - mpts2units(rx), mpts2units(bl), col, vsci, - mpts2units(text.getTextLetterSpaceAdjust()), - worddata.getBytes(encoding)); + String worddata = text.getText(); + data = worddata.getBytes(encoding); } catch (UnsupportedEncodingException usee) { log.error("renderText:: Font " + afpFontAttributes.getFontKey() + " caused UnsupportedEncodingException"); + return; } + int fontReference = afpFontAttributes.getFontReference(); + + int x = (currentIPPosition + text.getBorderAndPaddingWidthStart()); + int y = (currentBPPosition + text.getOffset() + text.getBaselineOffset()); + float[] srcPts = new float[] {x, y}; + int[] coords = mpts2units(srcPts); + + Color color = (Color) text.getTrait(Trait.COLOR); + + int variableSpaceCharacterIncrement = font.getWidth(' ', fontSize) / 1000 + + text.getTextWordSpaceAdjust() + + text.getTextLetterSpaceAdjust(); + int resolution = currentState.getResolution(); + variableSpaceCharacterIncrement /= (AFPConstants.DPI_72_MPTS / resolution); + + int interCharacterAdjustment = text.getTextLetterSpaceAdjust(); + interCharacterAdjustment /= (AFPConstants.DPI_72_MPTS / resolution); + + AFPTextDataInfo textDataInfo = new AFPTextDataInfo(); + textDataInfo.setFontReference(fontReference); + textDataInfo.setX(coords[X]); + textDataInfo.setY(coords[Y]); + textDataInfo.setColor(color); + textDataInfo.setVariableSpaceCharacterIncrement(variableSpaceCharacterIncrement); + textDataInfo.setInterCharacterAdjustment(interCharacterAdjustment); + textDataInfo.setData(data); + getAFPDataStream().createText(textDataInfo); + // word.getOffset() = only height of text itself + // currentBlockIPPosition: 0 for beginning of line; nonzero + // where previous line area failed to take up entire allocated space + super.renderText(text); - renderTextDecoration(font, currentFontSize, text, bl, rx); + renderTextDecoration(font, fontSize, text, coords[Y], coords[X]); } /** @@ -1291,58 +1015,6 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { super.renderLeader(area); } - /** - * Sets the AFPRenderer options - * - * @param options - * the Map containing the options - */ - // UNUSED - // public void setOptions(Map options) { - // - // this.afpOptions = options; - // - // } - /** - * Determines the orientation from the string representation, this method - * guarantees to return a value of either 0, 90, 180 or 270. - * - * @return the orientation - */ - // UNUSED - // private int getOrientation(String orientationString) { - // - // int orientation = 0; - // if (orientationString != null && orientationString.length() > 0) { - // try { - // orientation = Integer.parseInt(orientationString); - // } catch (NumberFormatException nfe) { - // log.error("Cannot use orientation of " + orientation - // + " defaulting to zero."); - // orientation = 0; - // } - // } else { - // orientation = 0; - // } - // switch (orientation) { - // case 0: - // break; - // case 90: - // break; - // case 180: - // break; - // case 270: - // break; - // default: - // log.error("Cannot use orientation of " + orientation - // + " defaulting to zero."); - // orientation = 0; - // break; - // } - // - // return orientation; - // - // } /** * Sets the rotation to be used for portrait pages, valid values are 0 * (default), 90, 180, 270. @@ -1351,15 +1023,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * The rotation in degrees. */ public void setPortraitRotation(int rotation) { - if (rotation == 0 || rotation == 90 || rotation == 180 - || rotation == 270) { - portraitRotation = rotation; - } else { - throw new IllegalArgumentException( - "The portrait rotation must be one" - + " of the values 0, 90, 180, 270"); - - } + currentState.setPortraitRotation(rotation); } /** @@ -1370,14 +1034,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * The rotation in degrees. */ public void setLandscapeRotation(int rotation) { - if (rotation == 0 || rotation == 90 || rotation == 180 - || rotation == 270) { - landscapeRotation = rotation; - } else { - throw new IllegalArgumentException( - "The landscape rotation must be one" - + " of the values 0, 90, 180, 270"); - } + currentState.setLandscapeRotation(rotation); } /** @@ -1444,215 +1101,6 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } - /** - * Converts FOP mpt measurement to afp measurement units - * - * @param mpt - * the millipoints value - */ - private int mpts2units(int mpt) { - return mpts2units((double) mpt); - } - - /** - * Converts FOP pt measurement to afp measurement units - * - * @param mpt - * the millipoints value - */ - private int pts2units(float mpt) { - return mpts2units(mpt * 1000d); - } - - /** - * Converts FOP mpt measurement to afp measurement units - * - * @param mpt - * the millipoints value - * @return afp measurement unit value - */ - private int mpts2units(double mpt) { - return (int) Math - .round(mpt / (DPI_CONVERSION_FACTOR / getResolution())); - } - - /** - * Converts a byte array containing 24 bit RGB image data to a grayscale - * image. - * - * @param io - * the target image object - * @param raw - * the buffer containing the RGB image data - * @param width - * the width of the image in pixels - * @param height - * the height of the image in pixels - * @param bitsPerPixel - * the number of bits to use per pixel - */ - protected static void convertToGrayScaleImage(ImageObject io, byte[] raw, - int width, int height, int bitsPerPixel) { - int pixelsPerByte = 8 / bitsPerPixel; - int bytewidth = (width / pixelsPerByte); - if ((width % pixelsPerByte) != 0) { - bytewidth++; - } - byte[] bw = new byte[height * bytewidth]; - byte ib; - for (int y = 0; y < height; y++) { - ib = 0; - int i = 3 * y * width; - for (int x = 0; x < width; x++, i += 3) { - - // see http://www.jguru.com/faq/view.jsp?EID=221919 - double greyVal = 0.212671d * ((int) raw[i] & 0xff) + 0.715160d - * ((int) raw[i + 1] & 0xff) + 0.072169d - * ((int) raw[i + 2] & 0xff); - switch (bitsPerPixel) { - case 1: - if (greyVal < 128) { - ib |= (byte) (1 << (7 - (x % 8))); - } - break; - case 4: - greyVal /= 16; - ib |= (byte) ((byte) greyVal << ((1 - (x % 2)) * 4)); - break; - case 8: - ib = (byte) greyVal; - break; - default: - throw new UnsupportedOperationException( - "Unsupported bits per pixel: " + bitsPerPixel); - } - - if ((x % pixelsPerByte) == (pixelsPerByte - 1) - || ((x + 1) == width)) { - bw[(y * bytewidth) + (x / pixelsPerByte)] = ib; - ib = 0; - } - } - } - io.setImageIDESize((byte) bitsPerPixel); - io.setImageData(bw); - } - - private final class ViewPortPos { - private int x = 0; - - private int y = 0; - - private int rot = 0; - - private ViewPortPos() { - } - - private ViewPortPos(Rectangle2D view, CTM ctm) { - ViewPortPos currentVP = (ViewPortPos) viewPortPositions - .get(viewPortPositions.size() - 1); - int xOrigin; - int yOrigin; - int width; - int height; - switch (currentVP.rot) { - case 90: - width = mpts2units(view.getHeight()); - height = mpts2units(view.getWidth()); - xOrigin = pageWidth - width - mpts2units(view.getY()) - - currentVP.y; - yOrigin = mpts2units(view.getX()) + currentVP.x; - break; - case 180: - width = mpts2units(view.getWidth()); - height = mpts2units(view.getHeight()); - xOrigin = pageWidth - width - mpts2units(view.getX()) - - currentVP.x; - yOrigin = pageHeight - height - mpts2units(view.getY()) - - currentVP.y; - break; - case 270: - width = mpts2units(view.getHeight()); - height = mpts2units(view.getWidth()); - xOrigin = mpts2units(view.getY()) + currentVP.y; - yOrigin = pageHeight - height - mpts2units(view.getX()) - - currentVP.x; - break; - default: - xOrigin = mpts2units(view.getX()) + currentVP.x; - yOrigin = mpts2units(view.getY()) + currentVP.y; - width = mpts2units(view.getWidth()); - height = mpts2units(view.getHeight()); - break; - } - this.rot = currentVP.rot; - double[] ctmf = ctm.toArray(); - if (ctmf[0] == 0.0d && ctmf[1] == -1.0d && ctmf[2] == 1.0d - && ctmf[3] == 0.d) { - this.rot += 270; - } else if (ctmf[0] == -1.0d && ctmf[1] == 0.0d && ctmf[2] == 0.0d - && ctmf[3] == -1.0d) { - this.rot += 180; - } else if (ctmf[0] == 0.0d && ctmf[1] == 1.0d && ctmf[2] == -1.0d - && ctmf[3] == 0.0d) { - this.rot += 90; - } - this.rot %= 360; - switch (this.rot) { - /* - * case 0: this.x = mpts2units(view.getX()) + x; this.y = - * mpts2units(view.getY()) + y; break; case 90: this.x = - * mpts2units(view.getY()) + y; this.y = _pageWidth - - * mpts2units(view.getX() + view.getWidth()) - x; break; case 180: - * this.x = _pageWidth - mpts2units(view.getX() + view.getWidth()) - - * x; this.y = _pageHeight - mpts2units(view.getY() + - * view.getHeight()) - y; break; case 270: this.x = _pageHeight - - * mpts2units(view.getY() + view.getHeight()) - y; this.y = - * mpts2units(view.getX()) + x; break; - */ - case 0: - this.x = xOrigin; - this.y = yOrigin; - break; - case 90: - this.x = yOrigin; - this.y = pageWidth - width - xOrigin; - break; - case 180: - this.x = pageWidth - width - xOrigin; - this.y = pageHeight - height - yOrigin; - break; - case 270: - this.x = pageHeight - height - yOrigin; - this.y = xOrigin; - break; - default: - } - } - - public String toString() { - return "x:" + x + " y:" + y + " rot:" + rot; - } - - } - - private List viewPortPositions = new java.util.ArrayList(); - - private void pushViewPortPos(ViewPortPos vpp) { - viewPortPositions.add(vpp); - getAFPDataStream().setOffsets(vpp.x, vpp.y, vpp.rot); - } - - private ViewPortPos popViewPortPos() { - ViewPortPos current = (ViewPortPos)viewPortPositions.remove(viewPortPositions.size() - 1); - if (viewPortPositions.size() > 0) { - ViewPortPos vpp = (ViewPortPos) viewPortPositions - .get(viewPortPositions.size() - 1); - getAFPDataStream().setOffsets(vpp.x, vpp.y, vpp.rot); - } - return current; - } - /** * Sets the number of bits used per pixel * @@ -1660,17 +1108,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * number of bits per pixel */ public void setBitsPerPixel(int bitsPerPixel) { - this.bitsPerPixel = bitsPerPixel; - switch (bitsPerPixel) { - case 1: - case 4: - case 8: - break; - default: - log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8."); - bitsPerPixel = 8; - break; - } + currentState.setBitsPerPixel(bitsPerPixel); } /** @@ -1680,7 +1118,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * color image output */ public void setColorImages(boolean colorImages) { - this.colorImages = colorImages; + currentState.setColorImages(colorImages); } /** @@ -1702,10 +1140,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * the output resolution (dpi) */ public void setResolution(int resolution) { - if (log.isDebugEnabled()) { - log.debug("renderer-resolution set to: " + resolution + "dpi"); - } - this.resolution = resolution; + ((AFPState)getState()).setResolution(resolution); } /** @@ -1714,18 +1149,19 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * @return the resolution in dpi */ public int getResolution() { - return this.resolution; + return ((AFPState)getState()).getResolution(); } - private AFPState getState() { + /** + * @return the current AFP state + */ + protected AbstractState getState() { if (currentState == null) { currentState = new AFPState(); } return currentState; } - private boolean gocaEnabled = false; - /** * @param enabled * true if AFP GOCA is enabled for SVG support @@ -1740,4 +1176,61 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { protected boolean isGOCAEnabled() { return this.gocaEnabled; } + + // TODO: remove this and use the superclass implementation + /** {@inheritDoc} */ + protected void renderReferenceArea(Block block) { + // save position and offset + int saveIP = currentIPPosition; + int saveBP = currentBPPosition; + + //Establish a new coordinate system + AffineTransform at = new AffineTransform(); + at.translate(currentIPPosition, currentBPPosition); + at.translate(block.getXOffset(), block.getYOffset()); + at.translate(0, block.getSpaceBefore()); + + if (!at.isIdentity()) { + saveGraphicsState(); + concatenateTransformationMatrix(at); + } + + currentIPPosition = 0; + currentBPPosition = 0; + handleBlockTraits(block); + + List children = block.getChildAreas(); + if (children != null) { + renderBlocks(block, children); + } + + if (!at.isIdentity()) { + restoreGraphicsState(); + } + + // stacked and relative blocks effect stacking + currentIPPosition = saveIP; + currentBPPosition = saveBP; + } + + protected int[] transformPoints(float[] srcPts, float[] dstPts) { + return transformPoints(srcPts, dstPts, true); + } + + protected int[] transformPoints(float[] srcPts, float[] dstPts, boolean milli) { + if (dstPts == null) { + dstPts = new float[srcPts.length]; + } + AbstractState state = (AbstractState)getState(); + AffineTransform at = state.getData().getTransform(); + at.transform(srcPts, 0, dstPts, 0, srcPts.length / 2); + int[] coords = new int[srcPts.length]; + for (int i = 0; i < srcPts.length; i++) { + if (!milli) { + dstPts[i] *= 1000; + } + coords[i] = Math.round(dstPts[i]); + } + return coords; + } } diff --git a/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java b/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java index a4b449bb0..360132863 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java @@ -35,15 +35,9 @@ public interface AFPRendererContextConstants extends RendererContextConstants { /** The font information for the AFP renderer. */ String AFP_FONT_INFO = "afpFontInfo"; - /** The afp resolution. */ - String AFP_RESOLUTION = "afpResolution"; - /** The afp datastream */ String AFP_DATASTREAM = "afpDataStream"; /** The afp state */ String AFP_STATE = "afpPageState"; - - /** The afp bits per pixel */ - String AFP_BITS_PER_PIXEL = "afpBitsPerPixel"; } diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index b0d155cd9..9173a1d23 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -34,6 +34,7 @@ import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContextConstants; +import org.apache.fop.render.afp.modca.AFPConstants; import org.apache.fop.render.afp.modca.AFPDataStream; import org.apache.fop.render.afp.modca.GraphicsObject; import org.apache.fop.svg.SVGUserAgent; @@ -71,19 +72,13 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { afpi.setHandlerConfiguration((Configuration)context.getProperty(HANDLER_CONFIGURATION)); afpi.setFontInfo((org.apache.fop.fonts.FontInfo)context.getProperty( AFPRendererContextConstants.AFP_FONT_INFO)); - afpi.setResolution(((Integer)context.getProperty( - AFPRendererContextConstants.AFP_RESOLUTION)).intValue()); afpi.setState((AFPState)context.getProperty( AFPRendererContextConstants.AFP_STATE)); afpi.setAFPDataStream((AFPDataStream)context.getProperty( AFPRendererContextConstants.AFP_DATASTREAM)); - afpi.setColor(!((Boolean)context.getProperty( - AFPRendererContextConstants.AFP_GRAYSCALE)).booleanValue()); - afpi.setBitsPerPixel(((Integer)context.getProperty( - AFPRendererContextConstants.AFP_BITS_PER_PIXEL)).intValue()); return afpi; } - + /** * Render the SVG document. * @@ -137,20 +132,20 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { double h = ctx.getDocumentSize().getHeight() * 1000f; // convert to afp inches - double sx = ((afpInfo.getWidth() / w) * res) / 72f; - double sy = ((afpInfo.getHeight() / h) * res) / 72f; - double xOffset = (afpInfo.getX() * res) / 72000f; - double yOffset = ((afpInfo.getHeight() - afpInfo.getY()) * res) / 72000f; + double scaleX = ((afpInfo.getWidth() / w) * res) / AFPConstants.DPI_72; + double scaleY = ((afpInfo.getHeight() / h) * res) / AFPConstants.DPI_72; + double xOffset = (afpInfo.getX() * res) / AFPConstants.DPI_72_MPTS; + double yOffset = ((afpInfo.getHeight() - afpInfo.getY()) * res) / AFPConstants.DPI_72_MPTS; // Transformation matrix that establishes the local coordinate system for the SVG graphic // in relation to the current coordinate system (note: y axis is inverted) - AffineTransform trans = new AffineTransform(sx, 0, 0, -sy, xOffset, yOffset); + AffineTransform trans = new AffineTransform(scaleX, 0, 0, -scaleY, xOffset, yOffset); graphics.setTransform(trans); - int x = (int)Math.round((afpInfo.getX() * 25.4f) / 1000); - int y = (int)Math.round((afpInfo.getY() * 25.4f) / 1000); - int width = (int)Math.round((afpInfo.getWidth() * res) / 72000f); - int height = (int)Math.round((afpInfo.getHeight() * res) / 72000f); + int x = (int)Math.round((afpInfo.getX() * 25.4f) / 1000f); + int y = (int)Math.round((afpInfo.getY() * 25.4f) / 1000f); + int width = (int)Math.round((afpInfo.getWidth() * res) / AFPConstants.DPI_72_MPTS); + int height = (int)Math.round((afpInfo.getHeight() * res) / AFPConstants.DPI_72_MPTS); // set the data object parameters DataObjectInfo dataObjectInfo = new DataObjectInfo(); diff --git a/src/java/org/apache/fop/render/afp/AFPState.java b/src/java/org/apache/fop/render/afp/AFPState.java index 7c28e8bf0..9d93817be 100644 --- a/src/java/org/apache/fop/render/afp/AFPState.java +++ b/src/java/org/apache/fop/render/afp/AFPState.java @@ -19,157 +19,183 @@ package org.apache.fop.render.afp; -import java.awt.Color; -import java.io.Serializable; -import java.util.Arrays; -import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** - * This keeps information about the current state when writing to pdf. + * This keeps information about the current state when writing to an AFP datastream. */ -public class AFPState { - private Data data = new Data(); - - private List stateStack = new java.util.ArrayList(); +public class AFPState extends org.apache.fop.render.AbstractState { + + private static Log log = LogFactory.getLog("org.apache.fop.render.afp.AFPState"); /** - * Set the current color. - * Check if the new color is a change and then set the current color. - * - * @param col the color to set - * @return true if the color has changed + * The portrait rotation */ - protected boolean setColor(Color col) { - if (!col.equals(getData().color)) { - getData().color = col; - return true; + private int portraitRotation = 0; + + /** + * The landscape rotation + */ + private int landscapeRotation = 270; + + /** + * Flag to the set the output object type for images + */ + private boolean colorImages = false; + + /** + * Default value for image depth + */ + private int bitsPerPixel = 8; + + /** + * The output resolution + */ + private int resolution = 240; // 240 dpi + + /** + * The current page + */ + private AFPPageState pageState = new AFPPageState(); + + /** + * Sets the rotation to be used for portrait pages, valid values are 0 + * (default), 90, 180, 270. + * + * @param rotation + * The rotation in degrees. + */ + protected void setPortraitRotation(int rotation) { + if (rotation == 0 || rotation == 90 || rotation == 180 + || rotation == 270) { + portraitRotation = rotation; + } else { + throw new IllegalArgumentException( + "The portrait rotation must be one" + + " of the values 0, 90, 180, 270"); + } - return false; } /** - * Sets if the current painted shape is to be filled - * @param fill true if the current painted shape is to be filled - * @return true if the fill value has changed + * @return the rotation to be used for portrait pages */ - protected boolean setFill(boolean fill) { - if (fill != getData().filled) { - getData().filled = fill; - return true; - } - return false; + protected int getPortraitRotation() { + return this.portraitRotation; } /** - * Get the color. - * @return the color + * Sets the rotation to be used for landscape pages, valid values are 0, 90, + * 180, 270 (default). + * + * @param rotation + * The rotation in degrees. */ - protected Color getColor() { - if (getData().color == null) { - getData().color = Color.black; + protected void setLandscapeRotation(int rotation) { + if (rotation == 0 || rotation == 90 || rotation == 180 + || rotation == 270) { + landscapeRotation = rotation; + } else { + throw new IllegalArgumentException( + "The landscape rotation must be one" + + " of the values 0, 90, 180, 270"); } - return getData().color; } /** - * Set the current line width. - * @param width the line width in points - * @return true if the line width has changed + * @return the landscape rotation */ - protected boolean setLineWidth(float width) { - if (getData().lineWidth != width) { - getData().lineWidth = width; - return true; - } - return false; + protected int getLandscapeRotation() { + return this.landscapeRotation; } /** - * Sets the dash array (line type) for the current basic stroke - * @param dash the line dash array - * @return true if the dash array has changed + * Sets the number of bits used per pixel + * + * @param bitsPerPixel + * number of bits per pixel */ - public boolean setDashArray(float[] dash) { - if (!Arrays.equals(dash, getData().dashArray)) { - getData().dashArray = dash; - return true; + public void setBitsPerPixel(int bitsPerPixel) { + this.bitsPerPixel = bitsPerPixel; + switch (bitsPerPixel) { + case 1: + case 4: + case 8: + break; + default: + log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8."); + bitsPerPixel = 8; + break; } - return false; } /** - * Gets the current line width - * @return the current line width + * @return the number of bits per pixel */ - protected float getLineWidth() { - return getData().lineWidth; + public int getBitsPerPixel() { + return this.bitsPerPixel; } /** - * Get the background color. - * @return the background color + * Sets whether images are color or not + * + * @param colorImages + * color image output */ - protected Color getBackColor() { - if (getData().backColor == null) { - getData().backColor = Color.white; - } - return getData().backColor; + public void setColorImages(boolean colorImages) { + this.colorImages = colorImages; } /** - * Set the current background color. - * Check if the new background color is a change and then set the current background color. - * - * @param col the background color to set - * @return true if the color has changed + * @return true if color images are to be used */ - protected boolean setBackColor(Color col) { - if (!col.equals(getData().backColor)) { - getData().backColor = col; - return true; - } - return false; + protected boolean isColorImages() { + return this.colorImages; } /** - * Set the current font name - * @param internalFontName the internal font name - * @return true if the font name has changed + * Sets the output/device resolution + * + * @param resolution + * the output resolution (dpi) */ - protected boolean setFontName(String internalFontName) { - if (!internalFontName.equals(getData().fontName)) { - getData().fontName = internalFontName; - return true; + public void setResolution(int resolution) { + if (log.isDebugEnabled()) { + log.debug("renderer-resolution set to: " + resolution + "dpi"); } - return false; + this.resolution = resolution; } /** - * Gets the current font name - * @return the current font name + * Returns the output/device resolution. + * + * @return the resolution in dpi */ - protected String getFontName() { - return getData().fontName; + protected int getResolution() { + return this.resolution; } - + + /** {@inheritDoc} */ + protected AbstractData instantiateData() { + return new AFPData(); + } + /** - * Gets the current font size - * @return the current font size + * @return the state of the current page */ - protected int getFontSize() { - return getData().fontSize; + protected AFPPageState getPageState() { + return this.pageState; } - + /** - * Set the current font size. - * Check if the font size is a change and then set the current font size. - * - * @param size the font size to set - * @return true if the font size has changed + * Sets if the current painted shape is to be filled + * @param fill true if the current painted shape is to be filled + * @return true if the fill value has changed */ - protected boolean setFontSize(int size) { - if (size != getData().fontSize) { - getData().fontSize = size; + protected boolean setFill(boolean fill) { + if (fill != ((AFPData)getData()).filled) { + ((AFPData)getData()).filled = fill; return true; } return false; @@ -180,137 +206,177 @@ public class AFPState { * @return the current page fonts */ protected AFPPageFonts getPageFonts() { - if (getData().pageFonts == null) { - getData().pageFonts = new AFPPageFonts(); - } - return getData().pageFonts; + return pageState.getFonts(); } /** - * Sets the image uri of the current image being processed - * @param uri the image uri of the current image being processed - * @return true if the image uri has changed + * Increments and returns the page font count + * @return the page font count */ - public boolean setImageUri(String uri) { - if (!uri.equals(getData().imageUri)) { - getData().imageUri = uri; - return true; - } - return false; + public int incrementPageFontCount() { + return pageState.incrementFontCount(); } /** - * Returns the image uri of the current image being processed - * @return the image uri of the current image being processed + * Sets the page width + * @param pageWidth the page width */ - protected String getImageUri() { - return getData().imageUri; + public void setPageWidth(int pageWidth) { + pageState.setWidth(pageWidth); } - + /** - * Push the current state onto the stack. - * This call should be used when the q operator is used - * so that the state is known when popped. + * @return the page width */ - public void push() { - Data copy; - try { - copy = (Data)getData().clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e.getMessage()); - } - stateStack.add(copy); + public int getPageWidth() { + return pageState.getWidth(); } /** - * Get the current stack level. - * - * @return the current stack level + * Sets the page height + * @param pageHeight the page height */ - public int getStackLevel() { - return stateStack.size(); + public void setPageHeight(int pageHeight) { + pageState.setHeight(pageHeight); } /** - * Pop the state from the stack and set current values to popped state. - * This should be called when a Q operator is used so - * the state is restored to the correct values. - * @return the restored state, null if the stack is empty + * @return the page height */ - public Data pop() { - if (getStackLevel() > 0) { - Data popped = (Data)stateStack.remove(stateStack.size() - 1); - data = popped; - return popped; - } else { - return null; - } + public int getPageHeight() { + return pageState.getHeight(); } /** - * @return the currently valid state + * Sets the uri of the current image + * @param uri the uri of the current image */ - public Data getData() { - return data; + protected void setImageUri(String uri) { + ((AFPData)getData()).imageUri = uri; } - - /** the state data instance */ - public class Data implements Cloneable, Serializable { - private static final long serialVersionUID = -1789481244175275686L; - /** The current color */ - private Color color = null; + /** + * Gets the uri of the current image + * @return the uri of the current image + */ + public String getImageUri() { + return ((AFPData)getData()).imageUri; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPState{portraitRotation=" + portraitRotation + + ", landscapeRotation=" + landscapeRotation + + ", colorImages=" + colorImages + + ", bitsPerPixel=" + bitsPerPixel + + ", resolution=" + resolution + + ", pageState=" + pageState + + "}"; + } - /** The current background color */ - private Color backColor = null; + /** + * Page level state data + */ + private class AFPPageState { + /** The current page width */ + private int width = 0; - /** The current font name */ - private String fontName = null; + /** The current page height */ + private int height = 0; - /** The current font size */ - private int fontSize = 0; + /** The current page fonts */ + private AFPPageFonts fonts = new AFPPageFonts(); - /** The current line width */ - private float lineWidth = 0; + /** The current page font count */ + private int fontCount = 0; - /** The dash array for the current basic stroke (line type) */ - private float[] dashArray = null; + /** + * @return the page width + */ + protected int getWidth() { + return width; + } + + /** + * Sets the page width + * @param width the page width + */ + protected void setWidth(int width) { + this.width = width; + } + + /** + * @return the page height + */ + protected int getHeight() { + return height; + } + + /** + * Sets the page height + * @param height the page height + */ + protected void setHeight(int height) { + this.height = height; + } + + /** + * @return the page fonts + */ + protected AFPPageFonts getFonts() { + return fonts; + } + + /** + * Sets the current page fonts + * @param fonts the current page fonts + */ + protected void setFonts(AFPPageFonts fonts) { + this.fonts = fonts; + } + + /** + * @return increment and return the current page font count + */ + protected int incrementFontCount() { + return ++fontCount; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPPageState{width=" + width + + ", height=" + height + + ", fonts=" + fonts + + ", fontCount=" + fontCount + + "}"; + } + } + + /** + * Block level data + */ + private class AFPData extends org.apache.fop.render.AbstractState.AbstractData { + private static final long serialVersionUID = -1789481244175275686L; /** The current fill status */ private boolean filled = false; - /** The fonts on the current page */ - private AFPPageFonts pageFonts = null; - - /** The current image uri */ private String imageUri = null; /** {@inheritDoc} */ public Object clone() throws CloneNotSupportedException { - Data obj = new Data(); - obj.color = this.color; - obj.backColor = this.backColor; - obj.fontName = this.fontName; - obj.fontSize = this.fontSize; - obj.lineWidth = this.lineWidth; - obj.dashArray = this.dashArray; + AFPData obj = (AFPData)super.clone(); obj.filled = this.filled; - obj.pageFonts = this.pageFonts; obj.imageUri = this.imageUri; return obj; } - /** {@inheritDoc} */ + /** {@inheritDoc} */ public String toString() { - return "color=" + color - + ", backColor=" + backColor - + ", fontName=" + fontName - + ", fontSize=" + fontSize - + ", lineWidth=" + lineWidth - + ", dashArray=" + dashArray + return "AFPData{" + super.toString() + ", filled=" + filled - + ", pageFonts=" + pageFonts - + ", imageUri=" + imageUri; + + ", imageUri=" + imageUri + + "}"; } } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java b/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java index 49b799489..b6538b327 100644 --- a/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java +++ b/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java @@ -16,6 +16,7 @@ */ /* $Id$ */ + package org.apache.fop.render.afp; public class ObjectAreaInfo { @@ -144,4 +145,4 @@ public class ObjectAreaInfo { + ", heightRes=" + heightRes + ", rotation=" + rotation; } -} \ No newline at end of file +} diff --git a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java index bad46dd7c..8c2c1b958 100644 --- a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java +++ b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java @@ -30,6 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.render.afp.AFPFontAttributes; +import org.apache.fop.render.afp.AFPTextDataInfo; import org.apache.fop.render.afp.DataObjectInfo; import org.apache.fop.render.afp.ObjectAreaInfo; import org.apache.fop.render.afp.ResourceInfo; @@ -121,20 +122,10 @@ public class AFPDataStream extends AbstractResourceGroupContainer { */ private int landscapeRotation = 270; - /** - * The x offset - */ - private int xOffset = 0; - - /** - * The y offset - */ - private int yOffset = 0; - /** * The rotation */ - private int rotation; + private int orientation; /** * The outputstream for the data stream @@ -276,7 +267,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { pageRotation, pageWidthRes, pageHeightRes); currentPage = currentPageObject; currentOverlay = null; - setOffsets(0, 0, 0); +// setOffsets(0, 0, 0); } /** @@ -315,7 +306,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { currentPageObject.createIncludePageOverlay(overlayName, x, y, 0); currentPage = currentOverlay; - setOffsets(0, 0, 0); +// setOffsets(0, 0, 0); } /** @@ -380,15 +371,24 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * the offset in the x direction * @param yOff * the offset in the y direction - * @param rot + * @param orientation * the rotation + * @deprecated offsets are no longer used, use setOrientation() for setting the orientation */ - public void setOffsets(int xOff, int yOff, int rot) { - this.xOffset = xOff; - this.yOffset = yOff; - this.rotation = rot; + public void setOffsets(int xOff, int yOff, int orientation) { + setOrientation(orientation); } + /** + * Sets the orientation to be used for element positioning + * + * @param orientation + * the orientation used for element positioning + */ + public void setOrientation(int orientation) { + this.orientation = orientation; + } + /** * Creates the given page fonts in the current page * @@ -425,25 +425,12 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * Helper method to create text on the current page, this method delegates * to the current presentation text object in order to construct the text. * - * @param fontReference - * the font reference used as the resource identifier - * @param x - * the x coordinate of the text - * @param y - * the y coordinate of the text - * @param col - * the text color - * @param vsci - * The variable space character increment. - * @param ica - * The inter character adjustment. - * @param data - * the text data to create + * @param textDataInfo + * the afp text data */ - public void createText(int fontReference, int x, int y, Color col, - int vsci, int ica, byte[] data) { - getCurrentPage().createText(fontReference, x + xOffset, y + yOffset, - rotation, col, vsci, ica, data); + public void createText(AFPTextDataInfo textDataInfo) { + textDataInfo.setOrientation(orientation); + getCurrentPage().createText(textDataInfo); } /** @@ -469,8 +456,8 @@ public class AFPDataStream extends AbstractResourceGroupContainer { //Update placement with current state ObjectAreaInfo areaInfo = dataObjectInfo.getObjectAreaInfo(); - areaInfo.setX(areaInfo.getX() + this.xOffset); - areaInfo.setY(areaInfo.getY() + this.yOffset); + areaInfo.setX(areaInfo.getX()); + areaInfo.setY(areaInfo.getY()); areaInfo.setRotation(this.rotation); Registry registry = Registry.getInstance(); @@ -593,8 +580,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { */ public void createLine(int x1, int y1, int x2, int y2, int thickness, Color col) { - getCurrentPage().createLine(x1 + xOffset, y1 + yOffset, x2 + xOffset, - y2 + yOffset, thickness, rotation, col); + getCurrentPage().createLine(x1, y1, x2, y2, thickness, orientation, col); } /** @@ -614,8 +600,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * the shading color */ public void createShading(int x, int y, int w, int h, Color col) { - currentPageObject.createShading(x + xOffset, y + xOffset, w, h, - col.getRed(), col.getGreen(), col.getBlue()); + currentPageObject.createShading(x, y, w, h, col.getRed(), col.getGreen(), col.getBlue()); } /** @@ -626,7 +611,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * the name of the static overlay */ public void createIncludePageOverlay(String name) { - currentPageObject.createIncludePageOverlay(name, 0, 0, rotation); + currentPageObject.createIncludePageOverlay(name, 0, 0, orientation); currentPageObject.getActiveEnvironmentGroup().createOverlay(name); } @@ -653,22 +638,22 @@ public class AFPDataStream extends AbstractResourceGroupContainer { public void createIncludePageSegment(String name, int x, int y) { int xOrigin; int yOrigin; - switch (rotation) { + switch (orientation) { case 90: - xOrigin = getCurrentPage().getWidth() - y - yOffset; - yOrigin = x + xOffset; + xOrigin = getCurrentPage().getWidth() - y; + yOrigin = x; break; case 180: - xOrigin = getCurrentPage().getWidth() - x - xOffset; - yOrigin = getCurrentPage().getHeight() - y - yOffset; + xOrigin = getCurrentPage().getWidth() - x; + yOrigin = getCurrentPage().getHeight() - y; break; case 270: - xOrigin = y + yOffset; - yOrigin = getCurrentPage().getHeight() - x - xOffset; + xOrigin = y; + yOrigin = getCurrentPage().getHeight() - x; break; default: - xOrigin = x + xOffset; - yOrigin = y + yOffset; + xOrigin = x; + yOrigin = y; break; } getCurrentPage().createIncludePageSegment(name, xOrigin, yOrigin); diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java index 065886a49..c5b2f3ea2 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.List; +import org.apache.fop.render.afp.AFPTextDataInfo; import org.apache.fop.render.afp.fonts.AFPFont; /** @@ -189,27 +190,11 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { * Helper method to create text on the current page, this method delegates * to the presentation text object in order to construct the text. * - * @param fontRef - * the font number used as the resource identifier - * @param x - * the x coordinate of the text data - * @param y - * the y coordinate of the text data - * @param textRotation - * the rotation of the text data - * @param col - * the text color - * @param vsci - * The variable space character increment. - * @param ica - * The inter character adjustment. - * @param data - * the text data to create + * @param textDataInfo + * the afp text data */ - public void createText(int fontRef, int x, int y, int textRotation, Color col, - int vsci, int ica, byte[] data) { - getPresentationTextObject().createTextData( - fontRef, x, y, textRotation, col, vsci, ica, data); + public void createText(AFPTextDataInfo textDataInfo) { + getPresentationTextObject().createTextData(textDataInfo); } /** diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java index b6b367ab5..03e3f848d 100644 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java +++ b/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java @@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import org.apache.fop.render.afp.AFPTextDataInfo; import org.apache.fop.render.afp.tools.BinaryUtils; /** @@ -33,18 +34,18 @@ import org.apache.fop.render.afp.tools.BinaryUtils; * that position them - modal control sequences that adjust the positions by * small amounts - other functions causing text to be presented with differences * in appearance. - * + * * The graphic characters are expected to conform to a coded font representation * so that they can be translated from the code point in the object data to the * character in the coded font. The units of measure for linear displacements * are derived from the PresentationTextDescriptor or from the hierarchical * defaults. - * + * * In addition to graphic character code points, Presentation Text data can * contain embedded control sequences. These are strings of two or more bytes * which signal an alternate mode of processing for the content of the current * Presentation Text data. - * + * */ public class PresentationTextData extends AbstractAFPObject { @@ -104,21 +105,20 @@ public class PresentationTextData extends AbstractAFPObject { * Constructor for the PresentationTextData, the boolean flag indicate * whether the control sequence prefix should be set to indicate the start * of a new control sequence. - * + * * @param controlInd * The control sequence indicator. */ public PresentationTextData(boolean controlInd) { - final byte[] data = { - 0x5A, // Structured field identifier - 0x00, // Record length byte 1 - 0x00, // Record length byte 2 - (byte) 0xD3, // PresentationTextData identifier byte 1 - (byte) 0xEE, // PresentationTextData identifier byte 2 - (byte) 0x9B, // PresentationTextData identifier byte 3 - 0x00, // Flag - 0x00, // Reserved - 0x00, // Reserved + final byte[] data = { 0x5A, // Structured field identifier + 0x00, // Record length byte 1 + 0x00, // Record length byte 2 + (byte) 0xD3, // PresentationTextData identifier byte 1 + (byte) 0xEE, // PresentationTextData identifier byte 2 + (byte) 0x9B, // PresentationTextData identifier byte 3 + 0x00, // Flag + 0x00, // Reserved + 0x00, // Reserved }; baos.write(data, 0, 9); @@ -131,7 +131,7 @@ public class PresentationTextData extends AbstractAFPObject { * The Set Coded Font Local control sequence activates a coded font and * specifies the character attributes to be used. This is a modal control * sequence. - * + * * @param font * The font local identifier. * @param afpdata @@ -152,13 +152,14 @@ public class PresentationTextData extends AbstractAFPObject { * Establishes the current presentation position on the baseline at a new * I-axis coordinate, which is a specified number of measurement units from * the B-axis. There is no change to the current B-axis coordinate. - * + * * @param coordinate * The coordinate for the inline move. * @param afpdata * The output stream to which data should be written. */ - private void absoluteMoveInline(int coordinate, ByteArrayOutputStream afpdata) { + private void absoluteMoveInline(int coordinate, + ByteArrayOutputStream afpdata) { byte[] b = BinaryUtils.convert(coordinate, 2); afpdata.write(new byte[] { 0x04, (byte) 0xC7, b[0], b[1], }, 0, 4); currentXCoordinate = coordinate; @@ -168,13 +169,14 @@ public class PresentationTextData extends AbstractAFPObject { * Establishes the baseline and the current presentation position at a new * B-axis coordinate, which is a specified number of measurement units from * the I-axis. There is no change to the current I-axis coordinate. - * + * * @param coordinate * The coordinate for the baseline move. * @param afpdata * The output stream to which data should be written. */ - private void absoluteMoveBaseline(int coordinate, ByteArrayOutputStream afpdata) { + private void absoluteMoveBaseline(int coordinate, + ByteArrayOutputStream afpdata) { byte[] b = BinaryUtils.convert(coordinate, 2); afpdata.write(new byte[] { 0x04, (byte) 0xD3, b[0], b[1], }, 0, 4); currentYCoordinate = coordinate; @@ -183,7 +185,7 @@ public class PresentationTextData extends AbstractAFPObject { /** * The Transparent Data control sequence contains a sequence of code points * that are presented without a scan for embedded control sequences. - * + * * @param data * The text data to add. * @param afpdata @@ -195,10 +197,10 @@ public class PresentationTextData extends AbstractAFPObject { if (l > 255) { // Check that we are not exceeding the maximum length throw new IllegalArgumentException( - "Transparent data is longer than 253 bytes: " + data); + "Transparent data is longer than 253 bytes: " + data); } afpdata.write(new byte[] { BinaryUtils.convert(l)[0], (byte) 0xDB, }, - 0, 2); + 0, 2); afpdata.write(data, 0, data.length); } @@ -206,7 +208,7 @@ public class PresentationTextData extends AbstractAFPObject { * Draws a line of specified length and specified width in the B-direction * from the current presentation position. The location of the current * presentation position is unchanged. - * + * * @param length * The length of the rule. * @param width @@ -214,9 +216,10 @@ public class PresentationTextData extends AbstractAFPObject { * @param afpdata * The output stream to which data should be written. */ - private void drawBaxisRule(int length, int width, ByteArrayOutputStream afpdata) { + private void drawBaxisRule(int length, int width, + ByteArrayOutputStream afpdata) { afpdata.write(new byte[] { 0x07, // Length - (byte) 0xE7, // Type + (byte) 0xE7, // Type }, 0, 2); // Rule length byte[] data1 = BinaryUtils.shortToByteArray((short) length); @@ -232,7 +235,7 @@ public class PresentationTextData extends AbstractAFPObject { * Draws a line of specified length and specified width in the I-direction * from the current presentation position. The location of the current * presentation position is unchanged. - * + * * @param length * The length of the rule. * @param width @@ -240,9 +243,10 @@ public class PresentationTextData extends AbstractAFPObject { * @param afpdata * The output stream to which data should be written. */ - private void drawIaxisRule(int length, int width, ByteArrayOutputStream afpdata) { + private void drawIaxisRule(int length, int width, + ByteArrayOutputStream afpdata) { afpdata.write(new byte[] { 0x07, // Length - (byte) 0xE5, // Type + (byte) 0xE5, // Type }, 0, 2); // Rule length byte[] data1 = BinaryUtils.shortToByteArray((short) length); @@ -256,73 +260,66 @@ public class PresentationTextData extends AbstractAFPObject { /** * Create the presentation text data for the byte array of data. - * - * @param fontNumber - * The font resource identifier. - * @param x - * The x coordinate for the text data. - * @param y - * The y coordinate for the text data. - * @param orientation - * The orientation of the text data. - * @param col - * The text color. - * @param vsci - * The variable space character increment. - * @param ica - * The inter character adjustment. - * @param data - * The text data to be created. + * + * @param textDataInfo + * the afp text data * @throws MaximumSizeExceededException + * thrown if the maximum number of text data is exceeded */ - public void createTextData(int fontNumber, int x, int y, int orientation, - Color col, int vsci, int ica, byte[] data) throws MaximumSizeExceededException { + public void createTextData(AFPTextDataInfo textDataInfo) + throws MaximumSizeExceededException { ByteArrayOutputStream afpdata = new ByteArrayOutputStream(); - if (currentOrientation != orientation) { - setTextOrientation(orientation, afpdata); - currentOrientation = orientation; + if (currentOrientation != textDataInfo.getOrientation()) { + setTextOrientation(textDataInfo.getOrientation(), afpdata); + currentOrientation = textDataInfo.getOrientation(); currentXCoordinate = -1; currentYCoordinate = -1; } // Avoid unnecessary specification of the Y co-ordinate - if (y != currentYCoordinate) { - absoluteMoveBaseline(y, afpdata); + if (textDataInfo.getY() != currentYCoordinate) { + absoluteMoveBaseline(textDataInfo.getY(), afpdata); currentXCoordinate = -1; } // Avoid unnecessary specification of the X co-ordinate - if (x != currentXCoordinate) { - absoluteMoveInline(x, afpdata); + if (textDataInfo.getX() != currentXCoordinate) { + absoluteMoveInline(textDataInfo.getX(), afpdata); } // Avoid unnecessary specification of the variable space increment - if (vsci != currentVariableSpaceCharacterIncrement) { - setVariableSpaceCharacterIncrement(vsci, afpdata); - currentVariableSpaceCharacterIncrement = vsci; + if (textDataInfo.getVariableSpaceCharacterIncrement() + != currentVariableSpaceCharacterIncrement) { + setVariableSpaceCharacterIncrement(textDataInfo + .getVariableSpaceCharacterIncrement(), afpdata); + currentVariableSpaceCharacterIncrement = textDataInfo + .getVariableSpaceCharacterIncrement(); } // Avoid unnecessary specification of the inter character adjustment - if (ica != currentInterCharacterAdjustment) { - setInterCharacterAdjustment(ica, afpdata); - currentInterCharacterAdjustment = ica; + if (textDataInfo.getInterCharacterAdjustment() != currentInterCharacterAdjustment) { + setInterCharacterAdjustment(textDataInfo.getInterCharacterAdjustment(), + afpdata); + currentInterCharacterAdjustment = textDataInfo + .getInterCharacterAdjustment(); } // Avoid unnecessary specification of the text color - if (!col.equals(currentColor)) { - setExtendedTextColor(col, afpdata); - currentColor = col; + if (!textDataInfo.getColor().equals(currentColor)) { + setExtendedTextColor(textDataInfo.getColor(), afpdata); + currentColor = textDataInfo.getColor(); } - setCodedFont(BinaryUtils.convert(fontNumber)[0], afpdata); - addTransparentData(data, afpdata); + setCodedFont(BinaryUtils.convert(textDataInfo.getFontReference())[0], + afpdata); + addTransparentData(textDataInfo.getData(), afpdata); currentXCoordinate = -1; - int s = afpdata.size(); + int dataSize = afpdata.size(); - if (baos.size() + s > MAX_SIZE) { + if (baos.size() + dataSize > MAX_SIZE) { currentXCoordinate = -1; currentYCoordinate = -1; throw new MaximumSizeExceededException(); @@ -335,7 +332,7 @@ public class PresentationTextData extends AbstractAFPObject { /** * Drawing of lines using the starting and ending coordinates, thickness and * colour arguments. - * + * * @param x1 * The starting X coordinate. * @param y1 @@ -350,9 +347,11 @@ public class PresentationTextData extends AbstractAFPObject { * The orientation of the text data. * @param col * The text color. + * @throws MaximumSizeExceededException + * thrown if the maximum number of line data has been exceeded */ public void createLineData(int x1, int y1, int x2, int y2, int thickness, - int orientation, Color col) throws MaximumSizeExceededException { + int orientation, Color col) throws MaximumSizeExceededException { ByteArrayOutputStream afpdata = new ByteArrayOutputStream(); @@ -399,105 +398,103 @@ public class PresentationTextData extends AbstractAFPObject { /** * The Set Text Orientation control sequence establishes the I-direction and * B-direction for the subsequent text. This is a modal control sequence. - * + * * Semantics: This control sequence specifies the I-axis and B-axis * orientations with respect to the Xp-axis for the current Presentation * Text object. The orientations are rotational values expressed in degrees * and minutes. - * + * * @param orientation - * The text orientation (0,90, 180, 270). + * The text orientation (0, 90, 180, 270). * @param afpdata * The output stream to which data should be written. */ - private void setTextOrientation(int orientation, ByteArrayOutputStream afpdata) { - afpdata.write(new byte[] { 0x06, (byte) 0xF7, }, 0, 2); + private void setTextOrientation(int orientation, + ByteArrayOutputStream afpdata) { + afpdata.write(new byte[] {0x06, (byte) 0xF7, }, 0, 2); switch (orientation) { - case 90: - afpdata.write(0x2D); - afpdata.write(0x00); - afpdata.write(0x5A); - afpdata.write(0x00); - break; - case 180: - afpdata.write(0x5A); - afpdata.write(0x00); - afpdata.write(0x87); - afpdata.write(0x00); - break; - case 270: - afpdata.write(0x87); - afpdata.write(0x00); - afpdata.write(0x00); - afpdata.write(0x00); - break; - default: - afpdata.write(0x00); - afpdata.write(0x00); - afpdata.write(0x2D); - afpdata.write(0x00); - break; + case 90: + afpdata.write(0x2D); + afpdata.write(0x00); + afpdata.write(0x5A); + afpdata.write(0x00); + break; + case 180: + afpdata.write(0x5A); + afpdata.write(0x00); + afpdata.write(0x87); + afpdata.write(0x00); + break; + case 270: + afpdata.write(0x87); + afpdata.write(0x00); + afpdata.write(0x00); + afpdata.write(0x00); + break; + default: + afpdata.write(0x00); + afpdata.write(0x00); + afpdata.write(0x2D); + afpdata.write(0x00); + break; } } /** * The Set Extended Text Color control sequence specifies a color value and - * defines the color space and encoding for that value. The specified color - * value is applied to foreground areas of the text presentation space. - * This is a modal control sequence. - * + * defines the color space and encoding for that value. The specified color + * value is applied to foreground areas of the text presentation space. This + * is a modal control sequence. + * * @param col * The color to be set. * @param afpdata * The output stream to which data should be written. */ - private void setExtendedTextColor(Color col, - ByteArrayOutputStream afpdata) { - - afpdata.write(new byte[] { - 15 // Control sequence length - , (byte)0x81 // Control sequence function type - , 0x00 // Reserved; must be zero - , 0x01 // Color space - 0x01 = RGB - , 0x00 // Reserved; must be zero - , 0x00 // Reserved; must be zero - , 0x00 // Reserved; must be zero - , 0x00 // Reserved; must be zero - , 8 // Number of bits in component 1 - , 8 // Number of bits in component 2 - , 8 // Number of bits in component 3 - , 0 // Number of bits in component 4 - , (byte)(col.getRed()) // Red intensity - , (byte)(col.getGreen()) // Green intensity - , (byte)(col.getBlue()) // Blue intensity - }, 0, 15); - + private void setExtendedTextColor(Color col, ByteArrayOutputStream afpdata) { + byte[] colorData = new byte[] { + 15, // Control sequence length + (byte) 0x81, // Control sequence function type + 0x00, // Reserved; must be zero + 0x01, // Color space - 0x01 = RGB + 0x00, // Reserved; must be zero + 0x00, // Reserved; must be zero + 0x00, // Reserved; must be zero + 0x00, // Reserved; must be zero + 8, // Number of bits in component 1 + 8, // Number of bits in component 2 + 8, // Number of bits in component 3 + 0, // Number of bits in component 4 + (byte) (col.getRed()), // Red intensity + (byte) (col.getGreen()), // Green intensity + (byte) (col.getBlue()), // Blue intensity + }; + + afpdata.write(colorData, 0, colorData.length); } /** - * //TODO - * This is a modal control sequence. - * + * //TODO This is a modal control sequence. + * * @param incr * The increment to be set. * @param afpdata * The output stream to which data should be written. */ - private void setVariableSpaceCharacterIncrement(int incr, ByteArrayOutputStream afpdata) { + private void setVariableSpaceCharacterIncrement(int incr, + ByteArrayOutputStream afpdata) { byte[] b = BinaryUtils.convert(incr, 2); afpdata.write(new byte[] { - 4 // Control sequence length - , (byte)0xC5 // Control sequence function type - , b[0] - , b[1] - }, 0, 4); + 4, // Control sequence length + (byte) 0xC5, // Control sequence function type + b[0], b[1] }, + 0, 4); } /** - * //TODO - * This is a modal control sequence. - * + * //TODO This is a modal control sequence. + * * @param incr * The increment to be set. * @param afpdata @@ -506,12 +503,10 @@ public class PresentationTextData extends AbstractAFPObject { private void setInterCharacterAdjustment(int incr, ByteArrayOutputStream afpdata) { byte[] b = BinaryUtils.convert(Math.abs(incr), 2); afpdata.write(new byte[] { - 5 // Control sequence length - , (byte)0xC3 // Control sequence function type - , b[0] - , b[1] - , (byte)(incr >= 0 ? 0 : 1) // Direction - }, 0, 5); + 5, // Control sequence length + (byte) 0xC3, // Control sequence function type + b[0], b[1], (byte) (incr >= 0 ? 0 : 1) // Direction + }, 0, 5); } /** @@ -531,8 +526,9 @@ public class PresentationTextData extends AbstractAFPObject { * and zero or more parameters. The control sequence can extend multiple * presentation text data objects, but must eventually be terminated. This * method terminates the control sequence. - * + * * @throws MaximumSizeExceededException + * thrown in the event that maximum size has been exceeded */ public void endControlSequence() throws MaximumSizeExceededException { byte[] data = new byte[2]; diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java index 3dda2006a..290a1e46a 100644 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java @@ -24,6 +24,8 @@ import java.io.IOException; import java.io.OutputStream; import java.util.List; +import org.apache.fop.render.afp.AFPTextDataInfo; + /** * The Presentation Text object is the data object used in document processing * environments for representing text which has been prepared for presentation. @@ -76,58 +78,18 @@ public class PresentationTextObject extends AbstractNamedAFPObject { /** * Create the presentation text data for the byte array of data. * - * @param fontNum - * The font resource identifier. - * @param x - * The x coordinate for the text data. - * @param y - * The y coordinate for the text data. - * @param col - * The text color. - * @param vsci - * The variable space character increment. - * @param ica - * The inter character increment. - * @param data - * The text data to be created. - */ - public void createTextData(int fontNum, int x, int y, Color col, - int vsci, int ica, byte[] data) { - // Use a default orientation of zero - createTextData(fontNum, x, y, 0, col, vsci, ica, data); - } - - /** - * Create the presentation text data for the byte array of data. - * - * @param fontRef - * The font resource identifier. - * @param x - * The x coordinate for the text data. - * @param y - * The y coordinate for the text data. - * @param orientation - * The orientation of the text data. - * @param col - * The text color. - * @param vsci - * The variable space character increment. - * @param ica - * The inter character adjustment. - * @param data - * The text data to be created. + * @param textDataInfo + * The afp text data */ - public void createTextData(int fontRef, int x, int y, int orientation, - Color col, int vsci, int ica, byte[] data) { + public void createTextData(AFPTextDataInfo textDataInfo) { if (currentPresentationTextData == null) { startPresentationTextData(); } try { - currentPresentationTextData.createTextData(fontRef, x, y, - orientation, col, vsci, ica, data); + currentPresentationTextData.createTextData(textDataInfo); } catch (MaximumSizeExceededException msee) { endPresentationTextData(); - createTextData(fontRef, x, y, orientation, col, vsci, ica, data); + createTextData(textDataInfo); } } diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index ff0e64806..c3e4a9657 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -112,6 +112,7 @@ import org.apache.fop.pdf.PDFTextUtil; import org.apache.fop.pdf.PDFXMode; import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.AbstractPathOrientedRenderer; +import org.apache.fop.render.AbstractState; import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.util.CharUtilities; @@ -1094,7 +1095,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { */ protected List breakOutOfStateStack() { List breakOutList = new java.util.ArrayList(); - PDFState.Data data; + AbstractState.AbstractData data; while (true) { data = currentState.getData(); if (currentState.pop() == null) { @@ -1115,10 +1116,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { */ protected void restoreStateStackAfterBreakOut(List breakOutList) { comment("------ restoring context after break-out..."); - PDFState.Data data; + AbstractState.AbstractData data; Iterator i = breakOutList.iterator(); while (i.hasNext()) { - data = (PDFState.Data)i.next(); + data = (AbstractState.AbstractData)i.next(); saveGraphicsState(); AffineTransform at = data.getTransform(); concatenateTransformationMatrix(at); -- cgit v1.2.3 From 030cd56ed235409e5fe6d2914d7224d9a58380c1 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Thu, 17 Jul 2008 19:13:56 +0000 Subject: * Added new DataObjectFactory to take care of MO:DCA DataObject creation/instantiation. * Created a DataObjectCache which is now used to cache all resource objects such as images to a RandomAccessFile so all the memory isn't eaten by them during rendering. * Added new GraphicsObjectPainter class invoked by DataObjectFactory on creation of GraphicsObject. * Added Category and Type inner interfaces and handy copySF() to base AbstractAFPObject with more code reuse, simplifications/optimizations of writeStart() and writeEnd(). * SVG entry and isImage() isGraphic() convenience methods added to MO:DCA Registry. * Updated AFPSVGHandler to use similar fox:conversion-mode foreign attribute mechanism for bitmap painting fallback used by PCLRenderer and PDFRenderer. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@677689 13f79535-47bb-0310-9956-ffa450edef68 --- conf/fop.xconf | 1 - .../fop/render/AbstractGenericSVGHandler.java | 5 +- .../org/apache/fop/render/afp/AFPGraphics2D.java | 110 +++++---- .../fop/render/afp/AFPGraphics2DAdapter.java | 77 ++++-- src/java/org/apache/fop/render/afp/AFPInfo.java | 39 ++- .../org/apache/fop/render/afp/AFPRenderer.java | 31 +-- .../fop/render/afp/AFPRendererConfigurator.java | 13 +- .../org/apache/fop/render/afp/AFPSVGHandler.java | 160 +++++++------ src/java/org/apache/fop/render/afp/AFPState.java | 77 ++++-- .../org/apache/fop/render/afp/DataObjectCache.java | 196 +++++++++++++++ .../org/apache/fop/render/afp/DataObjectInfo.java | 64 ++--- .../render/afp/ExternalResourceGroupManager.java | 100 ++++++++ .../apache/fop/render/afp/GraphicsObjectInfo.java | 46 ++++ .../fop/render/afp/GraphicsObjectPainter.java | 100 ++++++++ .../org/apache/fop/render/afp/ImageObjectInfo.java | 34 ++- .../org/apache/fop/render/afp/ObjectAreaInfo.java | 29 ++- .../org/apache/fop/render/afp/ResourceInfo.java | 71 +++++- .../org/apache/fop/render/afp/ResourceLevel.java | 89 ++++--- .../render/afp/goca/GraphicsChainedSegment.java | 52 ++-- .../apache/fop/render/afp/modca/AFPDataStream.java | 262 ++++++--------------- .../fop/render/afp/modca/AbstractAFPObject.java | 184 ++++++++++++++- .../fop/render/afp/modca/AbstractDataObject.java | 12 +- .../fop/render/afp/modca/AbstractDescriptor.java | 1 + .../render/afp/modca/AbstractEnvironmentGroup.java | 7 +- .../render/afp/modca/AbstractNamedAFPObject.java | 40 ++-- .../fop/render/afp/modca/AbstractPageObject.java | 41 +++- .../afp/modca/AbstractPreparedAFPObject.java | 6 +- .../afp/modca/AbstractPreparedObjectContainer.java | 14 +- .../AbstractResourceEnvironmentGroupContainer.java | 9 +- .../afp/modca/AbstractResourceGroupContainer.java | 24 +- .../afp/modca/AbstractStructuredAFPObject.java | 52 ++-- .../render/afp/modca/ActiveEnvironmentGroup.java | 71 ++---- .../fop/render/afp/modca/DataObjectFactory.java | 235 ++++++++++++++++-- .../org/apache/fop/render/afp/modca/Document.java | 40 +--- .../fop/render/afp/modca/GraphicsObject.java | 89 +++---- .../apache/fop/render/afp/modca/IMImageObject.java | 43 +--- .../fop/render/afp/modca/ImageCellPosition.java | 20 +- .../fop/render/afp/modca/ImageDataDescriptor.java | 46 ++-- .../fop/render/afp/modca/ImageInputDescriptor.java | 6 +- .../apache/fop/render/afp/modca/ImageObject.java | 58 ++--- .../fop/render/afp/modca/ImageOutputControl.java | 9 +- .../fop/render/afp/modca/ImageRasterData.java | 6 +- .../apache/fop/render/afp/modca/ImageSegment.java | 28 +-- .../fop/render/afp/modca/ImageSizeParameter.java | 6 +- .../apache/fop/render/afp/modca/IncludeObject.java | 173 +++++++------- .../fop/render/afp/modca/IncludePageOverlay.java | 37 +-- .../fop/render/afp/modca/IncludePageSegment.java | 46 ++-- .../fop/render/afp/modca/InterchangeSet.java | 15 +- .../fop/render/afp/modca/InvokeMediumMap.java | 20 +- .../apache/fop/render/afp/modca/MapCodedFont.java | 4 +- .../fop/render/afp/modca/MapDataResource.java | 28 +-- .../fop/render/afp/modca/ObjectAreaDescriptor.java | 10 +- .../fop/render/afp/modca/ObjectAreaPosition.java | 87 +++---- .../fop/render/afp/modca/ObjectContainer.java | 159 +++++-------- .../render/afp/modca/ObjectEnvironmentGroup.java | 62 +---- .../org/apache/fop/render/afp/modca/Overlay.java | 34 +-- .../fop/render/afp/modca/PageDescriptor.java | 10 +- .../org/apache/fop/render/afp/modca/PageGroup.java | 42 +--- .../apache/fop/render/afp/modca/PageObject.java | 38 +-- .../apache/fop/render/afp/modca/PageSegment.java | 46 +--- .../afp/modca/PreprocessPresentationObject.java | 17 +- .../afp/modca/PresentationTextDescriptor.java | 10 +- .../render/afp/modca/PresentationTextObject.java | 40 +--- .../org/apache/fop/render/afp/modca/Registry.java | 50 +++- .../render/afp/modca/ResourceEnvironmentGroup.java | 48 +--- .../apache/fop/render/afp/modca/ResourceGroup.java | 204 +++++++--------- .../fop/render/afp/modca/ResourceObject.java | 220 +++++++---------- .../org/apache/fop/render/afp/modca/Writable.java | 2 + .../fop/render/pdf/PDFRendererConfigurator.java | 12 +- .../org/apache/fop/render/pdf/PDFSVGHandler.java | 1 + 70 files changed, 2251 insertions(+), 1767 deletions(-) create mode 100644 src/java/org/apache/fop/render/afp/DataObjectCache.java create mode 100644 src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java create mode 100644 src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java create mode 100644 src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/conf/fop.xconf b/conf/fop.xconf index c1bdc3ffb..2f638c2b2 100644 --- a/conf/fop.xconf +++ b/conf/fop.xconf @@ -111,7 +111,6 @@ the location of this file. 240 resources.afp - cache */ + private static Map/**/ cacheMap + = new java.util.HashMap/**/(); + + + /** Mapping of data object uri --> cache entry */ + private Map/**/ cacheRecordMap + = new java.util.HashMap/**/(); + + /** Used for create data objects */ + private DataObjectFactory factory = new DataObjectFactory(); + + /** Used for storage of data objects */ + private RandomAccessFile raFile; + + /** File channel used for manipulating the temporary file */ + private FileChannel channel; + + /** The temporary cache file */ + private File tempFile; + + /** The cache id */ + private int id; + + /** The next file pointer position in the cache file */ + private long nextPos; + + /** + * Returns an instance of the cache + * + * @return an instance of the cache or null if failed + */ + public static DataObjectCache getInstance() { + synchronized (cacheMap) { + int id = System.identityHashCode(Thread.currentThread()); + Integer cacheKey = new Integer(id); + DataObjectCache cache = (DataObjectCache)cacheMap.get(cacheKey); + if (cache == null) { + try { + cache = new DataObjectCache(); + cacheMap.put(cacheKey, cache); + } catch (IOException e) { + log.error("Failed to create cache"); + } + } + return cache; + } + } + + /** + * Default constructor + */ + private DataObjectCache() throws IOException { + this.id = System.identityHashCode(Thread.currentThread()); + this.tempFile = File.createTempFile(CACHE_FILENAME_PREFIX + id, null); + this.raFile = new RandomAccessFile(tempFile, "rw"); + this.channel = raFile.getChannel(); + } + + /** + * Clears the data object cache + */ + public void clear() { + try { + raFile.close(); + tempFile.delete(); + } catch (IOException e) { + log.error("Failed to close temporary file"); + } + } + + /** + * Creates and adds a new data object and record to the cache as necessary. + * + * @param dataObjectInfo a data object info + * + * @return the name of the related data object + */ + public String put(DataObjectInfo dataObjectInfo) { + ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + Record record = (Record)cacheRecordMap.get(resourceInfo); + if (record == null) { + record = new Record(); + AbstractNamedAFPObject dataObj = factory.createObject(dataObjectInfo); + record.objectName = dataObj.getName(); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + try { + channel.position(nextPos); + record.position = channel.position(); + dataObj.write(os); + record.size = os.size(); + MappedByteBuffer byteBuffer + = channel.map(FileChannel.MapMode.READ_WRITE, record.position, record.size); + byteBuffer.put(os.toByteArray()); + channel.write(byteBuffer); + nextPos += record.size + 1; + } catch (IOException e) { + log.error("Failed to write cache record for '" + + resourceInfo + "', " + e.getMessage()); + } + cacheRecordMap.put(resourceInfo, record); + } + return record.objectName; + } + + /** + * Returns the written binary data of the AbstractDataObject from the cache file + * + * @param resourceInfo the data resource info + * @return the binary data of the AbstractDataObject or null if failed. + */ + public byte[] get(ResourceInfo resourceInfo) { + Record record = (Record)cacheRecordMap.get(resourceInfo); + if (record == null) { + throw new IllegalArgumentException("Unknown data object " + resourceInfo); + } + MappedByteBuffer byteBuffer = null; + try { + byteBuffer = channel.map(FileChannel.MapMode.READ_ONLY, record.position, record.size); + } catch (IOException e) { + log.error("Failed to read cache record for '" + resourceInfo + "', " + e.getMessage()); + return null; + } + if (byteBuffer.hasArray()) { + return byteBuffer.array(); + } else { + byte[] data = new byte[record.size]; + byteBuffer.get(data); + return data; + } + } + + /** + * Returns the data object factory + * + * @return the data object factory + */ + public DataObjectFactory getFactory() { + return this.factory; + } + + /** + * A cache record + */ + private class Record { + protected long position; + protected int size; + protected String objectName; + } +} diff --git a/src/java/org/apache/fop/render/afp/DataObjectInfo.java b/src/java/org/apache/fop/render/afp/DataObjectInfo.java index b25470551..021e5fef6 100644 --- a/src/java/org/apache/fop/render/afp/DataObjectInfo.java +++ b/src/java/org/apache/fop/render/afp/DataObjectInfo.java @@ -39,18 +39,14 @@ public class DataObjectInfo { private static final String RESOURCE_LEVEL = "afp:resource-level"; private static final String RESOURCE_GROUP_FILE = "afp:resource-group-file"; - private static final ResourceInfo DEFAULT_RESOURCE_INFO = new ResourceInfo(); - - private String uri; - /** the object area info */ private ObjectAreaInfo objectAreaInfo; /** object type entry */ - private ObjectType objectType; + private Registry.ObjectType objectType; /** resource info */ - private ResourceInfo resourceInfo = DEFAULT_RESOURCE_INFO; + private ResourceInfo resourceInfo; /** * Default constructor @@ -58,24 +54,9 @@ public class DataObjectInfo { public DataObjectInfo() { } - /** - * Sets the data object uri - * @param uri the data object uri - */ - public void setUri(String uri) { - this.uri = uri; - } - - - /** - * @return the uri of this data object - */ - public String getUri() { - return uri; - } - /** * Sets the object type + * * @param objectType the object type */ public void setObjectType(Registry.ObjectType objectType) { @@ -83,6 +64,8 @@ public class DataObjectInfo { } /** + * Returns the object type MOD:CA Registry entry + * * @return the object type MOD:CA Registry entry */ public ObjectType getObjectType() { @@ -90,14 +73,20 @@ public class DataObjectInfo { } /** + * Returns the resource level at which this data object should reside + * * @return the resource level at which this data object should reside */ public ResourceInfo getResourceInfo() { + if (resourceInfo == null) { + this.resourceInfo = new ResourceInfo(); + } return resourceInfo; } /** * Sets the resource level at which this object should reside + * * @param resourceInfo the resource level at which this data object should reside */ public void setResourceInfo(ResourceInfo resourceInfo) { @@ -106,6 +95,7 @@ public class DataObjectInfo { /** * Sets the object area info + * * @param objectAreaInfo the object area info */ public void setObjectAreaInfo(ObjectAreaInfo objectAreaInfo) { @@ -113,6 +103,8 @@ public class DataObjectInfo { } /** + * Returns the object area info + * * @return the object area info */ public ObjectAreaInfo getObjectAreaInfo() { @@ -121,6 +113,7 @@ public class DataObjectInfo { /** * Sets the resource group settings using the given foreign attributes + * * @param foreignAttributes a mapping of element attributes names to values */ public void setResourceInfoFromForeignAttributes(Map/**/ foreignAttributes) { @@ -165,7 +158,7 @@ public class DataObjectInfo { log.warn("overwritting external resource file: " + resourceExternalDest); } - resourceLevel.setExternalResourceGroupFile(resourceExternalGroupFile); + resourceLevel.setExternalFilePath(resourceExternalDest); } catch (SecurityException ex) { log.error("unable to gain read access to external resource file: " + resourceExternalDest); @@ -180,13 +173,28 @@ public class DataObjectInfo { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { - return "uri=" + uri - + (objectAreaInfo != null ? "objectAreaInfo=" + objectAreaInfo : "") + return (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "") + (objectType != null ? ", objectType=" + objectType : "") + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : ""); } + + /** + * Returns the uri of this data object + * + * @return the uri of this data object + */ + public String getUri() { + return getResourceInfo().getUri(); + } + + /** + * Sets the data object uri + * + * @param uri the data object uri + */ + public void setUri(String uri) { + getResourceInfo().setUri(uri); + } } diff --git a/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java b/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java new file mode 100644 index 000000000..205eb62fa --- /dev/null +++ b/src/java/org/apache/fop/render/afp/ExternalResourceGroupManager.java @@ -0,0 +1,100 @@ +package org.apache.fop.render.afp; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.render.afp.modca.ResourceGroup; + +/** + * Manages the use of resource groups (external and internal) + */ +public class ExternalResourceGroupManager { + + /** Static logging instance */ + protected static Log log = LogFactory.getLog(ExternalResourceGroupManager.class); + + /** A mapping of external resource destinations to resource groups */ + private Map/**/externalResourceGroups + = new java.util.HashMap/**/(); + + /** Sets the default resource group file */ + private String defaultResourceGroupFilePath; + + /** + * Default constructor + */ + public ExternalResourceGroupManager() { + } + + /** + * Sets the default resource group file + * + * @param resourceGroupFilePath the default resource group file path + */ + public void setDefaultResourceGroupFilePath(String resourceGroupFilePath) { + this.defaultResourceGroupFilePath = resourceGroupFilePath; + } + + /** + * Returns the corresponding resource group for the given resource level + * + * @param level the resource level + * @return the corresponding resource group for the given resource level + * or null if not found. + */ + public ResourceGroup getResourceGroup(ResourceLevel level) { + ResourceGroup resourceGroup = null; + // this resource info does not have an external resource group + // file definition + String filePath = level.getExternalFilePath(); + if (filePath != null) { + filePath = level.getExternalFilePath(); + resourceGroup = (ResourceGroup)externalResourceGroups.get(filePath); + if (resourceGroup == null) { + resourceGroup = new ResourceGroup(); + externalResourceGroups.put(filePath, resourceGroup); + } + } else if (defaultResourceGroupFilePath != null) { + // fallback to default resource group file + level.setExternalFilePath(defaultResourceGroupFilePath); + resourceGroup = getResourceGroup(level); + } + return resourceGroup; + } + + /** + * Writes out all external resource groups + */ + public void write() { + // write any external resources + Iterator it = externalResourceGroups.keySet().iterator(); + while (it.hasNext()) { + String filePath = (String)it.next(); + ResourceGroup resourceGroup + = (ResourceGroup)externalResourceGroups.get(filePath); + OutputStream os = null; + try { + log.debug("Writing external AFP resource file " + filePath); + os = new java.io.FileOutputStream(filePath); + resourceGroup.write(os); + } catch (IOException e) { + log.error( + "An error occurred when attempting to write external AFP resource file " + + filePath); + } finally { + if (os != null) { + try { + os.close(); + } catch (IOException e) { + log.error("Failed to close outputstream for external AFP resource file " + + filePath); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java b/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java new file mode 100644 index 000000000..108d7bfb6 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/GraphicsObjectInfo.java @@ -0,0 +1,46 @@ +/* + * 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; + +/** + * A graphics object info which contains necessary painting objects + */ +public class GraphicsObjectInfo extends DataObjectInfo { + + private GraphicsObjectPainter painter; + + /** + * Returns the graphics painter + * + * @return the graphics painter + */ + public GraphicsObjectPainter getPainter() { + return painter; + } + + /** + * Sets the graphics painter + * + * @param graphicsPainter the graphics painter + */ + public void setPainter(GraphicsObjectPainter graphicsPainter) { + this.painter = graphicsPainter; + } +} diff --git a/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java b/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java new file mode 100644 index 000000000..c9c9f516a --- /dev/null +++ b/src/java/org/apache/fop/render/afp/GraphicsObjectPainter.java @@ -0,0 +1,100 @@ +/* + * 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$ */ + +/* + * 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.batik.gvt.GraphicsNode; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.render.afp.modca.GraphicsObject; + +/** + * A simple AFP Graphics 2D painter + */ +public class GraphicsObjectPainter { + /** Static logging instance */ + protected static Log log = LogFactory.getLog(GraphicsObjectPainter.class); + + private AFPGraphics2D graphics2D; + + private GraphicsNode root; + + /** + * Default constructor + */ + public GraphicsObjectPainter() { + } + + /** + * Returns the graphics 2D + * + * @return the graphics 2D + */ + public AFPGraphics2D getGraphics2D() { + return graphics2D; + } + + /** + * Sets the graphics 2D + * + * @param graphics the AFP graphics 2D + */ + public void setGraphics2D(AFPGraphics2D graphics) { + this.graphics2D = graphics; + } + + /** + * Sets the graphics node + * + * @param rootNode the graphics root node + */ + public void setGraphicsNode(GraphicsNode rootNode) { + this.root = rootNode; + } + + /** + * Paints the graphics object + * + * @param graphicsObj the graphics object + */ + public void paint(GraphicsObject graphicsObj) { + log.debug("Generating SVG"); + graphics2D.setGraphicsObject(graphicsObj); + root.paint(graphics2D); + graphics2D.dispose(); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ImageObjectInfo.java b/src/java/org/apache/fop/render/afp/ImageObjectInfo.java index f9bbc82cf..8a3d55150 100644 --- a/src/java/org/apache/fop/render/afp/ImageObjectInfo.java +++ b/src/java/org/apache/fop/render/afp/ImageObjectInfo.java @@ -41,6 +41,7 @@ public class ImageObjectInfo extends DataObjectInfo { /** * Sets the number of bits per pixel + * * @param bitsPerPixel the number of bits per pixel */ public void setBitsPerPixel(int bitsPerPixel) { @@ -49,6 +50,7 @@ public class ImageObjectInfo extends DataObjectInfo { /** * Sets if this image is color + * * @param color true if this is a color image */ public void setColor(boolean color) { @@ -57,6 +59,7 @@ public class ImageObjectInfo extends DataObjectInfo { /** * Sets the image data + * * @param data the image data */ public void setData(byte[] data) { @@ -65,6 +68,7 @@ public class ImageObjectInfo extends DataObjectInfo { /** * Sets the image mime type + * * @param mimeType the image mime type */ public void setMimeType(String mimeType) { @@ -72,6 +76,8 @@ public class ImageObjectInfo extends DataObjectInfo { } /** + * Returns the number of bits used per pixel + * * @return the number of bits used per pixel */ public int getBitsPerPixel() { @@ -79,6 +85,8 @@ public class ImageObjectInfo extends DataObjectInfo { } /** + * Returns true if this is a color image + * * @return true if this is a color image */ public boolean isColor() { @@ -86,6 +94,8 @@ public class ImageObjectInfo extends DataObjectInfo { } /** + * Returns the image data + * * @return the image data */ public byte[] getData() { @@ -93,13 +103,17 @@ public class ImageObjectInfo extends DataObjectInfo { } /** - * @return true of this image uses compression + * Returns true if this image uses compression + * + * @return true if this image uses compression */ public boolean hasCompression() { return compression > -1; } /** + * Returns the compression type + * * @return the compression type */ public int getCompression() { @@ -107,7 +121,8 @@ public class ImageObjectInfo extends DataObjectInfo { } /** - * Sets the compression used with this image + * Sets the compression used with this image + * * @param compression the type of compression used with this image */ public void setCompression(int compression) { @@ -115,6 +130,8 @@ public class ImageObjectInfo extends DataObjectInfo { } /** + * Returns the image data width + * * @return the image data width */ public int getDataWidth() { @@ -123,6 +140,7 @@ public class ImageObjectInfo extends DataObjectInfo { /** * Sets the image data width + * * @param imageDataWidth the image data width */ public void setDataWidth(int imageDataWidth) { @@ -130,6 +148,8 @@ public class ImageObjectInfo extends DataObjectInfo { } /** + * Returns the image data height + * * @return the image data height */ public int getDataHeight() { @@ -138,6 +158,7 @@ public class ImageObjectInfo extends DataObjectInfo { /** * Sets the image data height + * * @param imageDataHeight the image data height */ public void setDataHeight(int imageDataHeight) { @@ -145,6 +166,8 @@ public class ImageObjectInfo extends DataObjectInfo { } /** + * Returns the mime type of this image + * * @return the mime type of this image */ public String getMimeType() { @@ -153,6 +176,7 @@ public class ImageObjectInfo extends DataObjectInfo { /** * Sets whether or not this is info about a buffered image + * * @param buffered true if this is info about a buffered image */ public void setBuffered(boolean buffered) { @@ -160,15 +184,15 @@ public class ImageObjectInfo extends DataObjectInfo { } /** + * Returns true if this image info is about a buffered image + * * @return true if this image info is about a buffered image */ public boolean isBuffered() { return this.buffered; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return super.toString() + ", mimeType=" + mimeType diff --git a/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java b/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java index b6538b327..7c654519b 100644 --- a/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java +++ b/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java @@ -19,6 +19,10 @@ package org.apache.fop.render.afp; +/** + * A common class used to convey locations, + * dimensions and resolutions of data objects. + */ public class ObjectAreaInfo { private int x; private int y; @@ -30,6 +34,7 @@ public class ObjectAreaInfo { /** * Sets the x position of the data object + * * @param x the x position of the data object */ public void setX(int x) { @@ -38,6 +43,7 @@ public class ObjectAreaInfo { /** * Sets the y position of the data object + * * @param y the y position of the data object */ public void setY(int y) { @@ -46,6 +52,7 @@ public class ObjectAreaInfo { /** * Sets the data object width + * * @param width the width of the data object */ public void setWidth(int width) { @@ -54,6 +61,7 @@ public class ObjectAreaInfo { /** * Sets the data object height + * * @param height the height of the data object */ public void setHeight(int height) { @@ -62,6 +70,7 @@ public class ObjectAreaInfo { /** * Sets the width resolution + * * @param widthRes the width resolution */ public void setWidthRes(int widthRes) { @@ -70,6 +79,7 @@ public class ObjectAreaInfo { /** * Sets the height resolution + * * @param heightRes the height resolution */ public void setHeightRes(int heightRes) { @@ -77,6 +87,8 @@ public class ObjectAreaInfo { } /** + * Returns the x coordinate of this data object + * * @return the x coordinate of this data object */ public int getX() { @@ -84,6 +96,8 @@ public class ObjectAreaInfo { } /** + * Returns the y coordinate of this data object + * * @return the y coordinate of this data object */ public int getY() { @@ -91,6 +105,8 @@ public class ObjectAreaInfo { } /** + * Returns the width of this data object + * * @return the width of this data object */ public int getWidth() { @@ -98,6 +114,8 @@ public class ObjectAreaInfo { } /** + * Returns the height of this data object + * * @return the height of this data object */ public int getHeight() { @@ -105,6 +123,8 @@ public class ObjectAreaInfo { } /** + * Returns the width resolution of this data object + * * @return the width resolution of this data object */ public int getWidthRes() { @@ -112,6 +132,8 @@ public class ObjectAreaInfo { } /** + * Returns the height resolution of this data object + * * @return the height resolution of this data object */ public int getHeightRes() { @@ -119,6 +141,8 @@ public class ObjectAreaInfo { } /** + * Returns the rotation of this data object + * * @return the rotation of this data object */ public int getRotation() { @@ -127,15 +151,14 @@ public class ObjectAreaInfo { /** * Sets the data object rotation + * * @param rotation the data object rotation */ public void setRotation(int rotation) { this.rotation = rotation; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return "x=" + x + ", y=" + y diff --git a/src/java/org/apache/fop/render/afp/ResourceInfo.java b/src/java/org/apache/fop/render/afp/ResourceInfo.java index 5bdc9c674..67f03bfd2 100644 --- a/src/java/org/apache/fop/render/afp/ResourceInfo.java +++ b/src/java/org/apache/fop/render/afp/ResourceInfo.java @@ -23,19 +23,36 @@ package org.apache.fop.render.afp; * The level at which a resource is to reside in the AFP output */ public class ResourceInfo { + /** the uri of this resource */ + private String uri; - /** - * the reference name of this resource - */ + /** the reference name of this resource */ private String name = null; + /** the resource level (default to print-file) */ + private ResourceLevel level = new ResourceLevel(ResourceLevel.PRINT_FILE); + /** - * the resource level (default to print-file) + * Sets the data object uri + * + * @param uri the data object uri */ - private ResourceLevel level = new ResourceLevel(ResourceLevel.PRINT_FILE); + public void setUri(String uri) { + this.uri = uri; + } + /** + * Returns the uri of this data object + * + * @return the uri of this data object + */ + public String getUri() { + return uri; + } + /** * Sets the resource reference name + * * @param resourceName the resource reference name */ public void setName(String resourceName) { @@ -43,6 +60,8 @@ public class ResourceInfo { } /** + * Returns the resource reference name + * * @return the resource reference name */ public String getName() { @@ -50,14 +69,8 @@ public class ResourceInfo { } /** - * {@inheritDoc} - */ - public String toString() { - return "ResourceInfo(" + (name != null ? "name=" + name - + ", " : "") + "level=" + level + ")"; - } - - /** + * Returns the resource level + * * @return the resource level */ public ResourceLevel getLevel() { @@ -66,9 +79,41 @@ public class ResourceInfo { /** * Sets the resource level + * * @param resourceLevel the resource level */ public void setLevel(ResourceLevel resourceLevel) { this.level = resourceLevel; } + + /** {@inheritDoc} */ + public String toString() { + return "ResourceInfo(uri=" + uri + + (name != null ? ", name=" + name : "") + + (level != null ? ", level=" + level : "") + ")"; + } + + /** {@inheritDoc} */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if ((obj == null) || !(obj instanceof ResourceInfo)) { + return false; + } + + ResourceInfo ri = (ResourceInfo)obj; + return (uri == ri.uri || uri != null && uri.equals(ri.uri)) + && (name == ri.name || name != null && name.equals(ri.name)) + && (level == ri.level || level != null && level.equals(ri.level)); + } + + /** {@inheritDoc} */ + public int hashCode() { + int hash = 7; + hash = 31 * hash + (null == uri ? 0 : uri.hashCode()); + hash = 31 * hash + (null == name ? 0 : name.hashCode()); + hash = 31 * hash + (null == level ? 0 : level.hashCode()); + return hash; + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ResourceLevel.java b/src/java/org/apache/fop/render/afp/ResourceLevel.java index 37a8e6dce..205a483ff 100644 --- a/src/java/org/apache/fop/render/afp/ResourceLevel.java +++ b/src/java/org/apache/fop/render/afp/ResourceLevel.java @@ -19,12 +19,11 @@ package org.apache.fop.render.afp; -import java.io.File; - /** * A resource level */ public class ResourceLevel { + /** page level **/ public static final int PAGE = 0; @@ -48,19 +47,18 @@ public class ResourceLevel { private static final String[] NAMES = new String[] {NAME_PAGE, NAME_PAGE_GROUP, NAME_DOCUMENT, NAME_PRINT_FILE, NAME_EXTERNAL}; + - /** - * where the resource will reside in the AFP output - */ + + /** where the resource will reside in the AFP output */ private int level = PRINT_FILE; // default is print-file level - /** - * the external resource group file - */ - private File externalResourceGroupFile = null; + /** the external resource group file path */ + private String extFilePath = null; /** * Sets the resource placement level within the AFP output + * * @param lvl the resource level (page, page-group, document, print-file or external) * @return true if the resource level was successfully set */ @@ -80,13 +78,25 @@ public class ResourceLevel { /** * Main constructor + * * @param level the resource level */ public ResourceLevel(int level) { + setLevel(level); + } + + /** + * Sets the resource level + * + * @param level the resource level + */ + public void setLevel(int level) { this.level = level; } /** + * Returns true if this is a page level resource group + * * @return true if this is a page level resource group */ public boolean isPage() { @@ -94,6 +104,8 @@ public class ResourceLevel { } /** + * Returns true if this is a page group level resource group + * * @return true if this is a page group level resource group */ public boolean isPageGroup() { @@ -101,6 +113,8 @@ public class ResourceLevel { } /** + * Returns true if this is a document level resource group + * * @return true if this is a document level resource group */ public boolean isDocument() { @@ -108,6 +122,8 @@ public class ResourceLevel { } /** + * Returns true if this is an external level resource group + * * @return true if this is an external level resource group */ public boolean isExternal() { @@ -115,6 +131,8 @@ public class ResourceLevel { } /** + * Returns true if this is a print-file level resource group + * * @return true if this is a print-file level resource group */ public boolean isPrintFile() { @@ -122,39 +140,48 @@ public class ResourceLevel { } /** - * @return the external resource group file of this resource - */ - public File getExternalResourceGroupFile() { - return this.externalResourceGroupFile; - } - - /** + * Returns the destination file path of the external resource group file + * * @return the destination file path of the external resource group file */ - public String getExternalResourceGroupFilePath() { - if (externalResourceGroupFile != null) { - return externalResourceGroupFile.getAbsolutePath(); - } - return null; + public String getExternalFilePath() { + return this.extFilePath; } /** * Sets the external destination of the resource - * @param file the external resource group file + * + * @param filePath the external resource group file */ - public void setExternalResourceGroupFile(File file) { - this.externalResourceGroupFile = file; + public void setExternalFilePath(String filePath) { + this.extFilePath = filePath; } - /** - * @return true if this resource has a defined external resource group file destination - */ - public boolean hasExternalResourceGroupFile() { - return getExternalResourceGroupFile() != null; + /** {@inheritDoc} */ + public String toString() { + return NAMES[level] + (isExternal() ? ", file=" + extFilePath : ""); } + + /** {@inheritDoc} */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if ((obj == null) || !(obj instanceof ResourceLevel)) { + return false; + } + ResourceLevel rl = (ResourceLevel)obj; + return (level == level) + && (extFilePath == rl.extFilePath + || extFilePath != null && extFilePath.equals(rl.extFilePath)); + } + /** {@inheritDoc} */ - public String toString() { - return NAMES[level] + (isExternal() ? ", file=" + externalResourceGroupFile : ""); + public int hashCode() { + int hash = 7; + hash = 31 * hash + level; + hash = 31 * hash + (null == extFilePath ? 0 : extFilePath.hashCode()); + return hash; } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java b/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java index 613a24a3d..9be20c4cb 100644 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java +++ b/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java @@ -31,9 +31,7 @@ import org.apache.fop.render.afp.tools.BinaryUtils; */ public final class GraphicsChainedSegment extends AbstractPreparedObjectContainer { - /** - * The maximum segment data length - */ + /** The maximum segment data length */ protected static final int MAX_DATA_LEN = 8192; /** the current area */ @@ -69,9 +67,7 @@ public final class GraphicsChainedSegment extends AbstractPreparedObjectContaine this.previous = previous; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public int getDataLength() { int dataLen = 14 + super.getDataLength(); if (previous == null) { @@ -84,9 +80,7 @@ public final class GraphicsChainedSegment extends AbstractPreparedObjectContaine return dataLen; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected int getNameLength() { return 4; } @@ -95,20 +89,20 @@ public final class GraphicsChainedSegment extends AbstractPreparedObjectContaine // private static final byte PROLOG = 4; // private static final byte APPEND_TO_EXISING = 48; - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { super.writeStart(os); int len = super.getDataLength(); byte[] segLen = BinaryUtils.convert(len, 2); + + byte[] nameBytes = getNameBytes(); byte[] data = new byte[] { 0x70, // BEGIN_SEGMENT 0x0C, // Length of following parameters - this.nameBytes[0], - this.nameBytes[1], - this.nameBytes[2], - this.nameBytes[3], + nameBytes[0], + nameBytes[1], + nameBytes[2], + nameBytes[3], 0x00, // FLAG1 (ignored) APPEND_NEW_SEGMENT, segLen[0], // SEGL @@ -120,17 +114,13 @@ public final class GraphicsChainedSegment extends AbstractPreparedObjectContaine }; // P/S NAME (predecessor name) if (previous != null) { - data[10] = previous.nameBytes[0]; - data[11] = previous.nameBytes[1]; - data[12] = previous.nameBytes[2]; - data[13] = previous.nameBytes[3]; + nameBytes = previous.getNameBytes(); + System.arraycopy(nameBytes, 0, data, 10, 4); } os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { // I am the first segment in the chain so write out the rest if (previous == null) { @@ -142,24 +132,18 @@ public final class GraphicsChainedSegment extends AbstractPreparedObjectContaine } } - /** - * Begins a graphics area (start of fill) - */ + /** Begins a graphics area (start of fill) */ protected void beginArea() { this.currentArea = new GraphicsArea(); super.addObject(currentArea); } - /** - * Ends a graphics area (end of fill) - */ + /** Ends a graphics area (end of fill) */ protected void endArea() { this.currentArea = null; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public PreparedAFPObject addObject(PreparedAFPObject drawingOrder) { if (currentArea != null) { currentArea.addObject(drawingOrder); @@ -169,9 +153,7 @@ public final class GraphicsChainedSegment extends AbstractPreparedObjectContaine return drawingOrder; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return "GraphicsChainedSegment(name=" + super.getName() + ")"; } diff --git a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java index 8c2c1b958..8d640b998 100644 --- a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java +++ b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java @@ -20,7 +20,6 @@ package org.apache.fop.render.afp.modca; import java.awt.Color; -import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; @@ -32,9 +31,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.fop.render.afp.AFPFontAttributes; import org.apache.fop.render.afp.AFPTextDataInfo; import org.apache.fop.render.afp.DataObjectInfo; +import org.apache.fop.render.afp.ExternalResourceGroupManager; import org.apache.fop.render.afp.ObjectAreaInfo; import org.apache.fop.render.afp.ResourceInfo; import org.apache.fop.render.afp.ResourceLevel; +import org.apache.fop.render.afp.DataObjectCache; import org.apache.fop.render.afp.fonts.AFPFont; import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; import org.apache.fop.render.afp.tools.StringUtils; @@ -56,11 +57,8 @@ import org.apache.fop.render.afp.tools.StringUtils; */ public class AFPDataStream extends AbstractResourceGroupContainer { - /** - * Static logging instance - */ - protected static Log log = LogFactory - .getLog("org.apache.fop.render.afp.modca"); + /** Static logging instance */ + protected static Log log = LogFactory.getLog("org.apache.fop.render.afp.modca"); /** * Boolean completion indicator @@ -192,15 +190,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { this.outputStream = outputStream; } - /** - * The document is written/ended by invoking this method which creates an - * instance of the AFP Document object and registers the start with a - * validation map which ensures that methods are not invoked out of the - * correct sequence. - * - * @throws java.io.IOException - * throws an I/O exception of some sort has occurred - */ + /** {@inheritDoc} */ public void write() throws IOException { if (complete) { String msg = "Invalid state - document already ended."; @@ -220,7 +210,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { if (interchangeSet.supportsLevel2()) { // Write out any external resource groups - getExternalResourceGroupManager().writeExternalResources(); + getExternalResourceGroupManager().write(); // Write out any print-file level resources if (hasResources()) { @@ -241,6 +231,8 @@ public class AFPDataStream extends AbstractResourceGroupContainer { this.document = null; this.outputStream = null; + + DataObjectCache.getInstance().clear(); } /** @@ -295,18 +287,13 @@ public class AFPDataStream extends AbstractResourceGroupContainer { String overlayName = "OVL" + StringUtils.lpad(String.valueOf(++overlayCount), '0', 5); - this.currentOverlay = new Overlay(overlayName, width, height, widthRes, - heightRes, overlayRotation); - - if (interchangeSet.supportsLevel2()) { - ResourceObject resourceObject = new ResourceObject(overlayName); - resourceObject.setDataObject(currentOverlay); - getResourceGroup().addObject(resourceObject); - } + DataObjectCache cache = DataObjectCache.getInstance(); + DataObjectFactory factory = cache.getFactory(); + this.currentOverlay = factory.createOverlay( + overlayName, width, height, widthRes, heightRes, overlayRotation); currentPageObject.createIncludePageOverlay(overlayName, x, y, 0); currentPage = currentOverlay; -// setOffsets(0, 0, 0); } /** @@ -439,10 +426,10 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * * @param dataObjectInfo * the data object info - * @return a data object */ - public AbstractNamedAFPObject createObject(DataObjectInfo dataObjectInfo) { - String uri = dataObjectInfo.getUri(); + public void createObject(DataObjectInfo dataObjectInfo) { + ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + String uri = resourceInfo.getUri(); if (uri == null) { uri = "/"; @@ -451,40 +438,50 @@ public class AFPDataStream extends AbstractResourceGroupContainer { // unique if (uri.endsWith("/")) { uri += "#" + (++instreamObjectCount); - dataObjectInfo.setUri(uri); + resourceInfo.setUri(uri); } - //Update placement with current state + // Update placement with current state ObjectAreaInfo areaInfo = dataObjectInfo.getObjectAreaInfo(); areaInfo.setX(areaInfo.getX()); areaInfo.setY(areaInfo.getY()); areaInfo.setRotation(this.rotation); + // Do we have a recognised/registered object type? Registry registry = Registry.getInstance(); Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); - // recognised object type if (objectType != null) { dataObjectInfo.setObjectType(objectType); + } + + DataObjectCache cache = DataObjectCache.getInstance(); + String includeName = cache.put(dataObjectInfo); - ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + if (objectType != null) { + ResourceLevel resourceLevel = resourceInfo.getLevel(); // is MO:DCA-L available? if (interchangeSet.supportsLevel2()) { - // can this data object use the include object (IOB) referencing + + // Can this data object use the include object (IOB) referencing // mechanism? if (objectType.canBeIncluded()) { + + // Create and return include + DataObjectFactory factory = cache.getFactory(); + IncludeObject includeObj = factory.createInclude(includeName, dataObjectInfo); + getCurrentPage().addObject(includeObj); + + // Record the resource cache key (uri) in the ResourceGroup ResourceGroup resourceGroup = getResourceGroup(resourceLevel); - IncludeObject includeObject = resourceGroup.createObject(dataObjectInfo); - - // add include to current page - getCurrentPage().addObject(includeObject); - return includeObject.getDataObject(); + resourceGroup.addObject(resourceInfo); + return; } else { - log.warn("data object located at '" + uri + "'" + log.warn("Data object located at '" + uri + "'" + " of type '" + objectType.getMimeType() + "'" + " cannot be included with an IOB so it will be embedded directly"); - } + } } else { if (resourceLevel.isExternal()) { log.warn(interchangeSet @@ -492,11 +489,8 @@ public class AFPDataStream extends AbstractResourceGroupContainer { } } } - // unrecognised/unsupported object type so create/embed data object - // directly in current page - AbstractNamedAFPObject dataObj = currentPageObject.createObject(dataObjectInfo); - getCurrentPage().addObject(dataObj); - return dataObj; + // Unrecognised/unsupported object type so add object reference directly in current page + currentPageObject.addObject(resourceInfo); } // /** @@ -713,6 +707,11 @@ public class AFPDataStream extends AbstractResourceGroupContainer { getCurrentPage().createNoOperation(content); } + /** + * Returns the current page group + * + * @return the current page group + */ private PageGroup getCurrentPageGroup() { if (currentPageGroup == null) { String pageGroupName = "PGP" @@ -747,8 +746,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * Sets the rotation to be used for portrait pages, valid values are 0 * (default), 90, 180, 270. * - * @param pageRotation - * The rotation in degrees. + * @param pageRotation the rotation in degrees. */ public void setPortraitRotation(int pageRotation) { if (pageRotation == 0 || pageRotation == 90 || pageRotation == 180 @@ -764,8 +762,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * Sets the rotation to be used for landscape pages, valid values are 0, 90, * 180, 270 (default). * - * @param pageRotation - * The rotation in degrees. + * @param pageRotation the rotation in degrees. */ public void setLandscapeRotation(int pageRotation) { if (pageRotation == 0 || pageRotation == 90 || pageRotation == 180 @@ -777,165 +774,58 @@ public class AFPDataStream extends AbstractResourceGroupContainer { } } - /** - * Returns the resource group for a given resource into - * - * @param level - * resource info - * @return a resource group container for the given resource info - */ - private ResourceGroup getResourceGroup(ResourceLevel level) { - ResourceGroup resourceGroup = null; - if (level.isPrintFile()) { - resourceGroup = getResourceGroup(); - } else if (level.isDocument()) { - resourceGroup = getDocument().getResourceGroup(); - } else if (level.isPageGroup()) { - resourceGroup = getCurrentPageGroup().getResourceGroup(); - } else if (level.isPage()) { - resourceGroup = currentPageObject.getResourceGroup(); - } else if (level.isExternal()) { - resourceGroup = getExternalResourceGroupManager() - .getExternalResourceGroup(level); - } - return resourceGroup; - } - /** * Sets the default resource group file * - * @param resourceGroupFile - * the default resource group file + * @param filePath the default resource group file path */ - public void setDefaultResourceGroupFile(File resourceGroupFile) { - getExternalResourceGroupManager().setDefaultResourceGroupFile( - resourceGroupFile); + public void setDefaultResourceGroupFilePath(String filePath) { + getExternalResourceGroupManager().setDefaultResourceGroupFilePath(filePath); } /** + * Returns the external resource group manager + * * @return the resource group manager */ protected ExternalResourceGroupManager getExternalResourceGroupManager() { if (externalResourceGroupManager == null) { - this.externalResourceGroupManager = new ExternalResourceGroupManager(this); + this.externalResourceGroupManager = new ExternalResourceGroupManager(); } return this.externalResourceGroupManager; } /** - * Manages the use of resource groups (external and internal) + * Returns the resource group for a given resource info + * + * @param level a resource level + * @return a resource group for the given resource info */ - private final class ExternalResourceGroupManager { - /** - * A mapping of external resource destinations to resource groups - */ - private Map/**/externalResourceGroups = null; - - /** sets the default resource group file */ - private File defaultResourceGroupFile; - - /** the container of this manager */ - private AbstractResourceGroupContainer container; - - /** - * Main constructor - * - * @param container - * the container of this manager - */ - private ExternalResourceGroupManager( - AbstractResourceGroupContainer container) { - this.container = container; - } - - /** - * Sets the default resource group file - * - * @param resourceGroupFile - * the default resource group file - */ - private void setDefaultResourceGroupFile(File resourceGroupFile) { - this.defaultResourceGroupFile = resourceGroupFile; - } - - /** - * Writes out external AFP resources - */ - private void writeExternalResources() { - // write any external resources - Iterator it = getExternalResourceGroups().keySet().iterator(); - while (it.hasNext()) { - File resourceGroupFile = (File) it.next(); - ResourceGroup resourceGroup = (ResourceGroup) getExternalResourceGroups() - .get(resourceGroupFile); - OutputStream os = null; - try { - log.debug("Writing external AFP resource file " - + resourceGroupFile.getAbsolutePath()); - - os = new java.io.FileOutputStream(resourceGroupFile); - resourceGroup.write(os); - } catch (IOException e) { - log.error( - "An error occurred when attempting to write external AFP resource file " - + resourceGroupFile.getAbsolutePath()); - } finally { - if (os != null) { - try { - os.close(); - } catch (IOException e) { - log.error("Failed to close outputstream for external AFP resource file " - + resourceGroupFile.getAbsolutePath()); - } - } - } - } - } - - /** - * Returns the corresponding resource group for the given resource level - * - * @param level - * the resource level - * @return the corresponding resource group for the given resource level - */ - private ResourceGroup getExternalResourceGroup(ResourceLevel level) { - ResourceGroup resourceGroup; - // this resource info does not have an external resource group - // file definition - if (!level.hasExternalResourceGroupFile()) { - if (defaultResourceGroupFile != null) { - // fallback to default resource group file - level.setExternalResourceGroupFile(defaultResourceGroupFile); - resourceGroup = getExternalResourceGroup(level); - } else { - // use print-file level resource group in the absence - // of an external resource group file definition - resourceGroup = container.getResourceGroup(); - } - } else { - File resourceGroupFile = level - .getExternalResourceGroupFile(); - resourceGroup = (ResourceGroup)getExternalResourceGroups().get(resourceGroupFile); - if (resourceGroup == null) { - resourceGroup = new ResourceGroup(); - externalResourceGroups - .put(resourceGroupFile, resourceGroup); - } - } - return resourceGroup; - } - - private Map/**/getExternalResourceGroups() { - if (externalResourceGroups == null) { - externalResourceGroups = new java.util.HashMap/**/(); + private ResourceGroup getResourceGroup(ResourceLevel level) { + ResourceGroup resourceGroup = null; + if (level.isExternal()) { + resourceGroup = getExternalResourceGroupManager().getResourceGroup(level); + // use print-file level resource group in the absence + // of an external resource group file definition + if (resourceGroup == null) { + level.setLevel(ResourceLevel.PRINT_FILE); } - return externalResourceGroups; } + if (level.isPrintFile()) { + resourceGroup = getResourceGroup(); + } else if (level.isDocument()) { + resourceGroup = getDocument().getResourceGroup(); + } else if (level.isPageGroup()) { + resourceGroup = getCurrentPageGroup().getResourceGroup(); + } else if (level.isPage()) { + resourceGroup = currentPageObject.getResourceGroup(); + } + return resourceGroup; } /** * Sets the MO:DCA interchange set to use + * * @param interchangeSet the MO:DCA interchange set */ public void setInterchangeSet(InterchangeSet interchangeSet) { @@ -943,6 +833,8 @@ public class AFPDataStream extends AbstractResourceGroupContainer { } /** + * Returns the MO:DCA interchange set in use + * * @return the MO:DCA interchange set in use */ public InterchangeSet getInterchangeSet() { diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java index 9cad38ef5..d9f3d6d1a 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java @@ -35,13 +35,52 @@ import org.apache.commons.logging.LogFactory; */ public abstract class AbstractAFPObject implements Writable { + /** Static logging instance */ + protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.modca"); + + private static final byte SF_CLASS = (byte)0xD3; + + private static final byte[] SF = new byte[] { + 0x5A, // Structured field identifier + 0x00, // Length byte 1 + 0x10, // Length byte 2 + (byte) SF_CLASS, // Structured field id byte 1 + (byte) 0x00, // Structured field id byte 2 + (byte) 0x00, // Structured field id byte 3 + 0x00, // Flags + 0x00, // Reserved + 0x00, // Reserved + }; + /** - * Static logging instance + * Copies the template structured field data array to the given byte array + * + * @param data the structured field data byte array + * @param type the type code + * @param category the category code */ - protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.modca"); + protected void copySF(byte[] data, byte type, byte category) { + copySF(data, SF_CLASS, type, category); + } + + /** + * Copies the template structured field data array to the given byte array + * + * @param data the structured field data byte array + * @param clazz the class code + * @param type the type code + * @param category the category code + */ + protected void copySF(byte[] data, byte clazz, byte type, byte category) { + System.arraycopy(SF, 0, data, 0, SF.length); + data[3] = clazz; + data[4] = type; + data[5] = category; + } /** * Help method to write a set of AFPObjects to the AFP datastream. + * * @param objects a list of AFPObjects * @param os The stream to write to * @throws java.io.IOException an I/O exception of some sort has occurred. @@ -55,5 +94,146 @@ public abstract class AbstractAFPObject implements Writable { } } } + + /** structured field type codes */ + interface Type { + + // Attribute + byte ATTRIBUTE = (byte)0x0A; + + // Copy Count + byte COPY_COUNT = (byte)0xA2; + + // Descriptor + byte DESCRIPTOR = (byte)0xA6; + + // Control + byte CONTROL = (byte)0xA7; + + // Begin + byte BEGIN = (byte)0xA8; + + // End + byte END = (byte)0xA9; + + // Map + byte MAP = (byte)0xAB; + + // Position + byte POSITION = (byte)0xAC; + + // Process + byte PROCESS = (byte)0xAD; + + // Include + byte INCLUDE = (byte)0xAF; + + // Table + byte TABLE = (byte)0xB0; + + // Migration + byte MIGRATION = (byte)0xB1; + + // Variable + byte VARIABLE = (byte)0xB2; + + // Link + byte LINK = (byte)0xB4; + + // Data + byte DATA = (byte)0xEE; + } + + /** structured field category codes */ + interface Category { + + // Page Segment + byte PAGE_SEGMENT = (byte)0x5F; + + // Object Area + byte OBJECT_AREA = (byte)0x6B; + + // Color Attribute Table + byte COLOR_ATTRIBUTE_TABLE = (byte)0x77; + + // IM Image + byte IM_IMAGE = (byte)0x7B; + + // Medium + byte MEDIUM = (byte)0x88; + + // Coded Font + byte CODED_FONT = (byte)0x8A; + + // Process Element + byte PROCESS_ELEMENT = (byte)0x90; + + // Object Container + byte OBJECT_CONTAINER = (byte)0x92; + + // Presentation Text + byte PRESENTATION_TEXT = (byte)0x9B; + + // Index + byte INDEX = (byte)0xA7; + + // Document + byte DOCUMENT = (byte)0xA8; + + // Page Group + byte PAGE_GROUP = (byte)0xAD; + + // Page + byte PAGE = (byte)0xAF; + + // Graphics + byte GRAPHICS = (byte)0xBB; + + // Data Resource + byte DATA_RESOURCE = (byte)0xC3; + + // Document Environment Group (DEG) + byte DOCUMENT_ENVIRONMENT_GROUP = (byte)0xC4; + + // Resource Group + byte RESOURCE_GROUP = (byte)0xC6; + + // Object Environment Group (OEG) + byte OBJECT_ENVIRONMENT_GROUP = (byte)0xC7; + + // Active Environment Group (AEG) + byte ACTIVE_ENVIRONMENT_GROUP = (byte)0xC9; + + // Medium Map + byte MEDIUM_MAP = (byte)0xCC; + + // Form Map + byte FORM_MAP = (byte)0xCD; + + // Name Resource + byte NAME_RESOURCE = (byte)0xCE; + + // Page Overlay + byte PAGE_OVERLAY = (byte)0xD8; + + // Resource Environment Group (REG) + byte RESOURCE_ENVIROMENT_GROUP = (byte)0xD9; + + // Overlay + byte OVERLAY = (byte)0xDF; + + // Data Suppression + byte DATA_SUPRESSION = (byte)0xEA; + + // Bar Code + byte BARCODE = (byte)0xEB; + + // No Operation + byte NO_OPERATION = (byte)0xEE; + + // Image + byte IMAGE = (byte)0xFB; + } + } diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java index f52047b62..f666de38b 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java @@ -24,20 +24,18 @@ import java.io.OutputStream; import org.apache.fop.render.afp.ObjectAreaInfo; - /** * Abstract base class used by the ImageObject and GraphicsObject which both * have define an ObjectEnvironmentGroup */ public abstract class AbstractDataObject extends AbstractPreparedObjectContainer { - /** - * The object environment group - */ + /** The object environment group */ protected ObjectEnvironmentGroup objectEnvironmentGroup = null; /** * Named constructor + * * @param name data object name */ public AbstractDataObject(String name) { @@ -56,6 +54,7 @@ public abstract class AbstractDataObject extends AbstractPreparedObjectContainer /** * Gets the ObjectEnvironmentGroup + * * @return the object environment group */ protected ObjectEnvironmentGroup getObjectEnvironmentGroup() { @@ -67,15 +66,14 @@ public abstract class AbstractDataObject extends AbstractPreparedObjectContainer /** * Sets the ObjectEnvironmentGroup. + * * @param objectEnvironmentGroup The objectEnvironmentGroup to set */ public void setObjectEnvironmentGroup(ObjectEnvironmentGroup objectEnvironmentGroup) { this.objectEnvironmentGroup = objectEnvironmentGroup; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { if (objectEnvironmentGroup != null) { objectEnvironmentGroup.write(os); 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 6d827766e..f5bc933a3 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java @@ -35,6 +35,7 @@ public abstract class AbstractDescriptor extends AbstractAFPObject { /** * Constructor a PresentationTextDescriptor for the specified * width and height. + * * @param width The width of the page. * @param height The height of the page. * @param widthResolution The width resolution of the page. diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java index 3f371d628..7e81e4934 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java @@ -36,6 +36,7 @@ public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject { /** * Main constructor + * * @param name the object name */ public AbstractEnvironmentGroup(String name) { @@ -52,6 +53,7 @@ public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject { /** * Actually creates the MPO object. * Also creates the supporting object (an IPO) + * * @param name the name of the overlay to be used */ public void createOverlay(String name) { @@ -78,6 +80,7 @@ public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject { /** * Getter method for the most recent MapPageOverlay added to the * Active Environment Group (returns null if no MapPageOverlay exist) + * * @return the most recent Map Coded Font */ private MapPageOverlay getCurrentMapPageOverlay() { @@ -88,9 +91,7 @@ public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); if (mapPageOverlays != null) { 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 8e6127b8a..6ed3411bc 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java @@ -34,11 +34,6 @@ public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject */ protected String name = null; - /** - * The name of the object in EBCIDIC bytes - */ - protected byte[] nameBytes; - /** * Default constructor */ @@ -48,16 +43,26 @@ public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject /** * Constructor for the ActiveEnvironmentGroup, this takes a * name parameter which should be 8 characters long. + * * @param name the object name */ protected AbstractNamedAFPObject(String name) { this.name = name; - if (name.length() < 8) { - name = (name + " ").substring(0, 8); - } else if (name.length() > 8) { - log.warn("Constructor:: name truncated to 8 chars" + name); - name = name.substring(0, 8); + } + + /** + * Returns the name as a byte array in EBCIDIC encoding + * + * @return the name as a byte array in EBCIDIC encoding + */ + protected byte[] getNameBytes() { + if (name.length() < DEFAULT_NAME_LENGTH) { + name = (name + " ").substring(0, DEFAULT_NAME_LENGTH); + } else if (name.length() > DEFAULT_NAME_LENGTH) { + log.warn("Constructor:: name truncated to " + DEFAULT_NAME_LENGTH + " chars" + name); + name = name.substring(0, DEFAULT_NAME_LENGTH); } + byte[] nameBytes = null; try { nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); } catch (UnsupportedEncodingException usee) { @@ -66,17 +71,20 @@ public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject "Constructor:: UnsupportedEncodingException translating the name " + name); } + return nameBytes; } - /** - * @return the name length of this object - */ - protected int getNameLength() { - return DEFAULT_NAME_LENGTH; + /** {@inheritDoc} */ + protected void copySF(byte[] data, byte type, byte category) { + super.copySF(data, type, category); + byte[] nameData = getNameBytes(); + System.arraycopy(nameData, 0, data, 9, nameData.length); } /** - * @return the name of the page group + * Returns the name of this object + * + * @return the name of this object */ public String getName() { return name; diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java index c5b2f3ea2..73c4b6821 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java @@ -22,9 +22,12 @@ package org.apache.fop.render.afp.modca; import java.awt.Color; import java.io.IOException; import java.io.OutputStream; +import java.util.Iterator; import java.util.List; import org.apache.fop.render.afp.AFPTextDataInfo; +import org.apache.fop.render.afp.DataObjectCache; +import org.apache.fop.render.afp.ResourceInfo; import org.apache.fop.render.afp.fonts.AFPFont; /** @@ -112,6 +115,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { /** * Named constructor + * * @param name the name of this page object */ public AbstractPageObject(String name) { @@ -218,6 +222,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { /** * Helper method to create a presentation text object * on the current page and to return the object. + * * @return the presentation text object */ private PresentationTextObject getPresentationTextObject() { @@ -305,6 +310,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { /** * Returns an indication if the page is complete + * * @return whether this page is complete */ public boolean isComplete() { @@ -313,6 +319,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { /** * Returns the height of the page + * * @return the height of the page */ public int getHeight() { @@ -321,6 +328,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { /** * Returns the width of the page + * * @return the width of the page */ public int getWidth() { @@ -329,15 +337,14 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { /** * Returns the rotation of the page + * * @return the rotation of the page */ public int getRotation() { return rotation; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); if (this instanceof PageObject || this instanceof Overlay) { @@ -345,23 +352,37 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { } writeObjects(this.includePageSegments, os); writeObjects(this.tagLogicalElements, os); - writeObjects(this.objects, os); + + DataObjectCache cache = DataObjectCache.getInstance(); + + // Write objects from cache + Iterator it = objects.iterator(); + while (it.hasNext()) { + Object obj = it.next(); + if (obj instanceof Writable) { + Writable writableObject = (Writable)obj; + writableObject.write(os); + } else if (obj instanceof ResourceInfo) { + ResourceInfo resourceInfo = (ResourceInfo)obj; + byte[] data = cache.get(resourceInfo); + os.write(data); + } + } } /** - * Adds an AFP object to the resource group in this container + * Adds an AFP object reference to this page + * * @param obj an AFP object */ - protected void addObject(AbstractAFPObject obj) { + protected void addObject(Object obj) { if (objects == null) { - this.objects = new java.util.ArrayList/**/(); + this.objects = new java.util.ArrayList(); } objects.add(obj); } -// /** -// * {@inheritDoc} -// */ +// /** {@inheritDoc} */ // protected void addObject(AbstractAFPObject obj) { // if (obj instanceof DataObjectAccessor) { // DataObjectAccessor dataObjectAccessor = (DataObjectAccessor)obj; diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java index d707384ed..16ed036f2 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java @@ -41,15 +41,14 @@ implements PreparedAFPObject { /** * Named constructor + * * @param name the name of this AFP object */ public AbstractPreparedAFPObject(String name) { super(name); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); // write triplets if (this.data != null) { @@ -83,6 +82,7 @@ implements PreparedAFPObject { /** * Sets the data + * * @param data the data */ protected void setData(byte[] data) { diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java b/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java index 3c2b3981d..03e646913 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java @@ -30,9 +30,7 @@ import java.util.List; public abstract class AbstractPreparedObjectContainer extends AbstractNamedAFPObject implements PreparedAFPObject { - /** - * list of objects contained within this container - */ + /** list of objects contained within this container */ protected List/**/ objects = null; /** @@ -43,15 +41,14 @@ implements PreparedAFPObject { /** * Named constructor + * * @param name the name of the container */ protected AbstractPreparedObjectContainer(String name) { super(name); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { if (objects != null) { super.writeObjects(objects, os); @@ -67,16 +64,19 @@ implements PreparedAFPObject { /** * Adds a given prepared object to this container + * * @param preparedObject the prepared object * @return the drawingOrder if it was added, null otherwise */ public PreparedAFPObject addObject(PreparedAFPObject preparedObject) { - log.debug(this + " adding " + preparedObject); +// log.debug(this + " adding " + preparedObject); getObjects().add(preparedObject); return preparedObject; } /** + * Returns the current data length + * * @return the current data length of this container including * all enclosed objects (and their containers) */ diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java b/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java index 4a5785981..d56ebef9b 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java @@ -36,6 +36,7 @@ public abstract class AbstractResourceEnvironmentGroupContainer /** * Main constructor + * * @param name the name of this resource container */ public AbstractResourceEnvironmentGroupContainer(String name) { @@ -44,6 +45,7 @@ public abstract class AbstractResourceEnvironmentGroupContainer /** * Adds a page to the resource container. + * * @param page - the Page object */ public void addPage(PageObject page) { @@ -52,6 +54,7 @@ public abstract class AbstractResourceEnvironmentGroupContainer /** * Adds a PageGroup to the resource container. + * * @param pageGroup the PageGroup object */ public void addPageGroup(PageGroup pageGroup) { @@ -68,9 +71,7 @@ public abstract class AbstractResourceEnvironmentGroupContainer addObject(new InvokeMediumMap(name)); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); if (resourceEnvironmentGroup != null) { @@ -79,6 +80,8 @@ public abstract class AbstractResourceEnvironmentGroupContainer } /** + * Returns the resource environment group + * * @return the resource environment group */ protected ResourceEnvironmentGroup getResourceEnvironmentGroup() { diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java b/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java index 71cc4698b..55f3a89b1 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java @@ -22,7 +22,7 @@ package org.apache.fop.render.afp.modca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.render.afp.DataObjectInfo; +//import org.apache.fop.render.afp.DataObjectInfo; /** * An abstract container of resource objects @@ -33,11 +33,6 @@ public abstract class AbstractResourceGroupContainer extends AbstractPageObject */ private ResourceGroup resourceGroup = null; - /** - * The data object factory - */ - private DataObjectFactory dataObjectFactory = new DataObjectFactory(); - /** * Default constructor */ @@ -47,6 +42,7 @@ public abstract class AbstractResourceGroupContainer extends AbstractPageObject /** * Named constructor + * * @param name the name of this resource container */ public AbstractResourceGroupContainer(String name) { @@ -102,14 +98,14 @@ public abstract class AbstractResourceGroupContainer extends AbstractPageObject return resourceGroup; } - /** - * Creates and returns a new data object - * @param dataObjectInfo the data object info - * @return a newly created data object - */ - public AbstractNamedAFPObject createObject(DataObjectInfo dataObjectInfo) { - return dataObjectFactory.create(dataObjectInfo); - } +// /** +// * Creates and returns a new data object +// * @param dataObjectInfo the data object info +// * @return a newly created data object +// */ +// public AbstractNamedAFPObject createObject(DataObjectInfo dataObjectInfo) { +// return dataObjectFactory.create(dataObjectInfo); +// } /** * {@inheritDoc} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java index 1a23511f5..b3a3c7afb 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java @@ -38,8 +38,7 @@ import org.apache.fop.render.afp.modca.triplets.Triplet; /** * An abstract class encapsulating an MODCA structured object */ -public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { - +public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * list of object triplets */ @@ -57,6 +56,8 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { } /** + * Returns the triplet data length + * * @return the triplet data length */ protected int getTripletDataLength() { @@ -74,6 +75,8 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { } /** + * Returns the triplet data + * * @return the triplet data * @throws IOException throws an I/O exception if one occurred */ @@ -88,6 +91,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Writes any triplet data + * * @param os The stream to write to * @throws IOException The stream to write to */ @@ -101,6 +105,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Helper method to write the start of the Object. + * * @param os The stream to write to * @throws IOException throws an I/O exception if one occurred */ @@ -108,8 +113,18 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { getTripletData(); } + /** + * Helper method to write the end of the Object. + * + * @param os The stream to write to + * @throws IOException an I/O exception if one occurred + */ + protected void writeEnd(OutputStream os) throws IOException { + } + /** * Helper method to write the contents of the Object. + * * @param os The stream to write to * @throws IOException throws an I/O exception if one occurred */ @@ -118,15 +133,8 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { } /** - * Helper method to write the end of the Object. - * @param os The stream to write to - * @throws IOException an I/O exception if one occurred - */ - protected void writeEnd(OutputStream os) throws IOException { - } - - /** - * Accessor method to write the AFP datastream for the Image Object + * Accessor method to write the AFP datastream for this structure field object + * * @param os The stream to write to * @throws IOException in the event that an I/O exception occurred */ @@ -137,7 +145,8 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { } /** - * Returns the first matching triplet found in the structured field triplet list + * Returns the first matching triplet found in the structured field triplet list + * * @param tripletId the triplet identifier */ private Triplet getTriplet(byte tripletId) { @@ -152,6 +161,8 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { } /** + * Returns true of this structured field has the given triplet + * * @param tripletId the triplet identifier * @return true if the structured field has the given triplet */ @@ -161,6 +172,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Adds a triplet to this structured object + * * @param triplet the triplet to add */ private void addTriplet(Triplet triplet) { @@ -169,6 +181,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Adds a list of triplets to the triplets contained within this structured field + * * @param tripletCollection a collection of triplets */ private void addTriplets(Collection/**/ tripletCollection) { @@ -177,9 +190,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { } } - /** - * @return the triplet list pertaining to this resource - */ + /** @return the triplet list pertaining to this resource */ protected List/**/ getTriplets() { if (triplets == null) { triplets = new java.util.ArrayList(); @@ -189,6 +200,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Sets the fully qualified name of this resource + * * @param fqnType the fully qualified name type of this resource * @param fqnFormat the fully qualified name format of this resource * @param fqName the fully qualified name of this resource @@ -197,9 +209,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { addTriplet(new FullyQualifiedNameTriplet(fqnType, fqnFormat, fqName)); } - /** - * @return the fully qualified name of this triplet or null if it does not exist - */ + /** @return the fully qualified name of this triplet or null if it does not exist */ public String getFullyQualifiedName() { FullyQualifiedNameTriplet fqNameTriplet = (FullyQualifiedNameTriplet)getTriplet(Triplet.FULLY_QUALIFIED_NAME); @@ -212,6 +222,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Sets the objects classification + * * @param objectClass the classification of the object * @param objectType the MOD:CA registry object type entry for the given * object/component type of the object @@ -224,6 +235,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Sets the objects classification with the default structure flags + * * @param objectClass the classification of the object * @param objectType the MOD:CA registry object type entry for the given * object/component type of the object @@ -234,6 +246,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Sets the extent of an object area in the X and Y directions + * * @param x the x direction extent * @param y the y direction extent */ @@ -243,6 +256,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Sets the measurement units used to specify the units of measure + * * @param xRes units per base on the x-axis * @param yRes units per base on the y-axis */ @@ -252,6 +266,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Sets the mapping option + * * @param optionValue the mapping option value */ public void setMappingOption(byte optionValue) { @@ -260,6 +275,7 @@ public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { /** * Sets a comment on this resource + * * @param comment a comment string */ public void setComment(String comment) { diff --git a/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java index 4dd735ccc..916544603 100644 --- a/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java +++ b/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java @@ -77,6 +77,7 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { /** * Default constructor for the ActiveEnvironmentGroup. + * * @param width the page width * @param height the page height * @param widthRes the page width resolution @@ -89,6 +90,7 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { /** * Constructor for the ActiveEnvironmentGroup, this takes a * name parameter which must be 8 characters long. + * * @param name the active environment group name * @param width the page width * @param height the page height @@ -112,6 +114,7 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { /** * Set the position of the object area + * * @param x the x offset * @param y the y offset * @param rotation the rotation @@ -124,6 +127,7 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { /** * Accessor method to obtain the PageDescriptor object of the * active environment group. + * * @return the page descriptor object */ public PageDescriptor getPageDescriptor() { @@ -133,15 +137,14 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { /** * Accessor method to obtain the PresentationTextDataDescriptor object of * the active environment group. + * * @return the presentation text descriptor */ public PresentationTextDescriptor getPresentationTextDataDescriptor() { return presentationTextDataDescriptor; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void writeContent(OutputStream os) throws IOException { super.writeTriplets(os); @@ -161,43 +164,17 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xC9; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.ACTIVE_ENVIRONMENT_GROUP); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xC9; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.ACTIVE_ENVIRONMENT_GROUP); os.write(data); } @@ -208,15 +185,16 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { return mapCodedFonts; } - private List getMapDataResources() { - if (mapDataResources == null) { - mapDataResources = new java.util.ArrayList(); - } - return mapDataResources; - } +// private List getMapDataResources() { +// if (mapDataResources == null) { +// mapDataResources = new java.util.ArrayList(); +// } +// return mapDataResources; +// } /** * Method to create a map coded font object + * * @param fontRef the font number used as the resource identifier * @param font the font * @param size the point size of the font @@ -247,6 +225,7 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { /** * Getter method for the most recent MapCodedFont added to the * Active Environment Group (returns null if no MapCodedFonts exist) + * * @return the most recent Map Coded Font. */ private MapCodedFont getCurrentMapCodedFont() { @@ -258,11 +237,11 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { } } - /** - * Method to create a map data resource object - * @param dataObjectAccessor a data object accessor - */ - protected void createMapDataResource(DataObjectAccessor dataObjectAccessor) { - getMapDataResources().add(new MapDataResource(dataObjectAccessor)); - } +// /** +// * Method to create a map data resource object +// * @param dataObjectAccessor a data object accessor +// */ +// protected void createMapDataResource(DataObjectAccessor dataObjectAccessor) { +// getMapDataResources().add(new MapDataResource(dataObjectAccessor)); +// } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java b/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java index 7e3f41a53..0a5fb5bbe 100644 --- a/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java +++ b/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java @@ -19,24 +19,45 @@ package org.apache.fop.render.afp.modca; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.fop.render.afp.DataObjectInfo; +import org.apache.fop.render.afp.GraphicsObjectInfo; +import org.apache.fop.render.afp.GraphicsObjectPainter; import org.apache.fop.render.afp.ImageObjectInfo; import org.apache.fop.render.afp.ObjectAreaInfo; +import org.apache.fop.render.afp.ResourceInfo; +import org.apache.fop.render.afp.ResourceLevel; +import org.apache.fop.render.afp.modca.Registry.ObjectType; import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; +import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet; +import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet; import org.apache.fop.render.afp.tools.StringUtils; import org.apache.xmlgraphics.image.codec.tiff.TIFFImage; /** - * Creator of MO;DCA data objects + * Creator of MO:DCA data objects */ public class DataObjectFactory { private static final String IMAGE_NAME_PREFIX = "IMG"; private static final String GRAPHIC_NAME_PREFIX = "GRA"; // private static final String BARCODE_NAME_PREFIX = "BAR"; // private static final String OTHER_NAME_PREFIX = "OTH"; + private static final String OBJECT_CONTAINER_NAME_PREFIX = "OC"; + private static final String RESOURCE_NAME_PREFIX = "RES"; private int imageCount = 0; private int graphicCount = 0; + private int objectContainerCount = 0; + private int resourceCount = 0; + + private Map/**/ includeMap + = new java.util.HashMap/**/(); + + /** Static logging instance */ + private static final Log log = LogFactory.getLog(DataObjectFactory.class); /** * Converts a byte array containing 24 bit RGB image data to a grayscale @@ -102,10 +123,11 @@ public class DataObjectFactory { /** * Helper method to create an image on the current container and to return * the object. + * * @param imageObjectInfo the image object info * @return a newly created image object */ - protected ImageObject createImage(ImageObjectInfo imageObjectInfo) { + private ImageObject createImage(ImageObjectInfo imageObjectInfo) { String name = IMAGE_NAME_PREFIX + StringUtils.lpad(String.valueOf(++imageCount), '0', 5); ImageObject imageObj = new ImageObject(name); @@ -144,36 +166,215 @@ public class DataObjectFactory { } /** - * Helper method to create a graphic in the current container and to return - * the object. - * @param info the data object info - * @return a newly created graphics object + * Creates and returns a new graphics object. + * + * @param graphicsObjectInfo the graphics object info + * @return a new graphics object */ - protected GraphicsObject createGraphic(DataObjectInfo info) { + private GraphicsObject createGraphic(GraphicsObjectInfo graphicsObjectInfo) { String name = GRAPHIC_NAME_PREFIX + StringUtils.lpad(String.valueOf(++graphicCount), '0', 5); GraphicsObject graphicsObj = new GraphicsObject(name); + + // paint the graphic using batik + GraphicsObjectPainter painter = graphicsObjectInfo.getPainter(); + painter.paint(graphicsObj); + return graphicsObj; } + /** + * Creates and returns a new include object. + * + * @param name the name of this include object + * @param dataObjectInfo a data object info + * + * @return a new include object + */ + public IncludeObject createInclude(String name, DataObjectInfo dataObjectInfo) { + ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + IncludeObject includeObj = (IncludeObject)includeMap.get(resourceInfo); + if (includeObj == null) { + includeObj = new IncludeObject(name); + + Registry.ObjectType objectType = dataObjectInfo.getObjectType(); + if (objectType.isImage()) { + includeObj.setDataObjectType(IncludeObject.TYPE_IMAGE); + } else if (objectType.isGraphic()) { + includeObj.setDataObjectType(IncludeObject.TYPE_GRAPHIC); + // } else if (dataObject instanceof PageSegment) { + // includeObj.setDataObjectType(IncludeObject.TYPE_PAGE_SEGMENT); + } else { + includeObj.setDataObjectType(IncludeObject.TYPE_OTHER); + // Strip any object container + // AbstractNamedAFPObject dataObject = dataObjectAccessor.getDataObject(); + // if (dataObject instanceof ObjectContainer) { + // ObjectContainer objectContainer = (ObjectContainer)dataObject; + // dataObject = objectContainer.getDataObject(); + // } + } + +// includeObj.setFullyQualifiedName( +// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, +// FullyQualifiedNameTriplet.FORMAT_CHARSTR, +// dataObjectInfo.getUri()); + + includeObj.setObjectClassification( + ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, + objectType); + + ObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + + includeObj.setObjectArea(objectAreaInfo.getX(), objectAreaInfo.getY()); + + includeObj.setObjectAreaSize( + objectAreaInfo.getWidth(), objectAreaInfo.getHeight()); + + includeObj.setMeasurementUnits( + objectAreaInfo.getWidthRes(), objectAreaInfo.getHeightRes()); + + includeObj.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT); + + includeMap.put(resourceInfo, includeObj); + } + + return includeObj; + } + + /** + * Creates and returns a new object container + * + * @return a new object container + */ + private ObjectContainer createObjectContainer() { + String name = OBJECT_CONTAINER_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++objectContainerCount), '0', 6); + return new ObjectContainer(name); + } + + /** + * Creates and returns a new resource object + * + * @param resourceName the resource name + * @return a new resource object + */ + private ResourceObject createResource(String resourceName) { + return new ResourceObject(resourceName); + } + + /** + * Creates and returns a new resource object + * + * @return a new resource object + */ + private ResourceObject createResource() { + String name = RESOURCE_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++resourceCount ), '0', 5); + return createResource(name); + } + + /** + * Creates and returns a new Overlay. + * + * @param overlayName + * the name of the overlay + * @param width + * the width of the overlay + * @param height + * the height of the overlay + * @param widthRes + * the width resolution of the overlay + * @param heightRes + * the height resolution of the overlay + * @param overlayRotation + * the rotation of the overlay + * + * @return a new overlay object + */ + public Overlay createOverlay(String overlayName, int width, int height, + int widthRes, int heightRes, int overlayRotation) { + Overlay overlay = new Overlay(overlayName, width, height, + overlayRotation, widthRes, heightRes); + return overlay; + } + /** * Creates and returns a new data object + * * @param dataObjectInfo the data object info + * * @return a newly created data object */ - public AbstractDataObject create(DataObjectInfo dataObjectInfo) { - AbstractDataObject dataObject; + public AbstractNamedAFPObject createObject(DataObjectInfo dataObjectInfo) { + AbstractNamedAFPObject dataObj; + if (dataObjectInfo instanceof ImageObjectInfo) { - dataObject = createImage((ImageObjectInfo)dataObjectInfo); + dataObj = createImage((ImageObjectInfo)dataObjectInfo); + } else if (dataObjectInfo instanceof GraphicsObjectInfo) { + dataObj = createGraphic((GraphicsObjectInfo)dataObjectInfo); } else { - dataObject = createGraphic(dataObjectInfo); + throw new IllegalArgumentException("Unknown data object type: " + dataObjectInfo); } - dataObject.setViewport(dataObjectInfo.getObjectAreaInfo()); + + if (dataObj instanceof AbstractDataObject) { + ((AbstractDataObject)dataObj).setViewport(dataObjectInfo.getObjectAreaInfo()); + } + + dataObj.setFullyQualifiedName( + FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF, + FullyQualifiedNameTriplet.FORMAT_CHARSTR, dataObj.getName()); - dataObject.setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, dataObject.getName()); + ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + ResourceLevel resourceLevel = resourceInfo.getLevel(); - return dataObject; - } + if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) { + + ObjectType objectType = dataObjectInfo.getObjectType(); + + if (objectType != null && objectType.canBeIncluded()) { + + // Wrap newly created data object in a resource object + // if it is to reside within a resource group at print-file or external level + if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) { + ResourceObject resourceObj = null; + String resourceName = resourceInfo.getName(); + if (resourceName != null) { + resourceObj = createResource(resourceName); + } else { + resourceObj = createResource(); + } + + if (dataObj instanceof ObjectContainer) { + resourceObj.setType(ResourceObject.OBJECT_CONTAINER); + } else if (dataObj instanceof ImageObject) { + resourceObj.setType(ResourceObject.IMAGE_OBJECT); + } else if (dataObj instanceof GraphicsObject) { + resourceObj.setType(ResourceObject.GRAPHICS_OBJECT); + } else if (dataObj instanceof Document) { + resourceObj.setType(ResourceObject.DOCUMENT_OBJECT); + } else if (dataObj instanceof PageSegment) { + resourceObj.setType(ResourceObject.PAGE_SEGMENT_OBJECT); + } else if (dataObj instanceof Overlay) { + resourceObj.setType(ResourceObject.OVERLAY_OBJECT); + } else { + throw new UnsupportedOperationException( + "Unsupported resource object type " + dataObj); + } + + resourceObj.setObjectClassification( + ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, + objectType); + + resourceObj.setDataObject(dataObj); + dataObj = resourceObj; + } + } else { + String uri = dataObjectInfo.getUri(); + log.warn("Data object '" + uri + "' not supported at " + + resourceLevel.toString() + " level, will be embedded in page."); + } + } + + return dataObj; + } } diff --git a/src/java/org/apache/fop/render/afp/modca/Document.java b/src/java/org/apache/fop/render/afp/modca/Document.java index efa022952..ae4a4b9fe 100644 --- a/src/java/org/apache/fop/render/afp/modca/Document.java +++ b/src/java/org/apache/fop/render/afp/modca/Document.java @@ -83,6 +83,7 @@ public final class Document extends AbstractResourceEnvironmentGroupContainer { /** * Returns an indication if the page group is complete + * * @return whether or not this page group is complete */ public boolean isComplete() { @@ -91,6 +92,7 @@ public final class Document extends AbstractResourceEnvironmentGroupContainer { /** * Accessor method to write the AFP datastream for document. + * * @param os The stream to write to * @throws java.io.IOException thrown if an I/O exception of some sort has occurred */ @@ -100,49 +102,21 @@ public final class Document extends AbstractResourceEnvironmentGroupContainer { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xA8; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.DOCUMENT); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xA8; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.DOCUMENT); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return this.name; } diff --git a/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java index a73c9fc70..ccf05aa19 100644 --- a/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java +++ b/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java @@ -48,9 +48,7 @@ import org.apache.fop.render.afp.goca.GraphicsString; */ public class GraphicsObject extends AbstractDataObject { - /** - * The graphics data - */ + /** The graphics data */ private GraphicsData graphicsData = null; /** @@ -62,9 +60,7 @@ public class GraphicsObject extends AbstractDataObject { super(name); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void setViewport(ObjectAreaInfo objectAreaInfo) { super.setViewport(objectAreaInfo); getObjectEnvironmentGroup().setGraphicsData( @@ -76,62 +72,26 @@ public class GraphicsObject extends AbstractDataObject { objectAreaInfo.getY() + objectAreaInfo.getHeight()); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ + protected byte getCategoryCode() { + return (byte)0xBB; + } + + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - byte[] data = new byte[] { - 0x5A, // Structured field identifier - 0x00, //sfLen[0], // Length byte 1 - 0x10, //sfLen[1], // Length byte 2 - (byte) 0xD3, // Structured field id byte 1 - (byte) 0xA8, // Structured field id byte 2 - (byte) 0xBB, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - super.nameBytes[0], // gdoName - super.nameBytes[1], - super.nameBytes[2], - super.nameBytes[3], - super.nameBytes[4], - super.nameBytes[5], - super.nameBytes[6], - super.nameBytes[7] - }; + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.GRAPHICS); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - 0x5A, // Structured field identifier - 0x00, // sfLen[0], // Length byte 1 - 0x10, // sfLen[1], // Length byte 2 - (byte) 0xD3, // Structured field id byte 1 - (byte) 0xA9, // Structured field id byte 2 - (byte) 0xBB, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - super.nameBytes[0], // gdoName - super.nameBytes[1], - super.nameBytes[2], - super.nameBytes[3], - super.nameBytes[4], - super.nameBytes[5], - super.nameBytes[6], - super.nameBytes[7] - }; + byte[] data = new byte[17]; + copySF(data, Type.END, Category.GRAPHICS); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public PreparedAFPObject addObject(PreparedAFPObject drawingOrder) { if (graphicsData == null || (graphicsData.getDataLength() + drawingOrder.getDataLength()) @@ -144,6 +104,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Gets the current graphics data, creating a new one if necessary + * * @return the current graphics data */ private GraphicsData getData() { @@ -155,6 +116,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Creates a new graphics data + * * @return a newly created graphics data */ private GraphicsData newData() { @@ -165,6 +127,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Sets the current color + * * @param col the active color to use */ public void setColor(Color col) { @@ -173,6 +136,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Sets the current position + * * @param coords the x and y coordinates of the current position */ public void setCurrentPosition(int[] coords) { @@ -181,6 +145,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Sets the line width + * * @param multiplier the line width multiplier */ public void setLineWidth(int multiplier) { @@ -190,6 +155,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Sets the line type + * * @param type the line type */ public void setLineType(byte type) { @@ -199,6 +165,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Sets whether to fill the next shape + * * @param fill whether to fill the next shape */ public void setFill(boolean fill) { @@ -211,6 +178,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Sets the character set to use + * * @param fontReference the character set (font) reference */ public void setCharacterSet(int fontReference) { @@ -219,6 +187,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Adds a line at the given x/y coordinates + * * @param coords the x/y coordinates (can be a series) */ public void addLine(int[] coords) { @@ -227,6 +196,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Adds a box at the given coordinates + * * @param coords the x/y coordinates */ public void addBox(int[] coords) { @@ -235,6 +205,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Adds a fillet (curve) at the given coordinates + * * @param coords the x/y coordinates */ public void addFillet(int[] coords) { @@ -242,7 +213,8 @@ public class GraphicsObject extends AbstractDataObject { } /** - * Sets the arc parameters + * Sets the arc parameters + * * @param xmaj the maximum value of the x coordinate * @param ymin the minimum value of the y coordinate * @param xmin the minimum value of the x coordinate @@ -254,6 +226,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Adds an arc + * * @param x the x coordinate * @param y the y coordinate * @param mh the integer portion of the multiplier @@ -265,6 +238,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Adds an image + * * @param x the x coordinate * @param y the y coordinate * @param width the image width @@ -283,6 +257,7 @@ public class GraphicsObject extends AbstractDataObject { /** * Adds a string + * * @param str the string * @param x the x coordinate * @param y the y coordinate @@ -310,9 +285,7 @@ public class GraphicsObject extends AbstractDataObject { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return "GraphicsObject: " + getName(); } diff --git a/src/java/org/apache/fop/render/afp/modca/IMImageObject.java b/src/java/org/apache/fop/render/afp/modca/IMImageObject.java index 73abb2843..3af8b5c28 100644 --- a/src/java/org/apache/fop/render/afp/modca/IMImageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/IMImageObject.java @@ -60,6 +60,7 @@ public class IMImageObject extends AbstractNamedAFPObject { /** * Constructor for the image object with the specified name, * the name must be a fixed length of eight characters. + * * @param name The name of the image. */ public IMImageObject(String name) { @@ -68,6 +69,7 @@ public class IMImageObject extends AbstractNamedAFPObject { /** * Sets the ImageOutputControl. + * * @param imageOutputControl The imageOutputControl to set */ public void setImageOutputControl(ImageOutputControl imageOutputControl) { @@ -76,6 +78,7 @@ public class IMImageObject extends AbstractNamedAFPObject { /** * Sets the ImageCellPosition. + * * @param imageCellPosition The imageCellPosition to set */ public void setImageCellPosition(ImageCellPosition imageCellPosition) { @@ -84,6 +87,7 @@ public class IMImageObject extends AbstractNamedAFPObject { /** * Sets the ImageInputDescriptor. + * * @param imageInputDescriptor The imageInputDescriptor to set */ public void setImageInputDescriptor(ImageInputDescriptor imageInputDescriptor) { @@ -92,15 +96,14 @@ public class IMImageObject extends AbstractNamedAFPObject { /** * Sets the ImageRastorData. + * * @param imageRasterData The imageRasterData to set */ public void setImageRasterData(ImageRasterData imageRasterData) { this.imageRasterData = imageRasterData; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); if (imageOutputControl != null) { @@ -117,43 +120,17 @@ public class IMImageObject extends AbstractNamedAFPObject { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0x7B; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.IM_IMAGE); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0x7B; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.IM_IMAGE); os.write(data); } } diff --git a/src/java/org/apache/fop/render/afp/modca/ImageCellPosition.java b/src/java/org/apache/fop/render/afp/modca/ImageCellPosition.java index c0eb77953..5f1f95932 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageCellPosition.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageCellPosition.java @@ -69,26 +69,14 @@ public class ImageCellPosition extends AbstractAFPObject { yOffset = y; } - /** - * Accessor method to write the AFP datastream for the Image Cell Position - * @param os The stream to write to - * @throws java.io.IOException if an I/O exception occurred - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] data = new byte[21]; - - data[0] = 0x5A; - - data[1] = 0x00; + copySF(data, Type.POSITION, Category.IM_IMAGE); + + data[1] = 0x00; // length data[2] = 0x14; - data[3] = (byte) 0xD3; - data[4] = (byte) 0xAC; - data[5] = (byte) 0x7B; - data[6] = 0x00; - data[7] = 0x00; - data[8] = 0x00; - /** * Specifies the offset along the Xp direction, in image points, * of this image cell from the IM image object area origin. diff --git a/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java index 45c029f71..243765727 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java @@ -27,35 +27,29 @@ import org.apache.fop.render.afp.tools.BinaryUtils; */ public class ImageDataDescriptor extends AbstractAFPObject { - private int _xresol = 0; - private int _yresol = 0; - private int _width = 0; - private int _height = 0; - + private int widthRes = 0; + private int heightRes = 0; + private int width = 0; + private int height = 0; + /** * Constructor for a ImageDataDescriptor for the specified * resolution, width and height. - * @param xresol The horizontal resolution of the image. - * @param yresol The vertical resolution of the image. + * + * @param widthRes The horizontal resolution of the image. + * @param heightRes The vertical resolution of the image. * @param width The width of the image. * @param height The height of the height. */ - public ImageDataDescriptor(int xresol, int yresol, int width, int height) { - - _xresol = xresol; - _yresol = yresol; - _width = width; - _height = height; - + public ImageDataDescriptor(int widthRes, int heightRes, int width, int height) { + this.widthRes = widthRes; + this.heightRes = heightRes; + this.width = width; + this.height = height; } - /** - * Accessor method to write the AFP datastream for the Image Data Descriptor - * @param os The stream to write to - * @throws java.io.IOException - */ - public void write(OutputStream os) - throws IOException { + /** {@inheritDoc} */ + public void write(OutputStream os) throws IOException { byte[] data = new byte[] { 0x5A, @@ -86,24 +80,22 @@ public class ImageDataDescriptor extends AbstractAFPObject { data[1] = l[0]; data[2] = l[1]; - byte[] x = BinaryUtils.convert(_xresol, 2); + byte[] x = BinaryUtils.convert(widthRes, 2); data[10] = x[0]; data[11] = x[1]; - byte[] y = BinaryUtils.convert(_yresol, 2); + byte[] y = BinaryUtils.convert(heightRes, 2); data[12] = y[0]; data[13] = y[1]; - byte[] w = BinaryUtils.convert(_width, 2); + byte[] w = BinaryUtils.convert(width, 2); data[14] = w[0]; data[15] = w[1]; - byte[] h = BinaryUtils.convert(_height, 2); + byte[] h = BinaryUtils.convert(height, 2); data[16] = h[0]; data[17] = h[1]; os.write(data); - } - } diff --git a/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java index a9aef38b9..370ec773d 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java @@ -36,11 +36,7 @@ public class ImageInputDescriptor extends AbstractAFPObject { private int resolution = 240; - /** - * Accessor method to write the AFP datastream for the Image Input Descriptor - * @param os The stream to write to - * @throws java.io.IOException if an I/O exception occurred - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] data = new byte[45]; diff --git a/src/java/org/apache/fop/render/afp/modca/ImageObject.java b/src/java/org/apache/fop/render/afp/modca/ImageObject.java index 928a9790c..67935cb2c 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageObject.java @@ -38,6 +38,7 @@ public class ImageObject extends AbstractDataObject { /** * Constructor for the image object with the specified name, * the name must be a fixed length of eight characters. + * * @param name The name of the image. */ public ImageObject(String name) { @@ -46,6 +47,7 @@ public class ImageObject extends AbstractDataObject { /** * Set the dimensions of the image. + * * @param xresol the x resolution of the image * @param yresol the y resolution of the image * @param width the image width @@ -61,6 +63,7 @@ public class ImageObject extends AbstractDataObject { /** * Sets the image encoding. + * * @param encoding The image encoding. */ public void setImageEncoding(byte encoding) { @@ -72,6 +75,7 @@ public class ImageObject extends AbstractDataObject { /** * Sets the image compression. + * * @param compression The image compression. */ public void setImageCompression(byte compression) { @@ -83,6 +87,7 @@ public class ImageObject extends AbstractDataObject { /** * Sets the image IDE size. + * * @param size The IDE size. */ public void setImageIDESize(byte size) { @@ -94,6 +99,7 @@ public class ImageObject extends AbstractDataObject { /** * Sets the image IDE color model. + * * @param colorModel the IDE color model. */ public void setImageIDEColorModel(byte colorModel) { @@ -105,6 +111,7 @@ public class ImageObject extends AbstractDataObject { /** * Set the data of the image. + * * @param data The image data */ public void setImageData(byte[] data) { @@ -116,6 +123,7 @@ public class ImageObject extends AbstractDataObject { /** * Helper method to return the start of the image object. + * * @param len the length of this ipd start * @return byte[] The data stream. */ @@ -135,9 +143,14 @@ public class ImageObject extends AbstractDataObject { return data; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.IMAGE); + os.write(data); + } + + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); if (imageSegment != null) { @@ -154,45 +167,10 @@ public class ImageObject extends AbstractDataObject { } } - /** - * {@inheritDoc} - */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xFB; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } - os.write(data); - } - - /** - * Helper method to write the end of the Image Object. - * @param os The stream to write to - * @throws IOException in the event - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xFB; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.IMAGE); os.write(data); } } diff --git a/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java b/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java index 0c38273de..4ba78f161 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java @@ -67,17 +67,11 @@ public class ImageOutputControl extends AbstractAFPObject { * The Y-axis offset. */ public ImageOutputControl(int x, int y) { - xCoord = x; yCoord = y; - } - /** - * Accessor method to write the AFP datastream for the Image Output Control - * @param os The stream to write to - * @throws java.io.IOException if an I/O exception occured - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] data = new byte[33]; @@ -170,7 +164,6 @@ public class ImageOutputControl extends AbstractAFPObject { data[32] = (byte) 0xFF; os.write(data); - } /** diff --git a/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java b/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java index dd9c5f699..7bdadb6b6 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java @@ -58,11 +58,7 @@ public class ImageRasterData extends AbstractAFPObject { this.rasterData = data; } - /** - * Accessor method to write the AFP datastream for the Image Raster Data - * @param os The stream to write to - * @throws java.io.IOException if an I/O exception occurred - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] data = new byte[9]; diff --git a/src/java/org/apache/fop/render/afp/modca/ImageSegment.java b/src/java/org/apache/fop/render/afp/modca/ImageSegment.java index 813dffed2..9a6c25ea0 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageSegment.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageSegment.java @@ -18,6 +18,7 @@ /* $Id$ */ package org.apache.fop.render.afp.modca; + import java.io.IOException; import java.io.OutputStream; @@ -59,16 +60,14 @@ public class ImageSegment extends AbstractNamedAFPObject { super(name); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected int getNameLength() { return 4; } /** - * Sets the image size parameters - * resolution, hsize and vsize. + * Sets the image size parameters resolution, hsize and vsize. + * * @param hresol The horizontal resolution of the image. * @param vresol The vertical resolution of the image. * @param hsize The horizontal size of the image. @@ -83,6 +82,7 @@ public class ImageSegment extends AbstractNamedAFPObject { /** * Sets the image encoding. + * * @param encoding The image encoding. */ public void setImageEncoding(byte encoding) { @@ -94,6 +94,7 @@ public class ImageSegment extends AbstractNamedAFPObject { /** * Sets the image compression. + * * @param compression The image compression. */ public void setImageCompression(byte compression) { @@ -105,6 +106,7 @@ public class ImageSegment extends AbstractNamedAFPObject { /** * Sets the image IDE size. + * * @param size The IDE size. */ public void setImageIDESize(byte size) { @@ -116,6 +118,7 @@ public class ImageSegment extends AbstractNamedAFPObject { /** * Sets the image IDE color model. + * * @param colorModel the IDE color model. */ public void setImageIDEColorModel(byte colorModel) { @@ -127,6 +130,7 @@ public class ImageSegment extends AbstractNamedAFPObject { /** * Set the data of the image. + * * @param data the image data */ public void setImageData(byte[] data) { @@ -136,19 +140,16 @@ public class ImageSegment extends AbstractNamedAFPObject { imageContent.setImageData(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void writeContent(OutputStream os) throws IOException { if (imageContent != null) { imageContent.write(os); } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { + byte[] nameBytes = getNameBytes(); byte[] data = new byte[] { 0x70, // ID 0x04, // Length @@ -160,11 +161,8 @@ public class ImageSegment extends AbstractNamedAFPObject { os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { 0x71, // ID 0x00, // Length diff --git a/src/java/org/apache/fop/render/afp/modca/ImageSizeParameter.java b/src/java/org/apache/fop/render/afp/modca/ImageSizeParameter.java index f66b76853..0506b7bdc 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageSizeParameter.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageSizeParameter.java @@ -48,11 +48,7 @@ public class ImageSizeParameter extends AbstractAFPObject { this.vSize = vsize; } - /** - * Accessor method to write the AFP datastream for the Image Size Parameter - * @param os The stream to write to - * @throws java.io.IOException if an I/O exception occured - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] data = new byte[] { (byte)0x94, // ID = Image Size Parameter diff --git a/src/java/org/apache/fop/render/afp/modca/IncludeObject.java b/src/java/org/apache/fop/render/afp/modca/IncludeObject.java index 85cb283a8..807d66421 100644 --- a/src/java/org/apache/fop/render/afp/modca/IncludeObject.java +++ b/src/java/org/apache/fop/render/afp/modca/IncludeObject.java @@ -22,11 +22,6 @@ package org.apache.fop.render.afp.modca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.render.afp.DataObjectInfo; -import org.apache.fop.render.afp.ObjectAreaInfo; -import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; -import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet; -import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet; import org.apache.fop.render.afp.tools.BinaryUtils; /** @@ -42,32 +37,32 @@ import org.apache.fop.render.afp.tools.BinaryUtils; * data objects in the page segment. *

      */ -public class IncludeObject extends AbstractNamedAFPObject implements DataObjectAccessor { +public class IncludeObject extends AbstractNamedAFPObject { /** * the include object is of type page segment */ - protected static final byte TYPE_PAGE_SEGMENT = (byte)0x5F; + public static final byte TYPE_PAGE_SEGMENT = (byte)0x5F; /** * the include object is of type other */ - protected static final byte TYPE_OTHER = (byte)0x92; + public static final byte TYPE_OTHER = (byte)0x92; /** * the include object is of type graphic */ - protected static final byte TYPE_GRAPHIC = (byte)0xBB; + public static final byte TYPE_GRAPHIC = (byte)0xBB; /** * the included object is of type barcode */ - protected static final byte TYPE_BARCODE = (byte)0xEB; + public static final byte TYPE_BARCODE = (byte)0xEB; /** * the included object is of type image */ - protected static final byte TYPE_IMAGE = (byte)0xFB; + public static final byte TYPE_IMAGE = (byte)0xFB; /** * The object type (default is other) @@ -99,10 +94,10 @@ public class IncludeObject extends AbstractNamedAFPObject implements DataObjectA */ private int yContentOffset = 0; - /** - * the referenced data object - */ - private DataObjectAccessor dataObjectAccessor = null; +// /** +// * the referenced data object +// */ +// private DataObjectAccessor dataObjectAccessor = null; /** * Constructor for the include object with the specified name, the name must @@ -112,69 +107,69 @@ public class IncludeObject extends AbstractNamedAFPObject implements DataObjectA * @param name the name of this include object * @param dataObjectAccessor the data object accessor */ - public IncludeObject(String name, DataObjectAccessor dataObjectAccessor) { + public IncludeObject(String name/*, DataObjectAccessor dataObjectAccessor*/) { super(name); - this.dataObjectAccessor = dataObjectAccessor; - - AbstractNamedAFPObject dataObject = dataObjectAccessor.getDataObject(); - if (dataObject instanceof ImageObject) { - this.dataObjectType = TYPE_IMAGE; - } else if (dataObject instanceof GraphicsObject) { - this.dataObjectType = TYPE_GRAPHIC; - } else if (dataObject instanceof PageSegment) { - this.dataObjectType = TYPE_PAGE_SEGMENT; - } else { - this.dataObjectType = TYPE_OTHER; - // Strip any object container - if (dataObject instanceof ObjectContainer) { - ObjectContainer objectContainer = (ObjectContainer)dataObject; - dataObject = objectContainer.getDataObject(); - } - } - - DataObjectInfo dataObjectInfo = dataObjectAccessor.getDataObjectInfo(); - ObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - setObjectArea(objectAreaInfo.getX(), objectAreaInfo.getY()); - - super.setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, - dataObjectInfo.getUri()); - - Registry registry = Registry.getInstance(); - Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); - super.setObjectClassification( - ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, - objectType); +// this.dataObjectAccessor = dataObjectAccessor; - super.setMeasurementUnits(objectAreaInfo.getWidthRes(), objectAreaInfo.getHeightRes()); - - super.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT); - - super.setObjectAreaSize(objectAreaInfo.getWidth(), objectAreaInfo.getHeight()); +// AbstractNamedAFPObject dataObject = dataObjectAccessor.getDataObject(); +// if (dataObject instanceof ImageObject) { +// this.dataObjectType = TYPE_IMAGE; +// } else if (dataObject instanceof GraphicsObject) { +// this.dataObjectType = TYPE_GRAPHIC; +// } else if (dataObject instanceof PageSegment) { +// this.dataObjectType = TYPE_PAGE_SEGMENT; +// } else { +// this.dataObjectType = TYPE_OTHER; +// // Strip any object container +// if (dataObject instanceof ObjectContainer) { +// ObjectContainer objectContainer = (ObjectContainer)dataObject; +// dataObject = objectContainer.getDataObject(); +// } +// } + +// DataObjectInfo dataObjectInfo = dataObjectAccessor.getDataObjectInfo(); +// ObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); +// setObjectArea(objectAreaInfo.getX(), objectAreaInfo.getY()); +// +// super.setFullyQualifiedName( +// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, +// FullyQualifiedNameTriplet.FORMAT_CHARSTR, +// dataObjectInfo.getUri()); +// +// Registry registry = Registry.getInstance(); +// Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); +// super.setObjectClassification( +// ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, +// objectType); +// +// super.setMeasurementUnits(objectAreaInfo.getWidthRes(), objectAreaInfo.getHeightRes()); +// +// super.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT); +// +// super.setObjectAreaSize(objectAreaInfo.getWidth(), objectAreaInfo.getHeight()); } - /** - * {@inheritDoc} - */ - public AbstractNamedAFPObject getDataObject() { - return dataObjectAccessor.getDataObject(); - } - - /** - * {@inheritDoc} - */ - public DataObjectInfo getDataObjectInfo() { - return dataObjectAccessor.getDataObjectInfo(); - } - - /** - * {@inheritDoc} - */ - public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { - dataObjectAccessor.setDataObjectInfo(dataObjectInfo); - } +// /** +// * {@inheritDoc} +// */ +// public AbstractNamedAFPObject getDataObject() { +// return dataObjectAccessor.getDataObject(); +// } +// +// /** +// * {@inheritDoc} +// */ +// public DataObjectInfo getDataObjectInfo() { +// return dataObjectAccessor.getDataObjectInfo(); +// } +// +// /** +// * {@inheritDoc} +// */ +// public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { +// dataObjectAccessor.setDataObjectInfo(dataObjectInfo); +// } /** * Sets the orientation to use for the Include Object. @@ -194,6 +189,7 @@ public class IncludeObject extends AbstractNamedAFPObject implements DataObjectA /** * Sets the x and y offset to the origin in the object area + * * @param x the X-axis origin of the object area * @param y the Y-axis origin of the object area */ @@ -203,7 +199,8 @@ public class IncludeObject extends AbstractNamedAFPObject implements DataObjectA } /** - * Sets the x and y offset of the content area to the object area + * Sets the x and y offset of the content area to the object area + * * @param x the X-axis origin defined in the object * @param y the Y-axis origin defined in the object */ @@ -213,30 +210,24 @@ public class IncludeObject extends AbstractNamedAFPObject implements DataObjectA } /** - * {@inheritDoc} + * Sets the data object type + * + * @param type the data object type */ + public void setDataObjectType(byte type) { + this.dataObjectType = type; + } + + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] data = new byte[36]; - data[0] = 0x5A; + super.copySF(data, Type.INCLUDE, Category.DATA_RESOURCE); // Set the total record length byte[] len = BinaryUtils.convert(35 + getTripletDataLength(), 2); //Ignore first byte data[1] = len[0]; data[2] = len[1]; - // Structured field ID for a IOB - data[3] = (byte) 0xD3; - data[4] = (byte) 0xAF; - data[5] = (byte) 0xC3; - - data[6] = 0x00; // Reserved - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } - data[17] = 0x00; // reserved data[18] = dataObjectType; @@ -330,9 +321,7 @@ public class IncludeObject extends AbstractNamedAFPObject implements DataObjectA os.write(tripletData); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return "IOB: " + this.getName(); } diff --git a/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java b/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java index 31021392e..540ebe7df 100644 --- a/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java +++ b/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java @@ -56,6 +56,7 @@ public class IncludePageOverlay extends AbstractNamedAFPObject { /** * Constructor for the Include Page Overlay + * * @param overlayName Name of the page segment * @param x The x position * @param y The y position @@ -63,6 +64,7 @@ public class IncludePageOverlay extends AbstractNamedAFPObject { */ public IncludePageOverlay(String overlayName, int x, int y, int orientation) { super(overlayName); + this.x = x; this.y = y; setOrientation(orientation); @@ -84,40 +86,25 @@ public class IncludePageOverlay extends AbstractNamedAFPObject { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] data = new byte[25]; //(9 +16) - data[0] = 0x5A; + copySF(data, Type.INCLUDE, Category.PAGE_OVERLAY); // Set the total record length byte[] len = BinaryUtils.convert(24, 2); //Ignore first byte data[1] = len[0]; data[2] = len[1]; - // Structured field ID for a IPO - data[3] = (byte) 0xD3; - data[4] = (byte) 0xAF; - data[5] = (byte) 0xD8; - - data[6] = 0x00; // Reserved - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } - - byte[] xcoord = BinaryUtils.convert(x, 3); - data[17] = xcoord[0]; // x coordinate - data[18] = xcoord[1]; - data[19] = xcoord[2]; + byte[] xPos = BinaryUtils.convert(x, 3); + data[17] = xPos[0]; // x coordinate + data[18] = xPos[1]; + data[19] = xPos[2]; - byte[] ycoord = BinaryUtils.convert(y, 3); - data[20] = ycoord[0]; // y coordinate - data[21] = ycoord[1]; - data[22] = ycoord[2]; + byte[] yPos = BinaryUtils.convert(y, 3); + data[20] = yPos[0]; // y coordinate + data[21] = yPos[1]; + data[22] = yPos[2]; switch (orientation) { case 90: diff --git a/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java b/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java index 4183b6717..b069f4f7a 100644 --- a/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java +++ b/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java @@ -45,56 +45,46 @@ public class IncludePageSegment extends AbstractNamedAFPObject { /** * The x position where we need to put this object on the page */ - private byte[] x; - + private int x; + /** * The y position where we need to put this object on the page */ - private byte[] y; - + private int y; + /** * Constructor for the Include Page Segment + * * @param name Name of the page segment * @param x The x position * @param y The y position */ public IncludePageSegment(String name, int x, int y) { super(name); - this.x = BinaryUtils.convert(x, 3); - this.y = BinaryUtils.convert(y, 3); + + this.x = x; + this.y = y; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { - byte[] data = new byte[23]; //(9 +14) - - data[0] = 0x5A; + copySF(data, Type.INCLUDE, Category.PAGE_SEGMENT); // Set the total record length byte[] len = BinaryUtils.convert(22, 2); //Ignore first byte data[1] = len[0]; data[2] = len[1]; - // Structured field ID for a IPS - data[3] = (byte) 0xD3; - data[4] = (byte) 0xAF; - data[5] = (byte) 0x5F; - data[6] = 0x00; // Reserved - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved + byte[] xPos = BinaryUtils.convert(x, 3); + data[17] = xPos[0]; // x coordinate + data[18] = xPos[1]; + data[19] = xPos[2]; - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } - data[17] = x[0]; // x coordinate - data[18] = x[1]; - data[19] = x[2]; - data[20] = y[0]; // y coordinate - data[21] = y[1]; - data[22] = y[2]; + byte[] yPos = BinaryUtils.convert(y, 3); + data[20] = yPos[0]; // y coordinate + data[21] = yPos[1]; + data[22] = yPos[2]; os.write(data); } diff --git a/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java b/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java index 1ef72b3cf..4d52df3d3 100644 --- a/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java +++ b/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java @@ -46,6 +46,8 @@ public class InterchangeSet { private int value; /** + * Returns the interchange set value of a given string + * * @param str an interchange set value * @return an interchange set */ @@ -60,6 +62,7 @@ public class InterchangeSet { throw new IllegalArgumentException("Invalid MO:DCA interchange set :" + str); } } + /** * Main constructor * @@ -70,6 +73,8 @@ public class InterchangeSet { } /** + * Returns true if complies with MOD:CA interchange set 1 + * * @return true if complies with MOD:CA interchange set 1 */ protected boolean is1() { @@ -77,6 +82,8 @@ public class InterchangeSet { } /** + * Returns true if complies with MOD:CA interchange set 2 + * * @return true if complies with MOD:CA interchange set 2 */ public boolean is2() { @@ -84,20 +91,22 @@ public class InterchangeSet { } /** + * Returns true if complies with MOD:CA resource set + * * @return true if complies with MOD:CA resource set */ public boolean isResource() { return value == RESOURCE_SET; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return NAMES[value]; } /** + * Returns true if MOD:CA interchange set 2 (resource groups) is supported + * * @return true if MOD:CA interchange set 2 (resource groups) is supported */ public boolean supportsLevel2() { diff --git a/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java b/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java index f72ee4e23..fd41ce305 100644 --- a/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java +++ b/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java @@ -34,38 +34,24 @@ public class InvokeMediumMap extends AbstractNamedAFPObject { /** * Constructor for the Invoke Medium Map + * * @param name the name of the medium map */ public InvokeMediumMap(String name) { super(name); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] data = new byte[17]; - - data[0] = 0x5A; + copySF(data, Type.MAP, Category.MEDIUM_MAP); // Set the total record length byte[] len = BinaryUtils.convert(16, 2); //Ignore first byte data[1] = len[0]; data[2] = len[1]; - // Structured field ID for a IPO - data[3] = (byte) 0xD3; - data[4] = (byte) 0xAB; - data[5] = (byte) 0xCC; - - data[6] = 0x00; // Reserved - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } os.write(data); } } \ No newline at end of file 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 4518be9f1..13c76083f 100644 --- a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java +++ b/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java @@ -56,9 +56,7 @@ public class MapCodedFont extends AbstractStructuredAFPObject { fontList = new java.util.ArrayList(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { byte[] startData = new byte[] { 0x5A, diff --git a/src/java/org/apache/fop/render/afp/modca/MapDataResource.java b/src/java/org/apache/fop/render/afp/modca/MapDataResource.java index 9b1abe06c..ae9df023f 100644 --- a/src/java/org/apache/fop/render/afp/modca/MapDataResource.java +++ b/src/java/org/apache/fop/render/afp/modca/MapDataResource.java @@ -34,6 +34,7 @@ import org.apache.fop.render.afp.tools.BinaryUtils; * required for presentation. */ public class MapDataResource extends AbstractStructuredAFPObject { + /** * Static default generated name reference */ @@ -41,6 +42,7 @@ public class MapDataResource extends AbstractStructuredAFPObject { /** * Main constructor + * * @param dataObjectAccessor a data object accessor */ public MapDataResource(DataObjectAccessor dataObjectAccessor) { @@ -49,7 +51,7 @@ public class MapDataResource extends AbstractStructuredAFPObject { ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); ResourceLevel resourceLevel = resourceInfo.getLevel(); if (resourceLevel.isExternal()) { - String url = resourceLevel.getExternalResourceGroupFilePath(); + String url = resourceLevel.getExternalFilePath(); if (url != null) { super.setFullyQualifiedName( FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF, @@ -69,30 +71,20 @@ public class MapDataResource extends AbstractStructuredAFPObject { objectType); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void writeStart(OutputStream os) throws IOException { super.writeStart(os); + byte[] data = new byte[9]; + copySF(data, Type.MAP, Category.DATA_RESOURCE); byte[] len = BinaryUtils.convert(10 + getTripletDataLength(), 2); - byte[] data = new byte[] { - 0x5A, // Structured field identifier - len[0], // Length byte 1 - len[1], // Length byte 2 - (byte) 0xD3, // Structured field id byte 1 - (byte) 0xAB, // Structured field id byte 2 - (byte) 0xC3, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00 // Reserved - }; + data[1] = len[0]; + data[2] = len[1]; + os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void writeContent(OutputStream os) throws IOException { // RGLength byte[] len = BinaryUtils.convert(2 + getTripletDataLength(), 2); 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 95f7b0c45..dabe4ec20 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java @@ -33,6 +33,7 @@ public class ObjectAreaDescriptor extends AbstractDescriptor { /** * Construct an object area descriptor for the specified object width * and object height. + * * @param width The page width. * @param height The page height. * @param widthResolution The page width resolution. @@ -42,13 +43,8 @@ public class ObjectAreaDescriptor extends AbstractDescriptor { super(width, height, widthResolution, heightResolution); } - /** - * Accessor method to write the AFP datastream for the Object Area Descriptor - * @param os The stream to write to - * @throws java.io.IOException thrown if an I/O exception of some sort has occurred - */ - public void write(OutputStream os) - throws IOException { + /** {@inheritDoc} */ + public void write(OutputStream os) throws IOException { byte[] data = new byte[29]; data[0] = 0x5A; diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java b/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java index 7ef00dede..d853be72a 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java @@ -33,9 +33,12 @@ public class ObjectAreaPosition extends AbstractAFPObject { private int x; private int y; private int rotation; - + private int xOffset; + private int yOffset; + /** * Construct an object area position for the specified object y, y position. + * * @param x The x coordinate. * @param y The y coordinate. * @param rotation The coordinate system rotation (must be 0, 90, 180, 270). @@ -46,50 +49,52 @@ public class ObjectAreaPosition extends AbstractAFPObject { this.rotation = rotation; } - /** - * Accessor method to write the AFP datastream for the Object Area Position - * @param os The stream to write to - * @throws java.io.IOException in the event that an I/O exception of some sort has occurred. - */ + /** {@inheritDoc} */ public void write(OutputStream os) throws IOException { + byte[] data = new byte[33]; + copySF(data, Type.POSITION, Category.OBJECT_AREA); + byte[] len = BinaryUtils.convert(32, 2); + data[1] = len[0]; // Length + data[2] = len[1]; + + data[9] = 0x01; // OAPosID = 1 + data[10] = 0x17; // RGLength = 23 + byte[] xcoord = BinaryUtils.convert(x, 3); + data[11] = xcoord[0]; // XoaOSet + data[12] = xcoord[1]; + data[13] = xcoord[2]; + byte[] ycoord = BinaryUtils.convert(y, 3); - byte[] data = new byte[] { - 0x5A, - len[0], // Length - len[1], // Length - (byte) 0xD3, - (byte) 0xAC, - (byte) 0x6B, - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - 0x01, // OAPosID = 1 - 0x17, // RGLength = 23 - xcoord[0], // XoaOSet - xcoord[1], - xcoord[2], - ycoord[0], // YoaOSet - ycoord[1], - ycoord[2], - (byte)(rotation / 2), // XoaOrent - 0x00, - (byte)(rotation / 2 + 45), // YoaOrent - 0x00, - 0x00, // Reserved - 0x00, // XocaOSet - 0x00, - 0x00, - 0x00, // YocaOSet - 0x00, - 0x00, - 0x00, // XocaOrent - 0x00, - 0x2D, // YocaOrent - 0x00, - 0x00, // RefCSys - }; + data[14] = ycoord[0]; // YoaOSet + data[15] = ycoord[1]; + data[16] = ycoord[2]; + + byte xorient = (byte)(rotation / 2); + data[17] = xorient; // XoaOrent + + byte yorient = (byte)(rotation / 2 + 45); + data[19] = yorient; // YoaOrent + + byte[] xoffset = BinaryUtils.convert(xOffset, 3); + data[22] = xoffset[0]; // XocaOSet + data[23] = xoffset[1]; + data[24] = xoffset[2]; + + byte[] yoffset = BinaryUtils.convert(yOffset, 3); + data[25] = yoffset[0]; // YocaOSet + data[26] = yoffset[1]; + data[27] = yoffset[2]; + + data[28] = 0x00; // XocaOrent + data[29] = 0x00; + + data[30] = 0x2D; // YocaOrent + data[31] = 0x00; + + data[32] = 0x01; // RefCSys + os.write(data); } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java b/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java index 599cb0b40..fc9edc4b7 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java @@ -31,24 +31,18 @@ import org.apache.fop.render.afp.tools.BinaryUtils; /** * Object containers are MO:DCA objects that envelop and carry object data. */ -public class ObjectContainer extends AbstractNamedAFPObject implements DataObjectAccessor { +public class ObjectContainer extends AbstractNamedAFPObject /*implements DataObjectAccessor*/ { private static final String DEFAULT_NAME = "OC000001"; - /** - * the data object - */ + /** the data object */ private AbstractDataObject dataObj = null; - /** - * the object data - */ + /** the object data */ private byte[] objectData = null; - /** - * the data object info - */ - private DataObjectInfo dataObjectInfo; +// /** the data object info */ +// private DataObjectInfo dataObjectInfo; /** * Default constructor @@ -59,6 +53,7 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec /** * Main constructor + * * @param name the name of this object container */ public ObjectContainer(String name) { @@ -67,85 +62,61 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec /** * Sets the data object for this object container + * * @param dataObj the data object to reside within this object container */ public void setDataObject(AbstractDataObject dataObj) { this.dataObj = dataObj; } - /** - * {@inheritDoc} - */ - public AbstractNamedAFPObject getDataObject() { - return this.dataObj; - } - - /** - * {@inheritDoc} - */ - public DataObjectInfo getDataObjectInfo() { - return this.dataObjectInfo; - } +// /** {@inheritDoc} */ +// public AbstractNamedAFPObject getDataObject() { +// return this.dataObj; +// } +// +// /** {@inheritDoc} */ +// public DataObjectInfo getDataObjectInfo() { +// return this.dataObjectInfo; +// } - /** - * {@inheritDoc} - */ - public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { - this.dataObjectInfo = dataObjectInfo; - - Registry registry = Registry.getInstance(); - Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); - if (objectType != null) { - super.setObjectClassification( - ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT, - objectType); - } else { - log.warn("no object type for " + dataObjectInfo.getUri()); - } - super.setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, - dataObjectInfo.getUri()); - } +// /** {@inheritDoc} */ +// public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { +// this.dataObjectInfo = dataObjectInfo; +// +// Registry registry = Registry.getInstance(); +// Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); +// if (objectType != null) { +// super.setObjectClassification( +// ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT, +// objectType); +// } else { +// log.warn("no object type for " + dataObjectInfo.getUri()); +// } +// super.setFullyQualifiedName( +// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, +// FullyQualifiedNameTriplet.FORMAT_CHARSTR, +// dataObjectInfo.getUri()); +// } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - // create object data from data object ByteArrayOutputStream bos = new ByteArrayOutputStream(); dataObj.write(bos); this.objectData = bos.toByteArray(); + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.OBJECT_CONTAINER); + // Set the total record length byte[] len = BinaryUtils.convert(16 + getTripletDataLength(), 2); - byte[] data = new byte[] { - 0x5A, // Structured field identifier - len[0], // Length byte 1 - len[1], // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xA8, // Structured field id byte 2 - (byte)0x92, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], - nameBytes[1], - nameBytes[2], - nameBytes[3], - nameBytes[4], - nameBytes[5], - nameBytes[6], - nameBytes[7] - }; + data[1] = len[0]; // Length byte 1 + data[2] = len[1]; // Length byte 2 + os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); @@ -156,29 +127,10 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xA9, // Structured field id byte 2 - (byte)0x92, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], - nameBytes[1], - nameBytes[2], - nameBytes[3], - nameBytes[4], - nameBytes[5], - nameBytes[6], - nameBytes[7], - }; + byte[] data = new byte[17]; + copySF(data, Type.END, Category.OBJECT_CONTAINER); os.write(data); } @@ -187,13 +139,12 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec */ private class ObjectContainerData extends AbstractPreparedAFPObject { - /** - * The maximum object container data length - */ + /** The maximum object container data length */ private static final int MAX_DATA_LEN = 32759; /** * Main constructor + * * @param objData the object data */ public ObjectContainerData(byte[] objData, int startIndex) { @@ -208,7 +159,7 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec data[2] = len[1]; // Length byte 2 data[3] = (byte)0xD3; // Structured field id byte 1 data[4] = (byte)0xEE; // Structured field id byte 2 - data[5] = (byte)0x92; // Structured field id byte 3 + data[5] = getCategoryCode(); // Structured field id byte 3 data[6] = 0x00; // Flags data[7] = 0x00; // Reserved data[8] = 0x00; // Reserved @@ -219,13 +170,21 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec super.setData(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return "ObjectContainerData(" + (data != null ? "" + (data.length - 2) : "null") + ")"; } + + /** {@inheritDoc} */ + protected byte getCategoryCode() { + return (byte)0x92; + } + } + + /** {@inheritDoc} */ + protected byte getCategoryCode() { + return (byte)0x92; } } diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java index 4b31da1f1..b2ef4fa20 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java @@ -73,6 +73,7 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { /** * Constructor for the ObjectEnvironmentGroup, this takes a * name parameter which must be 8 characters long. + * * @param name the object environment group name */ public ObjectEnvironmentGroup(String name) { @@ -81,6 +82,7 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { /** * Sets the object area parameters. + * * @param info the object area info */ public void setObjectArea(ObjectAreaInfo info) { @@ -93,6 +95,7 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { /** * Set the dimensions of the image. + * * @param xresol the x resolution of the image * @param yresol the y resolution of the image * @param width the image width @@ -104,6 +107,7 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { /** * Set the graphics data descriptor. + * * @param xresol the x resolution of the graphics window * @param yresol the y resolution of the graphics window * @param xlwind the left edge of the graphics window @@ -117,35 +121,14 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { xlwind, xrwind, ybwind, ytwind); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - (byte) 0xD3, // Structured field id byte 1 - (byte) 0xA8, // Structured field id byte 2 - (byte) 0xC7, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], // Name - nameBytes[1], // - nameBytes[2], // - nameBytes[3], // - nameBytes[4], // - nameBytes[5], // - nameBytes[6], // - nameBytes[7] // - }; + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.OBJECT_ENVIRONMENT_GROUP); os.write(data); } - - /** - * {@inheritDoc} - */ + + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); @@ -160,30 +143,11 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { graphicsDataDescriptor.write(os); } } - - /** - * {@inheritDoc} - */ + + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - (byte) 0xD3, // Structured field id byte 1 - (byte) 0xA9, // Structured field id byte 2 - (byte) 0xC7, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], // Name - nameBytes[1], // - nameBytes[2], // - nameBytes[3], // - nameBytes[4], // - nameBytes[5], // - nameBytes[6], // - nameBytes[7], // - }; + byte[] data = new byte[17]; + copySF(data, Type.END, Category.OBJECT_ENVIRONMENT_GROUP); os.write(data); } } 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 e7d3b87d0..74b42a281 100644 --- a/src/java/org/apache/fop/render/afp/modca/Overlay.java +++ b/src/java/org/apache/fop/render/afp/modca/Overlay.java @@ -53,43 +53,17 @@ public class Overlay extends AbstractPageObject { super(name, width, height, rotation, widthResolution, heightResolution); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xDF; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.OVERLAY); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xDF; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.OVERLAY); os.write(data); } } 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 e38c576d4..0ac029b99 100644 --- a/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java @@ -33,6 +33,7 @@ public class PageDescriptor extends AbstractDescriptor { /** * Construct a page descriptor for the specified page width * and page height. + * * @param width The page width. * @param height The page height. * @param widthResolution The page width resolution @@ -42,13 +43,8 @@ public class PageDescriptor extends AbstractDescriptor { super(width, height, widthResolution, heightResolution); } - /** - * Accessor method to write the AFP datastream for the Page Descriptor - * @param os The stream to write to - * @throws java.io.IOException in the event that an I/O Exception occurred - */ - public void write(OutputStream os) - throws IOException { + /** {@inheritDoc} */ + public void write(OutputStream os) throws IOException { log.debug("width=" + width); log.debug("height=" + height); diff --git a/src/java/org/apache/fop/render/afp/modca/PageGroup.java b/src/java/org/apache/fop/render/afp/modca/PageGroup.java index 8131eb7b0..b1f3aabc1 100644 --- a/src/java/org/apache/fop/render/afp/modca/PageGroup.java +++ b/src/java/org/apache/fop/render/afp/modca/PageGroup.java @@ -91,57 +91,27 @@ public class PageGroup extends AbstractResourceEnvironmentGroupContainer { return complete; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { writeObjects(tagLogicalElements, os); super.writeContent(os); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xAD; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.PAGE_GROUP); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xAD; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.PAGE_GROUP); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return this.getName(); } diff --git a/src/java/org/apache/fop/render/afp/modca/PageObject.java b/src/java/org/apache/fop/render/afp/modca/PageObject.java index 1db9c4c41..c80f21deb 100644 --- a/src/java/org/apache/fop/render/afp/modca/PageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PageObject.java @@ -225,49 +225,21 @@ public class PageObject extends AbstractResourceGroupContainer { addObject(imImageObject); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xAF; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.PAGE); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xAF; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.PAGE); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return this.getName(); } diff --git a/src/java/org/apache/fop/render/afp/modca/PageSegment.java b/src/java/org/apache/fop/render/afp/modca/PageSegment.java index 92d3c4470..292deb1b1 100644 --- a/src/java/org/apache/fop/render/afp/modca/PageSegment.java +++ b/src/java/org/apache/fop/render/afp/modca/PageSegment.java @@ -35,6 +35,7 @@ public class PageSegment extends AbstractNamedAFPObject { /** * Main constructor + * * @param name the name of this object */ public PageSegment(String name) { @@ -42,6 +43,8 @@ public class PageSegment extends AbstractNamedAFPObject { } /** + * Returns a list of objects contained withing this page segment + * * @return a list of objects contained within this page segment */ public List/**/ getObjects() { @@ -53,63 +56,34 @@ public class PageSegment extends AbstractNamedAFPObject { /** * Adds a resource object (image/graphic) to this page segment + * * @param object the resource objec to add to this page segment */ public void addObject(AbstractAFPObject object) { getObjects().add(object); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0x5F; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.PAGE_SEGMENT); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); writeObjects(objects, os); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0x5F; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.PAGE_SEGMENT); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return this.name; } diff --git a/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java b/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java index 688b9a28f..75442fb08 100644 --- a/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java @@ -41,6 +41,7 @@ public class PreprocessPresentationObject extends AbstractStructuredAFPObject { /** * Main constructor + * * @param prePresObj the presentation object to be preprocessed */ public PreprocessPresentationObject(AbstractStructuredAFPObject prePresObj) { @@ -66,6 +67,7 @@ public class PreprocessPresentationObject extends AbstractStructuredAFPObject { /** * Sets the object orientations relative to media leading edge + * * @param orientation the object orientations relative to media leading edge */ public void setOrientation(byte orientation) { @@ -74,6 +76,7 @@ public class PreprocessPresentationObject extends AbstractStructuredAFPObject { /** * Sets the X axis origin for object content + * * @param xOffset the X axis origin for object content */ public void setXOffset(int xOffset) { @@ -82,15 +85,14 @@ public class PreprocessPresentationObject extends AbstractStructuredAFPObject { /** * Sets the Y axis origin for object content + * * @param yOffset the Y axis origin for object content */ public void setYOffset(int yOffset) { this.objYOffset = yOffset; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void writeStart(OutputStream os) throws IOException { super.writeStart(os); @@ -109,9 +111,7 @@ public class PreprocessPresentationObject extends AbstractStructuredAFPObject { os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void writeContent(OutputStream os) throws IOException { byte[] data = new byte[12]; byte[] l = BinaryUtils.convert(12 + getTripletDataLength(), 2); @@ -146,4 +146,9 @@ public class PreprocessPresentationObject extends AbstractStructuredAFPObject { // Triplets super.writeContent(os); } + + /** {@inheritDoc} */ + protected byte getCategoryCode() { + return (byte)0xC3; + } } diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java index 10af1536e..706548d1a 100644 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java @@ -50,6 +50,7 @@ public class PresentationTextDescriptor extends AbstractDescriptor { /** * Constructor a PresentationTextDescriptor for the specified * width and height. + * * @param width The width of the page. * @param height The height of the page. * @param widthResolution The width resolution of the page. @@ -60,13 +61,8 @@ public class PresentationTextDescriptor extends AbstractDescriptor { super(width, height, widthResolution, heightResolution); } - /** - * Accessor method to write the AFP datastream for the Presentation Text Descriptor - * @param os The stream to write to - * @throws java.io.IOException thrown if an I/O exception of some sort has occurred - */ - public void write(OutputStream os) - throws IOException { + /** {@inheritDoc} */ + public void write(OutputStream os) throws IOException { byte[] data = new byte[23]; data[0] = 0x5A; diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java index 290a1e46a..88e29851f 100644 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java @@ -171,6 +171,7 @@ public class PresentationTextObject extends AbstractNamedAFPObject { /** * Accessor method to write the AFP datastream for the PresentationTextObject. + * * @param os The stream to write to * @throws java.io.IOException thrown if an I/O exception of some sort has occurred */ @@ -182,49 +183,24 @@ public class PresentationTextObject extends AbstractNamedAFPObject { /** * Returns the name of this presentation text object + * * @return the name of this presentation text object */ public String getName() { return name; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0x9B; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.PRESENTATION_TEXT); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0x9B; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.PRESENTATION_TEXT); os.write(data); } @@ -247,9 +223,7 @@ public class PresentationTextObject extends AbstractNamedAFPObject { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { if (presentationTextDataList != null) { return presentationTextDataList.toString(); diff --git a/src/java/org/apache/fop/render/afp/modca/Registry.java b/src/java/org/apache/fop/render/afp/modca/Registry.java index fcff8060c..dc2941ca8 100644 --- a/src/java/org/apache/fop/render/afp/modca/Registry.java +++ b/src/java/org/apache/fop/render/afp/modca/Registry.java @@ -128,6 +128,32 @@ public final class Registry { MimeConstants.MIME_PCL ) ); + mimeEntryMap.put( + MimeConstants.MIME_SVG, + new ObjectType( + COMPID_EPS, + null, // no component id + "Scaleable Vector Graphics", + false, + MimeConstants.MIME_SVG + ) + ); + } + + /** + * Returns the Registry ObjectType for a given mimetype + * + * @param mimeType the object mime type + * @return the Registry ObjectType for a given data object info + */ + public Registry.ObjectType getObjectType(String mimeType) { + ObjectType entry = null; + if (mimeType != null) { + entry = (Registry.ObjectType)mimeEntryMap.get(mimeType); + } else { + log.info("mimetype '" + mimeType + "' not found"); + } + return entry; } /** @@ -141,15 +167,11 @@ public final class Registry { if (dataObjectInfo instanceof ImageObjectInfo) { ImageObjectInfo imageInfo = (ImageObjectInfo)dataObjectInfo; String mimeType = imageInfo.getMimeType(); - if (mimeType != null) { - entry = (Registry.ObjectType)mimeEntryMap.get(mimeType); - } else { - log.info("mimetype for " + dataObjectInfo + " is null"); - } + return getObjectType(mimeType); } return entry; } - + /** * Encapsulates a MOD:CA Registry Object Type entry */ @@ -214,6 +236,22 @@ public final class Registry { return this.mimeType; } + /** + * @return true if this is an image type + */ + public boolean isImage() { + return mimeType == MimeConstants.MIME_TIFF + || mimeType == MimeConstants.MIME_GIF + || mimeType == MimeConstants.MIME_JPEG; + } + + /** + * @return true if this is a graphic type + */ + public boolean isGraphic() { + return mimeType == MimeConstants.MIME_SVG; + } + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java index 219dfd8cb..1d66f560f 100644 --- a/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java +++ b/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java @@ -103,58 +103,32 @@ public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup { /** * Returns an indication if the resource environment group is complete + * * @return whether or not this resource environment group is complete or not */ public boolean isComplete() { return complete; } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xD9; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.RESOURCE_ENVIROMENT_GROUP); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.RESOURCE_ENVIROMENT_GROUP); + os.write(data); + } + + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { writeObjects(mapDataResources, os); writeObjects(mapPageOverlays, os); writeObjects(preProcessPresentationObjects, os); } - /** - * {@inheritDoc} - */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xD9; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } - os.write(data); - } } diff --git a/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java b/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java index 1860d8ce7..baeefafd3 100644 --- a/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java +++ b/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java @@ -24,7 +24,9 @@ import java.io.OutputStream; import java.util.Collection; import java.util.Iterator; import java.util.Map; +import java.util.Set; +import org.apache.fop.render.afp.DataObjectCache; import org.apache.fop.render.afp.DataObjectInfo; import org.apache.fop.render.afp.ResourceInfo; import org.apache.fop.render.afp.ResourceLevel; @@ -35,15 +37,11 @@ import org.apache.fop.render.afp.tools.StringUtils; */ public final class ResourceGroup extends AbstractNamedAFPObject { - /** - * Default name for the resource group - */ + /** Default name for the resource group */ private static final String DEFAULT_NAME = "RG000001"; - /** - * Mapping of resource uri to data resource object (image/graphic) - */ - private Map/**/ resourceMap = null; + /** Set of resource uri */ + private Set/**/ resourceSet = new java.util.HashSet/**/(); /** * Default constructor @@ -55,67 +53,62 @@ public final class ResourceGroup extends AbstractNamedAFPObject { /** * Constructor for the ResourceGroup, this takes a * name parameter which must be 8 characters long. + * * @param name the resource group name */ public ResourceGroup(String name) { super(name); } - - private static final String OBJECT_CONTAINER_NAME_PREFIX = "OC"; - - private ObjectContainer createObjectContainer() { - String name = OBJECT_CONTAINER_NAME_PREFIX - + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 6); - return new ObjectContainer(name); - } - - private DataObjectFactory dataObjectFactory = new DataObjectFactory(); - /** - * Creates a data object in this resource group - * @param dataObjectInfo the data object info - * @return an include object reference - */ - public IncludeObject createObject(DataObjectInfo dataObjectInfo) { - DataObjectAccessor dataObjectAccessor - = (DataObjectAccessor)getResourceMap().get(dataObjectInfo.getUri()); - ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); - ResourceLevel resourceLevel = resourceInfo.getLevel(); - AbstractDataObject dataObj; - if (dataObjectAccessor == null) { - dataObj = dataObjectFactory.create(dataObjectInfo); - ObjectContainer objectContainer = null; - String resourceName = resourceInfo.getName(); - if (resourceName != null) { - objectContainer = new ObjectContainer(resourceName); - } else { - objectContainer = createObjectContainer(); - resourceName = objectContainer.getName(); - } - objectContainer.setDataObject(dataObj); - objectContainer.setDataObjectInfo(dataObjectInfo); - - // When located at print-file level or externally, - // wrap the object container in a resource object - if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) { - ResourceObject resourceObject = new ResourceObject(resourceName); - resourceObject.setDataObject(objectContainer); - resourceObject.setDataObjectInfo(dataObjectInfo); - dataObjectAccessor = resourceObject; - } else { // Access data object through container - dataObjectAccessor = objectContainer; - } - - // Add to resource map - getResourceMap().put(dataObjectInfo.getUri(), dataObjectAccessor); - } - String name = dataObjectAccessor.getName(); - IncludeObject includeObj = new IncludeObject(name, dataObjectAccessor); - return includeObj; - } +// /** +// * Creates a data object in this resource group +// * +// * @param dataObjectInfo the data object info +// * @return an include object reference +// */ +// public IncludeObject createObject(DataObjectInfo dataObjectInfo) { +// String uri = dataObjectInfo.getUri(); +// resourceSet.get(); +// DataObjectAccessor dataObjectAccessor +// = (DataObjectAccessor)getResourceMap().getData(dataObjectInfo.getUri()); +// ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); +// ResourceLevel resourceLevel = resourceInfo.getLevel(); +// AbstractDataObject dataObj; +// if (dataObjectAccessor == null) { +// dataObj = dataObjectFactory.createObject(dataObjectInfo); +// ObjectContainer objectContainer = null; +// String resourceName = resourceInfo.getName(); +// if (resourceName != null) { +// objectContainer = new ObjectContainer(resourceName); +// } else { +// objectContainer = createObjectContainer(); +// resourceName = objectContainer.getName(); +// } +// objectContainer.setDataObject(dataObj); +// objectContainer.setDataObjectInfo(dataObjectInfo); +// +// // When located at print-file level or externally, +// // wrap the object container in a resource object +// if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) { +// ResourceObject resourceObject = new ResourceObject(resourceName); +// resourceObject.setDataObject(objectContainer); +// resourceObject.setDataObjectInfo(dataObjectInfo); +// dataObjectAccessor = resourceObject; +// } else { // Access data object through container +// dataObjectAccessor = objectContainer; +// } +// +// // Add to resource map +// getResourceMap().put(dataObjectInfo.getUri(), dataObjectAccessor); +// } +// String name = dataObjectAccessor.getName(); +// IncludeObject includeObj = dataObjectFactory.createInclude(dataObjectInfo); +// return includeObj; +// } /** * Checks if a named object is of a valid type to be added to a resource group + * * @param namedObj a named object * @return true if the named object is of a valid type to be added to a resource group */ @@ -131,26 +124,23 @@ public final class ResourceGroup extends AbstractNamedAFPObject { // || namedObj instanceof BarcodeObject ); } + /** - * Adds a named object to this resource group - * @param namedObj a named AFP object + * Add this object cache resource info to this resource group + * + * @param resourceInfo the resource info */ - protected void addObject(AbstractNamedAFPObject namedObj) { - if (isValidObjectType(namedObj)) { - getResourceMap().put(namedObj.getName(), namedObj); - } else { - throw new IllegalArgumentException("invalid object type " + namedObj); - } + public void addObject(ResourceInfo resourceInfo) { + resourceSet.add(resourceInfo); } /** + * Returns the number of resources contained in this resource group + * * @return the number of resources contained in this resource group */ public int getResourceCount() { - if (resourceMap != null) { - return resourceMap.size(); - } - return 0; + return resourceSet.size(); } /** @@ -161,78 +151,42 @@ public final class ResourceGroup extends AbstractNamedAFPObject { * @return true if the resource exists within this resource group */ public boolean resourceExists(String uri) { - return getResourceMap().containsKey(uri); + return resourceSet.contains(uri); } - /** - * Returns the list of resources - * @return the list of resources - */ - public Map/**/ getResourceMap() { - if (resourceMap == null) { - resourceMap = new java.util.HashMap/**/(); - } - return resourceMap; - } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void writeContent(OutputStream os) throws IOException { - if (resourceMap != null) { - Collection includes = resourceMap.values(); - Iterator it = includes.iterator(); + Iterator it = resourceSet.iterator(); + if (it.hasNext()) { + DataObjectCache cache = DataObjectCache.getInstance(); while (it.hasNext()) { - Writable dataObject = (Writable)it.next(); - dataObject.write(os); + ResourceInfo resourceInfo = (ResourceInfo)it.next(); + byte[] data = cache.get(resourceInfo); + if (data != null) { + os.write(data); + } else { + log.error("data was null"); + } } } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA8; // Structured field id byte 2 - data[5] = (byte) 0xC6; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.BEGIN, Category.RESOURCE_GROUP); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { byte[] data = new byte[17]; - data[0] = 0x5A; // Structured field identifier - data[1] = 0x00; // Length byte 1 - data[2] = 0x10; // Length byte 2 - data[3] = (byte) 0xD3; // Structured field id byte 1 - data[4] = (byte) 0xA9; // Structured field id byte 2 - data[5] = (byte) 0xC6; // Structured field id byte 3 - data[6] = 0x00; // Flags - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - for (int i = 0; i < nameBytes.length; i++) { - data[9 + i] = nameBytes[i]; - } + copySF(data, Type.END, Category.RESOURCE_GROUP); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { - return this.name + " " + getResourceMap(); + return this.name + " " + resourceSet/*getResourceMap()*/; } } diff --git a/src/java/org/apache/fop/render/afp/modca/ResourceObject.java b/src/java/org/apache/fop/render/afp/modca/ResourceObject.java index e0ba1b4b7..6894bd426 100644 --- a/src/java/org/apache/fop/render/afp/modca/ResourceObject.java +++ b/src/java/org/apache/fop/render/afp/modca/ResourceObject.java @@ -22,9 +22,6 @@ package org.apache.fop.render.afp.modca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.render.afp.DataObjectInfo; -import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; -import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet; import org.apache.fop.render.afp.modca.triplets.Triplet; import org.apache.fop.render.afp.tools.BinaryUtils; @@ -32,18 +29,10 @@ import org.apache.fop.render.afp.tools.BinaryUtils; * This resource structured field begins an envelope that is used to carry * resource objects in print-file-level (external) resource groups. */ -public class ResourceObject extends AbstractPreparedAFPObject implements DataObjectAccessor { +public class ResourceObject extends AbstractPreparedAFPObject { - /** - * the object container of this resource object - */ private AbstractNamedAFPObject namedObject; - - /** - * the data object info - */ - private DataObjectInfo dataObjectInfo; - + /** * Default constructor * @@ -55,102 +44,71 @@ public class ResourceObject extends AbstractPreparedAFPObject implements DataObj /** * Sets the data object referenced by this resource object + * * @param obj the named data object */ public void setDataObject(AbstractNamedAFPObject obj) { - this.namedObject = obj; - - String fqn = obj.getFullyQualifiedName(); - if (fqn != null) { - super.setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, - fqn); - } - - byte type; - if (obj instanceof ObjectContainer) { - type = ResourceObjectTypeTriplet.OBJECT_CONTAINER; - } else if (obj instanceof ImageObject) { - type = ResourceObjectTypeTriplet.IMAGE_OBJECT; - } else if (obj instanceof GraphicsObject) { - type = ResourceObjectTypeTriplet.GRAPHICS_OBJECT; - } else if (obj instanceof Document) { - type = ResourceObjectTypeTriplet.DOCUMENT_OBJECT; - } else if (obj instanceof PageSegment) { - type = ResourceObjectTypeTriplet.PAGE_SEGMENT_OBJECT; - } else if (obj instanceof Overlay) { - type = ResourceObjectTypeTriplet.OVERLAY_OBJECT; - } else { - throw new UnsupportedOperationException( - "Unsupported resource object type " + obj); - } - getTriplets().add(new ResourceObjectTypeTriplet(type)); + this.namedObject = obj; +// +// String fqn = obj.getFullyQualifiedName(); +// if (fqn != null) { +// super.setFullyQualifiedName( +// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, +// FullyQualifiedNameTriplet.FORMAT_CHARSTR, +// fqn); +// } +// +// byte type; +// if (obj instanceof ObjectContainer) { +// type = ResourceObjectTypeTriplet.OBJECT_CONTAINER; +// } else if (obj instanceof ImageObject) { +// type = ResourceObjectTypeTriplet.IMAGE_OBJECT; +// } else if (obj instanceof GraphicsObject) { +// type = ResourceObjectTypeTriplet.GRAPHICS_OBJECT; +// } else if (obj instanceof Document) { +// type = ResourceObjectTypeTriplet.DOCUMENT_OBJECT; +// } else if (obj instanceof PageSegment) { +// type = ResourceObjectTypeTriplet.PAGE_SEGMENT_OBJECT; +// } else if (obj instanceof Overlay) { +// type = ResourceObjectTypeTriplet.OVERLAY_OBJECT; +// } else { +// throw new UnsupportedOperationException( +// "Unsupported resource object type " + obj); +// } +// getTriplets().add(new ResourceObjectTypeTriplet(type)); } - /** - * {@inheritDoc} - */ - public AbstractNamedAFPObject getDataObject() { - return namedObject; - } - - /** - * {@inheritDoc} - */ - public DataObjectInfo getDataObjectInfo() { - return this.dataObjectInfo; - } - - /** - * {@inheritDoc} - */ - public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { - this.dataObjectInfo = dataObjectInfo; +// /** {@inheritDoc} */ +// public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { +// this.dataObjectInfo = dataObjectInfo; +// +// if (namedObject instanceof ObjectContainer) { +// Registry.ObjectType objectType = dataObjectInfo.getObjectType(); +// super.setObjectClassification( +// ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, +// objectType); +// } +// } - if (namedObject instanceof ObjectContainer) { - Registry.ObjectType objectType = dataObjectInfo.getObjectType(); - super.setObjectClassification( - ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, - objectType); - } - } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { super.writeStart(os); - + + byte[] data = new byte[19]; + copySF(data, Type.BEGIN, Category.NAME_RESOURCE); + // Set the total record length byte[] len = BinaryUtils.convert(18 + getTripletDataLength(), 2); - byte[] data = new byte[] { - 0x5A, // Structured field identifier - len[0], // Length byte 1 - len[1], // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xA8, // Structured field id byte 2 - (byte)0xCE, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], - nameBytes[1], - nameBytes[2], - nameBytes[3], - nameBytes[4], - nameBytes[5], - nameBytes[6], - nameBytes[7], - 0x00, // Reserved - 0x00, // Reserved - }; + data[1] = len[0]; // Length byte 1 + data[2] = len[1]; // Length byte 2 + + // Set reserved bits + data[17] = 0x00; // Reserved + data[18] = 0x00; // Reserved os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); // write triplets if (namedObject != null) { @@ -158,59 +116,47 @@ public class ResourceObject extends AbstractPreparedAFPObject implements DataObj } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xA9, // Structured field id byte 2 - (byte)0xCE, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], - nameBytes[1], - nameBytes[2], - nameBytes[3], - nameBytes[4], - nameBytes[5], - nameBytes[6], - nameBytes[7], - }; + byte[] data = new byte[17]; + copySF(data, Type.END, Category.NAME_RESOURCE); os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return this.getName(); } + /** + * Sets Resource Object Type triplet + * + * @param type the resource object type + */ + public void setType(byte type) { + getTriplets().add(new ResourceObjectTypeTriplet(type)); + } + + /** + * Resource object types + */ + protected static final byte GRAPHICS_OBJECT = 0x03; +// private static final byte BARCODE_OBJECT = 0x05; + protected static final byte IMAGE_OBJECT = 0x06; +// private static final byte FONT_CHARACTER_SET_OBJECT = 0x40; +// private static final byte CODE_PAGE_OBJECT = 0x41; +// private static final byte CODED_FONT_OBJECT = 0x42; + protected static final byte OBJECT_CONTAINER = (byte) 0x92; + protected static final byte DOCUMENT_OBJECT = (byte) 0xA8; + protected static final byte PAGE_SEGMENT_OBJECT = (byte) 0xFB; + protected static final byte OVERLAY_OBJECT = (byte) 0xFC; +// private static final byte PAGEDEF_OBJECT = (byte) 0xFD; +// private static final byte FORMDEF_OBJECT = (byte) 0xFE; + private class ResourceObjectTypeTriplet extends Triplet { private static final byte RESOURCE_OBJECT = 0x21; - /** - * Resource object types - */ - private static final byte GRAPHICS_OBJECT = 0x03; -// private static final byte BARCODE_OBJECT = 0x05; - private static final byte IMAGE_OBJECT = 0x06; -// private static final byte FONT_CHARACTER_SET_OBJECT = 0x40; -// private static final byte CODE_PAGE_OBJECT = 0x41; -// private static final byte CODED_FONT_OBJECT = 0x42; - private static final byte OBJECT_CONTAINER = (byte) 0x92; - private static final byte DOCUMENT_OBJECT = (byte) 0xA8; - private static final byte PAGE_SEGMENT_OBJECT = (byte) 0xFB; - private static final byte OVERLAY_OBJECT = (byte) 0xFC; -// private static final byte PAGEDEF_OBJECT = (byte) 0xFD; -// private static final byte FORMDEF_OBJECT = (byte) 0xFE; - /** * Main constructor * diff --git a/src/java/org/apache/fop/render/afp/modca/Writable.java b/src/java/org/apache/fop/render/afp/modca/Writable.java index beaa6e21c..aa9de2d43 100644 --- a/src/java/org/apache/fop/render/afp/modca/Writable.java +++ b/src/java/org/apache/fop/render/afp/modca/Writable.java @@ -26,9 +26,11 @@ import java.io.OutputStream; * Implementing object is able to write to an AFPDataStream */ public interface Writable { + /** * DataStream objects must implement the write() * method to write its data to the given OutputStream + * * @param outputStream The outputsteam stream * @throws java.io.IOException an I/O exception of some sort has occurred. */ diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java index 51e13dde1..826f610c8 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java @@ -42,6 +42,7 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { /** * Default constructor + * * @param userAgent user agent */ public PDFRendererConfigurator(FOUserAgent userAgent) { @@ -52,6 +53,7 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { * Configure the PDF renderer. * Get the configuration to be used for pdf stream filters, * fonts etc. + * * @param renderer pdf renderer * @throws FOPException fop exception */ @@ -79,7 +81,8 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { if (s != null) { pdfRenderer.setXMode(PDFXMode.valueOf(s)); } - Configuration encryptionParamsConfig = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false); + Configuration encryptionParamsConfig + = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false); if (encryptionParamsConfig != null) { PDFEncryptionParams encryptionParams = new PDFEncryptionParams(); Configuration ownerPasswordConfig = encryptionParamsConfig.getChild( @@ -124,15 +127,18 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { if (s != null) { pdfRenderer.setOutputProfileURI(s); } - Configuration disableColorSpaceConfig = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false); + Configuration disableColorSpaceConfig = cfg.getChild( + PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false); if (disableColorSpaceConfig != null) { - pdfRenderer.disableSRGBColorSpace = disableColorSpaceConfig.getValueAsBoolean(false); + pdfRenderer.disableSRGBColorSpace + = disableColorSpaceConfig.getValueAsBoolean(false); } } } /** * Builds a filter map from an Avalon Configuration object. + * * @param cfg the Configuration object * @return Map the newly built filter map * @throws ConfigurationException if a filter list is defined twice diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java index cb7c7cf89..73b50e323 100644 --- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java @@ -91,6 +91,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); pdfi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION); Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); + QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); if (foreign != null && "bitmap".equalsIgnoreCase((String)foreign.get(qName))) { -- 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/pdf') 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 @@
      - +
      Latest ReleaseLatest Stable Release
      Repository URL
      Latest Release
      Repository URL + + http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_95beta/ + +
      Web view + + http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_95beta/ + +
      Trunk
      Image Supportstable, but in need of a redesignbeta (recently rewritten)
      Hyphenation Subsystem - + X @@ -298,6 +303,19 @@
      AFP + + + + + + + + + +
      Forrest diff --git a/src/documentation/content/xdocs/trunk/compiling.xml b/src/documentation/content/xdocs/trunk/compiling.xml index c6c17a3c0..57761429f 100644 --- a/src/documentation/content/xdocs/trunk/compiling.xml +++ b/src/documentation/content/xdocs/trunk/compiling.xml @@ -41,7 +41,7 @@
      JDK

      - Building FOP requires a minimum Java Development Kit (JDK/SDK) of 1.3 + Building FOP requires a minimum Java Development Kit (JDK/SDK) of 1.4 (A Java Runtime Environment is not sufficient).

      @@ -59,7 +59,7 @@

      The build script uses Apache Ant, a popular Java-based build tool, which usually requires that the environment variable JAVA_HOME point to - your local JDK root directory. This is true even if you use JDK 1.3 or above, which normally + your local JDK root directory. This is true even if you use JDK 1.4 or above, which normally does not need this setting.

      diff --git a/src/documentation/content/xdocs/trunk/fonts.xml b/src/documentation/content/xdocs/trunk/fonts.xml index e12527fe3..423eaad11 100644 --- a/src/documentation/content/xdocs/trunk/fonts.xml +++ b/src/documentation/content/xdocs/trunk/fonts.xml @@ -31,11 +31,6 @@
      Summary - The FOP Font subsystem is currently undergoing a significant change. - The details provided here especially related to the generation of FOP Font - Metrics files and the FOP Font configuration are likely to change substantially - in the future. -

      The following table summarizes the font capabilities of the various FOP renderers:

      @@ -59,22 +54,22 @@ - + - - + - + + - + @@ -95,19 +90,26 @@ + + + + + + + + @@ -120,8 +122,8 @@
      Base-14 Fonts

      - The Adobe PDF Specification specifies a set of 14 fonts that must be - available to every PDF reader: + The Adobe PostScript and PDF Specification specify a set of 14 fonts that must be + available to every PostScript interpreter and PDF reader: Helvetica (normal, bold, italic, bold italic), Times (normal, bold, italic, bold italic), Courier (normal, bold, italic, bold italic), @@ -147,73 +149,132 @@

      - AWT/Operating System Fonts -

      The AWT family of renderers (AWT, Print, SVG), use the Java AWT libraries for font metric information. Through operating system registration, the AWT libraries know what fonts are available on the system, and the font metrics for each one.

      + Java2D/AWT/Operating System Fonts +

      + The Java2D family of renderers (Java2D, AWT, Print, TIFF, PNG), use the + Java AWT subsystem for font metric information. Through operating system + registration, the AWT subsystem knows what fonts are available on the system, + and the font metrics for each one. +

      +

      + When working with one of these output formats and you're missing a font, just + install it in your operating system and they should be available for these + renderers. Please note that this is not true for other output formats such as + PDF or PostScript. +

      +
      Custom Fonts -

      Support for custom fonts is added by creating font metric files (written in XML) from the actual font files, and registering them with FOP. Currently only Type 1 and TrueType fonts can be added. -More information about fonts can be found at:

      +

      + Support for custom fonts is highly output format dependent (see above table). + This section shows how to add Type 1 and TrueType fonts to the PDF, PostScript and + Java2D-based renderers. Other renderers (like AFP) support other font formats. Details + in this case can be found on the page about output formats. +

      +

      + Prior to FOP version 0.94, it was always necessary to create an XML font metrics file + if you wanted to add a custom font. This unconvenient step has been removed and in + addition to that, FOP supports auto-registration of fonts, i.e. FOP can find fonts + installed in your operating system or can scan user-specified directories for fonts. + Font registration via XML font metrics file is still supported and is still necessary + if you want to use a TrueType Collection (*.ttc). Direct support for TrueType + collections may be added later. Furthermore, the XML font metrics files are still + required if you don't want to embed, but only reference a font. +

      +

      + Basic information about fonts can be found at: +

      +
      + +
      + Basic font configuration +

      + If you want FOP to use custom fonts, you need to tell it where to find them. This + is done in the configuration file and once per renderer (because each output format + is a little different). In the basic form, you can either tell FOP to find your + operating system fonts or you can specify directories that it will search for + support fonts. These fonts will then automatically be registered. +

      + + + C:\MyFonts1 + + + C:\MyFonts2 + + + +]]> + + Review the documentation for FOP Configuration + for instructions on making the FOP configuration available to FOP when it runs. + Otherwise, FOP has no way of finding your custom font information. It is currently + not possible to easily configure fonts from Java code. + +
      + +
      + Advanced font configuration +

      + The instructions found above should be sufficient for most users. Below are some + additional instructions in case the basic font configuration doesn't lead to + the desired results. +

      Type 1 Font Metrics

      FOP includes PFMReader, which reads the PFM file that normally comes with a Type 1 font, and generates an appropriate font metrics file for it. -To use it, run the class org.apache.fop.fonts.apps.PFMReader:

      -

      Windows (on JDK 1.4 and later):

      + To use it, run the class org.apache.fop.fonts.apps.PFMReader:

      +

      Windows:

      java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar - org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file -

      Windows (on JDK 1.3.x):

      - java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar;lib\xml-apis.jar; - lib\xercesImpl.jar;lib\xalan.jar;lib\serializer.jar - org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file -

      Unix (on JDK 1.4 and later):

      + org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file +

      Unix:

      java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar - org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file -

      Unix (on JDK 1.3.1):

      - java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar:lib/xml-apis.jar: - lib/xercesImpl.jar:lib/xalan.jar:lib/serializer.jar - org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file + org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file

      PFMReader [options]:

      • -fn <fontname> By default, FOP uses the fontname from the -.pfm file when embedding the font. Use the "-fn" option to override this name with one you have -chosen. This may be useful in some cases to ensure that applications using the output document -(Acrobat Reader for example) use the embedded font instead of a local font with the same -name.
      • + .pfm file when embedding the font. Use the "-fn" option to override this name with one you have + chosen. This may be useful in some cases to ensure that applications using the output document + (Acrobat Reader for example) use the embedded font instead of a local font with the same + name.
      The classpath in the above example has been simplified for readability. -You will have to adjust the classpath to the names of the actual JAR files in the lib directory. -xml-apis.jar, xercesImpl.jar, xalan.jar and serializer.jar are not necessary for JDK version 1.4 or later. + You will have to adjust the classpath to the names of the actual JAR files in the lib directory. + xml-apis.jar, xercesImpl.jar, xalan.jar and serializer.jar are not necessary for JDK version 1.4 or later. The tool will construct some values (FontBBox, StemV and ItalicAngle) based on assumptions and calculations which are only an approximation to the real values. -FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file. -The PFMReader tool does not yet interpret PFB or AFM files, so if you want to be correct, you may have to adjust the values in the XML file manually. -The constructed values however appear to have no visible influence. + FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file. + The PFMReader tool does not yet interpret PFB or AFM files, so if you want to be correct, you may have to adjust the values in the XML file manually. + The constructed values however appear to have no visible influence.
      TrueType Font Metrics

      FOP includes TTFReader, which reads the TTF file and generates an appropriate font metrics file for it. -Use it in a similar manner to PFMReader. -For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf:

      + Use it in a similar manner to PFMReader. + For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf:

      java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar - org.apache.fop.fonts.apps.TTFReader [options] - C:\myfonts\cmr10.ttf ttfcm.xml + org.apache.fop.fonts.apps.TTFReader [options] + C:\myfonts\cmr10.ttf ttfcm.xml

      TTFReader [options]:

      • -d <DEBUG | INFO > Sets the debug level (default is -INFO).
      • + INFO).
      • -fn <fontname> Same as for PFMReader.
      • -ttcname <fontname> If you're reading data from a -TrueType Collection (.ttc file) you must specify which font from the collection you will read -metrics from. -If you read from a .ttc file without this option, the fontnames will be listed for you.
      • + TrueType Collection (.ttc file) you must specify which font from the collection you will read + metrics from. + If you read from a .ttc file without this option, the fontnames will be listed for you.
      • -enc ansi Creates a WinAnsi-encoded font metrics file. -Without this option, a CID-keyed font metrics file is created. -The table below summarizes the differences between these two encoding options as currently -used within FOP. -Please note that this information only applies to TrueType fonts and TrueType collections:
      • + Without this option, a CID-keyed font metrics file is created. + The table below summarizes the differences between these two encoding options as currently + used within FOP. + Please note that this information only applies to TrueType fonts and TrueType collections:
      yes yes
      TXTyes (used for layout but not for output)AFP noyes (used for layout but not for output) noyesyes
      AWTJava2D/AWT/Bitmap if available from OS yes yesn/a
      TXTyes (used for layout but not for output)noyes (used for layout but not for output)no
      XML yes
      @@ -240,13 +301,13 @@ Please note that this information only applies to TrueType fonts and TrueType co
      TrueType Collections Font Metrics

      TrueType collections (.ttc files) contain more than one font. -To create metrics files for these fonts, you must specify which font in the collection should be generated, by using the "-ttcname" option with the TTFReader.

      + To create metrics files for these fonts, you must specify which font in the collection should be generated, by using the "-ttcname" option with the TTFReader.

      To get a list of the fonts in a collection, just start the TTFReader as if it were a normal TrueType file (without the -ttcname option). -It will display all of the font names and exit with an Exception.

      + It will display all of the font names and exit with an Exception.

      Here is an example of generating a metrics file for a .ttc file:

      java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar - org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho" - msmincho.ttc msminch.xml + org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho" + msmincho.ttc msminch.xml
      Register Fonts with FOP @@ -269,16 +330,16 @@ It will display all of the font names and exit with an Exception.

      ]]> - Review the documentation for FOP Configuration for instructions on making the FOP configuration available to FOP when it runs. Otherwise, FOP has no way of finding your custom font information.
      • URLs are used to access the font metric and font files. Relative URLs are resolved relative to the font-base property (or base) if available. See FOP: Configuration for more information.
      • +
      • The "metrics-url" attribute is generally not necessary except if you run into problems with certain fonts.
      • Either an "embed-url" or a "metrics-url" must be specified for font tag configurations.
      • -
      • The font "kerning" attribute is optional.
      • -
      • If embedding is off, the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.
      • +
      • The font "kerning" attribute is optional. Default is "true".
      • +
      • If embedding is off (i.e. embed-url is not set), the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.
      • When setting the "embed-url" attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.
      • The fonts "directory" tag can be used to register fonts contained within a single or list of directory paths. The "recursive" attribute can be specified to recursively add fonts from all sub directories.
      • The fonts "auto-detect" tag can be used to automatically register fonts that are found to be installed on the native operating system.
      • @@ -294,37 +355,38 @@ It will display all of the font names and exit with an Exception.

      Auto-Detect and auto-embedd feature -

      When the "auto-detect" flag is set in the configuration, FOP will automatically search for fonts in the default paths for your operating system.

      -

      FOP will also auto-detect fonts which are available in the classpath, if they are described as "application/x-font" in the MANIFEST.MF file. For example, if your .jar file contains font/myfont.ttf:

      - Manifest-Version: 1.0 - -Name: font/myfont.ttf -Content-Type: application/x-font -

      This feature allows you to create JAR files containing fonts. The JAR files can be added to fop by providem them in the classpath, e.g. copying them into the lib/ directory.

      +

      When the "auto-detect" flag is set in the configuration, FOP will automatically search for fonts in the default paths for your operating system.

      +

      FOP will also auto-detect fonts which are available in the classpath, if they are described as "application/x-font" in the MANIFEST.MF file. For example, if your .jar file contains font/myfont.ttf:

      + Manifest-Version: 1.0 + + Name: font/myfont.ttf + Content-Type: application/x-font +

      This feature allows you to create JAR files containing fonts. The JAR files can be added to fop by providem them in the classpath, e.g. copying them into the lib/ directory.

      Embedding The PostScript renderer does not yet support TrueType fonts, but can embed Type 1 fonts. The font is simply embedded into the PDF file, it is not converted.

      Font embedding is enabled in the userconfig.xml file and controlled by the embed-url attribute. -If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.

      + If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.

      Omitting the embed-url attribute for CID-encoded TrueType fonts will currently produce invalid PDF files! If you create the XML font metric file using the "-enc ansi" option, you can omit the embed-url attribute for TrueType fonts but you're restricted to the WinAnsi character set.

      When FOP embeds a font, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font. -This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.

      + This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.

      When embedding PostScript fonts, the entire font is always embedded.

      When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the original font, containing only the glyphs used, is embedded in the output document.

      + diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml index d6021414f..628df1248 100644 --- a/src/documentation/content/xdocs/trunk/output.xml +++ b/src/documentation/content/xdocs/trunk/output.xml @@ -48,6 +48,35 @@ The net effect is that the layout of a given FO document can be quite different between renderers that do not use the same font information.

      +

      + Theoretically, there's some potential to make the output of the PDF/PS renderers match + the output of the Java2D-based renderers. If FOP used the font metrics from its own + font subsystem but still used Java2D for text painting in the Java2D-based renderers, + this could probably be achieved. However, this approach hasn't been implemented, yet. +

      +

      + With a work-around, it is possible to match the PDF/PS output in a Java2D-based + renderer pretty closely. The clue is to use the + intermediate format. The trick is to layout the + document using FOP's own font subsystem but then render the document using Java2D. + Here are the necessary steps (using the command-line): +

      +
        +
      1. + Produce an IF file: fop -fo myfile.fo -at application/pdf myfile.at.xml
        + Specifying "application/pdf" for the "-at" parameter causes FOP to use FOP's own + font subsystem (which is used by the PDF renderer). Note that no PDF file is created + in this step. +
      2. +
      3. Render to a PDF file: fop -atin myfile.at.xml -pdf myfile.pdf
      4. +
      5. Render to a Java2D-based renderer: +
          +
        • fop -atin myfile.at.xml -print
        • +
        • fop -atin myfile.at.xml -awt
        • +
        • fop -atin myfile.at.xml -tiff myfile.tiff
        • +
        +
      6. +
      Output to a Printer or Other Device diff --git a/src/documentation/content/xdocs/trunk/pdfencryption.xml b/src/documentation/content/xdocs/trunk/pdfencryption.xml index c8cdbb29c..22d965057 100644 --- a/src/documentation/content/xdocs/trunk/pdfencryption.xml +++ b/src/documentation/content/xdocs/trunk/pdfencryption.xml @@ -204,15 +204,13 @@ Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent);

      1. - Download the binary distribution for your JDK version. If you have JDK - 1.3 or earlier you must also download a JCE from the same page. + Download the binary distribution for your JDK version.
      2. Unpack the distribution. Add the jar file to your classpath. A convenient way to use the jar on Linux is to simply drop it into the FOP lib directory, it will be automatically picked up by - fop.sh. If you have JDK 1.3 or earlier don't forget to - install the JCE as well. + fop.sh.
      3. Open the java.security file and add
        diff --git a/src/documentation/content/xdocs/trunk/running.xml b/src/documentation/content/xdocs/trunk/running.xml index 38df4be82..38e31cc6c 100644 --- a/src/documentation/content/xdocs/trunk/running.xml +++ b/src/documentation/content/xdocs/trunk/running.xml @@ -305,7 +305,7 @@ Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl
        • Increase memory available to the JVM. See - the -Xmx option + the -Xmx option for more information. It is usually unwise to increase the memory allocated to the JVM beyond the amount of diff --git a/src/documentation/poster/README.txt b/src/documentation/poster/README.txt index bc21dcc37..d5ef2c0a2 100644 --- a/src/documentation/poster/README.txt +++ b/src/documentation/poster/README.txt @@ -5,7 +5,8 @@ created for OpenExpo '06 (http://www.openexpo.ch). To create the PDF just call go.bat. -The fully reconstruct the PDF you need to copy some fonts into -the cfg directory. Please see the README.txt there for details. +The fully reconstruct the PDF you need some fonts installed in +your operating system: Verdana and Lucida Console which are +available in every Windows installation. You will also need English hyphenation patterns. \ No newline at end of file diff --git a/src/documentation/poster/cfg/README.txt b/src/documentation/poster/cfg/README.txt deleted file mode 100644 index b63dc83dd..000000000 --- a/src/documentation/poster/cfg/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -The following files are missing here for license reasons: - -lucon.ttf - Lucida Console Font -verdana.ttf - Verdana Font -verdanab.ttf - Verdana Bold Font - -They can be found in every MS Windows installation. \ No newline at end of file diff --git a/src/documentation/poster/cfg/VERDANA.ttf.xml b/src/documentation/poster/cfg/VERDANA.ttf.xml deleted file mode 100644 index 1c113be9d..000000000 --- a/src/documentation/poster/cfg/VERDANA.ttf.xml +++ /dev/null @@ -1,1817 +0,0 @@ - - - - - Verdana - - 727 - 545 - 764 - -206 - - -49 - -206 - 1446 - 1000 - - 33 - 0 - 0 - TYPE0 - - CIDFontType2 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/documentation/poster/cfg/VERDANAB.ttf.xml b/src/documentation/poster/cfg/VERDANAB.ttf.xml deleted file mode 100644 index 0666d19b2..000000000 --- a/src/documentation/poster/cfg/VERDANAB.ttf.xml +++ /dev/null @@ -1,1167 +0,0 @@ - - - - - Verdana,Bold - - 727 - 548 - 764 - -206 - - -73 - -207 - 1707 - 1000 - - 33 - 0 - 0 - TYPE0 - - CIDFontType2 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/documentation/poster/cfg/fop.xconf b/src/documentation/poster/cfg/fop.xconf index 93b89465c..788d58920 100644 --- a/src/documentation/poster/cfg/fop.xconf +++ b/src/documentation/poster/cfg/fop.xconf @@ -17,23 +17,13 @@ --> - . 72 300 - - - - - - - - - - + diff --git a/src/documentation/poster/cfg/lucon.ttf.xml b/src/documentation/poster/cfg/lucon.ttf.xml deleted file mode 100644 index 27daebf6c..000000000 --- a/src/documentation/poster/cfg/lucon.ttf.xml +++ /dev/null @@ -1,925 +0,0 @@ - - - - - LucidaConsole - - 626 - 530 - 783 - -205 - - 0 - -210 - 602 - 789 - - 35 - 0 - 0 - TYPE0 - - CIDFontType2 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/documentation/poster/svg/pepe-business-card.svg b/src/documentation/poster/svg/pepe-business-card.svg index 6183e8cf2..559c87abe 100644 --- a/src/documentation/poster/svg/pepe-business-card.svg +++ b/src/documentation/poster/svg/pepe-business-card.svg @@ -16,7 +16,8 @@ limitations under the License. --> - diff --git a/src/documentation/poster/xml/business-card-demo.xml b/src/documentation/poster/xml/business-card-demo.xml index bfd56d793..9b7f80029 100644 --- a/src/documentation/poster/xml/business-card-demo.xml +++ b/src/documentation/poster/xml/business-card-demo.xml @@ -37,13 +37,13 @@ - +

          - - + + @@ -65,11 +65,11 @@ - - -

          The XSLT stylesheet which contains the rules to convert the business card XML to XSL-FO:

          - + + +

          The XSLT stylesheet which contains the rules to convert the business card XML to XSL-FO:

          + @@ -77,7 +77,8 @@ - + diff --git a/src/documentation/poster/xml/fop-history.xml b/src/documentation/poster/xml/fop-history.xml index ea8cc133f..0baa6340f 100644 --- a/src/documentation/poster/xml/fop-history.xml +++ b/src/documentation/poster/xml/fop-history.xml @@ -39,13 +39,12 @@

          In 2005, the redesign finally took a leap forward, which resulted in the first release from - the new codebase (FOP 0.90alpha). Shortly thereafter, FOP 0.91beta was released in December - 2005 and FOP 0.92beta in April 2006. Although 0.92beta still carries the beta tag, - it has many advantages over the old version 0.20.5. + the new codebase (FOP 0.90alpha). The project team has published a number of releases + since then. FOP made big steps forward.

          - The next version, to be released shortly, will be 0.93. This version should be the last release - before the long-awaited version 1.0, for which the team only has to implement a handful of - additional features. + The next version, to be released in March 2008, will be 0.95. Although FOP still carries + pre 1.0 version numbers it is production-ready. Some features are still missing before + version 1.0 can be released.

      diff --git a/src/documentation/poster/xml/fop-poster.xml b/src/documentation/poster/xml/fop-poster.xml index 67b44480b..419378b27 100644 --- a/src/documentation/poster/xml/fop-poster.xml +++ b/src/documentation/poster/xml/fop-poster.xml @@ -21,11 +21,11 @@
      -
      -
      -
      +
      +
      +
      -
      +
      -
      +
      diff --git a/src/documentation/poster/xml/fop-transformation-chain.xml b/src/documentation/poster/xml/fop-transformation-chain.xml index 7a713fdb2..58c8de856 100644 --- a/src/documentation/poster/xml/fop-transformation-chain.xml +++ b/src/documentation/poster/xml/fop-transformation-chain.xml @@ -19,7 +19,7 @@
      Transformation Chain - +

      This diagram shows a complete transformation chain (exemplary). It begins with your data source, diff --git a/src/documentation/poster/xml/fop-use-cases.xml b/src/documentation/poster/xml/fop-use-cases.xml index 250a6436c..d2f4878a5 100644 --- a/src/documentation/poster/xml/fop-use-cases.xml +++ b/src/documentation/poster/xml/fop-use-cases.xml @@ -19,8 +19,7 @@

      Use Cases - - + diff --git a/src/documentation/poster/xslt/common.xsl b/src/documentation/poster/xslt/common.xsl index ad8ac0109..5b02f52fd 100644 --- a/src/documentation/poster/xslt/common.xsl +++ b/src/documentation/poster/xslt/common.xsl @@ -37,14 +37,14 @@ + space-after.optimum="0.3em" space-after.maximum="1em"> + space-before.optimum="0.3em" space-before.maximum="1em" + space-after.optimum="0.3em" space-after.maximum="1em"> diff --git a/src/documentation/poster/xslt/fop-poster.xsl b/src/documentation/poster/xslt/fop-poster.xsl index 9c0b1a82b..dca0f6cfc 100644 --- a/src/documentation/poster/xslt/fop-poster.xsl +++ b/src/documentation/poster/xslt/fop-poster.xsl @@ -60,9 +60,6 @@ - - - @@ -84,14 +81,14 @@ - + Apache FOP - The leading open source XSL-FO formatter A product of the Apache XML Graphics Project - + For more details, please visit: http://xmlgraphics.apache.org/fop/ @@ -111,7 +108,7 @@ - + - + diff --git a/src/documentation/sitemap.xmap b/src/documentation/sitemap.xmap index bfc1e2bbe..470db0b7b 100644 --- a/src/documentation/sitemap.xmap +++ b/src/documentation/sitemap.xmap @@ -20,44 +20,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -65,13 +34,13 @@ - + - + @@ -80,7 +49,7 @@ - + @@ -88,13 +57,13 @@ - + - + diff --git a/src/documentation/skinconf.xml b/src/documentation/skinconf.xml index 65a271a64..e87baab34 100644 --- a/src/documentation/skinconf.xml +++ b/src/documentation/skinconf.xml @@ -91,7 +91,7 @@ which will be used to configure the chosen Forrest skin. - 1999-2007 + 1999-2008 The Apache Software Foundation. http://www.apache.org/licenses/ @@ -164,6 +164,7 @@ which will be used to configure the chosen Forrest skin. .ForrestTable td.partial { background-color: #FFFFCC; text-align: center; } .ForrestTable td.category { /*background-color: #CFDCED;*/ font-size: 1.2em } + .menuitemgroup{ display: block;} @@ -311,8 +312,8 @@ which will be used to configure the chosen Forrest skin. portrait). Supported text alignments are left, right, justify (default left). --> - - + + 1 - 1in - 1in + 0.5in + 0.5in 1in - 1in + 0.5in - - -org.apache.fop.image.analyser Package - -

      Image analyzers for determining the format of an image and to preload its intrinsic size.

      - - \ No newline at end of file diff --git a/src/java/org/apache/fop/image/package.html b/src/java/org/apache/fop/image/package.html index 0145864b2..cbd2d7c5e 100644 --- a/src/java/org/apache/fop/image/package.html +++ b/src/java/org/apache/fop/image/package.html @@ -18,6 +18,6 @@ org.apache.fop.image Package -

      Contains image loading adapters for various image sources and the image cache.

      +

      Contains image loading adapters for various image sources.

      \ No newline at end of file diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index 54fd315b1..65d537bcd 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -272,7 +272,7 @@ public abstract class AbstractBreaker { */ public void doLayout(int flowBPD, boolean autoHeight) { LayoutContext childLC = createLayoutContext(); - childLC.setStackLimit(new MinOptMax(flowBPD)); + childLC.setStackLimitBP(new MinOptMax(flowBPD)); if (getCurrentDisplayAlign() == Constants.EN_X_FILL) { //EN_X_FILL is non-standard (by LF) @@ -495,7 +495,7 @@ public abstract class AbstractBreaker { int averageLineLength = optimizeLineLength(effectiveList, startElementIndex, endElementIndex); if (averageLineLength != 0) { - childLC.setStackLimit(new MinOptMax(averageLineLength)); + childLC.setStackLimitBP(new MinOptMax(averageLineLength)); } } /* *** *** non-standard extension *** *** */ diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index f75fffc0d..656b5e2df 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -113,7 +113,7 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager if (curChildLM != null && !curChildLM.isFinished()) { return curChildLM; } - while (childLMiter.hasNext()) { + if (childLMiter.hasNext()) { curChildLM = (LayoutManager) childLMiter.next(); curChildLM.initialize(); return curChildLM; @@ -350,6 +350,10 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager /** * Registers the FO's markers on the current PageViewport + * + * @param isStarting boolean indicating whether the markers qualify as 'starting' + * @param isFirst boolean indicating whether the markers qualify as 'first' + * @param isLast boolean indicating whether the markers qualify as 'last' */ protected void addMarkersToPage(boolean isStarting, boolean isFirst, boolean isLast) { if (this.markers != null) { @@ -361,10 +365,18 @@ public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager } } + /** + * Registers the FO's id on the current PageViewport + */ + protected void addId() { + if (fobj != null) { + getPSLM().addIDToPage(fobj.getId()); + } + } + /** {@inheritDoc} */ public String toString() { return (super.toString() + (fobj != null ? "[fobj=" + fobj.toString() + "]" : "")); } - } diff --git a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java index 80e0b74cc..1b0d02639 100644 --- a/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java +++ b/src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java @@ -117,7 +117,7 @@ public class AreaAdditionUtil { // set space after for each LM, in order to implement // display-align = distribute lc.setSpaceAfter(layoutContext.getSpaceAfter()); - lc.setStackLimit(layoutContext.getStackLimit()); + lc.setStackLimitsFrom(layoutContext); childLM.addAreas(childPosIter, lc); } diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index fc60b561e..e8ca88c1c 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -38,7 +38,6 @@ 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.layoutmgr.inline.InlineLayoutManager; import org.apache.fop.traits.MinOptMax; import org.apache.fop.traits.SpaceVal; @@ -201,7 +200,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); autoHeight = false; //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); - int maxbpd = context.getStackLimit().opt; + int maxbpd = context.getStackLimitBP().opt; int allocBPD; if (height.getEnum() == EN_AUTO || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) { @@ -249,7 +248,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager MinOptMax stackLimit = new MinOptMax(relDims.bpd); - LinkedList returnedList = null; + LinkedList returnedList; LinkedList contentList = new LinkedList(); LinkedList returnList = new LinkedList(); @@ -280,8 +279,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager LayoutContext childLC = new LayoutContext(0); childLC.copyPendingMarksFrom(context); // curLM is a ? - childLC.setStackLimit(MinOptMax.subtract(context - .getStackLimit(), stackLimit)); + childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit)); childLC.setRefIPD(relDims.ipd); childLC.setWritingMode(getBlockContainerFO().getWritingMode()); @@ -388,6 +386,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); + + //All child content is processed. Only break-after can occur now, so... + context.clearPendingMarks(); addKnuthElementsForBreakAfter(returnList, context); setFinished(true); @@ -411,7 +412,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager if (isFixed()) { availHeight = (int)getCurrentPV().getViewArea().getHeight(); } else { - availHeight = context.getStackLimit().opt; + availHeight = context.getStackLimitBP().opt; } allocBPD = availHeight; allocBPD -= offset.y; @@ -444,7 +445,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } } } else { - int maxbpd = context.getStackLimit().opt; + int maxbpd = context.getStackLimitBP().opt; allocBPD = maxbpd; if (!switchedProgressionDirection) { autoHeight = true; @@ -601,11 +602,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } public boolean isOverflow() { - if (isEmpty()) { - return false; - } else { - return (deferredAlg.getPageBreaks().size() > 1); - } + return !isEmpty() && (deferredAlg.getPageBreaks().size() > 1); } protected LayoutManager getTopLevelLM() { @@ -625,7 +622,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager while ((curLM = getChildLM()) != null) { LayoutContext childLC = new LayoutContext(0); - childLC.setStackLimit(context.getStackLimit()); + childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(context.getRefIPD()); childLC.setWritingMode(getBlockContainerFO().getWritingMode()); @@ -707,7 +704,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore())); } - LayoutManager childLM = null; + LayoutManager childLM; LayoutManager lastLM = null; LayoutContext lc = new LayoutContext(0); lc.setSpaceAdjust(layoutContext.getSpaceAdjust()); @@ -736,7 +733,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } Position innerPosition = pos; if (pos instanceof NonLeafPosition) { - innerPosition = ((NonLeafPosition)pos).getPosition(); + innerPosition = pos.getPosition(); } if (pos instanceof BlockContainerPosition) { if (bcpos != null) { @@ -772,7 +769,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } } - getPSLM().addIDToPage(getBlockContainerFO().getId()); + addId(); addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); @@ -854,7 +851,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager // set last area flag lc.setFlags(LayoutContext.LAST_AREA, (layoutContext.isLastArea() && childLM == lastLM)); - /*LF*/lc.setStackLimit(layoutContext.getStackLimit()); + /*LF*/lc.setStackLimitBP(layoutContext.getStackLimitBP()); // Add the line areas to Area childLM.addAreas(childPosIter, lc); } @@ -873,7 +870,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager referenceArea = null; resetSpaces(); - getPSLM().notifyEndOfLayout(((BlockContainer)getFObj()).getId()); + getPSLM().notifyEndOfLayout(fobj.getId()); } /** @@ -992,30 +989,21 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public boolean mustKeepTogether() { //TODO Keeps will have to be more sophisticated sooner or later - return (!getBlockContainerFO().getKeepTogether().getWithinPage().isAuto() - || !getBlockContainerFO().getKeepTogether().getWithinColumn().isAuto() - || (getParent() instanceof BlockLevelLayoutManager - && ((BlockLevelLayoutManager) getParent()).mustKeepTogether()) - || (getParent() instanceof InlineLayoutManager - && ((InlineLayoutManager) getParent()).mustKeepTogether())); + return super.mustKeepTogether() + || !getBlockContainerFO().getKeepTogether().getWithinPage().isAuto() + || !getBlockContainerFO().getKeepTogether().getWithinColumn().isAuto(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public boolean mustKeepWithPrevious() { return !getBlockContainerFO().getKeepWithPrevious().getWithinPage().isAuto() || !getBlockContainerFO().getKeepWithPrevious().getWithinColumn().isAuto(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public boolean mustKeepWithNext() { return !getBlockContainerFO().getKeepWithNext().getWithinPage().isAuto() || !getBlockContainerFO().getKeepWithNext().getWithinColumn().isAuto(); diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index bb39def8d..f5270107c 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -25,6 +25,7 @@ import java.util.ListIterator; 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.area.LineArea; @@ -146,7 +147,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager * @return true if there are more child lms */ public boolean hasNext() { - return (curPos < listLMs.size()) ? true : createNextChildLMs(curPos); + return (curPos < listLMs.size()) || createNextChildLMs(curPos); } /** @@ -249,7 +250,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore())); } - LayoutManager childLM = null; + LayoutManager childLM; LayoutManager lastLM = null; LayoutContext lc = new LayoutContext(0); lc.setSpaceAdjust(layoutContext.getSpaceAdjust()); @@ -279,7 +280,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager Position innerPosition = pos; if (pos instanceof NonLeafPosition) { //Not all elements are wrapped - innerPosition = ((NonLeafPosition) pos).getPosition(); + innerPosition = pos.getPosition(); } if (innerPosition == null) { // pos was created by this BlockLM and was inside an element @@ -308,7 +309,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } } - getPSLM().addIDToPage(getBlockFO().getId()); + addId(); addMarkersToPage(true, isFirst(firstPos), isLast(lastPos)); @@ -389,7 +390,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager // set last area flag lc.setFlags(LayoutContext.LAST_AREA, (layoutContext.isLastArea() && childLM == lastLM)); - lc.setStackLimit(layoutContext.getStackLimit()); + lc.setStackLimitBP(layoutContext.getStackLimitBP()); // Add the line areas to Area childLM.addAreas(childPosIter, lc); } diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index 5faad623c..67ed1de9f 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -274,13 +274,14 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (curLM instanceof LineLayoutManager) { // curLM is a LineLayoutManager // set stackLimit for lines (stack limit is now i-p-direction, not b-p-direction!) - childLC.setStackLimit(new MinOptMax(getContentAreaIPD())); + childLC.setStackLimitBP(context.getStackLimitBP()); + childLC.setStackLimitIP(new MinOptMax(getContentAreaIPD())); childLC.setRefIPD(getContentAreaIPD()); } else { // curLM is a ? //childLC.setStackLimit(MinOptMax.subtract(context // .getStackLimit(), stackSize)); - childLC.setStackLimit(context.getStackLimit()); + childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(referenceIPD); } @@ -293,15 +294,22 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (returnedList != null && returnedList.size() == 1 && ((ListElement) returnedList.getFirst()).isForcedBreak()) { - // a descendant of this block has break-before - contentList.addAll(returnedList); if (curLM.isFinished() && !hasNextChildLM()) { - forcedBreakAfterLast = (BreakElement)contentList.removeLast(); + // a descendant of this block has break-before + forcedBreakAfterLast = (BreakElement) returnedList.getFirst(); context.clearPendingMarks(); break; } + if (contentList.size() == 0) { + // 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; @@ -392,6 +400,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager addKnuthElementsForBorderPaddingAfter(returnList, true); addKnuthElementsForSpaceAfter(returnList, alignment); + + //All child content is processed. Only break-after can occur now, so... + context.clearPendingMarks(); if (forcedBreakAfterLast == null) { addKnuthElementsForBreakAfter(returnList, context); } diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java index a70dd0883..115532cf1 100644 --- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java @@ -99,7 +99,7 @@ public class FlowLayoutManager extends BlockStackingLayoutManager //MinOptMax bpd = context.getStackLimit(); LayoutContext childLC = new LayoutContext(0); - childLC.setStackLimit(context.getStackLimit()); + childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(context.getRefIPD()); childLC.setWritingMode(getCurrentPage().getSimplePageMaster().getWritingMode()); diff --git a/src/java/org/apache/fop/layoutmgr/LayoutContext.java b/src/java/org/apache/fop/layoutmgr/LayoutContext.java index 9eb38600b..79b5e232f 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutContext.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutContext.java @@ -74,18 +74,29 @@ public class LayoutContext { private int flags; // Contains some set of flags defined above /** * Total available stacking dimension for a "galley-level" layout - * manager (Line or Flow). It is passed by the parent LM. For LineLM, - * the block LM determines this based on indent properties. + * manager in block-progression-direction. It is passed by the + * parent LM. * These LM may wish to pass this information down to lower * level LM to allow them to optimize returned break possibilities. */ - private MinOptMax stackLimit; + private MinOptMax stackLimitBP; + /** + * Total available stacking dimension for a "galley-level" layout + * manager in inline-progression-direction. It is passed by the + * parent LM. For LineLM, the block LM determines this based on + * indent properties. + * These LM may wish to pass this information down to lower + * level LM to allow them to optimize returned break possibilities. + */ + private MinOptMax stackLimitIP; /** True if current element list is spanning in multi-column layout. */ private int nextSpan = Constants.NOT_SET; /** inline-progression-dimension of nearest ancestor reference area */ private int refIPD; + //TODO After the split of stackLimit into stackLimitBP and stackLimitIP there's now some + //overlap with refIPD. Need to investigate how best to refactor that. /** the writing mode established by the nearest ancestor reference area */ private int writingMode = Constants.EN_LR_TB; @@ -145,7 +156,7 @@ public class LayoutContext { this.flags = parentLC.flags; this.refIPD = parentLC.refIPD; this.writingMode = parentLC.writingMode; - this.stackLimit = null; // Don't reference parent MinOptMax! + setStackLimitsFrom(parentLC); this.leadingSpace = parentLC.leadingSpace; //??? this.trailingSpace = parentLC.trailingSpace; //??? this.hyphContext = parentLC.hyphContext; @@ -166,7 +177,8 @@ public class LayoutContext { public LayoutContext(int flags) { this.flags = flags; this.refIPD = 0; - stackLimit = new MinOptMax(0); + stackLimitBP = new MinOptMax(0); + stackLimitIP = new MinOptMax(0); leadingSpace = null; trailingSpace = null; } @@ -273,12 +285,8 @@ public class LayoutContext { * Clears all pending marks on the LayoutContext. */ public void clearPendingMarks() { - if (this.pendingBeforeMarks != null) { - this.pendingBeforeMarks.clear(); - } - if (this.pendingAfterMarks != null) { - this.pendingAfterMarks.clear(); - } + this.pendingBeforeMarks = null; + this.pendingAfterMarks = null; } /** @@ -306,14 +314,47 @@ public class LayoutContext { } } - public void setStackLimit(MinOptMax limit) { - stackLimit = limit; + /** + * Sets the stack limit in block-progression-dimension. + * @param limit the stack limit + */ + public void setStackLimitBP(MinOptMax limit) { + stackLimitBP = limit; } - public MinOptMax getStackLimit() { - return stackLimit; + /** + * Returns the stack limit in block-progression-dimension. + * @return the stack limit + */ + public MinOptMax getStackLimitBP() { + return stackLimitBP; } + /** + * Sets the stack limit in inline-progression-dimension. + * @param limit the stack limit + */ + public void setStackLimitIP(MinOptMax limit) { + stackLimitIP = limit; + } + + /** + * Returns the stack limit in inline-progression-dimension. + * @return the stack limit + */ + public MinOptMax getStackLimitIP() { + return stackLimitIP; + } + + /** + * Sets (Copies) the stack limits in both directions from another layout context. + * @param context the layout context to taje the values from + */ + public void setStackLimitsFrom(LayoutContext context) { + setStackLimitBP(context.getStackLimitBP()); + setStackLimitIP(context.getStackLimitIP()); + } + /** * Sets the inline-progression-dimension of the nearest ancestor reference area. */ @@ -536,22 +577,27 @@ public class LayoutContext { /** {@inheritDoc} */ public String toString() { - return "Layout Context:" + - "\nStack Limit: \t" + (getStackLimit() == null ? "null" : getStackLimit().toString()) + - "\nTrailing Space: \t" + (getTrailingSpace() == null ? "null" : getTrailingSpace().toString()) + - "\nLeading Space: \t" + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) + - "\nReference IPD: \t" + getRefIPD() + - "\nSpace Adjust: \t" + getSpaceAdjust() + - "\nIPD Adjust: \t" + getIPDAdjust() + - "\nResolve Leading Space: \t" + resolveLeadingSpace() + - "\nSuppress Leading Space: \t" + suppressLeadingSpace() + - "\nIs First Area: \t" + isFirstArea() + - "\nStarts New Area: \t" + startsNewArea() + - "\nIs Last Area: \t" + isLastArea() + - "\nTry Hyphenate: \t" + tryHyphenate() + - "\nKeeps: \t[" + (isKeepWithNextPending() ? "keep-with-next" : "") + "][" - + (isKeepWithPreviousPending() ? "keep-with-previous" : "") + "] pending" + - "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" + return "Layout Context:" + + "\nStack Limit BPD: \t" + + (getStackLimitBP() == null ? "null" : getStackLimitBP().toString()) + + "\nStack Limit IPD: \t" + + (getStackLimitIP() == null ? "null" : getStackLimitIP().toString()) + + "\nTrailing Space: \t" + + (getTrailingSpace() == null ? "null" : getTrailingSpace().toString()) + + "\nLeading Space: \t" + + (getLeadingSpace() == null ? "null" : getLeadingSpace().toString()) + + "\nReference IPD: \t" + getRefIPD() + + "\nSpace Adjust: \t" + getSpaceAdjust() + + "\nIPD Adjust: \t" + getIPDAdjust() + + "\nResolve Leading Space: \t" + resolveLeadingSpace() + + "\nSuppress Leading Space: \t" + suppressLeadingSpace() + + "\nIs First Area: \t" + isFirstArea() + + "\nStarts New Area: \t" + startsNewArea() + + "\nIs Last Area: \t" + isLastArea() + + "\nTry Hyphenate: \t" + tryHyphenate() + + "\nKeeps: \t[" + (isKeepWithNextPending() ? "keep-with-next" : "") + "][" + + (isKeepWithPreviousPending() ? "keep-with-previous" : "") + "] pending" + + "\nBreaks: \tforced [" + (breakBefore != Constants.EN_AUTO ? "break-before" : "") + "][" + (breakAfter != Constants.EN_AUTO ? "break-after" : "") + "]"; } diff --git a/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java b/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java index ff9bdb1d9..b58af1cfe 100644 --- a/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java +++ b/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java @@ -68,19 +68,16 @@ public class MinOptMaxUtil { } /** - * Extend the minimum length to the given length. + * 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 - * @param optToLen if set adjusts the optimum length to be the smaller of the - * minimum length and the given length */ - public static void extendMinimum(MinOptMax mom, int len, boolean optToLen) { + public static void extendMinimum(MinOptMax mom, int len) { if (mom.min < len) { mom.min = len; mom.opt = Math.max(mom.min, mom.opt); - if (optToLen) { - mom.opt = Math.min(mom.min, len); - } mom.max = Math.max(mom.opt, mom.max); } } @@ -111,7 +108,7 @@ public class MinOptMaxUtil { ? 0 : prop.getMinimum(context).getLength().getValue(context)), (prop.getOptimum(context).isAuto() ? 0 : prop.getOptimum(context).getLength().getValue(context)), - (prop.getMinimum(context).isAuto() + (prop.getMaximum(context).isAuto() ? Integer.MAX_VALUE : prop.getMaximum(context).getLength().getValue(context))); return mom; diff --git a/src/java/org/apache/fop/layoutmgr/PageBreaker.java b/src/java/org/apache/fop/layoutmgr/PageBreaker.java index cf830a7ec..3e100cd50 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreaker.java @@ -156,7 +156,7 @@ public class PageBreaker extends AbstractBreaker { // element represents a line with footnote citations bFootnotesPresent = true; LayoutContext footnoteContext = new LayoutContext(context); - footnoteContext.setStackLimit(context.getStackLimit()); + footnoteContext.setStackLimitBP(context.getStackLimitBP()); footnoteContext.setRefIPD(pslm.getCurrentPV() .getRegionReference(Constants.FO_REGION_BODY).getIPD()); LinkedList footnoteBodyLMs = ((KnuthBlockBox) element).getFootnoteBodyLMs(); diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java index 57fc4600e..d98d29b5c 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java @@ -364,7 +364,13 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } else { // there are no footnotes } - return getLineWidth(activeNode.line) - actualWidth; + int diff = getLineWidth(activeNode.line) - actualWidth; + if (autoHeight && diff < 0) { + //getLineWidth() for auto-height parts return 0 so the diff will be negative + return 0; //...but we don't want to shrink in this case. Stick to optimum. + } else { + return diff; + } } /** Checks whether footnotes from preceding pages may be deferred to the page after diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java index c8b89e6af..b1e414527 100644 --- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java @@ -93,7 +93,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { //TODO Empty this method?!? // set layout dimensions setContentAreaIPD(context.getRefIPD()); - setContentAreaBPD(context.getStackLimit().opt); + setContentAreaBPD(context.getStackLimitBP().opt); //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. // currently active LM @@ -111,10 +111,10 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { } // Set up a LayoutContext - MinOptMax bpd = context.getStackLimit(); + MinOptMax bpd = context.getStackLimitBP(); LayoutContext childLC = new LayoutContext(0); - childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize)); + childLC.setStackLimitBP(MinOptMax.subtract(bpd, stackSize)); childLC.setRefIPD(context.getRefIPD()); // get elements from curLM @@ -307,7 +307,7 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { while ((curLM = getChildLM()) != null) { LayoutContext childLC = new LayoutContext(0); - childLC.setStackLimit(context.getStackLimit()); + childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(context.getRefIPD()); childLC.setWritingMode(context.getWritingMode()); diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java index 841a94705..dfc8c99f2 100644 --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -29,6 +29,7 @@ import org.apache.fop.datatypes.SimplePercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; +import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; import org.apache.fop.fonts.Font; @@ -280,6 +281,90 @@ public class TraitSetter { } } + /** + * Add background to an area. This method is mainly used by table-related layout + * managers to add background for column, body or row. Since the area corresponding to + * border-separation must be filled with the table's background, for every cell an + * additional area with the same dimensions is created to hold the background for the + * corresponding column/body/row. An additional shift must then be added to + * 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 + * @param ipdShift horizontal shift to affect to the background, in addition to the + * value of the background-position-horizontal property + * @param bpdShift vertical shift to affect to the background, in addition to the + * value of the background-position-vertical property + * @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, + CommonBorderPaddingBackground backProps, + PercentBaseContext context, + int ipdShift, int bpdShift, int referenceIPD, int referenceBPD) { + if (!backProps.hasBackground()) { + return; + } + Trait.Background back = new Trait.Background(); + back.setColor(backProps.backgroundColor); + + if (backProps.getImageInfo() != null) { + back.setURL(backProps.backgroundImage); + back.setImageInfo(backProps.getImageInfo()); + back.setRepeat(backProps.backgroundRepeat); + if (backProps.backgroundPositionHorizontal != null) { + if (back.getRepeat() == Constants.EN_NOREPEAT + || back.getRepeat() == Constants.EN_REPEATY) { + if (area.getIPD() > 0) { + PercentBaseContext refContext = new SimplePercentBaseContext(context, + LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL, + (referenceIPD - back.getImageInfo().getSize().getWidthMpt())); + + back.setHoriz(ipdShift + + backProps.backgroundPositionHorizontal.getValue(refContext)); + } else { + // TODO Area IPD has to be set for this to work + log.warn("Horizontal background image positioning ignored" + + " because the IPD was not set on the area." + + " (Yes, it's a bug in FOP)"); + } + } + } + if (backProps.backgroundPositionVertical != null) { + if (back.getRepeat() == Constants.EN_NOREPEAT + || back.getRepeat() == Constants.EN_REPEATX) { + if (area.getBPD() > 0) { + PercentBaseContext refContext = new SimplePercentBaseContext(context, + LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL, + (referenceBPD - back.getImageInfo().getSize().getHeightMpt())); + back.setVertical(bpdShift + + backProps.backgroundPositionVertical.getValue(refContext)); + } else { + // TODO Area BPD has to be set for this to work + log.warn("Vertical background image positioning ignored" + + " because the BPD was not set on the area." + + " (Yes, it's a bug in FOP)"); + } + } + } + } + + area.addTrait(Trait.BACKGROUND, back); + } + /** * Add background to an area. * Layout managers that create areas with a background can use this to @@ -312,7 +397,7 @@ public class TraitSetter { back.setHoriz(backProps.backgroundPositionHorizontal.getValue( new SimplePercentBaseContext(context, LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL, - (width - back.getImageInfo().getSize().getHeightMpt()) + (width - back.getImageInfo().getSize().getWidthMpt()) ) )); } else { diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java index 6426f15db..38e0c35bc 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java @@ -123,13 +123,6 @@ public abstract class AbstractGraphicsLayoutManager extends LeafNodeLayoutManage ); } - /** - * {@inheritDoc} - */ - protected void addId() { - getPSLM().addIDToPage(fobj.getId()); - } - /** * Returns the image of foreign object area to be put into * the viewport. diff --git a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java index 41d4af1c1..c92bdb6fc 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java @@ -51,7 +51,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa * Constructor * * @param node the formatting object that creates this area - * @todo better retrieval of font info + * TODO better retrieval of font info */ public AbstractPageNumberCitationLayoutManager(AbstractPageNumberCitation node) { super(node); @@ -83,7 +83,7 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa /** {@inheritDoc} */ public InlineArea get(LayoutContext context) { - curArea = getPageNumberCitationInlineArea(parentLM); + curArea = getPageNumberCitationInlineArea(); return curArea; } @@ -99,12 +99,15 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa } /** - * if id can be resolved then simply return a word, otherwise + * If id can be resolved then simply return a word, otherwise * return a resolvable area + * + * @param parentLM the parent LayoutManager + * @return a corresponding InlineArea */ - private InlineArea getPageNumberCitationInlineArea(LayoutManager parentLM) { + private InlineArea getPageNumberCitationInlineArea() { PageViewport page = getPSLM().getFirstPVWithID(fobj.getRefId()); - TextArea text = null; + TextArea text; if (page != null) { String str = page.getPageNumberString(); // get page string from parent, build area @@ -150,9 +153,5 @@ public abstract class AbstractPageNumberCitationLayoutManager extends LeafNodeLa return width; } - /** {@inheritDoc} */ - protected void addId() { - getPSLM().addIDToPage(fobj.getId()); - } } diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java index 0430eef0c..b53e442d4 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java @@ -45,7 +45,6 @@ import org.apache.fop.util.CharUtilities; * LayoutManager for the fo:character formatting object */ public class CharacterLayoutManager extends LeafNodeLayoutManager { - private Character fobj; private MinOptMax letterSpaceIPD; private int hyphIPD; private Font font; @@ -57,13 +56,13 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { * @param node the fo:character formatting object */ public CharacterLayoutManager(Character node) { - // @todo better null checking of node super(node); - fobj = node; } /** {@inheritDoc} */ public void initialize() { + Character fobj = (Character)this.fobj; + FontInfo fi = fobj.getFOEventHandler().getFontInfo(); FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this)); @@ -90,7 +89,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { text.addWord(String.valueOf(ch), 0); } TraitSetter.setProducerID(text, node.getId()); - TraitSetter.addTextDecoration(text, fobj.getTextDecoration()); + TraitSetter.addTextDecoration(text, node.getTextDecoration()); return text; } @@ -105,6 +104,8 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { return null; } + Character fobj = (Character)this.fobj; + ipd = new MinOptMax(font.getCharWidth(fobj.getCharacter())); curArea.setIPD(ipd.opt); @@ -178,14 +179,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { /** {@inheritDoc} */ public boolean applyChanges(List oldList) { setFinished(false); - if (isSomethingChanged) { - // there is nothing to do, - // possible changes have already been applied - // in the hyphenate() method - return true; - } else { - return false; - } + return isSomethingChanged; } /** {@inheritDoc} */ @@ -238,10 +232,5 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { return returnList; } - /** {@inheritDoc} */ - protected void addId() { - getPSLM().addIDToPage(fobj.getId()); - } - } diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java index 03e9b382a..ff7c5b3ce 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java @@ -19,9 +19,20 @@ package org.apache.fop.layoutmgr.inline; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.area.Area; +import org.apache.fop.area.Block; +import org.apache.fop.area.LineArea; +import org.apache.fop.area.inline.InlineArea; import org.apache.fop.fo.Constants; import org.apache.fop.fo.pagination.Title; import org.apache.fop.layoutmgr.AbstractBaseLayoutManager; @@ -34,19 +45,8 @@ import org.apache.fop.layoutmgr.PageSequenceLayoutManager; import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.SpaceSpecifier; -import org.apache.fop.area.Area; -import org.apache.fop.area.LineArea; -import org.apache.fop.area.inline.InlineArea; - -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.ArrayList; -import java.util.Iterator; import org.apache.fop.traits.MinOptMax; -import org.apache.fop.area.Block; - /** * Content Layout Manager. * For use with objects that contain inline areas such as @@ -115,7 +115,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager childLC.setLeadingSpace(new SpaceSpecifier(false)); childLC.setTrailingSpace(new SpaceSpecifier(false)); // set stackLimit for lines - childLC.setStackLimit(new MinOptMax(ipd)); + childLC.setStackLimitIP(new MinOptMax(ipd)); childLC.setRefIPD(ipd); int lineHeight = 14000; diff --git a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java index 4ffafb061..7ca9e0d5e 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ICLayoutManager.java @@ -31,12 +31,10 @@ import org.apache.fop.fo.flow.InlineContainer; * and id areas are maintained for later retrieval. */ public class ICLayoutManager extends LeafNodeLayoutManager { - private InlineContainer fobj; private List childrenLM; public ICLayoutManager(InlineContainer node, List childLM) { super(node); - fobj = node; childrenLM = childLM; } @@ -44,7 +42,4 @@ public class ICLayoutManager extends LeafNodeLayoutManager { return null; } - protected void addId() { - getPSLM().addIDToPage(fobj.getId()); - } } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java index b449b6689..e9919e02f 100755 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java @@ -19,12 +19,13 @@ package org.apache.fop.layoutmgr.inline; -import java.util.ListIterator; import java.util.LinkedList; import java.util.List; +import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.area.Area; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.InlineBlockParent; @@ -47,12 +48,12 @@ import org.apache.fop.layoutmgr.InlineKnuthSequence; import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.KnuthSequence; import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.NonLeafPosition; -import org.apache.fop.layoutmgr.SpaceSpecifier; -import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.NonLeafPosition; import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.SpaceSpecifier; +import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.traits.MinOptMax; import org.apache.fop.traits.SpaceVal; @@ -296,7 +297,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { ); } - while ((curLM = (LayoutManager) getChildLM()) != null) { + while ((curLM = getChildLM()) != null) { if (!(curLM instanceof InlineLevelLayoutManager)) { // A block LM @@ -435,7 +436,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { // layout context given to lastLM, but must be cleared in the // layout context given to the other LMs. LinkedList positionList = new LinkedList(); - NonLeafPosition pos = null; + NonLeafPosition pos; LayoutManager lastLM = null;// last child LM in this iterator Position lastPos = null; while (parentIter.hasNext()) { @@ -599,9 +600,4 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { return this.auxiliaryPosition; } - /** {@inheritDoc} */ - protected void addId() { - getPSLM().addIDToPage(fobj.getId()); - } - } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java index 4d0872a6d..bf1538a7c 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java @@ -75,15 +75,9 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager private Area currentArea; // LineArea or InlineParent - //private BreakPoss prevBP; - /** The child layout context */ protected LayoutContext childLC; - private boolean bAreaCreated = false; - - //private LayoutManager currentLM = null; - /** Used to store previous content IPD for each child LM. */ private HashMap hmPrevIPD = new HashMap(); @@ -170,14 +164,6 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager hmPrevIPD.clear(); } - /** - * This method is called by addAreas() so IDs can be added to a page for FOs that - * support the 'id' property. - */ - protected void addId() { - // Do nothing here, overriden in subclasses that have an 'id' property. - } - /** * Returns the current area. * @return the current area @@ -255,7 +241,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager // "unwrap" the Position stored in each element of oldList while (oldListIterator.hasNext()) { element = (KnuthElement) oldListIterator.next(); - element.setPosition(((NonLeafPosition)element.getPosition()).getPosition()); + element.setPosition(element.getPosition().getPosition()); } // The last element may not have a layout manager (its position == null); @@ -288,7 +274,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager // "unwrap" the Position stored in each element of oldList while (oldListIterator.hasNext()) { element = (KnuthElement) oldListIterator.next(); - element.setPosition(((NonLeafPosition)element.getPosition()).getPosition()); + element.setPosition(element.getPosition().getPosition()); } ((InlineLevelLayoutManager) @@ -298,14 +284,14 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager /** {@inheritDoc} */ public void getWordChars(StringBuffer sbChars, Position pos) { - Position newPos = ((NonLeafPosition) pos).getPosition(); + Position newPos = pos.getPosition(); ((InlineLevelLayoutManager) newPos.getLM()).getWordChars(sbChars, newPos); } /** {@inheritDoc} */ public void hyphenate(Position pos, HyphContext hc) { - Position newPos = ((NonLeafPosition) pos).getPosition(); + Position newPos = pos.getPosition(); ((InlineLevelLayoutManager) newPos.getLM()).hyphenate(newPos, hc); } @@ -318,7 +304,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager while (oldListIterator.hasNext()) { oldElement = (KnuthElement) oldListIterator.next(); oldElement.setPosition - (((NonLeafPosition) oldElement.getPosition()).getPosition()); + (oldElement.getPosition().getPosition()); } // reset the iterator oldListIterator = oldList.listIterator(); @@ -385,7 +371,7 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager while (oldListIterator.hasNext()) { oldElement = (KnuthElement) oldListIterator.next(); oldElement.setPosition - (((NonLeafPosition) oldElement.getPosition()).getPosition()); + (oldElement.getPosition().getPosition()); } // reset the iterator oldListIterator = oldList.listIterator(); diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index 5f93ab98c..f4bcde96f 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java @@ -339,11 +339,6 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { return returnList; } - /** {@inheritDoc} */ - protected void addId() { - getPSLM().addIDToPage(fobj.getId()); - } - /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java index 78d126194..fb5e9ee4d 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java @@ -65,8 +65,6 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager /** The alignment context applying to this area */ protected AlignmentContext alignmentContext = null; - private MinOptMax ipd; - /** Flag to indicate if something was changed as part of the getChangeKnuthElements sequence */ protected boolean isSomethingChanged = false; /** Our area info for the Knuth elements */ @@ -204,14 +202,6 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager return curArea; } - /** - * This method is called by addAreas() so IDs can be added to a page for FOs that - * support the 'id' property. - */ - protected void addId() { - // Do nothing here, overriden in subclasses that have an 'id' property. - } - /** * Offset this area. * Offset the inline area in the bpd direction when adding the diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 6df7ac00c..9a818232c 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -26,6 +26,7 @@ import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.area.Area; import org.apache.fop.area.LineArea; import org.apache.fop.area.Trait; @@ -582,9 +583,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager // Get a break from currently active child LM // Set up constraints for inline level managers - // IPD remaining in line - MinOptMax availIPD = context.getStackLimit(); - clearPrevIPD(); //PHASE 1: Create Knuth elements @@ -646,7 +644,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager InlineLevelLayoutManager curLM; LinkedList returnedList = null; - iLineWidth = context.getStackLimit().opt; + iLineWidth = context.getStackLimitIP().opt; // convert all the text in a sequence of paragraphs made // of KnuthBox, KnuthGlue and KnuthPenalty objects @@ -1687,7 +1685,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager */ if (false && textAlignment == EN_JUSTIFY) { // re-compute space adjust ratio - int updatedDifference = context.getStackLimit().opt + int updatedDifference = context.getStackLimitIP().opt - lbp.lineWidth + lbp.difference; double updatedRatio = 0.0; if (updatedDifference > 0) { @@ -1701,12 +1699,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager } else if (false && textAlignment == EN_CENTER) { // re-compute indent int updatedIndent = lbp.startIndent - + (context.getStackLimit().opt - lbp.lineWidth) / 2; + + (context.getStackLimitIP().opt - lbp.lineWidth) / 2; lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent)); } else if (false && textAlignment == EN_END) { // re-compute indent int updatedIndent = lbp.startIndent - + (context.getStackLimit().opt - lbp.lineWidth); + + (context.getStackLimitIP().opt - lbp.lineWidth); lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent)); } @@ -1770,7 +1768,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // set last area flag blocklc.setFlags(LayoutContext.LAST_AREA, (context.isLastArea() && childLM == lastLM)); - blocklc.setStackLimit(context.getStackLimit()); + blocklc.setStackLimitsFrom(context); // Add the line areas to Area childLM.addAreas(childPosIter, blocklc); blocklc.setLeadingSpace(blocklc.getTrailingSpace()); diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java index 88f1d283c..1aaaaf527 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java @@ -42,7 +42,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { * Constructor * * @param node the fo:page-number formatting object that creates the area - * @todo better null checking of node, font + * TODO better null checking of node, font */ public PageNumberLayoutManager(PageNumber node) { super(node); @@ -131,9 +131,5 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { return width; } - /** {@inheritDoc} */ - protected void addId() { - getPSLM().addIDToPage(fobj.getId()); - } } diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index 470cbbe9c..c17ddc711 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java @@ -19,29 +19,29 @@ package org.apache.fop.layoutmgr.list; +import java.util.Iterator; +import java.util.LinkedList; +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.fo.flow.ListBlock; -import org.apache.fop.layoutmgr.BlockLevelLayoutManager; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.ConditionalElementListener; import org.apache.fop.layoutmgr.ElementListUtils; -import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.Position; +import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.NonLeafPosition; +import org.apache.fop.layoutmgr.Position; +import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.RelSide; import org.apache.fop.layoutmgr.TraitSetter; -import org.apache.fop.area.Area; -import org.apache.fop.area.Block; import org.apache.fop.traits.MinOptMax; import org.apache.fop.traits.SpaceVal; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - /** * LayoutManager for a list-block FO. * A list block contains list items which are stacked within @@ -156,11 +156,11 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager addBlockSpacing(0.0, new MinOptMax(layoutContext.getSpaceBefore())); } - getPSLM().addIDToPage(getListBlockFO().getId()); + addId(); // the list block contains areas stacked from each list item - LayoutManager childLM = null; + LayoutManager childLM; LayoutContext lc = new LayoutContext(0); LayoutManager firstLM = null; LayoutManager lastLM = null; @@ -181,10 +181,10 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager } if (pos instanceof NonLeafPosition && (pos.getPosition() != null) - && ((NonLeafPosition) pos).getPosition().getLM() != this) { + && pos.getPosition().getLM() != this) { // pos was created by a child of this ListBlockLM - positionList.add(((NonLeafPosition) pos).getPosition()); - lastLM = ((NonLeafPosition) pos).getPosition().getLM(); + positionList.add(pos.getPosition()); + lastLM = pos.getPosition().getLM(); if (firstLM == null) { firstLM = lastLM; } @@ -200,7 +200,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager lc.setSpaceAdjust(layoutContext.getSpaceAdjust()); lc.setFlags(LayoutContext.FIRST_AREA, childLM == firstLM); lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM); - lc.setStackLimit(layoutContext.getStackLimit()); + lc.setStackLimitBP(layoutContext.getStackLimitBP()); childLM.addAreas(childPosIter, lc); } @@ -218,7 +218,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager curBlockArea = null; resetSpaces(); - getPSLM().notifyEndOfLayout(((ListBlock)getFObj()).getId()); + getPSLM().notifyEndOfLayout(fobj.getId()); } /** @@ -280,7 +280,7 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager /** {@inheritDoc} */ public boolean mustKeepTogether() { //TODO Keeps will have to be more sophisticated sooner or later - return ((BlockLevelLayoutManager)getParent()).mustKeepTogether() + return super.mustKeepTogether() || !getListBlockFO().getKeepTogether().getWithinPage().isAuto() || !getListBlockFO().getKeepTogether().getWithinColumn().isAuto(); } diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java index 853b1a128..8b0028a8f 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemContentLayoutManager.java @@ -19,24 +19,24 @@ package org.apache.fop.layoutmgr.list; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.fop.area.Area; +import org.apache.fop.area.Block; import org.apache.fop.fo.flow.AbstractListItemPart; import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.layoutmgr.BlockLevelLayoutManager; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; -import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.Position; +import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.NonLeafPosition; +import org.apache.fop.layoutmgr.Position; +import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition; -import org.apache.fop.area.Area; -import org.apache.fop.area.Block; - -import java.util.Iterator; -import java.util.List; -import java.util.LinkedList; /** * LayoutManager for a list-item-label or list-item-body FO. @@ -115,9 +115,9 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { LayoutContext layoutContext) { getParentArea(null); - getPSLM().addIDToPage(getPartFO().getId()); + addId(); - LayoutManager childLM = null; + LayoutManager childLM; LayoutContext lc = new LayoutContext(0); LayoutManager firstLM = null; LayoutManager lastLM = null; @@ -141,8 +141,8 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { } if (pos instanceof NonLeafPosition) { // pos was created by a child of this ListBlockLM - positionList.add(((NonLeafPosition) pos).getPosition()); - lastLM = ((NonLeafPosition) pos).getPosition().getLM(); + positionList.add(pos.getPosition()); + lastLM = pos.getPosition().getLM(); if (firstLM == null) { firstLM = lastLM; } @@ -162,7 +162,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { lc.setFlags(LayoutContext.LAST_AREA, childLM == lastLM); // set the space adjustment ratio lc.setSpaceAdjust(layoutContext.getSpaceAdjust()); - lc.setStackLimit(layoutContext.getStackLimit()); + lc.setStackLimitBP(layoutContext.getStackLimitBP()); childLM.addAreas(childPosIter, lc); } @@ -172,7 +172,7 @@ public class ListItemContentLayoutManager extends BlockStackingLayoutManager { curBlockArea = null; - getPSLM().notifyEndOfLayout(((AbstractListItemPart)getFObj()).getId()); + getPSLM().notifyEndOfLayout(fobj.getId()); } /** diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index dc28e98e2..c6b5b8cf9 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -19,8 +19,16 @@ package org.apache.fop.layoutmgr.list; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; + 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.fo.flow.ListItem; import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; @@ -30,28 +38,21 @@ import org.apache.fop.layoutmgr.BreakElement; import org.apache.fop.layoutmgr.ConditionalElementListener; import org.apache.fop.layoutmgr.ElementListObserver; import org.apache.fop.layoutmgr.ElementListUtils; -import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.KnuthBox; +import org.apache.fop.layoutmgr.KnuthElement; +import org.apache.fop.layoutmgr.KnuthPenalty; +import org.apache.fop.layoutmgr.KnuthPossPosIter; import org.apache.fop.layoutmgr.LayoutContext; -import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.Position; +import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.NonLeafPosition; +import org.apache.fop.layoutmgr.Position; +import org.apache.fop.layoutmgr.PositionIterator; import org.apache.fop.layoutmgr.RelSide; import org.apache.fop.layoutmgr.SpaceResolver; import org.apache.fop.layoutmgr.TraitSetter; -import org.apache.fop.layoutmgr.KnuthElement; -import org.apache.fop.layoutmgr.KnuthBox; -import org.apache.fop.layoutmgr.KnuthPenalty; -import org.apache.fop.layoutmgr.KnuthPossPosIter; -import org.apache.fop.area.Area; -import org.apache.fop.area.Block; import org.apache.fop.traits.MinOptMax; import org.apache.fop.traits.SpaceVal; -import java.util.ArrayList; -import java.util.List; -import java.util.LinkedList; -import java.util.ListIterator; - /** * LayoutManager for a list-item FO. * The list item contains a list item label and a list item body. @@ -72,8 +73,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager private LinkedList labelList = null; private LinkedList bodyList = null; - private int listItemHeight; - private boolean discardBorderBefore; private boolean discardBorderAfter; private boolean discardPaddingBefore; @@ -83,7 +82,9 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager private boolean keepWithNextPendingOnLabel; private boolean keepWithNextPendingOnBody; - + + private int listItemHeight; + private class ListItemPosition extends Position { private int iLabelFirstIndex; private int iLabelLastIndex; @@ -115,6 +116,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager return iBodyLastIndex; } + /** {@inheritDoc} */ + public boolean generatesAreas() { + return true; + } + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer("ListItemPosition:"); @@ -301,12 +307,12 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager int additionalPenaltyHeight = 0; KnuthElement endEl = (KnuthElement)elementLists[0].get(end[0]); if (endEl instanceof KnuthPenalty) { - additionalPenaltyHeight = ((KnuthPenalty)endEl).getW(); + additionalPenaltyHeight = endEl.getW(); } endEl = (KnuthElement)elementLists[1].get(end[1]); if (endEl instanceof KnuthPenalty) { additionalPenaltyHeight = Math.max( - additionalPenaltyHeight, ((KnuthPenalty)endEl).getW()); + additionalPenaltyHeight, endEl.getW()); } int boxHeight = step - addedBoxHeight - penaltyHeight; @@ -413,10 +419,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // body // "unwrap" the Positions stored in the elements ListIterator oldListIterator = oldList.listIterator(); - KnuthElement oldElement = null; + KnuthElement oldElement; while (oldListIterator.hasNext()) { oldElement = (KnuthElement)oldListIterator.next(); - Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition(); + Position innerPosition = oldElement.getPosition().getPosition(); //log.debug(" BLM> unwrapping: " + (oldElement.isBox() // ? "box " : (oldElement.isGlue() ? "glue " : "penalty")) // + " creato da " + oldElement.getLayoutManager().getClass().getName()); @@ -459,7 +465,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager LayoutContext layoutContext) { getParentArea(null); - getPSLM().addIDToPage(getListItemFO().getId()); + addId(); LayoutContext lc = new LayoutContext(0); Position firstPos = null; @@ -478,7 +484,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager } if (pos instanceof NonLeafPosition && pos.getPosition() != null) { // pos contains a ListItemPosition created by this ListBlockLM - positionList.add(((NonLeafPosition) pos).getPosition()); + positionList.add(pos.getPosition()); } } @@ -510,7 +516,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // set the space adjustment ratio lc.setSpaceAdjust(layoutContext.getSpaceAdjust()); // TO DO: use the right stack limit for the label - lc.setStackLimit(layoutContext.getStackLimit()); + lc.setStackLimitBP(layoutContext.getStackLimitBP()); label.addAreas(labelIter, lc); } @@ -531,7 +537,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager // set the space adjustment ratio lc.setSpaceAdjust(layoutContext.getSpaceAdjust()); // TO DO: use the right stack limit for the body - lc.setStackLimit(layoutContext.getStackLimit()); + lc.setStackLimitBP(layoutContext.getStackLimitBP()); body.addAreas(bodyIter, lc); } @@ -554,7 +560,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager curBlockArea = null; resetSpaces(); - getPSLM().notifyEndOfLayout(((ListItem)getFObj()).getId()); + getPSLM().notifyEndOfLayout(fobj.getId()); } /** diff --git a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java index c1e4ae619..61d0f8e6f 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java +++ b/src/java/org/apache/fop/layoutmgr/table/ActiveCell.java @@ -33,6 +33,8 @@ import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthPenalty; +import org.apache.fop.layoutmgr.MinOptMaxUtil; +import org.apache.fop.traits.MinOptMax; /** * A cell playing in the construction of steps for a row-group. @@ -133,6 +135,49 @@ class ActiveCell { } } + // TODO to be removed along with the RowPainter#computeContentLength method + /** See {@link ActiveCell#handleExplicitHeight(MinOptMax, MinOptMax)}. */ + private static class FillerPenalty extends KnuthPenalty { + + private int contentLength; + + FillerPenalty(KnuthPenalty p, int length) { + super(length, p.getP(), p.isFlagged(), p.getBreakClass(), + p.getPosition(), p.isAuxiliary()); + contentLength = p.getW(); + } + + FillerPenalty(int length) { + super(length, 0, false, null, true); + contentLength = 0; + } + } + + /** See {@link ActiveCell#handleExplicitHeight(MinOptMax, MinOptMax)}. */ + private static class FillerBox extends KnuthBox { + FillerBox(int length) { + super(length, null, true); + } + } + + /** + * 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 + */ + static int getElementContentLength(KnuthElement el) { + if (el instanceof FillerPenalty) { + return ((FillerPenalty) el).contentLength; + } else if (el instanceof FillerBox) { + return 0; + } else { + return el.getW(); + } + } + ActiveCell(PrimaryGridUnit pgu, EffRow row, int rowIndex, int previousRowsLength, TableLayoutManager tableLM) { this.pgu = pgu; @@ -149,23 +194,10 @@ class ActiveCell { + pgu.getBeforeBorderWidth(0, ConditionalBorder.REST); bpAfterNormal = paddingAfterNormal + pgu.getAfterBorderWidth(ConditionalBorder.NORMAL); bpAfterTrailing = paddingAfterTrailing + pgu.getAfterBorderWidth(0, ConditionalBorder.REST); - boolean makeBoxForWholeRow = false; - if (row.getExplicitHeight().min > 0) { - boolean contentsSmaller = ElementListUtils.removeLegalBreaks( - pgu.getElements(), row.getExplicitHeight()); - if (contentsSmaller) { - makeBoxForWholeRow = true; - } - } - if (makeBoxForWholeRow) { - elementList = new java.util.ArrayList(1); - int height = row.getHeight().opt; - height -= 2 * tableLM.getHalfBorderSeparationBPD(); - height -= bpBeforeNormal + bpAfterNormal; - elementList.add(new KnuthBoxCellWithBPD(height)); - } else { - elementList = pgu.getElements(); - } + elementList = pgu.getElements(); + handleExplicitHeight( + MinOptMaxUtil.toMinOptMax(pgu.getCell().getBlockProgressionDimension(), tableLM), + row.getExplicitHeight()); knuthIter = elementList.listIterator(); includedLength = -1; // Avoid troubles with cells having content of zero length totalLength = previousRowsLength + ElementListUtils.calcContentLength(elementList); @@ -182,6 +214,46 @@ 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. + */ + private void handleExplicitHeight(MinOptMax cellBPD, MinOptMax rowBPD) { + int minBPD = Math.max(cellBPD.min, rowBPD.min); + if (minBPD > 0) { + ListIterator iter = elementList.listIterator(); + int cumulateLength = 0; + boolean prevIsBox = false; + while (iter.hasNext() && cumulateLength < minBPD) { + KnuthElement el = (KnuthElement) iter.next(); + if (el.isBox()) { + prevIsBox = true; + cumulateLength += el.getW(); + } else if (el.isGlue()) { + if (prevIsBox) { + elementList.add(iter.nextIndex() - 1, + new FillerPenalty(minBPD - cumulateLength)); + } + prevIsBox = false; + cumulateLength += el.getW(); + } else { + prevIsBox = false; + if (cumulateLength + el.getW() < minBPD) { + iter.set(new FillerPenalty((KnuthPenalty) el, minBPD - cumulateLength)); + } + } + } + } + int optBPD = Math.max(minBPD, Math.max(cellBPD.opt, rowBPD.opt)); + if (pgu.getContentLength() < optBPD) { + elementList.add(new FillerBox(optBPD - pgu.getContentLength())); + } + } + PrimaryGridUnit getPrimaryGridUnit() { return pgu; } @@ -265,14 +337,22 @@ class ActiveCell { } /** - * Returns the last step for this cell. + * Returns the last step for this cell. This includes the normal border- and + * padding-before, the whole content, the normal padding-after, and the + * trailing after border. Indeed, if the normal border is taken instead, + * and appears to be smaller than the trailing one, the last step may be smaller than + * the current step (see TableStepper#considerRowLastStep). This will produce a wrong + * 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 step including all of the cell's content plus the normal borders and paddings + * @return the length of last step */ int getLastStep() { assert nextStep.end == elementList.size() - 1; assert nextStep.contentLength == totalLength && nextStep.penaltyLength == 0; - int lastStep = bpBeforeNormal + totalLength + bpAfterNormal; + int lastStep = bpBeforeNormal + totalLength + paddingAfterNormal + + pgu.getAfterBorderWidth(ConditionalBorder.LEADING_TRAILING); log.debug(this + ": last step = " + lastStep); return lastStep; } @@ -394,8 +474,12 @@ class ActiveCell { */ void endRow(int rowIndex) { if (endsOnRow(rowIndex)) { + // Subtract the old value of bpAfterTrailing... + nextStep.totalLength -= bpAfterTrailing; bpAfterTrailing = paddingAfterNormal + pgu.getAfterBorderWidth(ConditionalBorder.LEADING_TRAILING); + // ... and add the new one + nextStep.totalLength += bpAfterTrailing; lastCellPart = true; } else { bpBeforeLeading = paddingBeforeLeading @@ -445,13 +529,6 @@ class ActiveCell { return new CellPart(pgu, nextStep.start, previousStep.end, lastCellPart, 0, 0, previousStep.penaltyLength, bpBeforeNormal, bpBeforeFirst, bpAfterNormal, bpAfterTrailing); - } else if (nextStep.start == 0 && nextStep.end == 0 - && elementList.size() == 1 - && elementList.get(0) instanceof KnuthBoxCellWithBPD) { - //Special case: Cell with fixed BPD - return new CellPart(pgu, 0, pgu.getElements().size() - 1, lastCellPart, - nextStep.condBeforeContentLength, length, nextStep.penaltyLength, - bpBeforeNormal, bpBeforeFirst, bpAfterNormal, bpAfterTrailing); } else { return new CellPart(pgu, nextStep.start, nextStep.end, lastCellPart, nextStep.condBeforeContentLength, length, nextStep.penaltyLength, @@ -463,20 +540,9 @@ class ActiveCell { return keepWithNextSignal; } - + /** {@inheritDoc} */ public String toString() { return "Cell " + (pgu.getRowIndex() + 1) + "." + (pgu.getColIndex() + 1); } - - - /** - * Marker class denoting table cells fitting in just one box (no legal break inside). - */ - private static class KnuthBoxCellWithBPD extends KnuthBox { - - public KnuthBoxCellWithBPD(int w) { - super(w, null, true); - } - } } diff --git a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java index c2e26e18d..9c97ca827 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java @@ -19,16 +19,16 @@ package org.apache.fop.layoutmgr.table; +import java.util.Iterator; import java.util.LinkedList; -import java.util.List; 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.flow.table.EffRow; import org.apache.fop.fo.flow.table.GridUnit; import org.apache.fop.fo.flow.table.PrimaryGridUnit; +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; @@ -94,137 +94,119 @@ class RowGroupLayoutManager { private void createElementsForRowGroup(LayoutContext context, int alignment, int bodyType, LinkedList returnList) { log.debug("Handling row group with " + rowGroup.length + " rows..."); + EffRow row; + for (int rgi = 0; rgi < rowGroup.length; rgi++) { + row = rowGroup[rgi]; + for (Iterator iter = row.getGridUnits().iterator(); iter.hasNext();) { + GridUnit gu = (GridUnit) iter.next(); + if (gu.isPrimary()) { + PrimaryGridUnit primary = gu.getPrimary(); + // TODO a new LM must be created for every new static-content + primary.createCellLM(); + primary.getCellLM().setParent(tableLM); + //Calculate width of cell + int spanWidth = 0; + Iterator colIter = tableLM.getTable().getColumns().listIterator( + primary.getColIndex()); + for (int i = 0, c = primary.getCell().getNumberColumnsSpanned(); i < c; i++) { + spanWidth += ((TableColumn) colIter.next()).getColumnWidth().getValue( + tableLM); + } + LayoutContext childLC = new LayoutContext(0); + childLC.setStackLimitBP(context.getStackLimitBP()); //necessary? + childLC.setRefIPD(spanWidth); + + //Get the element list for the cell contents + LinkedList elems = primary.getCellLM().getNextKnuthElements( + childLC, alignment); + ElementListObserver.observe(elems, "table-cell", primary.getCell().getId()); + primary.setElements(elems); + } + } + } + computeRowHeights(); + LinkedList elements = tableStepper.getCombinedKnuthElementsForRowGroup(context, + rowGroup, bodyType); + returnList.addAll(elements); + } + + /** + * 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 + */ + private void computeRowHeights() { + log.debug("rowGroup:"); MinOptMax[] rowHeights = new MinOptMax[rowGroup.length]; - MinOptMax[] explicitRowHeights = new MinOptMax[rowGroup.length]; EffRow row; - List pgus = new java.util.ArrayList(); //holds a list of a row's primary grid units for (int rgi = 0; rgi < rowGroup.length; rgi++) { row = rowGroup[rgi]; - rowHeights[rgi] = new MinOptMax(0, 0, Integer.MAX_VALUE); - explicitRowHeights[rgi] = new MinOptMax(0, 0, Integer.MAX_VALUE); - - pgus.clear(); - TableRow tableRow = null; - // The row's minimum content height; 0 if the row's height is auto, otherwise - // the .minimum component of the explicitly specified value - int minRowBPD = 0; // The BPD of the biggest cell in the row - int maxCellBPD = 0; - for (int j = 0; j < row.getGridUnits().size(); j++) { - GridUnit gu = row.getGridUnit(j); - if ((gu.isPrimary() || (gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan())) - && !gu.isEmpty()) { +// int maxCellBPD = 0; + MinOptMax explicitRowHeight; + TableRow tableRowFO = rowGroup[rgi].getTableRow(); + if (tableRowFO == null) { + rowHeights[rgi] = new MinOptMax(0, 0, Integer.MAX_VALUE); + explicitRowHeight = new MinOptMax(0, 0, Integer.MAX_VALUE); + } else { + LengthRangeProperty rowBPD = tableRowFO.getBlockProgressionDimension(); + rowHeights[rgi] = MinOptMaxUtil.toMinOptMax(rowBPD, tableLM); + explicitRowHeight = MinOptMaxUtil.toMinOptMax(rowBPD, tableLM); + } + for (Iterator iter = row.getGridUnits().iterator(); iter.hasNext();) { + GridUnit gu = (GridUnit) iter.next(); + if (!gu.isEmpty() && gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan()) { PrimaryGridUnit primary = gu.getPrimary(); - - if (gu.isPrimary()) { - // TODO a new LM must be created for every new static-content - primary.createCellLM(); - primary.getCellLM().setParent(tableLM); - - //Determine the table-row if any - if (tableRow == null && primary.getRow() != null) { - tableRow = primary.getRow(); - - //Check for bpd on row, see CSS21, 17.5.3 Table height algorithms - LengthRangeProperty rowBPD = tableRow.getBlockProgressionDimension(); - if (!rowBPD.getMinimum(tableLM).isAuto()) { - minRowBPD = Math.max(minRowBPD, - rowBPD.getMinimum(tableLM).getLength().getValue(tableLM)); - } - MinOptMaxUtil.restrict(explicitRowHeights[rgi], rowBPD, tableLM); - - } - - //Calculate width of cell - int spanWidth = 0; - for (int i = primary.getColIndex(); - i < primary.getColIndex() - + primary.getCell().getNumberColumnsSpanned(); - i++) { - if (tableLM.getColumns().getColumn(i + 1) != null) { - spanWidth += tableLM.getColumns().getColumn(i + 1) - .getColumnWidth().getValue(tableLM); - } - } - LayoutContext childLC = new LayoutContext(0); - childLC.setStackLimit(context.getStackLimit()); //necessary? - childLC.setRefIPD(spanWidth); - - //Get the element list for the cell contents - LinkedList elems = primary.getCellLM().getNextKnuthElements( - childLC, alignment); - ElementListObserver.observe(elems, "table-cell", primary.getCell().getId()); - primary.setElements(elems); + int effectiveCellBPD = 0; + LengthRangeProperty cellBPD = primary.getCell().getBlockProgressionDimension(); + if (!cellBPD.getMinimum(tableLM).isAuto()) { + effectiveCellBPD = cellBPD.getMinimum(tableLM).getLength() + .getValue(tableLM); } - - //Calculate height of row, see CSS21, 17.5.3 Table height algorithms - if (gu.isLastGridUnitRowSpan()) { - // The effective cell's bpd, after taking into account bpd - // (possibly explicitly) set on the row or on the cell, and the - // cell's content length - int effectiveCellBPD = minRowBPD; - LengthRangeProperty cellBPD = primary.getCell() - .getBlockProgressionDimension(); - if (!cellBPD.getMinimum(tableLM).isAuto()) { - effectiveCellBPD = Math.max(effectiveCellBPD, - cellBPD.getMinimum(tableLM).getLength().getValue(tableLM)); - } - if (!cellBPD.getOptimum(tableLM).isAuto()) { - effectiveCellBPD = Math.max(effectiveCellBPD, - cellBPD.getOptimum(tableLM).getLength().getValue(tableLM)); - } - if (gu.getRowSpanIndex() == 0) { - //TODO ATM only non-row-spanned cells are taken for this - MinOptMaxUtil.restrict(explicitRowHeights[rgi], cellBPD, tableLM); - } - effectiveCellBPD = Math.max(effectiveCellBPD, - primary.getContentLength()); - - int borderWidths = primary.getBeforeAfterBorderWidth(); - int padding = 0; - maxCellBPD = Math.max(maxCellBPD, effectiveCellBPD); - CommonBorderPaddingBackground cbpb - = primary.getCell().getCommonBorderPaddingBackground(); - padding += cbpb.getPaddingBefore(false, primary.getCellLM()); - padding += cbpb.getPaddingAfter(false, primary.getCellLM()); - int effRowHeight = effectiveCellBPD - + padding + borderWidths; - for (int previous = 0; previous < gu.getRowSpanIndex(); previous++) { - effRowHeight -= rowHeights[rgi - previous - 1].opt; - } - if (effRowHeight > rowHeights[rgi].min) { - //This is the new height of the (grid) row - MinOptMaxUtil.extendMinimum(rowHeights[rgi], effRowHeight, false); - } + if (!cellBPD.getOptimum(tableLM).isAuto()) { + effectiveCellBPD = cellBPD.getOptimum(tableLM).getLength() + .getValue(tableLM); } - - if (gu.isPrimary()) { - pgus.add(primary); + if (gu.getRowSpanIndex() == 0) { + effectiveCellBPD = Math.max(effectiveCellBPD, explicitRowHeight.opt); + } + effectiveCellBPD = Math.max(effectiveCellBPD, primary.getContentLength()); + int borderWidths = primary.getBeforeAfterBorderWidth(); + int padding = 0; + CommonBorderPaddingBackground cbpb = primary.getCell() + .getCommonBorderPaddingBackground(); + padding += cbpb.getPaddingBefore(false, primary.getCellLM()); + padding += cbpb.getPaddingAfter(false, primary.getCellLM()); + int effRowHeight = effectiveCellBPD + padding + borderWidths; + for (int prev = rgi - 1; prev >= rgi - gu.getRowSpanIndex(); prev--) { + effRowHeight -= rowHeights[prev].opt; + } + if (effRowHeight > rowHeights[rgi].min) { + // This is the new height of the (grid) row + MinOptMaxUtil.extendMinimum(rowHeights[rgi], effRowHeight); } } } row.setHeight(rowHeights[rgi]); - row.setExplicitHeight(explicitRowHeights[rgi]); - if (maxCellBPD > row.getExplicitHeight().max) { - log.warn(FONode.decorateWithContextInfo( - "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.", - row.getTableRow())); - } - } - if (log.isDebugEnabled()) { - log.debug("rowGroup:"); - for (int i = 0; i < rowHeights.length; i++) { - log.debug(" height=" + rowHeights[i] + " explicit=" + explicitRowHeights[i]); + row.setExplicitHeight(explicitRowHeight); + // TODO re-enable and improve after clarification +// if (maxCellBPD > row.getExplicitHeight().max) { +// log.warn(FONode.decorateWithContextInfo( +// "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.", +// row.getTableRow())); +// } + if (log.isDebugEnabled()) { + log.debug(" height=" + rowHeights[rgi] + " explicit=" + explicitRowHeight); } } - LinkedList elements = tableStepper.getCombinedKnuthElementsForRowGroup(context, - rowGroup, bodyType); - returnList.addAll(elements); } } diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java index 022ff0589..bed9c53ae 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java @@ -23,25 +23,27 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.area.Block; import org.apache.fop.fo.flow.table.ConditionalBorder; import org.apache.fop.fo.flow.table.EffRow; import org.apache.fop.fo.flow.table.GridUnit; import org.apache.fop.fo.flow.table.PrimaryGridUnit; -import org.apache.fop.fo.flow.table.TableRow; +import org.apache.fop.fo.flow.table.TableBody; +import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthPossPosIter; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.SpaceResolver; +import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.traits.BorderProps; class RowPainter { private static Log log = LogFactory.getLog(RowPainter.class); - /** The fo:table-row containing the currently handled grid rows. */ - private TableRow rowFO = null; private int colCount; private int currentRowOffset = 0; /** Currently handled row (= last encountered row). */ @@ -71,6 +73,13 @@ class RowPainter { private CellPart[] firstCellParts; private CellPart[] lastCellParts; + /** y-offset of the current table part. */ + private int tablePartOffset = 0; + /** See {@link RowPainter#registerPartBackgroundArea(Block)}. */ + private CommonBorderPaddingBackground tablePartBackground; + /** See {@link RowPainter#registerPartBackgroundArea(Block)}. */ + private List tablePartBackgroundAreas; + private TableContentLayoutManager tclm; RowPainter(TableContentLayoutManager tclm, LayoutContext layoutContext) { @@ -85,6 +94,44 @@ class RowPainter { this.firstRowOnPageIndex = -1; } + void startTablePart(TableBody tablePart) { + CommonBorderPaddingBackground background = tablePart.getCommonBorderPaddingBackground(); + if (background.hasBackground()) { + tablePartBackground = background; + if (tablePartBackgroundAreas == null) { + tablePartBackgroundAreas = new ArrayList(); + } + } + tablePartOffset = currentRowOffset; + } + + /** + * 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 + * instead of normal, or rest if the cell is unfinished) + * @param lastOnPage true if the part is the last to be displayed on the current page. + * In which case collapsed after borders for the cells on the last row must be drawn + * in the outer mode + */ + void endTablePart(boolean lastInBody, boolean lastOnPage) { + addAreasAndFlushRow(lastInBody, lastOnPage); + + if (tablePartBackground != null) { + TableLayoutManager tableLM = tclm.getTableLM(); + for (Iterator iter = tablePartBackgroundAreas.iterator(); iter.hasNext();) { + Block backgroundArea = (Block) iter.next(); + TraitSetter.addBackground(backgroundArea, tablePartBackground, tableLM, + -backgroundArea.getXOffset(), tablePartOffset - backgroundArea.getYOffset(), + tableLM.getContentAreaIPD(), currentRowOffset - tablePartOffset); + } + tablePartBackground = null; + tablePartBackgroundAreas.clear(); + } + } + int getAccumulatedBPD() { return currentRowOffset; } @@ -108,7 +155,6 @@ class RowPainter { currentRow = row; } } - rowFO = currentRow.getTableRow(); if (firstRowIndex < 0) { firstRowIndex = currentRow.getIndex(); if (firstRowOnPageIndex < 0) { @@ -148,7 +194,7 @@ class RowPainter { * displayed on the current page. In which case collapsed after borders must be drawn * in the outer mode */ - void addAreasAndFlushRow(boolean lastInPart, boolean lastOnPage) { + private void addAreasAndFlushRow(boolean lastInPart, boolean lastOnPage) { if (log.isDebugEnabled()) { log.debug("Remembering yoffset for row " + currentRow.getIndex() + ": " + currentRowOffset); @@ -182,8 +228,6 @@ class RowPainter { } // Then add areas for cells finishing on the current row - tclm.addRowBackgroundArea(rowFO, actualRowHeight, layoutContext.getRefIPD(), - currentRowOffset); for (int i = 0; i < colCount; i++) { GridUnit currentGU = currentRow.getGridUnit(i); if (!currentGU.isEmpty() && currentGU.getColSpanIndex() == 0 @@ -255,18 +299,22 @@ class RowPainter { // cell, in most cases) return 0; } else { - int actualStart = startIndex; + ListIterator iter = pgu.getElements().listIterator(startIndex); // Skip from the content length calculation glues and penalties occurring at the // beginning of the page - while (actualStart <= endIndex - && !((KnuthElement) pgu.getElements().get(actualStart)).isBox()) { - actualStart++; + boolean nextIsBox = false; + while (iter.nextIndex() <= endIndex && !nextIsBox) { + nextIsBox = ((KnuthElement) iter.next()).isBox(); } - int len = ElementListUtils.calcContentLength( - pgu.getElements(), actualStart, endIndex); - KnuthElement el = (KnuthElement)pgu.getElements().get(endIndex); - if (el.isPenalty()) { - len += el.getW(); + int len = 0; + if (((KnuthElement) iter.previous()).isBox()) { + while (iter.nextIndex() < endIndex) { + KnuthElement el = (KnuthElement) iter.next(); + if (el.isBox() || el.isGlue()) { + len += el.getW(); + } + } + len += ActiveCell.getElementContentLength((KnuthElement) iter.next()); } return len; } @@ -278,8 +326,20 @@ class RowPainter { * Determine the index of the first row of this cell that will be displayed on the * current page. */ - int startRowIndex = Math.max(pgu.getRowIndex(), firstRowIndex); int currentRowIndex = currentRow.getIndex(); + int startRowIndex; + int firstRowHeight; + if (pgu.getRowIndex() >= firstRowIndex) { + startRowIndex = pgu.getRowIndex(); + if (startRowIndex < currentRowIndex) { + firstRowHeight = getRowOffset(startRowIndex + 1) - getRowOffset(startRowIndex); + } else { + firstRowHeight = rowHeight; + } + } else { + startRowIndex = firstRowIndex; + firstRowHeight = 0; + } /* * In collapsing-border model, if the cell spans over several columns/rows then @@ -319,7 +379,25 @@ class RowPainter { cellLM.addAreas(new KnuthPossPosIter(pgu.getElements(), startPos, endPos + 1), layoutContext, spannedGridRowHeights, startRowIndex - pgu.getRowIndex(), currentRowIndex - pgu.getRowIndex(), borderBeforeWhich, borderAfterWhich, - startRowIndex == firstRowOnPageIndex, lastOnPage); + startRowIndex == firstRowOnPageIndex, lastOnPage, this, firstRowHeight); + } + + + /** + * Registers the given area, that will be used to render the part of + * table-header/footer/body background covered by a table-cell. If percentages are + * used to place the background image, the final bpd of the (fraction of) table part + * that will be rendered on the current page must 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 + * {@link #addAreasAndFlushRow(boolean, boolean)}. + * + * @param backgroundArea the block of the cell's dimensions that will hold the part + * background + */ + void registerPartBackgroundArea(Block backgroundArea) { + tclm.getTableLM().addBackgroundArea(backgroundArea); + tablePartBackgroundAreas.add(backgroundArea); } /** @@ -357,11 +435,13 @@ class RowPainter { } // TODO get rid of that + /** Signals that the first table-body instance has started. */ void startBody() { Arrays.fill(firstCellOnPage, true); } // TODO get rid of that + /** Signals that the last table-body instance has ended. */ void endBody() { Arrays.fill(firstCellOnPage, false); } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java index 6d2e49e96..2e5bbdf1f 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java @@ -23,7 +23,6 @@ import org.apache.fop.fo.flow.table.TableAndCaption; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.Position; import org.apache.fop.area.Area; import org.apache.fop.area.Block; @@ -36,8 +35,7 @@ import org.apache.fop.area.Block; * @todo Implement getNextKnuthElements() */ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { - private TableAndCaption fobj; - + private Block curBlockArea; //private List childBreaks = new java.util.ArrayList(); @@ -48,7 +46,6 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { */ public TableAndCaptionLayoutManager(TableAndCaption node) { super(node); - fobj = node; } /** @@ -134,7 +131,7 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - getPSLM().addIDToPage(fobj.getId()); + addId(); /* TODO: Reimplement using Knuth approach LayoutManager childLM; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java index 4c21df937..674fd9a90 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java @@ -23,7 +23,6 @@ import org.apache.fop.fo.flow.table.TableCaption; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.Position; import org.apache.fop.area.Area; import org.apache.fop.area.Block; @@ -34,7 +33,6 @@ import org.apache.fop.area.Block; * @todo Implement getNextKnuthElements() */ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { - private TableCaption fobj; private Block curBlockArea; @@ -46,7 +44,6 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { */ public TableCaptionLayoutManager(TableCaption node) { super(node); - fobj = node; } /** @@ -133,7 +130,7 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - getPSLM().addIDToPage(fobj.getId()); + addId(); /* TODO: Reimplement using Knuth approach LayoutManager childLM; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index 289785d68..8acfebca0 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -23,16 +23,19 @@ import java.util.LinkedList; 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.area.Trait; import org.apache.fop.datatypes.PercentBaseContext; -import org.apache.fop.fo.FONode; import org.apache.fop.fo.flow.table.ConditionalBorder; import org.apache.fop.fo.flow.table.GridUnit; import org.apache.fop.fo.flow.table.PrimaryGridUnit; import org.apache.fop.fo.flow.table.Table; +import org.apache.fop.fo.flow.table.TableBody; import org.apache.fop.fo.flow.table.TableCell; +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.CommonBorderPaddingBackground.BorderInfo; import org.apache.fop.layoutmgr.AreaAdditionUtil; @@ -71,9 +74,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager private int xoffset; private int yoffset; private int cellIPD; - private int rowHeight; + private int totalHeight; private int usedBPD; - private int borderAndPaddingBPD; private boolean emptyCell = true; /** @@ -96,31 +98,11 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager return getTable().isSeparateBorderModel(); } - /** {@inheritDoc} */ - public void initialize() { - borderAndPaddingBPD = 0; - borderAndPaddingBPD += getTableCell() - .getCommonBorderPaddingBackground().getBorderBeforeWidth(false); - borderAndPaddingBPD += getTableCell() - .getCommonBorderPaddingBackground().getBorderAfterWidth(false); - if (!isSeparateBorderModel()) { - borderAndPaddingBPD /= 2; - } - borderAndPaddingBPD += getTableCell().getCommonBorderPaddingBackground() - .getPaddingBefore(false, this); - borderAndPaddingBPD += getTableCell().getCommonBorderPaddingBackground() - .getPaddingAfter(false, this); - } - /** * @return the table owning this cell */ public Table getTable() { - FONode node = fobj.getParent(); - while (!(node instanceof Table)) { - node = node.getParent(); - } - return (Table)node; + return getTableCell().getTable(); } @@ -148,13 +130,13 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager * {@inheritDoc} */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { - MinOptMax stackLimit = new MinOptMax(context.getStackLimit()); + MinOptMax stackLimit = new MinOptMax(context.getStackLimitBP()); referenceIPD = context.getRefIPD(); cellIPD = referenceIPD; cellIPD -= getIPIndents(); - LinkedList returnedList = null; + LinkedList returnedList; LinkedList contentList = new LinkedList(); LinkedList returnList = new LinkedList(); @@ -163,8 +145,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) { LayoutContext childLC = new LayoutContext(0); // curLM is a ? - childLC.setStackLimit(MinOptMax.subtract(context - .getStackLimit(), stackLimit)); + childLC.setStackLimitBP(MinOptMax.subtract(context + .getStackLimitBP(), stackLimit)); childLC.setRefIPD(cellIPD); // get elements from curLM @@ -260,7 +242,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager p.setP(0); } - getPSLM().notifyEndOfLayout(((TableCell)getFObj()).getId()); + getPSLM().notifyEndOfLayout(fobj.getId()); setFinished(true); return returnList; @@ -303,7 +285,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager * @param h the height of cell */ public void setTotalHeight(int h) { - rowHeight = h; + totalHeight = h; } /** @@ -330,6 +312,10 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager * which case collapsed before borders must be drawn in the outer mode * @param lastOnPage true if the cell will be the very last one on the page, in which * case collapsed after borders must be drawn in the outer mode + * @param painter painter + * @param firstRowHeight height of the first row spanned by this cell (may be zero if + * this row is placed on a previous page). Used to calculate the placement of the + * row's background image if any */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext, @@ -339,13 +325,25 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager int borderBeforeWhich, int borderAfterWhich, boolean firstOnPage, - boolean lastOnPage) { + boolean lastOnPage, + RowPainter painter, + int firstRowHeight) { getParentArea(null); - getPSLM().addIDToPage(getTableCell().getId()); + addId(); int borderBeforeWidth = primaryGridUnit.getBeforeBorderWidth(startRow, borderBeforeWhich); int borderAfterWidth = primaryGridUnit.getAfterBorderWidth(endRow, borderAfterWhich); + + CommonBorderPaddingBackground padding = primaryGridUnit.getCell() + .getCommonBorderPaddingBackground(); + int paddingRectBPD = totalHeight - borderBeforeWidth - borderAfterWidth; + int cellBPD = paddingRectBPD; + cellBPD -= padding.getPaddingBefore(borderBeforeWhich == ConditionalBorder.REST, this); + cellBPD -= padding.getPaddingAfter(borderAfterWhich == ConditionalBorder.REST, this); + + addBackgroundAreas(painter, firstRowHeight, borderBeforeWidth, paddingRectBPD); + if (isSeparateBorderModel()) { if (!emptyCell || getTableCell().showEmptyCells()) { if (borderBeforeWidth > 0) { @@ -421,7 +419,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager int dx = xoffset; for (int x = 0; x < gridUnits.length; x++) { int ipd = getTable().getColumn(primaryGridUnit.getColIndex() + x) - .getColumnWidth().getValue((PercentBaseContext) getParent()); + .getColumnWidth().getValue(getParent()); if (blocks[y][x] != null) { Block block = blocks[y][x]; adjustYOffset(block, dy); @@ -437,18 +435,12 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager } } - CommonBorderPaddingBackground padding = primaryGridUnit.getCell() - .getCommonBorderPaddingBackground(); TraitSetter.addPadding(curBlockArea, padding, borderBeforeWhich == ConditionalBorder.REST, borderAfterWhich == ConditionalBorder.REST, false, false, this); - int cellBPD = rowHeight - borderBeforeWidth - borderAfterWidth; - cellBPD -= padding.getPaddingBefore(borderBeforeWhich == ConditionalBorder.REST, this); - cellBPD -= padding.getPaddingAfter(borderAfterWhich == ConditionalBorder.REST, this); - //Handle display-align if (usedBPD < cellBPD) { if (getTableCell().getDisplayAlign() == EN_CENTER) { @@ -468,16 +460,9 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager curBlockArea.setBPD(cellBPD); // Add background after we know the BPD - if (isSeparateBorderModel()) { - if (!emptyCell || getTableCell().showEmptyCells()) { - TraitSetter.addBackground(curBlockArea, - getTableCell().getCommonBorderPaddingBackground(), - this); - } - } else { + if (!isSeparateBorderModel() || !emptyCell || getTableCell().showEmptyCells()) { TraitSetter.addBackground(curBlockArea, - getTableCell().getCommonBorderPaddingBackground(), - this); + getTableCell().getCommonBorderPaddingBackground(), this); } flush(); @@ -485,6 +470,33 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager curBlockArea = null; } + /** Adds background areas for the column, body and row, if any. */ + private void addBackgroundAreas(RowPainter painter, int firstRowHeight, int borderBeforeWidth, + int paddingRectBPD) { + TableColumn column = getTable().getColumn(primaryGridUnit.getColIndex()); + if (column.getCommonBorderPaddingBackground().hasBackground()) { + Block colBackgroundArea = getBackgroundArea(paddingRectBPD, borderBeforeWidth); + ((TableLayoutManager) parentLM).registerColumnBackgroundArea(column, colBackgroundArea, + -startIndent); + } + + TableBody body = primaryGridUnit.getTableBody(); + if (body.getCommonBorderPaddingBackground().hasBackground()) { + painter.registerPartBackgroundArea( + getBackgroundArea(paddingRectBPD, borderBeforeWidth)); + } + + TableRow row = primaryGridUnit.getRow(); + if (row != null && row.getCommonBorderPaddingBackground().hasBackground()) { + Block rowBackgroundArea = getBackgroundArea(paddingRectBPD, borderBeforeWidth); + ((TableLayoutManager) parentLM).addBackgroundArea(rowBackgroundArea); + TraitSetter.addBackground(rowBackgroundArea, row.getCommonBorderPaddingBackground(), + parentLM, + -xoffset - startIndent, -borderBeforeWidth, + parentLM.getContentAreaIPD(), firstRowHeight); + } + } + private void addBorder(Block[][] blocks, int i, int j, Integer side, BorderInfo border, boolean outer) { if (blocks[i][j] == null) { @@ -513,6 +525,21 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager block.setBPD(block.getBPD() + amount); } + private Block getBackgroundArea(int bpd, int borderBeforeWidth) { + 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); + block.setIPD(cellIPD + paddingStart + paddingEnd); + block.setBPD(bpd); + block.setXOffset(xoffset + startIndent - paddingStart); + block.setYOffset(yoffset + borderBeforeWidth); + return block; + } + /** * Return an Area which can contain the passed childArea. The childArea * may not yet have any content, but it has essential traits set. diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index b9a118e28..7cdeb79d5 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -27,8 +27,6 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.area.Block; -import org.apache.fop.area.Trait; import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; @@ -36,7 +34,6 @@ import org.apache.fop.fo.flow.table.EffRow; import org.apache.fop.fo.flow.table.PrimaryGridUnit; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; -import org.apache.fop.fo.flow.table.TableRow; import org.apache.fop.layoutmgr.BreakElement; import org.apache.fop.layoutmgr.ElementListUtils; import org.apache.fop.layoutmgr.KnuthBox; @@ -46,7 +43,6 @@ import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.ListElement; import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.PositionIterator; -import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.layoutmgr.SpaceResolver.SpaceHandlingBreakPosition; import org.apache.fop.util.BreakUtil; @@ -293,7 +289,7 @@ public class TableContentLayoutManager implements PercentBaseContext { this.usedBPD = 0; RowPainter painter = new RowPainter(this, layoutContext); - List positions = new java.util.ArrayList(); + List tablePositions = new ArrayList(); List headerElements = null; List footerElements = null; Position firstPos = null; @@ -330,7 +326,7 @@ public class TableContentLayoutManager implements PercentBaseContext { //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 } else if (pos instanceof TableContentPosition) { - positions.add(pos); + tablePositions.add(pos); } else { if (log.isDebugEnabled()) { log.debug("Ignoring position: " + pos); @@ -359,21 +355,23 @@ public class TableContentLayoutManager implements PercentBaseContext { 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 - PositionIterator nestedIter = new KnuthPossPosIter(headerElements); - iterateAndPaintPositions(nestedIter, painter, false); + addHeaderFooterAreas(headerElements, tableLM.getTable().getTableHeader(), painter, + false); } - //Iterate over all steps - Iterator posIter = positions.iterator(); - painter.startBody(); - // Here we are sure that posIter iterates only over TableContentPosition instances - iterateAndPaintPositions(posIter, painter, footerElements == null); - painter.endBody(); + if (tablePositions.isEmpty()) { + // TODO make sure this actually never happens + log.error("tablePositions empty." + + " Please send your FO file to fop-users@xmlgraphics.apache.org"); + } else { + // Here we are sure that posIter iterates only over TableContentPosition instances + addBodyAreas(tablePositions.iterator(), painter, footerElements == null); + } if (footerElements != null) { //Positions for footers are simply added at the end - PositionIterator nestedIter = new KnuthPossPosIter(footerElements); - iterateAndPaintPositions(nestedIter, painter, true); + addHeaderFooterAreas(footerElements, tableLM.getTable().getTableFooter(), painter, + true); } this.usedBPD += painter.getAccumulatedBPD(); @@ -384,105 +382,73 @@ public class TableContentLayoutManager implements PercentBaseContext { } } + private void addHeaderFooterAreas(List elements, TableBody part, RowPainter painter, + boolean lastOnPage) { + List lst = new ArrayList(elements.size()); + for (Iterator iter = new KnuthPossPosIter(elements); iter.hasNext();) { + Position pos = (Position) iter.next(); + /* + * Unlike for the body the Positions associated to the glues generated by + * TableStepper haven't been removed yet. + */ + if (pos instanceof TableContentPosition) { + lst.add((TableContentPosition) pos); + } + } + addTablePartAreas(lst, painter, part, true, true, true, lastOnPage); + } + /** - * Iterates over a part of the table (header, footer, body) and paints the related - * elements. + * 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 Position elements. Those positions correspond to the - * elements of the table present on the current page + * @param iterator iterator over TableContentPosition elements. Those positions + * correspond to the elements of the body present on the current page * @param painter - * @param lastOnPage true if the corresponding part will be the last on the page - * (either body or footer, obviously) + * @param lastOnPage true if the table has no footer (then the last line of the table + * that will be present on the page belongs to the body) */ - private void iterateAndPaintPositions(Iterator iterator, RowPainter painter, + private void addBodyAreas(Iterator iterator, RowPainter painter, boolean lastOnPage) { + painter.startBody(); List lst = new ArrayList(); - boolean firstPos = false; - TableBody body = null; + TableContentPosition pos = (TableContentPosition) iterator.next(); + boolean isFirstPos = pos.getFlag(TableContentPosition.FIRST_IN_ROWGROUP) + && pos.getRow().getFlag(EffRow.FIRST_IN_PART); + TableBody body = pos.getTableBody(); + lst.add(pos); while (iterator.hasNext()) { - Position pos = (Position)iterator.next(); - if (pos instanceof TableContentPosition) { - TableContentPosition tcpos = (TableContentPosition)pos; - lst.add(tcpos); - CellPart part = (CellPart)tcpos.cellParts.get(0); - if (body == null) { - body = part.pgu.getBody(); - } - if (tcpos.getFlag(TableContentPosition.FIRST_IN_ROWGROUP) - && tcpos.getRow().getFlag(EffRow.FIRST_IN_PART)) { - firstPos = true; - - } - if (tcpos.getFlag(TableContentPosition.LAST_IN_ROWGROUP) - && tcpos.getRow().getFlag(EffRow.LAST_IN_PART)) { - log.trace("LAST_IN_ROWGROUP + LAST_IN_PART"); - handleMarkersAndPositions(lst, body, firstPos, true, painter); - //reset - firstPos = false; - body = null; - lst.clear(); - } + pos = (TableContentPosition) iterator.next(); + if (pos.getTableBody() != body) { + addTablePartAreas(lst, painter, body, isFirstPos, true, false, false); + isFirstPos = true; + lst.clear(); + body = pos.getTableBody(); } + lst.add(pos); } - if (body != null) { - // Entering this block means that the end of the current table-part hasn't - // been reached (otherwise it would have been caught by the test above). So - // lastPos is necessarily false - handleMarkersAndPositions(lst, body, firstPos, false, painter); - } - painter.addAreasAndFlushRow(true, lastOnPage); - } - - private void handleMarkersAndPositions(List positions, TableBody body, boolean firstPos, - boolean lastPos, RowPainter painter) { - getTableLM().getCurrentPV().addMarkers(body.getMarkers(), - true, firstPos, lastPos); - int size = positions.size(); - for (int i = 0; i < size; i++) { - painter.handleTableContentPosition((TableContentPosition)positions.get(i)); - } - getTableLM().getCurrentPV().addMarkers(body.getMarkers(), - false, firstPos, lastPos); + boolean isLastPos = pos.getFlag(TableContentPosition.LAST_IN_ROWGROUP) + && pos.getRow().getFlag(EffRow.LAST_IN_PART); + addTablePartAreas(lst, painter, body, isFirstPos, isLastPos, true, lastOnPage); + painter.endBody(); } /** - * Get the area for a row for background. - * @param row the table-row object or null - * @return the row area or null if there's no background to paint + * Adds the areas corresponding to a single fo:table-header/footer/body element. */ - Block getRowArea(TableRow row) { - if (row == null || !row.getCommonBorderPaddingBackground().hasBackground()) { - return null; - } else { - Block block = new Block(); - block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); - block.setPositioning(Block.ABSOLUTE); - return block; + private void addTablePartAreas(List positions, RowPainter painter, TableBody body, + boolean isFirstPos, boolean isLastPos, boolean lastInBody, boolean lastOnPage) { + 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(), + false, isFirstPos, isLastPos); + painter.endTablePart(lastInBody, lastOnPage); } - /** - * Adds the area for the row background if any. - * @param row row for which to generate the background - * @param bpd block-progression-dimension of the row - * @param ipd inline-progression-dimension of the row - * @param yoffset Y offset at which to paint - */ - void addRowBackgroundArea(TableRow row, int bpd, int ipd, int yoffset) { - //Add row background if any - Block rowBackground = getRowArea(row); - if (rowBackground != null) { - rowBackground.setBPD(bpd); - rowBackground.setIPD(ipd); - rowBackground.setXOffset(this.startXOffset); - rowBackground.setYOffset(yoffset); - getTableLM().addChildArea(rowBackground); - TraitSetter.addBackground(rowBackground, - row.getCommonBorderPaddingBackground(), getTableLM()); - } - } - - /** * Sets the overall starting x-offset. Used for proper placement of cells. * @param startXOffset starting x-offset (table's start-indent) diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java index e702c58a9..260b8cfdf 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentPosition.java @@ -22,6 +22,7 @@ package org.apache.fop.layoutmgr.table; import java.util.List; import org.apache.fop.fo.flow.table.EffRow; +import org.apache.fop.fo.flow.table.TableBody; import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.layoutmgr.Position; @@ -79,6 +80,10 @@ class TableContentPosition extends Position { return row; } + TableBody getTableBody() { + return ((CellPart) cellParts.get(0)).pgu.getTableBody(); + } + /** * Returns a flag for this GridUnit. * @param which the requested flag @@ -101,10 +106,12 @@ class TableContentPosition extends Position { } } + /** {@inheritDoc} */ public boolean generatesAreas() { return true; } + /** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer("TableContentPosition:"); sb.append(getIndex()); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java index afa166985..3e504a45c 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableHFPenaltyPosition.java @@ -43,6 +43,11 @@ class TableHFPenaltyPosition extends Position { super(lm); } + /** {@inheritDoc} */ + public boolean generatesAreas() { + return true; + } + public String toString() { StringBuffer sb = new StringBuffer("TableHFPenaltyPosition:"); sb.append(getIndex()).append("("); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java b/src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java index c3ae72c74..8d3b993b2 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableHeaderFooterPosition.java @@ -48,6 +48,11 @@ class TableHeaderFooterPosition extends Position { this.nestedElements = nestedElements; } + /** {@inheritDoc} */ + public boolean generatesAreas() { + return true; + } + public String toString() { StringBuffer sb = new StringBuffer("Table"); sb.append(header ? "Header" : "Footer"); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index 1cbc3e50a..d6bba5cb5 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -19,8 +19,10 @@ package org.apache.fop.layoutmgr.table; +import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -79,7 +81,27 @@ public class TableLayoutManager extends BlockStackingLayoutManager private int halfBorderSeparationBPD; private int halfBorderSeparationIPD; - + + /** See {@link TableLayoutManager#registerColumnBackgroundArea(TableColumn, Block, int)}. */ + private List columnBackgroundAreas; + + /** + * Temporary holder of column background informations for a table-cell's area. + * + * @see TableLayoutManager#registerColumnBackgroundArea(TableColumn, Block, int) + */ + private static final class ColumnBackgroundInfo { + private TableColumn column; + private Block backgroundArea; + private int xShift; + + private ColumnBackgroundInfo(TableColumn column, Block backgroundArea, int xShift) { + this.column = column; + this.backgroundArea = backgroundArea; + this.xShift = xShift; + } + } + /** * Create a new table layout manager. * @param node the table FO @@ -211,7 +233,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager // Elements for the table-header/footer/body - LinkedList contentKnuthElements = null; + LinkedList contentKnuthElements; contentLM = new TableContentLayoutManager(this); LayoutContext childLC = new LayoutContext(0); /* @@ -263,7 +285,30 @@ public class TableLayoutManager extends BlockStackingLayoutManager resetSpaces(); return returnList; } - + + /** + * Registers the given area, that will be used to render the part of column background + * covered by a table-cell. If percentages are used to place the background image, the + * final bpd of the (fraction of) table that will be rendered on the current page must + * 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 + * background + * @param xShift additional amount by which the image must be shifted to be correctly + * placed (to counterbalance the cell's start border) + */ + void registerColumnBackgroundArea(TableColumn column, Block backgroundArea, int xShift) { + addBackgroundArea(backgroundArea); + if (columnBackgroundAreas == null) { + columnBackgroundAreas = new ArrayList(); + } + columnBackgroundAreas.add(new ColumnBackgroundInfo(column, backgroundArea, xShift)); + } + /** * The table area is a reference area that contains areas for * columns, bodies, rows and the contents are in cells. @@ -274,7 +319,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - getPSLM().addIDToPage(getTable().getId()); + addId(); // add space before, in order to implement display-align = "center" or "after" if (layoutContext.getSpaceBefore() != 0) { @@ -298,6 +343,17 @@ public class TableLayoutManager extends BlockStackingLayoutManager curBlockArea.setBPD(tableHeight); + if (columnBackgroundAreas != null) { + for (Iterator iter = columnBackgroundAreas.iterator(); iter.hasNext();) { + ColumnBackgroundInfo b = (ColumnBackgroundInfo) iter.next(); + TraitSetter.addBackground(b.backgroundArea, + b.column.getCommonBorderPaddingBackground(), this, + b.xShift, -b.backgroundArea.getYOffset(), + b.column.getColumnWidth().getValue(this), tableHeight); + } + columnBackgroundAreas.clear(); + } + if (getTable().isSeparateBorderModel()) { TraitSetter.addBorders(curBlockArea, getTable().getCommonBorderPaddingBackground(), @@ -323,7 +379,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager resetSpaces(); curBlockArea = null; - getPSLM().notifyEndOfLayout(((Table)getFObj()).getId()); + getPSLM().notifyEndOfLayout(fobj.getId()); } /** @@ -366,6 +422,15 @@ 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) { + curBlockArea.addChildArea(background); + } + /** {@inheritDoc} */ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { // TODO Auto-generated method stub diff --git a/src/java/org/apache/fop/pdf/PDFCMap.java b/src/java/org/apache/fop/pdf/PDFCMap.java index bdf8108c2..1be5e9dc4 100644 --- a/src/java/org/apache/fop/pdf/PDFCMap.java +++ b/src/java/org/apache/fop/pdf/PDFCMap.java @@ -21,7 +21,6 @@ package org.apache.fop.pdf; import java.io.IOException; import java.io.OutputStream; -import java.io.StringWriter; import java.io.Writer; /** @@ -425,10 +424,8 @@ public class PDFCMap extends PDFStream { /** {@inheritDoc} */ protected int output(OutputStream stream) throws IOException { - StringWriter writer = new StringWriter(); - CMapBuilder builder = createCMapBuilder(writer); + CMapBuilder builder = createCMapBuilder(getBufferWriter()); builder.writeCMap(); - add(writer.getBuffer().toString()); //TODO Could be optimized by not buffering return super.output(stream); } } diff --git a/src/java/org/apache/fop/pdf/PDFEncoding.java b/src/java/org/apache/fop/pdf/PDFEncoding.java index b2fba6e53..6dc448b40 100644 --- a/src/java/org/apache/fop/pdf/PDFEncoding.java +++ b/src/java/org/apache/fop/pdf/PDFEncoding.java @@ -131,6 +131,14 @@ public class PDFEncoding extends PDFDictionary { return this; } + /** + * Indicates whether any differences have been recorded. + * @return true if there are differences. + */ + public boolean hasDifferences() { + return (this.differences.length() > 0); + } + /** * Creates and returns the PDFArray representing the Differences entry. * @return the Differences entry diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index 687b32016..f4474331f 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -43,6 +43,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.xmp.Metadata; import org.apache.fop.fonts.CIDFont; +import org.apache.fop.fonts.CIDSubset; import org.apache.fop.fonts.CodePointMapping; import org.apache.fop.fonts.CustomFont; import org.apache.fop.fonts.FontDescriptor; @@ -50,6 +51,8 @@ import org.apache.fop.fonts.FontMetrics; import org.apache.fop.fonts.FontType; import org.apache.fop.fonts.LazyFont; import org.apache.fop.fonts.MultiByteFont; +import org.apache.fop.fonts.SimpleSingleByteEncoding; +import org.apache.fop.fonts.SingleByteEncoding; import org.apache.fop.fonts.SingleByteFont; import org.apache.fop.fonts.Typeface; import org.apache.fop.fonts.truetype.FontFileReader; @@ -1166,7 +1169,7 @@ public class PDFFactory { } /** - * make a Type1 /Font object + * Make a Type1 /Font object. * * @param fontname internal name to use for this font (eg "F1") * @param basefont name of the base font (eg "Helvetica") @@ -1217,10 +1220,12 @@ public class PDFFactory { (PDFCIDFontDescriptor)pdfdesc); getDocument().registerObject(cidFont); - PDFCMap cmap = new PDFToUnicodeCMap(cidMetrics.getCharsUsed(), "fop-ucs-H", - new PDFCIDSystemInfo("Adobe", - "Identity", - 0)); + PDFCMap cmap = new PDFToUnicodeCMap( + cidMetrics.getCIDSubset().getSubsetChars(), + "fop-ucs-H", + new PDFCIDSystemInfo("Adobe", + "Identity", + 0)); getDocument().registerObject(cmap); ((PDFFontType0)font).setCMAP(cmap); ((PDFFontType0)font).setDescendantFonts(cidFont); @@ -1238,35 +1243,20 @@ public class PDFFactory { int lastChar = singleByteFont.getLastChar(); nonBase14.setWidthMetrics(firstChar, lastChar, - makeArray(metrics.getWidths())); + new PDFArray(null, metrics.getWidths())); //Handle encoding - CodePointMapping mapping = singleByteFont.getCodePointMapping(); + SingleByteEncoding mapping = singleByteFont.getEncoding(); if (PDFEncoding.isPredefinedEncoding(mapping.getName())) { font.setEncoding(mapping.getName()); } else { - CodePointMapping winansi = CodePointMapping.getMapping( - CodePointMapping.WIN_ANSI_ENCODING); - PDFEncoding pdfEncoding = new PDFEncoding(winansi.getName()); - PDFEncoding.DifferencesBuilder builder - = pdfEncoding.createDifferencesBuilder(); - int start = -1; - String[] winansiNames = winansi.getCharNameMap(); - String[] charNameMap = mapping.getCharNameMap(); - for (int i = 0; i < 256; i++) { - String wac = winansiNames[i]; - String c = charNameMap[i]; - if (!wac.equals(c)) { - if (start != i) { - builder.addDifference(i); - start = i; - } - builder.addName(c); - start++; - } + Object pdfEncoding = createPDFEncoding(mapping, + singleByteFont.getFontName()); + if (pdfEncoding instanceof PDFEncoding) { + font.setEncoding((PDFEncoding)pdfEncoding); + } else { + font.setEncoding((String)pdfEncoding); } - pdfEncoding.setDifferences(builder.toPDFArray()); - font.setEncoding(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 @@ -1278,21 +1268,88 @@ 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++) { + SimpleSingleByteEncoding addEncoding + = singleByteFont.getAdditionalEncoding(i); + String name = fontname + "_" + (i + 1); + Object pdfenc = createPDFEncoding(addEncoding, + singleByteFont.getFontName()); + PDFFontNonBase14 addFont = (PDFFontNonBase14)PDFFont.createFont( + name, fonttype, + basefont, pdfenc); + addFont.setDescriptor(pdfdesc); + addFont.setWidthMetrics( + addEncoding.getFirstChar(), + addEncoding.getLastChar(), + new PDFArray(null, singleByteFont.getAdditionalWidths(i))); + getDocument().registerObject(addFont); + getDocument().getResources().addFont(addFont); + } + } } return font; } } + /** + * Creates a PDFEncoding instance from a CodePointMapping instance. + * @param encoding the code point mapping (encoding) + * @return the PDF Encoding dictionary (or a String with the predefined encoding) + */ + public Object createPDFEncoding(SingleByteEncoding encoding, String fontNameHint) { + SingleByteEncoding baseEncoding; + if (fontNameHint.indexOf("Symbol") >= 0) { + baseEncoding = CodePointMapping.getMapping( + CodePointMapping.SYMBOL_ENCODING); + } else { + baseEncoding = CodePointMapping.getMapping( + CodePointMapping.STANDARD_ENCODING); + } + PDFEncoding pdfEncoding = new PDFEncoding(baseEncoding.getName()); + PDFEncoding.DifferencesBuilder builder + = pdfEncoding.createDifferencesBuilder(); + int start = -1; + String[] baseNames = baseEncoding.getCharNameMap(); + String[] charNameMap = encoding.getCharNameMap(); + for (int i = 0, ci = charNameMap.length; i < ci; i++) { + String basec = baseNames[i]; + String c = charNameMap[i]; + if (!basec.equals(c)) { + if (start != i) { + builder.addDifference(i); + start = i; + } + builder.addName(c); + start++; + } + } + if (builder.hasDifferences()) { + pdfEncoding.setDifferences(builder.toPDFArray()); + return pdfEncoding; + } else { + return baseEncoding.getName(); + } + } + + /** + * Creates and returns a width array with the widths of all the characters in the subset. + * @param cidFont the font + * @return the width array + */ public PDFWArray getSubsetWidths(CIDFont cidFont) { // Create widths for reencoded chars PDFWArray warray = new PDFWArray(); - int[] tmpWidth = new int[cidFont.usedGlyphsCount]; + int[] widths = cidFont.getWidths(); + CIDSubset subset = cidFont.getCIDSubset(); + int[] tmpWidth = new int[subset.getSubsetSize()]; - for (int i = 0; i < cidFont.usedGlyphsCount; i++) { - Integer nw = (Integer)cidFont.usedGlyphsIndex.get(new Integer(i)); - int nwx = (nw == null) ? 0 : nw.intValue(); - tmpWidth[i] = cidFont.width[nwx]; + for (int i = 0, c = subset.getSubsetSize(); i < c; i++) { + int nwx = Math.max(0, subset.getGlyphIndexForSubsetIndex(i)); + tmpWidth[i] = widths[nwx]; } warray.addEntry(0, tmpWidth); return warray; @@ -1345,12 +1402,7 @@ public class PDFFactory { } private void buildCIDSet(PDFFontDescriptor descriptor, CIDFont cidFont) { - BitSet cidSubset = new BitSet(); - Iterator iter = cidFont.usedGlyphs.keySet().iterator(); - while (iter.hasNext()) { - Integer cid = (Integer)iter.next(); - cidSubset.set(cid.intValue()); - } + BitSet cidSubset = cidFont.getCIDSubset().getGlyphIndexBitSet(); PDFStream cidSet = makeStream(null, true); ByteArrayOutputStream baout = new ByteArrayOutputStream(cidSubset.length() / 8 + 1); int value = 0; @@ -1548,14 +1600,13 @@ public class PDFFactory { } /** - * make an Array object (ex. Widths array for a font) + * Make an Array object (ex. Widths array for a font). * * @param values the int array values * @return the PDF Array with the int values */ public PDFArray makeArray(int[] values) { PDFArray array = new PDFArray(null, values); - getDocument().registerObject(array); return array; } diff --git a/src/java/org/apache/fop/pdf/PDFResources.java b/src/java/org/apache/fop/pdf/PDFResources.java index 66ccdc78b..b0c0128e1 100644 --- a/src/java/org/apache/fop/pdf/PDFResources.java +++ b/src/java/org/apache/fop/pdf/PDFResources.java @@ -110,7 +110,7 @@ public class PDFResources extends PDFObject { desc = (FontDescriptor)font; } addFont(doc.getFactory().makeFont( - f, font.getEmbedFontName(), font.getEncoding(), font, desc)); + f, font.getEmbedFontName(), font.getEncodingName(), font, desc)); } } } diff --git a/src/java/org/apache/fop/pdf/PDFStream.java b/src/java/org/apache/fop/pdf/PDFStream.java index 59a8336c5..a213340e3 100644 --- a/src/java/org/apache/fop/pdf/PDFStream.java +++ b/src/java/org/apache/fop/pdf/PDFStream.java @@ -19,8 +19,9 @@ package org.apache.fop.pdf; -import java.io.OutputStream; import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; /** * Class representing a PDF stream. @@ -37,6 +38,8 @@ public class PDFStream extends AbstractPDFStream { */ protected StreamCache data; + private transient Writer streamWriter; + /** * Create an empty stream object */ @@ -44,6 +47,10 @@ public class PDFStream extends AbstractPDFStream { super(); try { data = StreamCacheFactory.getInstance().createStreamCache(); + this.streamWriter = new java.io.OutputStreamWriter( + getBufferOutputStream(), PDFDocument.ENCODING); + //Buffer to minimize calls to the converter + this.streamWriter = new java.io.BufferedWriter(this.streamWriter); } catch (IOException ex) { //TODO throw the exception and catch it elsewhere ex.printStackTrace(); @@ -57,14 +64,25 @@ public class PDFStream extends AbstractPDFStream { */ public void add(String s) { try { - data.getOutputStream().write(PDFDocument.encode(s)); + this.streamWriter.write(s); } catch (IOException ex) { //TODO throw the exception and catch it elsewhere ex.printStackTrace(); } - + } + + private void flush() throws IOException { + this.streamWriter.flush(); } + /** + * Returns a Writer that writes to the OutputStream of the buffer. + * @return the Writer + */ + public Writer getBufferWriter() { + return this.streamWriter; + } + /** * Returns an OutputStream that can be used to write to the buffer which is used * to build up the PDF stream. @@ -72,6 +90,9 @@ public class PDFStream extends AbstractPDFStream { * @throws IOException In case of an I/O problem */ public OutputStream getBufferOutputStream() throws IOException { + if (this.streamWriter != null) { + flush(); //Just to be sure + } return this.data.getOutputStream(); } @@ -91,6 +112,7 @@ public class PDFStream extends AbstractPDFStream { */ public int getDataLength() { try { + flush(); return data.getSize(); } catch (Exception e) { //TODO throw the exception and catch it elsewhere @@ -99,17 +121,15 @@ public class PDFStream extends AbstractPDFStream { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected int getSizeHint() throws IOException { + flush(); return data.getSize(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void outputRawStreamData(OutputStream out) throws IOException { + flush(); data.outputContents(out); } diff --git a/src/java/org/apache/fop/pdf/PDFTTFStream.java b/src/java/org/apache/fop/pdf/PDFTTFStream.java index b3488f6a1..5570c62f3 100644 --- a/src/java/org/apache/fop/pdf/PDFTTFStream.java +++ b/src/java/org/apache/fop/pdf/PDFTTFStream.java @@ -67,7 +67,7 @@ public class PDFTTFStream extends PDFStream { */ public void setData(byte[] data, int size) throws IOException { this.data.clear(); - this.data.getOutputStream().write(data, 0, size); + getBufferOutputStream().write(data, 0, size); } } diff --git a/src/java/org/apache/fop/pdf/PDFTextUtil.java b/src/java/org/apache/fop/pdf/PDFTextUtil.java new file mode 100644 index 000000000..224bb6a1d --- /dev/null +++ b/src/java/org/apache/fop/pdf/PDFTextUtil.java @@ -0,0 +1,295 @@ +/* + * 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.pdf; + +import java.awt.geom.AffineTransform; + +/** + * Utility class for generating PDF text objects. It needs to be subclassed to add writing + * functionality (see {@link #write(String)}). + */ +public abstract class PDFTextUtil { + + /** 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 */ + public static final int TR_STROKE = 1; + /** PDF text rendering mode: Fill, then stroke text */ + public static final int TR_FILL_STROKE = 2; + /** PDF text rendering mode: Neither fill nor stroke text (invisible) */ + public static final int TR_INVISIBLE = 3; + /** PDF text rendering mode: Fill text and add to path for clipping */ + public static final int TR_FILL_CLIP = 4; + /** PDF text rendering mode: Stroke text and add to path for clipping */ + public static final int TR_STROKE_CLIP = 5; + /** PDF text rendering mode: Fill, then stroke text and add to path for clipping */ + 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); + sb.append(PDFNumber.doubleOut(lt[0], DEC)).append(" "); + sb.append(PDFNumber.doubleOut(lt[1], DEC)).append(" "); + sb.append(PDFNumber.doubleOut(lt[2], DEC)).append(" "); + sb.append(PDFNumber.doubleOut(lt[3], DEC)).append(" "); + sb.append(PDFNumber.doubleOut(lt[4], DEC)).append(" "); + sb.append(PDFNumber.doubleOut(lt[5], DEC)); + } + + private void writeChar(char ch, StringBuffer sb) { + if (!useMultiByte) { + if (ch < 32 || ch > 127) { + sb.append("\\").append(Integer.toOctalString((int)ch)); + } else { + switch (ch) { + case '(': + case ')': + case '\\': + sb.append("\\"); + break; + default: + } + sb.append(ch); + } + } else { + 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 + */ + 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. + */ + public void beginTextObject() { + if (inTextObject) { + throw new IllegalStateException("Already in text object"); + } + write("BT\n"); + this.inTextObject = true; + } + + /** + * Called when a text object should be ended. + */ + public void endTextObject() { + checkInTextObject(); + write("ET\n"); + this.inTextObject = false; + initValues(); + } + + /** + * Resets the state fields. + */ + protected void initValues() { + this.currentFontName = null; + 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. + */ + public void restoreGraphicsState() { + write("Q\n"); + } + + /** + * Creates a "cm" command. + * @param at the transformation matrix + */ + public void concatMatrix(AffineTransform at) { + if (!at.isIdentity()) { + writeTJ(); + StringBuffer sb = new StringBuffer(); + writeAffineTransform(at, sb); + sb.append(" cm\n"); + write(sb.toString()); + } + } + + /** + * Writes a "Tf" command, setting a new current font. + * @param fontName the name of the font to select + * @param fontSize the font size (in points) + */ + public void writeTf(String fontName, double fontSize) { + checkInTextObject(); + write("/" + fontName + " " + PDFNumber.doubleOut(fontSize) + " Tf\n"); + + this.startText = useMultiByte ? "<" : "("; + this.endText = useMultiByte ? ">" : ")"; + } + + /** + * Updates the current font. This method only writes a "Tf" if the current font changes. + * @param fontName the name of the font to select + * @param fontSize the font size (in points) + * @param multiByte true indicates the font is a multi-byte font, false means single-byte + */ + public void updateTf(String fontName, double fontSize, boolean multiByte) { + checkInTextObject(); + if (!fontName.equals(this.currentFontName) || (fontSize != this.currentFontSize)) { + writeTJ(); + this.currentFontName = fontName; + this.currentFontSize = fontSize; + this.useMultiByte = multiByte; + writeTf(fontName, fontSize); + } + } + + /** + * Sets the text rendering mode. + * @param mode the rendering mode (value 0 to 7, see PDF Spec, constants: TR_*) + */ + public void setTextRenderingMode(int mode) { + if (mode < 0 || mode > 7) { + throw new IllegalArgumentException( + "Illegal value for text rendering mode. Expected: 0-7"); + } + if (mode != this.textRenderingMode) { + writeTJ(); + this.textRenderingMode = mode; + write(this.textRenderingMode + " Tr\n"); + } + } + + /** + * Sets the text rendering mode. + * @param fill true if the text should be filled + * @param stroke true if the text should be stroked + * @param addToClip true if the path should be added for clipping + */ + public void setTextRenderingMode(boolean fill, boolean stroke, boolean addToClip) { + int mode; + if (fill) { + mode = (stroke ? 2 : 0); + } else { + mode = (stroke ? 1 : 3); + } + if (addToClip) { + mode += 4; + } + setTextRenderingMode(mode); + } + + /** + * Writes a "Tm" command, setting a new text transformation matrix. + * @param localTransform the new text transformation matrix + */ + public void writeTextMatrix(AffineTransform localTransform) { + StringBuffer sb = new StringBuffer(); + writeAffineTransform(localTransform, sb); + sb.append(" Tm "); + write(sb.toString()); + } + + /** + * Writes a char to the "TJ-Buffer". + * @param codepoint the mapped character (code point/character code) + */ + public void writeTJMappedChar(char codepoint) { + if (bufTJ == null) { + bufTJ = new StringBuffer(); + } + if (bufTJ.length() == 0) { + bufTJ.append("[").append(startText); + } + writeChar(codepoint, bufTJ); + } + + /** + * Writes a glyph adjust value to the "TJ-Buffer". + * @param adjust the glyph adjust value in thousands of text unit space. + */ + public void adjustGlyphTJ(double adjust) { + bufTJ.append(endText).append(" "); + bufTJ.append(PDFNumber.doubleOut(adjust, DEC - 4)); + bufTJ.append(" "); + bufTJ.append(startText); + } + + /** + * Writes a "TJ" command, writing out the accumulated buffer with the characters and glyph + * positioning values. The buffer is reset afterwards. + */ + public void writeTJ() { + if (isInString()) { + bufTJ.append(endText).append("] TJ\n"); + write(bufTJ.toString()); + bufTJ.setLength(0); + } + } + + private boolean isInString() { + return bufTJ != null && bufTJ.length() > 0; + } + +} diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index f74699fd5..c0c9ce88c 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -47,7 +47,7 @@ import org.apache.fop.svg.SVGUserAgent; public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererContextConstants { /** logging instance */ - private static Log log = LogFactory.getLog(AbstractGenericSVGHandler.class); + protected static Log log = LogFactory.getLog(AbstractGenericSVGHandler.class); /** {@inheritDoc} */ public void handleXML(RendererContext context, diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index b10f4b30f..cb3d3a433 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -940,10 +940,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { int x = origin.x + posInt.x; int y = origin.y + posInt.y; - String name = null; - if (pageSegmentsMap != null) { - name = (String) pageSegmentsMap.get(uri); - } + String name = (String)getPageSegments().get(uri); if (name != null) { afpDataStream.createIncludePageSegment(name, mpts2units(x), mpts2units(y)); } else { @@ -1543,6 +1540,13 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { return MimeConstants.MIME_AFP; } + private Map getPageSegments() { + if (pageSegmentsMap == null) { + pageSegmentsMap = new java.util.HashMap(); + } + return pageSegmentsMap; + } + /** * Method to render the page extension. *

      @@ -1571,17 +1575,11 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { .equals(element)) { String name = aps.getName(); String source = aps.getValue(); - if (pageSegmentsMap == null) { - pageSegmentsMap = new java.util.HashMap(); - } - pageSegmentsMap.put(source, name); + getPageSegments().put(source, name); } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT .equals(element)) { String name = aps.getName(); String value = aps.getValue(); - if (pageSegmentsMap == null) { - pageSegmentsMap = new java.util.HashMap(); - } afpDataStream.createTagLogicalElement(name, value); } else if (AFPElementMapping.NO_OPERATION.equals(element)) { String content = aps.getContent(); @@ -1589,7 +1587,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { afpDataStream.createNoOperation(content); } } else if (AFPElementMapping.RESOURCE.equals(element)) { - System.out.println("resource: " + attachment); + log.info("resource: " + attachment); } } } diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index 4c8a3dc9f..cde464ba5 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java @@ -234,8 +234,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator { Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false); if (rendererResolutionCfg != null) { - afpRenderer.setResolution(rendererResolutionCfg.getValueAsInteger( - AFPRenderer.DPI_240_RESOLUTION)); + afpRenderer.setResolution(rendererResolutionCfg.getValueAsInteger(240)); } Configuration gocaSupportCfg = cfg.getChild("goca-enabled", false); diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index 2641e6fbe..1d469ea94 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -49,9 +49,6 @@ import org.w3c.dom.Document; */ public class AFPSVGHandler extends AbstractGenericSVGHandler { - /** logging instance */ - private static Log log = LogFactory.getLog(AFPSVGHandler.class); - /** {@inheritDoc} */ public void handleXML(RendererContext context, Document doc, String ns) throws Exception { @@ -196,7 +193,10 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { } /** {@inheritDoc} */ - public String getNamespace() { - return SVGDOMImplementation.SVG_NAMESPACE_URI; + protected void updateRendererContext(RendererContext context) { + //Work around a problem in Batik: Gradients cannot be done in ColorSpace.CS_GRAY + context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE, + Boolean.FALSE); } + } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPElement.java b/src/java/org/apache/fop/render/afp/extensions/AFPElement.java index 808cd88f1..659c79a8e 100755 --- a/src/java/org/apache/fop/render/afp/extensions/AFPElement.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPElement.java @@ -55,7 +55,8 @@ public class AFPElement extends AbstractAFPExtensionObject { } } - protected ExtensionAttachment instantiateExtensionAttachment() { - return null; - } + protected ExtensionAttachment instantiateExtensionAttachment() { + return new AFPPageSetup(getName()); + } + } diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java b/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java index 8d4b0ae5e..ad80399e3 100755 --- a/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java @@ -19,8 +19,6 @@ package org.apache.fop.render.afp.extensions; -import java.util.HashMap; - import org.apache.fop.fo.ElementMapping; import org.apache.fop.fo.FONode; @@ -39,7 +37,7 @@ public class AFPElementMapping extends ElementMapping { public static final String PAGE = "page"; /** page group element */ - public static final String PAGE_GROUP = "page-group"; +// public static final String PAGE_GROUP = "page-group"; /** tag logical element */ public static final String TAG_LOGICAL_ELEMENT = "tag-logical-element"; @@ -78,9 +76,12 @@ public class AFPElementMapping extends ElementMapping { protected void initialize() { if (foObjs == null) { - foObjs = new HashMap(); + super.foObjs = new java.util.HashMap(); foObjs.put(PAGE, new AFPPageSetupMaker()); - // foObjs.put(PAGE_GROUP, new AFPMaker()); +// foObjs.put( +// PAGE_GROUP, +// new AFPPageGroupMaker() +// ); foObjs.put( TAG_LOGICAL_ELEMENT, new AFPTagLogicalElementMaker()); @@ -94,7 +95,6 @@ public class AFPElementMapping extends ElementMapping { NO_OPERATION, new AFPNoOperationMaker()); } - } static class AFPPageSetupMaker extends ElementMapping.Maker { @@ -126,4 +126,10 @@ public class AFPElementMapping extends ElementMapping { return new AFPElement(parent, NO_OPERATION); } } + +// static class AFPPageGroupMaker extends ElementMapping.Maker { +// public FONode make(FONode parent) { +// return new AFPElement(parent, PAGE_GROUP); +// } +// } } 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 7fdf7cd11..fca486279 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java @@ -54,7 +54,7 @@ public class AFPExtensionHandler extends DefaultHandler || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY) || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT) || localName.equals(AFPElementMapping.PAGE) - || localName.equals(AFPElementMapping.PAGE_GROUP)) { + /*|| localName.equals(AFPElementMapping.PAGE_GROUP)*/) { //handled in endElement } else { handled = false; diff --git a/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java b/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java index 57886f89c..f8dd9a1ed 100644 --- a/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java +++ b/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java @@ -174,11 +174,8 @@ public class OutlineFont extends AFPFont { return charSet.mapChar(c); } - /** - * Get the encoding of the font. - * @return the encoding - */ - public String getEncoding() { + /** {@inheritDoc} */ + public String getEncodingName() { return charSet.getEncoding(); } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/fonts/RasterFont.java b/src/java/org/apache/fop/render/afp/fonts/RasterFont.java index a61f97ab5..44dcd0e9f 100644 --- a/src/java/org/apache/fop/render/afp/fonts/RasterFont.java +++ b/src/java/org/apache/fop/render/afp/fonts/RasterFont.java @@ -229,11 +229,8 @@ public class RasterFont extends AFPFont { return charSet.mapChar(c); } - /** - * Get the encoding of the font. - * @return the encoding - */ - public String getEncoding() { + /** {@inheritDoc} */ + public String getEncodingName() { return charSet.getEncoding(); } diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java index 26d42b2d4..106454ad6 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java @@ -44,7 +44,7 @@ public abstract class AbstractAFPObject { * DataStream objects must implement the writeDataStream() * method to write its data to the given OutputStream * @param os The outputsteam stream - * @throws java.io.IOException in the event that an I/O exception occurred + * @throws java.io.IOException */ public abstract void writeDataStream(OutputStream os) throws IOException; @@ -52,10 +52,10 @@ public abstract class AbstractAFPObject { * Help method to write a set of AFPObjects to the AFP datastream. * @param objects a list of AFPObjects * @param os The stream to write to - * @throws java.io.IOException in the event that an I/O exception occurred + * @throws java.io.IOException */ protected void writeObjects(Collection/**/ objects, OutputStream os) - throws IOException { + throws IOException { if (objects != null) { for (Iterator it = objects.iterator(); it.hasNext();) { Object obj1 = it.next(); @@ -63,5 +63,7 @@ public abstract class AbstractAFPObject { obj.writeDataStream(os); } } + } -} \ No newline at end of file +} + 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 29c619d32..6d827766e 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java @@ -28,22 +28,22 @@ public abstract class AbstractDescriptor extends AbstractAFPObject { /** height of this descriptor */ protected int height = 0; /** width resolution of this descriptor */ - protected int widthRes = 0; + protected int widthResolution = 0; /** height resolution of this descriptor */ - protected int heightRes = 0; + protected int heightResolution = 0; /** * Constructor a PresentationTextDescriptor for the specified * width and height. * @param width The width of the page. * @param height The height of the page. - * @param widthRes The width resolution of the page. - * @param heightRes The height resolution of the page. + * @param widthResolution The width resolution of the page. + * @param heightResolution The height resolution of the page. */ - public AbstractDescriptor(int width, int height, int widthRes, int heightRes) { + public AbstractDescriptor(int width, int height, int widthResolution, int heightResolution) { this.width = width; this.height = height; - this.widthRes = widthRes; - this.heightRes = heightRes; + this.widthResolution = widthResolution; + this.heightResolution = heightResolution; } } 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 393cff84b..09fa33f8f 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java @@ -38,7 +38,7 @@ public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject * The name of the object in EBCIDIC bytes */ protected byte[] nameBytes; - + /** * Default constructor */ @@ -51,19 +51,17 @@ public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject * @param name the object name */ protected AbstractNamedAFPObject(String name) { - int nameLen = getNameLength(); - if (name.length() < nameLen) { - this.name = (name + " ").substring(0, nameLen); - } else if (name.length() > nameLen) { - log.warn("Constructor:: name truncated to " + nameLen + " chars: " + name); - this.name = name.substring(0, nameLen); - } else { - this.name = name; + this.name = name; + if (name.length() < 8) { + name = (name + " ").substring(0, 8); + } else if (name.length() > 8) { + log.warn("Constructor:: name truncated to 8 chars" + name); + name = name.substring(0, 8); } try { - this.nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); + nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); } catch (UnsupportedEncodingException usee) { - this.nameBytes = name.getBytes(); + nameBytes = name.getBytes(); log.warn( "Constructor:: UnsupportedEncodingException translating the name " + name); @@ -82,5 +80,6 @@ public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject */ public String getName() { return name; - } + } + } diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java index f373b5bf7..984aa44c9 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java @@ -310,7 +310,7 @@ public abstract class AbstractPageObject extends AbstractResourceGroupContainer private PresentationTextObject getPresentationTextObject() { if (presentationTextObject == null) { this.presentationTextObject = new PresentationTextObject(); - addObject(this.presentationTextObject); + super.addObject(this.presentationTextObject); } return presentationTextObject; } diff --git a/src/java/org/apache/fop/render/afp/modca/ImageContent.java b/src/java/org/apache/fop/render/afp/modca/ImageContent.java index 4aea02901..726c58762 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageContent.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageContent.java @@ -18,13 +18,11 @@ /* $Id$ */ package org.apache.fop.render.afp.modca; - import java.io.IOException; import java.io.OutputStream; import org.apache.fop.render.afp.tools.BinaryUtils; /** - * Image content IOCA object */ public class ImageContent extends AbstractStructuredAFPObject { @@ -55,27 +53,27 @@ public class ImageContent extends AbstractStructuredAFPObject { /** * The image size parameter */ - private ImageSizeParameter imageSizeParam = null; + private ImageSizeParameter _imageSizeParameter = null; /** * The image encoding */ - private byte encoding = 0x03; + private byte _encoding = 0x03; /** * The image ide size */ - private byte size = 1; + private byte _size = 1; /** * The image compression */ - private byte compression = (byte)0xC0; + private byte _compression = (byte)0xC0; /** * The image color model */ - private byte colorModel = 0x01; + private byte _colorModel = 0x01; /** * The image data @@ -97,39 +95,39 @@ public class ImageContent extends AbstractStructuredAFPObject { * @param vsize The vertival size of the image. */ public void setImageSize(int hresol, int vresol, int hsize, int vsize) { - this.imageSizeParam = new ImageSizeParameter(hresol, vresol, hsize, vsize); + _imageSizeParameter = new ImageSizeParameter(hresol, vresol, hsize, vsize); } /** * Sets the image encoding. - * @param enc The image encoding. + * @param encoding The image encoding. */ - public void setImageEncoding(byte enc) { - this.encoding = enc; + public void setImageEncoding(byte encoding) { + _encoding = encoding; } /** * Sets the image compression. - * @param comp The image compression. + * @param compression The image compression. */ - public void setImageCompression(byte comp) { - this.compression = comp; + public void setImageCompression(byte compression) { + _compression = compression; } /** * Sets the image IDE size. - * @param siz The IDE size. + * @param size The IDE size. */ - public void setImageIDESize(byte siz) { - this.size = siz; + public void setImageIDESize(byte size) { + _size = size; } /** * Sets the image IDE color model. - * @param model the IDE color model. + * @param colorModel the IDE color model. */ - public void setImageIDEColorModel(byte model) { - this.colorModel = model; + public void setImageIDEColorModel(byte colorModel) { + _colorModel = colorModel; } /** @@ -144,8 +142,8 @@ public class ImageContent extends AbstractStructuredAFPObject { * {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { - if (imageSizeParam != null) { - imageSizeParam.writeDataStream(os); + if (_imageSizeParameter != null) { + _imageSizeParameter.writeDataStream(os); } os.write(getImageEncodingParameter()); os.write(getImageIDESizeParameter()); @@ -190,16 +188,21 @@ public class ImageContent extends AbstractStructuredAFPObject { * @return byte[] The data stream. */ private byte[] getImageDataStart(int len) { - byte[] imageDataStartData = new byte[] { + + byte[] data = new byte[] { (byte)0xFE, // ID (byte)0x92, // ID 0x00, // Length 0x00, // Length }; + byte[] l = BinaryUtils.convert(len, 2); - imageDataStartData[2] = l[0]; - imageDataStartData[3] = l[1]; - return imageDataStartData; + data[2] = l[0]; + data[3] = l[1]; + + + return data; + } /** @@ -207,13 +210,16 @@ public class ImageContent extends AbstractStructuredAFPObject { * @return byte[] The data stream. */ private byte[] getImageEncodingParameter() { - byte[] imageEncParamData = new byte[] { + + byte[] data = new byte[] { (byte)0x95, // ID 0x02, // Length - encoding, + _encoding, 0x01, // RECID }; - return imageEncParamData; + + return data; + } /** @@ -221,8 +227,9 @@ public class ImageContent extends AbstractStructuredAFPObject { * @return byte[] The data stream. */ private byte[] getExternalAlgorithmParameter() { - if (encoding == (byte)0x83 && compression != 0) { - byte[] extAlgParamData = new byte[] { + + if (_encoding == (byte)0x83 && _compression != 0) { + byte[] data = new byte[] { (byte)0x95, // ID 0x00, // Length 0x10, // ALGTYPE = Compression Algorithm @@ -231,13 +238,13 @@ public class ImageContent extends AbstractStructuredAFPObject { 0x00, // Reserved 0x00, // Reserved 0x00, // Reserved - compression, // MARKER + _compression, // MARKER 0x00, // Reserved 0x00, // Reserved 0x00, // Reserved }; - extAlgParamData[1] = (byte)(extAlgParamData.length - 2); - return extAlgParamData; + data[1] = (byte)(data.length - 2); + return data; } return new byte[0]; } @@ -247,12 +254,15 @@ public class ImageContent extends AbstractStructuredAFPObject { * @return byte[] The data stream. */ private byte[] getImageIDESizeParameter() { - byte[] imageIDESizeParamData = new byte[] { + + byte[] data = new byte[] { (byte)0x96, // ID 0x01, // Length - size, + _size, }; - return imageIDESizeParamData; + + return data; + } /** @@ -260,14 +270,15 @@ public class ImageContent extends AbstractStructuredAFPObject { * @return byte[] The data stream. */ private byte[] getIDEStructureParameter() { - if (colorModel != 0 && size == 24) { - byte bits = (byte)(size / 3); - byte[] ideStructParamData = new byte[] { + + if (_colorModel != 0 && _size == 24) { + byte bits = (byte)(_size / 3); + byte[] data = new byte[] { (byte)0x9B, // ID 0x00, // Length 0x00, // FLAGS 0x00, // Reserved - colorModel, // COLOR MODEL + _colorModel, // COLOR MODEL 0x00, // Reserved 0x00, // Reserved 0x00, // Reserved @@ -275,9 +286,10 @@ public class ImageContent extends AbstractStructuredAFPObject { bits, bits, }; - ideStructParamData[1] = (byte)(ideStructParamData.length - 2); - return ideStructParamData; + data[1] = (byte)(data.length - 2); + return data; } return new byte[0]; } + } diff --git a/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java index d1c2c11c7..9250f0c7f 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java @@ -27,17 +27,10 @@ import org.apache.fop.render.afp.tools.BinaryUtils; */ public class ImageDataDescriptor extends AbstractAFPObject { - /** x resolution */ - private int xresol = 0; - - /** y resolution */ - private int yresol = 0; - - /** width */ - private int width = 0; - - /** height */ - private int height = 0; + private int _xresol = 0; + private int _yresol = 0; + private int _width = 0; + private int _height = 0; /** * Constructor for a ImageDataDescriptor for the specified @@ -48,25 +41,26 @@ public class ImageDataDescriptor extends AbstractAFPObject { * @param height The height of the height. */ public ImageDataDescriptor(int xresol, int yresol, int width, int height) { - this.xresol = xresol; - this.yresol = yresol; - this.width = width; - this.height = height; + + _xresol = xresol; + _yresol = yresol; + _width = width; + _height = height; + } /** - * {@inheritDoc} + * Accessor method to write the AFP datastream for the Image Data Descriptor + * @param os The stream to write to + * @throws java.io.IOException */ - public void writeDataStream(OutputStream os) throws IOException { - byte[] len = BinaryUtils.convert(21, 2); - byte[] xres = BinaryUtils.convert(xresol, 2); - byte[] yres = BinaryUtils.convert(yresol, 2); - byte[] w = BinaryUtils.convert(width, 2); - byte[] h = BinaryUtils.convert(height, 2); + public void writeDataStream(OutputStream os) + throws IOException { + byte[] data = new byte[] { 0x5A, - len[0], - len[1], + 0x00, + 0x20, (byte) 0xD3, (byte) 0xA6, (byte) 0xFB, @@ -74,19 +68,42 @@ public class ImageDataDescriptor extends AbstractAFPObject { 0x00, // Reserved 0x00, // Reserved 0x00, // Unit base - 10 Inches - xres[0], // XRESOL - xres[1], // - yres[0], // YRESOL - yres[1], // - w[0], // XSIZE - w[1], // - h[0], // YSIZE - h[1], // + 0x00, // XRESOL + 0x00, // + 0x00, // YRESOL + 0x00, // + 0x00, // XSIZE + 0x00, // + 0x00, // YSIZE + 0x00, // (byte)0xF7, // ID = Set IOCA Function Set 0x02, // Length 0x01, // Category = Function set identifier 0x0B, // FCNSET = IOCA FS 11 }; + + byte[] l = BinaryUtils.convert(data.length - 1, 2); + data[1] = l[0]; + data[2] = l[1]; + + byte[] x = BinaryUtils.convert(_xresol, 2); + data[10] = x[0]; + data[11] = x[1]; + + byte[] y = BinaryUtils.convert(_yresol, 2); + data[12] = y[0]; + data[13] = y[1]; + + byte[] w = BinaryUtils.convert(_width, 2); + data[14] = w[0]; + data[15] = w[1]; + + byte[] h = BinaryUtils.convert(_height, 2); + data[16] = h[0]; + data[17] = h[1]; + os.write(data); + } + } diff --git a/src/java/org/apache/fop/render/afp/modca/ImageSegment.java b/src/java/org/apache/fop/render/afp/modca/ImageSegment.java index 2876e8348..ea8eb334b 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageSegment.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageSegment.java @@ -18,7 +18,6 @@ /* $Id$ */ package org.apache.fop.render.afp.modca; - import java.io.IOException; import java.io.OutputStream; @@ -165,6 +164,7 @@ public class ImageSegment extends AbstractNamedAFPObject { * {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[] { 0x71, // ID 0x00, // Length 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 aa35db10e..7c940148b 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java @@ -35,11 +35,11 @@ public class ObjectAreaDescriptor extends AbstractDescriptor { * and object height. * @param width The page width. * @param height The page height. - * @param widthRes The page width resolution. - * @param heightRes The page height resolution. + * @param widthResolution The page width resolution. + * @param heightResolution The page height resolution. */ - public ObjectAreaDescriptor(int width, int height, int widthRes, int heightRes) { - super(width, height, widthRes, heightRes); + public ObjectAreaDescriptor(int width, int height, int widthResolution, int heightResolution) { + super(width, height, widthResolution, heightResolution); } /** @@ -47,7 +47,8 @@ public class ObjectAreaDescriptor extends AbstractDescriptor { * @param os The stream to write to * @throws java.io.IOException thrown if an I/O exception of some sort has occurred */ - public void writeDataStream(OutputStream os) throws IOException { + public void writeDataStream(OutputStream os) + throws IOException { byte[] data = new byte[29]; data[0] = 0x5A; @@ -71,12 +72,12 @@ public class ObjectAreaDescriptor extends AbstractDescriptor { data[15] = 0x00; // YaoBase = 10 inches // XaoUnits - byte[] xdpi = BinaryUtils.convert(this.widthRes * 10, 2); + byte[] xdpi = BinaryUtils.convert(widthResolution * 10, 2); data[16] = xdpi[0]; data[17] = xdpi[1]; // YaoUnits - byte[] ydpi = BinaryUtils.convert(this.heightRes * 10, 2); + byte[] ydpi = BinaryUtils.convert(heightResolution * 10, 2); data[18] = ydpi[0]; data[19] = ydpi[1]; @@ -84,16 +85,18 @@ public class ObjectAreaDescriptor extends AbstractDescriptor { data[21] = 0x4C; // tid = Object Area Size data[22] = 0x02; // Size Type - byte[] x = BinaryUtils.convert(this.width, 3); + byte[] x = BinaryUtils.convert(width, 3); data[23] = x[0]; data[24] = x[1]; data[25] = x[2]; - byte[] y = BinaryUtils.convert(this.height, 3); + byte[] y = BinaryUtils.convert(height, 3); data[26] = y[0]; data[27] = y[1]; data[28] = y[2]; os.write(data); + } + } \ No newline at end of file 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 ffa5f3c85..1cdec7616 100644 --- a/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java @@ -35,11 +35,11 @@ public class PageDescriptor extends AbstractDescriptor { * and page height. * @param width The page width. * @param height The page height. - * @param widthRes The page width resolution - * @param heightRes The page height resolution + * @param widthResolution The page width resolution + * @param heightResolution The page height resolution */ - public PageDescriptor(int width, int height, int widthRes, int heightRes) { - super(width, height, widthRes, heightRes); + public PageDescriptor(int width, int height, int widthResolution, int heightResolution) { + super(width, height, widthResolution, heightResolution); } /** @@ -68,12 +68,12 @@ public class PageDescriptor extends AbstractDescriptor { data[10] = 0x00; // YpgBase = 10 inches // XpgUnits - byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); + byte[] xdpi = BinaryUtils.convert(widthResolution * 10, 2); data[11] = xdpi[0]; data[12] = xdpi[1]; // YpgUnits - byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2); + byte[] ydpi = BinaryUtils.convert(heightResolution * 10, 2); data[13] = ydpi[0]; data[14] = ydpi[1]; diff --git a/src/java/org/apache/fop/render/afp/modca/PageObject.java b/src/java/org/apache/fop/render/afp/modca/PageObject.java index bad80bcc1..9a8646ba0 100644 --- a/src/java/org/apache/fop/render/afp/modca/PageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PageObject.java @@ -56,14 +56,14 @@ public class PageObject extends AbstractPageObject { * the height of the page. * @param rotation * the rotation of the page. - * @param widthRes + * @param widthResolution * the width resolution of the page. - * @param heightRes + * @param heightResolution * the height resolution of the page. */ public PageObject(String name, int width, int height, int rotation, - int widthRes, int heightRes) { - super(name, width, height, rotation, widthRes, heightRes); + int widthResolution, int heightResolution) { + super(name, width, height, rotation, widthResolution, heightResolution); } /** diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java index 30a78d6c9..98beb96f7 100644 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java +++ b/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java @@ -56,42 +56,42 @@ public class PresentationTextData extends AbstractAFPObject { /** * The afp data relating to this presentaion text data. */ - private ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); + private ByteArrayOutputStream _baos = new ByteArrayOutputStream(1024); /** * The current x coordinate. */ - private int currentXCoordinate = -1; + private int _currentXCoordinate = -1; /** * The current y cooridnate */ - private int currentYCoordinate = -1; + private int _currentYCoordinate = -1; /** * The current font */ - private String currentFont = ""; + private String _currentFont = ""; /** * The current orientation */ - private int currentOrientation = 0; + private int _currentOrientation = 0; /** * The current color */ - private Color currentColor = new Color(0, 0, 0); + private Color _currentColor = new Color(0, 0, 0); /** * The current variable space increment */ - private int currentVariableSpaceCharacterIncrement = 0; + private int _currentVariableSpaceCharacterIncrement = 0; /** * The current inter character adjustment */ - private int currentInterCharacterAdjustment = 0; + private int _currentInterCharacterAdjustment = 0; /** * Default constructor for the PresentationTextData. @@ -112,7 +112,7 @@ public class PresentationTextData extends AbstractAFPObject { */ public PresentationTextData(boolean controlInd) { - baos.write(new byte[] {0x5A, // Structured field identifier + _baos.write(new byte[] { 0x5A, // Structured field identifier 0x00, // Record length byte 1 0x00, // Record length byte 2 (byte) 0xD3, // PresentationTextData identifier byte 1 @@ -124,7 +124,7 @@ public class PresentationTextData extends AbstractAFPObject { }, 0, 9); if (controlInd) { - baos.write(new byte[] {0x2B, (byte) 0xD3}, 0, 2); + _baos.write(new byte[] { 0x2B, (byte) 0xD3 }, 0, 2); } } @@ -142,13 +142,13 @@ public class PresentationTextData extends AbstractAFPObject { private void setCodedFont(byte font, ByteArrayOutputStream afpdata) { // Avoid unnecessary specification of the font - if (String.valueOf(font).equals(currentFont)) { + if (String.valueOf(font).equals(_currentFont)) { return; } else { - currentFont = String.valueOf(font); + _currentFont = String.valueOf(font); } - afpdata.write(new byte[] {0x03, (byte) 0xF1, font}, 0, 3); + afpdata.write(new byte[] { 0x03, (byte) 0xF1, font, }, 0, 3); } @@ -167,9 +167,9 @@ public class PresentationTextData extends AbstractAFPObject { byte[] b = BinaryUtils.convert(coordinate, 2); - afpdata.write(new byte[] {0x04, (byte) 0xC7, b[0], b[1]}, 0, 4); + afpdata.write(new byte[] { 0x04, (byte) 0xC7, b[0], b[1], }, 0, 4); - currentXCoordinate = coordinate; + _currentXCoordinate = coordinate; } @@ -188,9 +188,9 @@ public class PresentationTextData extends AbstractAFPObject { byte[] b = BinaryUtils.convert(coordinate, 2); - afpdata.write(new byte[] {0x04, (byte) 0xD3, b[0], b[1]}, 0, 4); + afpdata.write(new byte[] { 0x04, (byte) 0xD3, b[0], b[1], }, 0, 4); - currentYCoordinate = coordinate; + _currentYCoordinate = coordinate; } @@ -214,7 +214,7 @@ public class PresentationTextData extends AbstractAFPObject { "Transparent data is longer than 253 bytes: " + data); } - afpdata.write(new byte[] {BinaryUtils.convert(l)[0], (byte) 0xDB}, + afpdata.write(new byte[] { BinaryUtils.convert(l)[0], (byte) 0xDB, }, 0, 2); afpdata.write(data, 0, data.length); @@ -236,7 +236,7 @@ public class PresentationTextData extends AbstractAFPObject { private void drawBaxisRule(int length, int width, ByteArrayOutputStream afpdata) { - afpdata.write(new byte[] {0x07, // Length + afpdata.write(new byte[] { 0x07, // Length (byte) 0xE7, // Type }, 0, 2); @@ -266,7 +266,7 @@ public class PresentationTextData extends AbstractAFPObject { private void drawIaxisRule(int length, int width, ByteArrayOutputStream afpdata) { - afpdata.write(new byte[] {0x07, // Length + afpdata.write(new byte[] { 0x07, // Length (byte) 0xE5, // Type }, 0, 2); @@ -284,7 +284,7 @@ public class PresentationTextData extends AbstractAFPObject { /** * Create the presentation text data for the byte array of data. * - * @param fontReference + * @param fontNumber * The font resource identifier. * @param x * The x coordinate for the text data. @@ -300,64 +300,64 @@ public class PresentationTextData extends AbstractAFPObject { * The inter character adjustment. * @param data * The text data to be created. - * @throws MaximumSizeExceededException if the maximum size is exceeded + * @throws MaximumSizeExceededException */ - public void createTextData(int fontReference, int x, int y, int orientation, + public void createTextData(int fontNumber, int x, int y, int orientation, Color col, int vsci, int ica, byte[] data) throws MaximumSizeExceededException { ByteArrayOutputStream afpdata = new ByteArrayOutputStream(); - if (currentOrientation != orientation) { + if (_currentOrientation != orientation) { setTextOrientation(orientation, afpdata); - currentOrientation = orientation; - currentXCoordinate = -1; - currentYCoordinate = -1; + _currentOrientation = orientation; + _currentXCoordinate = -1; + _currentYCoordinate = -1; } // Avoid unnecessary specification of the Y co-ordinate - if (y != currentYCoordinate) { + if (y != _currentYCoordinate) { absoluteMoveBaseline(y, afpdata); - currentXCoordinate = -1; + _currentXCoordinate = -1; } // Avoid unnecessary specification of the X co-ordinate - if (x != currentXCoordinate) { + if (x != _currentXCoordinate) { absoluteMoveInline(x, afpdata); } // Avoid unnecessary specification of the variable space increment - if (vsci != currentVariableSpaceCharacterIncrement) { + if (vsci != _currentVariableSpaceCharacterIncrement) { setVariableSpaceCharacterIncrement(vsci, afpdata); - currentVariableSpaceCharacterIncrement = vsci; + _currentVariableSpaceCharacterIncrement = vsci; } // Avoid unnecessary specification of the inter character adjustment - if (ica != currentInterCharacterAdjustment) { + if (ica != _currentInterCharacterAdjustment) { setInterCharacterAdjustment(ica, afpdata); - currentInterCharacterAdjustment = ica; + _currentInterCharacterAdjustment = ica; } // Avoid unnecessary specification of the text color - if (!col.equals(currentColor)) { + if (!col.equals(_currentColor)) { setExtendedTextColor(col, afpdata); - currentColor = col; + _currentColor = col; } - setCodedFont(BinaryUtils.convert(fontReference)[0], afpdata); + setCodedFont(BinaryUtils.convert(fontNumber)[0], afpdata); addTransparentData(data, afpdata); - currentXCoordinate = -1; + _currentXCoordinate = -1; int s = afpdata.size(); - if (baos.size() + s > MAX_SIZE) { - currentXCoordinate = -1; - currentYCoordinate = -1; + if (_baos.size() + s > MAX_SIZE) { + _currentXCoordinate = -1; + _currentYCoordinate = -1; throw new MaximumSizeExceededException(); } byte[] outputdata = afpdata.toByteArray(); - baos.write(outputdata, 0, outputdata.length); + _baos.write(outputdata, 0, outputdata.length); } @@ -379,31 +379,30 @@ public class PresentationTextData extends AbstractAFPObject { * The orientation of the text data. * @param col * The text color. - * @throws MaximumSizeExceededException if the maximum size is exceeded */ public void createLineData(int x1, int y1, int x2, int y2, int thickness, int orientation, Color col) throws MaximumSizeExceededException { ByteArrayOutputStream afpdata = new ByteArrayOutputStream(); - if (currentOrientation != orientation) { + if (_currentOrientation != orientation) { setTextOrientation(orientation, afpdata); - currentOrientation = orientation; + _currentOrientation = orientation; } // Avoid unnecessary specification of the Y coordinate - if (y1 != currentYCoordinate) { + if (y1 != _currentYCoordinate) { absoluteMoveBaseline(y1, afpdata); } // Avoid unnecessary specification of the X coordinate - if (x1 != currentXCoordinate) { + if (x1 != _currentXCoordinate) { absoluteMoveInline(x1, afpdata); } - if (!col.equals(currentColor)) { + if (!col.equals(_currentColor)) { setExtendedTextColor(col, afpdata); - currentColor = col; + _currentColor = col; } if (y1 == y2) { @@ -416,14 +415,14 @@ public class PresentationTextData extends AbstractAFPObject { int s = afpdata.size(); - if (baos.size() + s > MAX_SIZE) { - currentXCoordinate = -1; - currentYCoordinate = -1; + if (_baos.size() + s > MAX_SIZE) { + _currentXCoordinate = -1; + _currentYCoordinate = -1; throw new MaximumSizeExceededException(); } byte[] outputdata = afpdata.toByteArray(); - baos.write(outputdata, 0, outputdata.length); + _baos.write(outputdata, 0, outputdata.length); } @@ -444,7 +443,7 @@ public class PresentationTextData extends AbstractAFPObject { private void setTextOrientation(int orientation, ByteArrayOutputStream afpdata) { - afpdata.write(new byte[] {0x06, (byte) 0xF7}, 0, 2); + afpdata.write(new byte[] { 0x06, (byte) 0xF7, }, 0, 2); switch (orientation) { case 90: @@ -560,11 +559,12 @@ public class PresentationTextData extends AbstractAFPObject { * Accessor method to write the AFP datastream for * the text data. * @param os The stream to write to - * @throws java.io.IOException if an I/O exception occurred + * @throws java.io.IOException */ - public void writeDataStream(OutputStream os) throws IOException { + public void writeDataStream(OutputStream os) + throws IOException { - byte[] data = baos.toByteArray(); + byte[] data = _baos.toByteArray(); byte[] size = BinaryUtils.convert(data.length - 1, 2); data[1] = size[0]; data[2] = size[1]; @@ -580,7 +580,7 @@ public class PresentationTextData extends AbstractAFPObject { * presentation text data objects, but must eventually be terminated. This * method terminates the control sequence. * - * @throws MaximumSizeExceededException if the maximum size is exceeded + * @throws MaximumSizeExceededException */ public void endControlSequence() throws MaximumSizeExceededException { @@ -588,10 +588,12 @@ public class PresentationTextData extends AbstractAFPObject { data[0] = 0x02; data[1] = (byte) 0xF8; - if (data.length + baos.size() > MAX_SIZE) { + if (data.length + _baos.size() > MAX_SIZE) { throw new MaximumSizeExceededException(); } - baos.write(data, 0, data.length); + + _baos.write(data, 0, data.length); + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java index 27b3de5ca..3858f4169 100644 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java @@ -52,11 +52,12 @@ public class PresentationTextDescriptor extends AbstractDescriptor { * width and height. * @param width The width of the page. * @param height The height of the page. - * @param widthRes The width resolution of the page. - * @param heightRes The height resolution of the page. + * @param widthResolution The width resolution of the page. + * @param heightResolution The height resolution of the page. */ - public PresentationTextDescriptor(int width, int height, int widthRes, int heightRes) { - super(width, height, widthRes, heightRes); + public PresentationTextDescriptor(int width, int height, + int widthResolution, int heightResolution) { + super(width, height, widthResolution, heightResolution); } /** @@ -80,11 +81,11 @@ public class PresentationTextDescriptor extends AbstractDescriptor { data[9] = 0x00; data[10] = 0x00; - byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); + byte[] xdpi = BinaryUtils.convert(widthResolution * 10, 2); data[11] = xdpi[0]; // xdpi data[12] = xdpi[1]; - byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2); + byte[] ydpi = BinaryUtils.convert(heightResolution * 10, 2); data[13] = ydpi[0]; // ydpi data[14] = ydpi[1]; diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java index 49f7c81a8..5df9fdb4c 100644 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java @@ -117,7 +117,6 @@ public class PresentationTextObject extends AbstractNamedAFPObject { startPresentationTextData(); } try { - currentPresentationTextData.createTextData(fontRef, x, y, orientation, col, vsci, ica, data); } catch (MaximumSizeExceededException msee) { @@ -279,4 +278,4 @@ public class PresentationTextObject extends AbstractNamedAFPObject { endControlSequence(); } } -} \ No newline at end of file +} diff --git a/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java b/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java index 99f31ba14..29ac9eb5d 100644 --- a/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java +++ b/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java @@ -47,7 +47,7 @@ public class TagLogicalElementBean { * @return the key */ public String getKey() { - return this.key; + return key; } /** @@ -55,7 +55,7 @@ public class TagLogicalElementBean { * @return the value */ public String getValue() { - return this.value; + return value; } } diff --git a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java index 208bc303a..3a773a2db 100644 --- a/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java +++ b/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java @@ -112,7 +112,7 @@ public class CustomFontMetricsMapper extends Typeface implements FontMetricsMapp } /** {@inheritDoc} */ - public final String getEncoding() { + public final String getEncodingName() { return null; //Not applicable to Java2D rendering } diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index 8442af229..583d2ad2f 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -312,6 +312,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); } + graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, + RenderingHints.VALUE_STROKE_PURE); // transform page based on scale factor supplied AffineTransform at = graphics.getTransform(); diff --git a/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java b/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java index ed7391383..19e9a4d1d 100644 --- a/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java +++ b/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java @@ -172,7 +172,7 @@ public class SystemFontMetricsMapper extends Typeface implements FontMetricsMapp } /** {@inheritDoc} */ - public String getEncoding() { + public String getEncodingName() { return null; //Not applicable to Java2D rendering } diff --git a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java index b676ad6d5..caf8928ac 100644 --- a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java +++ b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java @@ -81,7 +81,7 @@ public abstract class AbstractImageAdapter implements PDFImage { /** {@inheritDoc} */ public void setup(PDFDocument doc) { - ICC_Profile prof = image.getICCProfile(); + ICC_Profile prof = getEffectiveICCProfile(); PDFDeviceColorSpace pdfCS = toPDFColorSpace(getImageColorSpace()); if (prof != null) { pdfICCStream = setupColorProfile(doc, prof, pdfCS); @@ -100,6 +100,14 @@ public abstract class AbstractImageAdapter implements PDFImage { } } + /** + * Returns the effective ICC profile for the image. + * @return an ICC profile or null + */ + protected ICC_Profile getEffectiveICCProfile() { + return image.getICCProfile(); + } + private static PDFICCStream setupColorProfile(PDFDocument doc, ICC_Profile prof, PDFDeviceColorSpace pdfCS) { boolean defaultsRGB = ColorProfileUtil.isDefaultsRGB(prof); diff --git a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java index 4b0ce4a85..1c8fceb50 100644 --- a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java +++ b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java @@ -18,19 +18,33 @@ /* $Id$ */ package org.apache.fop.render.pdf; +import java.awt.color.ICC_Profile; +import java.io.DataInput; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; +import org.apache.commons.io.IOUtils; + import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; +import org.apache.xmlgraphics.image.loader.impl.JPEGConstants; +import org.apache.xmlgraphics.image.loader.impl.JPEGFile; +import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.fop.pdf.DCTFilter; import org.apache.fop.pdf.PDFDeviceColorSpace; import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFFilter; import org.apache.fop.pdf.PDFFilterList; +import org.apache.fop.util.ColorProfileUtil; /** * PDFImage implementation for the PDF renderer which handles raw JPEG images. + *

      + * The JPEG is copied to the XObject's stream as-is but some elements (marker segments) are + * filtered. For example, an embedded color profile is filtered since it is already added as + * a PDF object and associated with the XObject. This way, the PDF file size is kept as small + * as possible. */ public class ImageRawJPEGAdapter extends AbstractImageAdapter { @@ -67,6 +81,21 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter { return toPDFColorSpace(getImageColorSpace()); } + /** {@inheritDoc} */ + protected ICC_Profile getEffectiveICCProfile() { + ICC_Profile profile = super.getEffectiveICCProfile(); + if (profile != null + && profile.getNumComponents() == 3 + && !ColorProfileUtil.isDefaultsRGB(profile)) { + //RGB profiles which are not sRGB don't seem to work. + //Without this override, the image drifts into yellow for an unknown reason. + //TODO Find out why this happens. + //Test using a JPEG images with, for example, "Adobe RGB 1998" color profile. + profile = null; + } + return profile; + } + /** {@inheritDoc} */ public int getBitsPerComponent() { return 8; @@ -84,7 +113,77 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter { /** {@inheritDoc} */ public void outputContents(OutputStream out) throws IOException { - getImage().writeTo(out); + InputStream in = getImage().createInputStream(); + in = ImageUtil.decorateMarkSupported(in); + 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. + //TODO Metadata (XMP, IPTC, EXIF) could safely be skipped, too. + while (true) { + int reclen; + int segID = jpeg.readMarkerSegment(); + switch (segID) { + case JPEGConstants.SOI: + out.write(0xFF); + out.write(segID); + break; + case JPEGConstants.EOI: + case JPEGConstants.SOS: + out.write(0xFF); + out.write(segID); + IOUtils.copy(in, out); //Just copy the rest! + return; + /* + case JPEGConstants.APP1: //Metadata + case JPEGConstants.APPD: + jpeg.skipCurrentMarkerSegment(); + break;*/ + case JPEGConstants.APP2: //ICC (see ICC1V42.pdf) + boolean skipICCProfile = false; + in.mark(16); + try { + reclen = jpeg.readSegmentLength(); + // Check for ICC profile + byte[] iccString = new byte[11]; + din.readFully(iccString); + din.skipBytes(1); //string terminator (null byte) + + if ("ICC_PROFILE".equals(new String(iccString, "US-ASCII"))) { + skipICCProfile = (this.image.getICCProfile() != null); + } + } finally { + in.reset(); + } + if (skipICCProfile) { + //ICC profile is skipped as it is already embedded as a PDF object + jpeg.skipCurrentMarkerSegment(); + break; + } + default: + out.write(0xFF); + out.write(segID); + + reclen = jpeg.readSegmentLength(); + //write short + out.write((reclen >>> 8) & 0xFF); + out.write((reclen >>> 0) & 0xFF); + int left = reclen - 2; + byte[] buf = new byte[2048]; + while (left > 0) { + int part = Math.min(buf.length, left); + din.readFully(buf, 0, part); + out.write(buf, 0, part); + left -= part; + } + } + } + } finally { + IOUtils.closeQuietly(in); + } } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java index 1a121e294..c47b944d0 100644 --- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java @@ -89,8 +89,8 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes, pdfInfo.fi, pdfInfo.pdfDoc, pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(), - renderer.currentFontName, - renderer.currentFontSize); + pdfInfo.currentFontName, + pdfInfo.currentFontSize); graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); AffineTransform transform = new AffineTransform(); diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 19f274902..55524534e 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -63,7 +63,6 @@ import org.apache.fop.area.OffDocumentExtensionAttachment; import org.apache.fop.area.OffDocumentItem; import org.apache.fop.area.PageSequence; import org.apache.fop.area.PageViewport; -import org.apache.fop.area.RegionViewport; import org.apache.fop.area.Trait; import org.apache.fop.area.inline.AbstractTextArea; import org.apache.fop.area.inline.Image; @@ -78,6 +77,8 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.extensions.ExtensionAttachment; import org.apache.fop.fo.extensions.xmp.XMPMetadata; import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.LazyFont; +import org.apache.fop.fonts.SingleByteFont; import org.apache.fop.fonts.Typeface; import org.apache.fop.pdf.PDFAMode; import org.apache.fop.pdf.PDFAction; @@ -106,7 +107,7 @@ import org.apache.fop.pdf.PDFResourceContext; import org.apache.fop.pdf.PDFResources; import org.apache.fop.pdf.PDFState; import org.apache.fop.pdf.PDFStream; -import org.apache.fop.pdf.PDFText; +import org.apache.fop.pdf.PDFTextUtil; import org.apache.fop.pdf.PDFXMode; import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.AbstractPathOrientedRenderer; @@ -250,21 +251,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** drawing state */ protected PDFState currentState = null; - /** Name of currently selected font */ - protected String currentFontName = ""; - /** Size of currently selected font */ - protected int currentFontSize = 0; + /** Text generation utility holding the current font status */ + protected PDFTextUtil textutil; /** page height */ protected int pageHeight; /** Registry of PDF filters */ protected Map filterMap; - /** - * true if a BT command has been written. - */ - protected boolean inTextMode = false; - /** Image handler registry */ private PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry(); @@ -527,7 +521,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentContext = null; currentPage = null; currentState = null; - currentFontName = ""; + this.textutil = null; idPositions.clear(); idGoTos.clear(); @@ -665,19 +659,15 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** Indicates the beginning of a text object. */ protected void beginTextObject() { - if (!inTextMode) { - currentStream.add("BT\n"); - currentFontName = ""; - inTextMode = true; + if (!textutil.isInTextObject()) { + textutil.beginTextObject(); } } /** Indicates the end of a text object. */ protected void endTextObject() { - closeText(); - if (inTextMode) { - currentStream.add("ET\n"); - inTextMode = false; + if (textutil.isInTextObject()) { + textutil.endTextObject(); } } @@ -787,6 +777,11 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream = this.pdfDoc.getFactory() .makeStream(PDFFilterList.CONTENT_FILTER, false); + this.textutil = new PDFTextUtil() { + protected void write(String code) { + currentStream.add(code); + } + }; currentState = new PDFState(); // Transform the PDF's default coordinate system (0,0 at lower left) to the PDFRenderer's @@ -795,9 +790,6 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentState.concatenate(basicPageTransform); currentStream.add(CTMHelper.toPDFString(basicPageTransform, false) + " cm\n"); - - currentFontName = ""; - super.renderPage(page); this.pdfDoc.registerObject(currentStream); @@ -808,6 +800,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } this.pdfDoc.addObject(currentPage); this.pdfDoc.output(ostream); + this.textutil = null; } /** {@inheritDoc} */ @@ -840,17 +833,6 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } } - /** - * Handle the traits for a region - * This is used to draw the traits for the given page region. - * (See Sect. 6.4.1.2 of XSL-FO spec.) - * @param region the RegionViewport whose region is to be drawn - */ - protected void handleRegionTraits(RegionViewport region) { - currentFontName = ""; - super.handleRegionTraits(region); - } - /** * Formats a float value (normally coordinates) as Strings. * @param value the value @@ -866,7 +848,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { float w = x2 - x1; float h = y2 - y1; if ((w < 0) || (h < 0)) { - log.error("Negative extent received (w=" + w + ", h=" + h + "). Border won't be painted."); + log.error("Negative extent received (w=" + w + ", h=" + h + + "). Border won't be painted."); return; } switch (style) { @@ -1329,12 +1312,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { super.renderBlock(block); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void renderLineArea(LineArea line) { super.renderLineArea(line); - closeText(); } /** @@ -1423,11 +1403,20 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } } - /** - * {@inheritDoc} - */ + private Typeface getTypeface(String fontName) { + Typeface tf = (Typeface) fontInfo.getFonts().get(fontName); + if (tf instanceof LazyFont) { + tf = ((LazyFont)tf).getRealFont(); + } + return tf; + } + + /** {@inheritDoc} */ public void renderText(TextArea text) { renderInlineAreaBackAndBorders(text); + Color ct = (Color) text.getTrait(Trait.COLOR); + updateColor(ct, true); + beginTextObject(); StringBuffer pdf = new StringBuffer(); @@ -1435,12 +1424,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); // This assumes that *all* CIDFonts use a /ToUnicode mapping - Typeface tf = (Typeface) fontInfo.getFonts().get(fontName); - boolean useMultiByte = tf.isMultiByte(); + Typeface tf = getTypeface(fontName); + + textutil.updateTf(fontName, size / 1000f, tf.isMultiByte()); - updateFont(fontName, size, pdf); - Color ct = (Color) text.getTrait(Trait.COLOR); - updateColor(ct, true, pdf); // word.getOffset() = only height of text itself // currentBlockIPPosition: 0 for beginning of line; nonzero @@ -1448,66 +1435,46 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { int rx = currentIPPosition + text.getBorderAndPaddingWidthStart(); int bl = currentBPPosition + text.getOffset() + text.getBaselineOffset(); - pdf.append("1 0 0 -1 " + format(rx / 1000f) + " " + format(bl / 1000f) + " Tm " - /*+ format(text.getTextLetterSpaceAdjust() / 1000f) + " Tc\n"*/ - /*+ format(text.getTextWordSpaceAdjust() / 1000f) + " Tw ["*/); + textutil.writeTextMatrix(new AffineTransform(1, 0, 0, -1, rx / 1000f, bl / 1000f)); - pdf.append("["); currentStream.add(pdf.toString()); super.renderText(text); - currentStream.add("] TJ\n"); + textutil.writeTJ(); renderTextDecoration(tf, size, text, bl, rx); } - - /** - * {@inheritDoc} - */ + + /** {@inheritDoc} */ public void renderWord(WordArea word) { Font font = getFontFromArea(word.getParentArea()); - Typeface tf = (Typeface) fontInfo.getFonts().get(font.getFontName()); - boolean useMultiByte = tf.isMultiByte(); - - StringBuffer pdf = new StringBuffer(); - String s = word.getWord(); - escapeText(s, word.getLetterAdjustArray(), - font, (AbstractTextArea)word.getParentArea(), useMultiByte, pdf); - currentStream.add(pdf.toString()); + escapeText(s, word.getLetterAdjustArray(), + font, (AbstractTextArea)word.getParentArea()); super.renderWord(word); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void renderSpace(SpaceArea space) { Font font = getFontFromArea(space.getParentArea()); - Typeface tf = (Typeface) fontInfo.getFonts().get(font.getFontName()); - boolean useMultiByte = tf.isMultiByte(); - String s = space.getSpace(); - StringBuffer pdf = new StringBuffer(); - AbstractTextArea textArea = (AbstractTextArea)space.getParentArea(); - escapeText(s, null, font, textArea, useMultiByte, pdf); + escapeText(s, null, font, textArea); if (space.isAdjustable()) { int tws = -((TextArea) space.getParentArea()).getTextWordSpaceAdjust() - 2 * textArea.getTextLetterSpaceAdjust(); if (tws != 0) { - pdf.append(format(tws / (font.getFontSize() / 1000f))); - pdf.append(" "); + float adjust = tws / (font.getFontSize() / 1000f); + textutil.adjustGlyphTJ(adjust); } } - currentStream.add(pdf.toString()); - super.renderSpace(space); } @@ -1515,101 +1482,77 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * Escapes text according to PDF rules. * @param s Text to escape * @param letterAdjust an array of widths for letter adjustment (may be null) - * @param fs Font state + * @param font to font in use + * @param parentArea the parent text area to retrieve certain traits from + */ + protected void escapeText(String s, + int[] letterAdjust, + Font font, AbstractTextArea parentArea) { + escapeText(s, 0, s.length(), letterAdjust, font, parentArea); + } + + /** + * Escapes text according to PDF rules. + * @param s Text to escape + * @param start the start position in the text + * @param end the end position in the text + * @param letterAdjust an array of widths for letter adjustment (may be null) + * @param font to font in use * @param parentArea the parent text area to retrieve certain traits from - * @param useMultiByte Indicates the use of multi byte convention - * @param pdf target buffer for the escaped text */ - public void escapeText(String s, int[] letterAdjust, - Font fs, AbstractTextArea parentArea, - boolean useMultiByte, StringBuffer pdf) { - String startText = useMultiByte ? "<" : "("; - String endText = useMultiByte ? "> " : ") "; - - /* - boolean kerningAvailable = false; - Map kerning = fs.getKerning(); - if (kerning != null && !kerning.isEmpty()) { - //kerningAvailable = true; - //TODO Reenable me when the layout engine supports kerning, too - log.warn("Kerning support is disabled until it is supported by the layout engine!"); - } - */ + protected void escapeText(String s, int start, int end, + int[] letterAdjust, + Font font, AbstractTextArea parentArea) { + String fontName = font.getFontName(); + float fontSize = font.getFontSize() / 1000f; + Typeface tf = getTypeface(fontName); + SingleByteFont singleByteFont = null; + if (tf instanceof SingleByteFont) { + singleByteFont = (SingleByteFont)tf; + } int l = s.length(); - - float fontSize = fs.getFontSize() / 1000f; - boolean startPending = true; - for (int i = 0; i < l; i++) { + + for (int i = start; i < end; i++) { char orgChar = s.charAt(i); char ch; float glyphAdjust = 0; - if (fs.hasChar(orgChar)) { - ch = fs.mapChar(orgChar); + if (font.hasChar(orgChar)) { + ch = font.mapChar(orgChar); + if (singleByteFont != null && singleByteFont.hasAdditionalEncodings()) { + int encoding = ch / 256; + if (encoding == 0) { + textutil.updateTf(fontName, fontSize, tf.isMultiByte()); + } else { + textutil.updateTf(fontName + "_" + Integer.toString(encoding), + fontSize, tf.isMultiByte()); + ch = (char)(ch % 256); + } + } int tls = (i < l - 1 ? parentArea.getTextLetterSpaceAdjust() : 0); glyphAdjust -= tls; } else { if (CharUtilities.isFixedWidthSpace(orgChar)) { //Fixed width space are rendered as spaces so copy/paste works in a reader - ch = fs.mapChar(CharUtilities.SPACE); - glyphAdjust = fs.getCharWidth(ch) - fs.getCharWidth(orgChar); + ch = font.mapChar(CharUtilities.SPACE); + glyphAdjust = font.getCharWidth(ch) - font.getCharWidth(orgChar); } else { - ch = fs.mapChar(orgChar); + ch = font.mapChar(orgChar); } } if (letterAdjust != null && i < l - 1) { glyphAdjust -= letterAdjust[i + 1]; } - if (startPending) { - pdf.append(startText); - startPending = false; - } - if (!useMultiByte) { - if (ch < 32 || ch > 127) { - pdf.append("\\"); - pdf.append(Integer.toOctalString((int) ch)); - } else { - switch (ch) { - case '(': - case ')': - case '\\': - pdf.append("\\"); - break; - default: - } - pdf.append(ch); - } - } else { - pdf.append(PDFText.toUnicodeHex(ch)); - } + textutil.writeTJMappedChar(ch); float adjust = glyphAdjust / fontSize; if (adjust != 0) { - pdf.append(endText).append(format(adjust)).append(' '); - startPending = true; + textutil.adjustGlyphTJ(adjust); } } - if (!startPending) { - pdf.append(endText); - } - } - - /** - * Checks to see if we have some text rendering commands open - * still and writes out the TJ command to the stream if we do - */ - protected void closeText() { - /* - if (textOpen) { - currentStream.add("] TJ\n"); - textOpen = false; - prevWordX = 0; - prevWordY = 0; - currentFontName = ""; - }*/ } /** @@ -1623,8 +1566,6 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { protected void setColor(Color col, boolean fill, StringBuffer pdf) { PDFColor color = new PDFColor(this.pdfDoc, col); - closeText(); - if (pdf != null) { pdf.append(color.getColorSpaceOut(fill)); } else { @@ -1656,22 +1597,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - protected void updateColor(Color col, boolean fill) { + protected void updateColor(Color col, boolean fill) { updateColor(col, fill, null); } - private void updateFont(String name, int size, StringBuffer pdf) { - if ((!name.equals(this.currentFontName)) - || (size != this.currentFontSize)) { - closeText(); - - this.currentFontName = name; - this.currentFontSize = size; - pdf = pdf.append("/" + name + " " + format((float) size / 1000f) - + " Tf\n"); - } - } - /** {@inheritDoc} */ public void renderImage(Image image, Rectangle2D pos) { endTextObject(); @@ -1727,8 +1656,6 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { 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); @@ -1803,9 +1730,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { context.setProperty(PDFRendererContextConstants.PDF_CONTEXT, currentContext); context.setProperty(PDFRendererContextConstants.PDF_STREAM, currentStream); context.setProperty(PDFRendererContextConstants.PDF_FONT_INFO, fontInfo); - context.setProperty(PDFRendererContextConstants.PDF_FONT_NAME, currentFontName); - context.setProperty(PDFRendererContextConstants.PDF_FONT_SIZE, - new Integer(currentFontSize)); + context.setProperty(PDFRendererContextConstants.PDF_FONT_NAME, ""); + context.setProperty(PDFRendererContextConstants.PDF_FONT_SIZE, new Integer(0)); return context; } diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java index bbc811b4e..1566ef799 100644 --- a/src/java/org/apache/fop/render/ps/PSFontUtils.java +++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java @@ -32,16 +32,20 @@ import javax.xml.transform.stream.StreamSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.xmlgraphics.fonts.Glyphs; import org.apache.xmlgraphics.ps.DSCConstants; import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.xmlgraphics.ps.PSResource; import org.apache.xmlgraphics.ps.dsc.ResourceTracker; +import org.apache.fop.fonts.Base14Font; import org.apache.fop.fonts.CustomFont; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontType; import org.apache.fop.fonts.LazyFont; +import org.apache.fop.fonts.SingleByteEncoding; +import org.apache.fop.fonts.SingleByteFont; import org.apache.fop.fonts.Typeface; /** @@ -81,9 +85,21 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { while (iter.hasNext()) { String key = (String)iter.next(); Typeface tf = getTypeFace(fontInfo, fonts, key); - PSResource fontRes = new PSResource("font", tf.getFontName()); + 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++) { + SingleByteEncoding encoding = sbf.getAdditionalEncoding(i); + defineEncoding(gen, encoding); + String postFix = "_" + (i + 1); + PSResource derivedFontRes = defineDerivedFont(gen, tf.getFontName(), + tf.getFontName() + postFix, encoding.getName()); + fontResources.put(key + postFix, derivedFontRes); + } + } } gen.commentln("%FOPEndFontDict"); reencodeFonts(gen, fonts); @@ -91,29 +107,35 @@ 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"); - defineWinAnsiEncoding(gen); //Rewrite font encodings Iterator iter = fonts.keySet().iterator(); while (iter.hasNext()) { String key = (String)iter.next(); - Typeface fm = (Typeface)fonts.get(key); - if (fm instanceof LazyFont && ((LazyFont)fm).getRealFont() == null) { - continue; - } else if (null == fm.getEncoding()) { + Typeface tf = (Typeface)fonts.get(key); + if (tf instanceof LazyFont) { + tf = ((LazyFont)tf).getRealFont(); + if (tf == null) { + continue; + } + } + if (null == tf.getEncodingName()) { //ignore (ZapfDingbats and Symbol used to run through here, kept for safety reasons) - } else if ("SymbolEncoding".equals(fm.getEncoding())) { + } else if ("SymbolEncoding".equals(tf.getEncodingName())) { //ignore (no encoding redefinition) - } else if ("ZapfDingbatsEncoding".equals(fm.getEncoding())) { + } else if ("ZapfDingbatsEncoding".equals(tf.getEncodingName())) { //ignore (no encoding redefinition) - } else if ("WinAnsiEncoding".equals(fm.getEncoding())) { - redefineFontEncoding(gen, fm.getFontName(), fm.getEncoding()); } else { - /* Don't complain anymore, just use the font's default encoding. - gen.commentln("%WARNING: Only WinAnsiEncoding is supported. Font '" - + fm.getFontName() + "' asks for: " + fm.getEncoding()); - */ + if (tf instanceof Base14Font) { + //Our Base 14 fonts don't use the default encoding + redefineFontEncoding(gen, tf.getFontName(), tf.getEncodingName()); + } } } gen.commentln("%FOPEndFontReencode"); @@ -233,10 +255,88 @@ public class PSFontUtils extends org.apache.xmlgraphics.ps.PSFontUtils { if (isEmbeddable(cf)) { resTracker.registerSuppliedResource(fontRes); } + if (tf instanceof SingleByteFont) { + SingleByteFont sbf = (SingleByteFont)tf; + for (int i = 0, c = sbf.getAdditionalEncodingCount(); i < c; i++) { + SingleByteEncoding encoding = sbf.getAdditionalEncoding(i); + PSResource encodingRes = new PSResource( + PSResource.TYPE_ENCODING, encoding.getName()); + resTracker.registerSuppliedResource(encodingRes); + PSResource derivedFontRes = new PSResource( + PSResource.TYPE_FONT, tf.getFontName() + "_" + (i + 1)); + resTracker.registerSuppliedResource(derivedFontRes); + } + } } } } return fontResources; } + /** + * Defines the single-byte encoding for use in PostScript files. + * @param gen the PostScript generator + * @param encoding the single-byte encoding + * @return the PSResource instance that represents the encoding + * @throws IOException In case of an I/O problem + */ + public static PSResource defineEncoding(PSGenerator gen, SingleByteEncoding encoding) + throws IOException { + PSResource res = new PSResource(PSResource.TYPE_ENCODING, encoding.getName()); + gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, res); + gen.writeln("/" + encoding.getName() + " ["); + String[] charNames = encoding.getCharNameMap(); + for (int i = 0; i < 256; i++) { + if (i > 0) { + if ((i % 5) == 0) { + gen.newLine(); + } else { + gen.write(" "); + } + } + String glyphname = null; + if (i < charNames.length) { + glyphname = charNames[i]; + } + if (glyphname == null || "".equals(glyphname)) { + glyphname = Glyphs.NOTDEF; + } + gen.write("/"); + gen.write(glyphname); + } + gen.newLine(); + gen.writeln("] def"); + gen.writeDSCComment(DSCConstants.END_RESOURCE); + gen.getResourceTracker().registerSuppliedResource(res); + return res; + } + + /** + * Derives a new font based on an existing font with a given encoding. The encoding must + * have been registered before. + * @param gen the PostScript generator + * @param baseFontName the font name of the font to derive from + * @param fontName the font name of the new font to be define + * @param encoding the new encoding (must be predefined in the PS file) + * @return the PSResource representing the derived font + * @throws IOException In case of an I/O problem + */ + public static PSResource defineDerivedFont(PSGenerator gen, String baseFontName, String fontName, + String encoding) throws IOException { + PSResource res = new PSResource(PSResource.TYPE_FONT, fontName); + gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE, res); + gen.commentln("%XGCDependencies: font " + baseFontName); + gen.commentln("%XGC+ encoding " + encoding); + gen.writeln("/" + baseFontName + " findfont"); + gen.writeln("dup length dict begin"); + gen.writeln(" {1 index /FID ne {def} {pop pop} ifelse} forall"); + gen.writeln(" /Encoding " + encoding + " def"); + gen.writeln(" currentdict"); + gen.writeln("end"); + gen.writeln("/" + fontName + " exch definefont pop"); + gen.writeDSCComment(DSCConstants.END_RESOURCE); + gen.getResourceTracker().registerSuppliedResource(res); + return res; + } + } diff --git a/src/java/org/apache/fop/render/ps/PSImageUtils.java b/src/java/org/apache/fop/render/ps/PSImageUtils.java deleted file mode 100644 index 004d5a22a..000000000 --- a/src/java/org/apache/fop/render/ps/PSImageUtils.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.xmlgraphics.ps.PSGenerator; - -import org.apache.fop.image.EPSImage; -import org.apache.fop.image.FopImage; - -/** - * Utility code for rendering images in PostScript. - */ -public class PSImageUtils extends org.apache.xmlgraphics.ps.PSImageUtils { - - /** logging instance */ - protected static Log log = LogFactory.getLog(PSImageUtils.class); - - /** - * Renders an EPS image to PostScript. - * @param img EPS image to render - * @param x x position - * @param y y position - * @param w width - * @param h height - * @param gen PS generator - * @deprecated Use {@link #renderEPS(java.io.InputStream, String, java.awt.geom.Rectangle2D, - * java.awt.geom.Rectangle2D, PSGenerator)} instead - */ - public static void renderEPS(EPSImage img, - float x, float y, float w, float h, - PSGenerator gen) { - try { - if (!img.load(FopImage.ORIGINAL_DATA)) { - gen.commentln("%EPS image could not be processed: " + img); - return; - } - int[] bbox = img.getBBox(); - int bboxw = bbox[2] - bbox[0]; - int bboxh = bbox[3] - bbox[1]; - String name = img.getDocName(); - if (name == null || name.length() == 0) { - name = img.getOriginalURI(); - } - renderEPS(img.getEPSImage(), name, - x, y, w, h, - bbox[0], bbox[1], bboxw, bboxh, gen); - - } catch (Exception e) { - log.error("PSRenderer.renderImageArea(): Error rendering bitmap (" - + e.getMessage() + ")", e); - } - } - -} diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index ecd403749..7e32977e6 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -89,6 +89,7 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.extensions.ExtensionAttachment; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.LazyFont; +import org.apache.fop.fonts.SingleByteFont; import org.apache.fop.fonts.Typeface; import org.apache.fop.render.AbstractPathOrientedRenderer; import org.apache.fop.render.Graphics2DAdapter; @@ -660,6 +661,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer } private String getPostScriptNameForFontKey(String key) { + int pos = key.indexOf('_'); + String postFix = null; + if (pos > 0) { + postFix = key.substring(pos); + key = key.substring(0, pos); + } Map fonts = fontInfo.getFonts(); Typeface tf = (Typeface)fonts.get(key); if (tf instanceof LazyFont) { @@ -668,7 +675,11 @@ public class PSRenderer extends AbstractPathOrientedRenderer if (tf == null) { throw new IllegalStateException("Font not available: " + key); } - return tf.getFontName(); + if (postFix == null) { + return tf.getFontName(); + } else { + return tf.getFontName() + postFix; + } } /** @@ -698,7 +709,6 @@ public class PSRenderer extends AbstractPathOrientedRenderer protected void useFont(String key, int size) { try { PSResource res = getPSResourceForFontKey(key); - //gen.useFont(key, size / 1000f); gen.useFont("/" + res.getName(), size / 1000f); gen.getResourceTracker().notifyResourceUsageOnPage(res); } catch (IOException ioe) { @@ -951,7 +961,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer if (!isOptimizeResources()) { this.fontResources = PSFontUtils.writeFontDict(gen, fontInfo); } else { - gen.commentln("%FOPFontSetup"); + gen.commentln("%FOPFontSetup"); //Place-holder, will be replaced in the second pass } gen.writeDSCComment(DSCConstants.END_SETUP); } @@ -1292,17 +1302,16 @@ public class PSRenderer extends AbstractPathOrientedRenderer */ public void renderText(TextArea area) { renderInlineAreaBackAndBorders(area); - String fontname = getInternalFontNameForArea(area); + String fontkey = getInternalFontNameForArea(area); int fontsize = area.getTraitAsInteger(Trait.FONT_SIZE); // This assumes that *all* CIDFonts use a /ToUnicode mapping - Typeface tf = (Typeface) fontInfo.getFonts().get(fontname); + Typeface tf = (Typeface) fontInfo.getFonts().get(fontkey); //Determine position int rx = currentIPPosition + area.getBorderAndPaddingWidthStart(); int bl = currentBPPosition + area.getOffset() + area.getBaselineOffset(); - useFont(fontname, fontsize); Color ct = (Color)area.getTrait(Trait.COLOR); if (ct != null) { try { @@ -1347,30 +1356,75 @@ public class PSRenderer extends AbstractPathOrientedRenderer super.renderSpace(space); } + private Typeface getTypeface(String fontName) { + Typeface tf = (Typeface)fontInfo.getFonts().get(fontName); + if (tf instanceof LazyFont) { + tf = ((LazyFont)tf).getRealFont(); + } + return tf; + } + private void renderText(AbstractTextArea area, String text, int[] letterAdjust) { + String fontkey = getInternalFontNameForArea(area); + int fontSize = area.getTraitAsInteger(Trait.FONT_SIZE); Font font = getFontFromArea(area); - Typeface tf = (Typeface) fontInfo.getFonts().get(font.getFontName()); + Typeface tf = getTypeface(font.getFontName()); + SingleByteFont singleByteFont = null; + if (tf instanceof SingleByteFont) { + singleByteFont = (SingleByteFont)tf; + } + int textLen = text.length(); + if (singleByteFont != null && singleByteFont.hasAdditionalEncodings()) { + int start = 0; + int currentEncoding = -1; + for (int i = 0; i < textLen; i++) { + char c = text.charAt(i); + char mapped = tf.mapChar(c); + int encoding = mapped / 256; + if (currentEncoding != encoding) { + if (i > 0) { + writeText(area, text, start, i - start, letterAdjust, fontSize, tf); + } + if (encoding == 0) { + useFont(fontkey, fontSize); + } else { + useFont(fontkey + "_" + Integer.toString(encoding), fontSize); + } + currentEncoding = encoding; + start = i; + } + } + writeText(area, text, start, textLen - start, letterAdjust, fontSize, tf); + } else { + useFont(fontkey, fontSize); + writeText(area, text, 0, textLen, letterAdjust, fontSize, tf); + } + } + + private void writeText(AbstractTextArea area, String text, int start, int len, + int[] letterAdjust, int fontsize, Typeface tf) { + int end = start + len; int initialSize = text.length(); initialSize += initialSize / 2; StringBuffer sb = new StringBuffer(initialSize); - int textLen = text.length(); if (letterAdjust == null && area.getTextLetterSpaceAdjust() == 0 && area.getTextWordSpaceAdjust() == 0) { sb.append("("); - for (int i = 0; i < textLen; i++) { + for (int i = start; i < end; i++) { final char c = text.charAt(i); - final char mapped = tf.mapChar(c); + final char mapped = (char)(tf.mapChar(c) % 256); PSGenerator.escapeChar(mapped, sb); } sb.append(") t"); } else { sb.append("("); - int[] offsets = new int[textLen]; - for (int i = 0; i < textLen; i++) { + int[] offsets = new int[len]; + for (int i = start; i < end; i++) { final char c = text.charAt(i); final char mapped = tf.mapChar(c); + char codepoint = (char)(mapped % 256); int wordSpace; if (CharUtilities.isAdjustableSpace(mapped)) { @@ -1378,14 +1432,14 @@ public class PSRenderer extends AbstractPathOrientedRenderer } else { wordSpace = 0; } - int cw = tf.getWidth(mapped, font.getFontSize()) / 1000; - int ladj = (letterAdjust != null && i < textLen - 1 ? letterAdjust[i + 1] : 0); - int tls = (i < textLen - 1 ? area.getTextLetterSpaceAdjust() : 0); - offsets[i] = cw + ladj + tls + wordSpace; - PSGenerator.escapeChar(mapped, sb); + 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); + offsets[i - start] = cw + ladj + tls + wordSpace; + PSGenerator.escapeChar(codepoint, sb); } sb.append(")" + PSGenerator.LF + "["); - for (int i = 0; i < textLen; i++) { + for (int i = 0; i < len; i++) { if (i > 0) { if (i % 8 == 0) { sb.append(PSGenerator.LF); @@ -1398,7 +1452,6 @@ public class PSRenderer extends AbstractPathOrientedRenderer sb.append("]" + PSGenerator.LF + "xshow"); } writeln(sb.toString()); - } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/rtf/SVGConverter.java b/src/java/org/apache/fop/render/rtf/SVGConverter.java deleted file mode 100644 index 11ba8dc82..000000000 --- a/src/java/org/apache/fop/render/rtf/SVGConverter.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.apache.batik.transcoder.TranscoderException; -import org.apache.batik.transcoder.TranscoderInput; -import org.apache.batik.transcoder.TranscoderOutput; -import org.apache.batik.transcoder.image.JPEGTranscoder; -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.image.XMLImage; - -/** - * Helper class for converting SVG to bitmap images. - */ -public final class SVGConverter { - - /** logger instance */ - private static Log log = LogFactory.getLog(SVGConverter.class); - - /** - * Constructor is private, because it's just a utility class. - */ - private SVGConverter() { - } - - /** - * Converts a SVG image to a JPEG bitmap. - * @param image the SVG image - * @return a byte array containing the JPEG image - */ - public static byte[] convertToJPEG(XMLImage image) { - JPEGTranscoder transcoder = new JPEGTranscoder(); - /* TODO Disabled to avoid side-effect due to the mixing of source and target resolutions - * This should be reenabled when it has been determined how exactly to handle this - transcoder.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, - new Float(25.4f / 300)); //300dpi should be enough for now. - */ - transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(0.9f)); - TranscoderInput input = new TranscoderInput(image.getDocument()); - ByteArrayOutputStream baout = new ByteArrayOutputStream(16384); - TranscoderOutput output = new TranscoderOutput(baout); - try { - transcoder.transcode(input, output); - return baout.toByteArray(); - } catch (TranscoderException e) { - log.error(e); - return null; - } - } - -} diff --git a/src/java/org/apache/fop/svg/GraphicsConfiguration.java b/src/java/org/apache/fop/svg/GraphicsConfiguration.java new file mode 100644 index 000000000..a92baed27 --- /dev/null +++ b/src/java/org/apache/fop/svg/GraphicsConfiguration.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.svg; + +import java.awt.image.VolatileImage; + +/** + * Adapter to allow subclassing java.awt.GraphicsConfiguration without + * 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. + * + */ +abstract public class GraphicsConfiguration extends java.awt.GraphicsConfiguration { + + /** + * @see java.awt.GraphicsConfiguration#createCompatibleVolatileImage(int, int) + * @since JDK 1.4 + */ + public VolatileImage createCompatibleVolatileImage(int width, int height) { + return null; + } + + /** + * @see java.awt.GraphicsConfiguration#createCompatibleVolatileImage(int, int, int) + * @since JDK 1.5 + */ + public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency) { + return null; + } + +} diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 864809ebe..f6a7cbc3b 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -70,12 +70,10 @@ import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.java2d.AbstractGraphics2D; import org.apache.xmlgraphics.java2d.GraphicContext; -import org.apache.fop.fonts.CIDFont; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontSetup; import org.apache.fop.fonts.FontTriplet; -import org.apache.fop.fonts.LazyFont; import org.apache.fop.pdf.BitmapImage; import org.apache.fop.pdf.PDFAnnotList; import org.apache.fop.pdf.PDFColor; @@ -1473,14 +1471,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { // This assumes that *all* CIDFonts use a /ToUnicode mapping org.apache.fop.fonts.Typeface f = (org.apache.fop.fonts.Typeface)fontInfo.getFonts().get(name); - if (f instanceof LazyFont) { - if (((LazyFont) f).getRealFont() instanceof CIDFont) { - return true; - } - } else if (f instanceof CIDFont) { - return true; - } - return false; + return f.isMultiByte(); } private void addKerning(StringWriter buf, Integer ch1, Integer ch2, diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java index 7154c68a9..754b0794b 100644 --- a/src/java/org/apache/fop/svg/PDFTextPainter.java +++ b/src/java/org/apache/fop/svg/PDFTextPainter.java @@ -43,6 +43,7 @@ import org.apache.batik.gvt.renderer.StrokingTextPainter; import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; import org.apache.batik.gvt.text.TextPaintInfo; import org.apache.batik.gvt.text.TextSpanLayout; + import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; @@ -83,8 +84,12 @@ public class PDFTextPainter extends StrokingTextPainter { super.paintTextRuns(textRuns, g2d); return; } - PDFGraphics2D pdf = (PDFGraphics2D)g2d; - PDFTextUtil textUtil = new PDFTextUtil(pdf); + final PDFGraphics2D pdf = (PDFGraphics2D)g2d; + PDFTextUtil textUtil = new PDFTextUtil(pdf.fontInfo) { + protected void write(String code) { + pdf.currentStream.write(code); + } + }; for (int i = 0; i < textRuns.size(); i++) { TextRun textRun = (TextRun)textRuns.get(i); AttributedCharacterIterator runaci = textRun.getACI(); @@ -134,7 +139,7 @@ public class PDFTextPainter extends StrokingTextPainter { } textUtil.saveGraphicsState(); - textUtil.concatMatrixCurrentTransform(); + textUtil.concatMatrix(g2d.getTransform()); Shape imclip = g2d.getClip(); pdf.writeClip(imclip); diff --git a/src/java/org/apache/fop/svg/PDFTextUtil.java b/src/java/org/apache/fop/svg/PDFTextUtil.java index 0fb552026..f3c7f31a2 100644 --- a/src/java/org/apache/fop/svg/PDFTextUtil.java +++ b/src/java/org/apache/fop/svg/PDFTextUtil.java @@ -19,145 +19,33 @@ package org.apache.fop.svg; -import java.awt.geom.AffineTransform; - import org.apache.fop.fonts.Font; -import org.apache.fop.pdf.PDFNumber; -import org.apache.fop.pdf.PDFText; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.Typeface; /** - * Utility class for generating PDF text objects. + * Utility class for generating PDF text objects. It needs to be subclassed to add writing + * functionality (see {@link #write(String)}). */ -public class PDFTextUtil { +public abstract class PDFTextUtil extends org.apache.fop.pdf.PDFTextUtil { - /** 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 */ - public static final int TR_STROKE = 1; - /** PDF text rendering mode: Fill, then stroke text */ - public static final int TR_FILL_STROKE = 2; - /** PDF text rendering mode: Neither fill nor stroke text (invisible) */ - public static final int TR_INVISIBLE = 3; - /** PDF text rendering mode: Fill text and add to path for clipping */ - public static final int TR_FILL_CLIP = 4; - /** PDF text rendering mode: Stroke text and add to path for clipping */ - public static final int TR_STROKE_CLIP = 5; - /** PDF text rendering mode: Fill, then stroke text and add to path for clipping */ - 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 PDFGraphics2D g2d; - private boolean inTextObject = false; + private FontInfo fontInfo; private Font[] fonts; private Font font; - private String startText; - private String endText; - private boolean useMultiByte; - private StringBuffer bufTJ; - private int textRenderingMode = 0; /** * Main constructor. - * @param g2d the PDFGraphics2D instance to work with + * @param fontInfo the font catalog */ - public PDFTextUtil(PDFGraphics2D g2d) { - this.g2d = g2d; + public PDFTextUtil(FontInfo fontInfo) { + super(); + this.fontInfo = fontInfo; } - private void writeAffineTransform(AffineTransform at, StringBuffer sb) { - double[] lt = new double[6]; - at.getMatrix(lt); - sb.append(PDFNumber.doubleOut(lt[0], DEC)).append(" "); - sb.append(PDFNumber.doubleOut(lt[1], DEC)).append(" "); - sb.append(PDFNumber.doubleOut(lt[2], DEC)).append(" "); - sb.append(PDFNumber.doubleOut(lt[3], DEC)).append(" "); - sb.append(PDFNumber.doubleOut(lt[4], DEC)).append(" "); - sb.append(PDFNumber.doubleOut(lt[5], DEC)); - } - - private void writeChar(char ch, StringBuffer sb) { - if (!useMultiByte) { - if (ch > 127) { - sb.append("\\").append(Integer.toOctalString((int)ch)); - } else { - switch (ch) { - case '(': - case ')': - case '\\': - sb.append("\\"); - break; - default: - } - sb.append(ch); - } - } else { - sb.append(PDFText.toUnicodeHex(ch)); - } - } - - private void checkInTextObject() { - if (!inTextObject) { - throw new IllegalStateException("Not in text object"); - } - } - - /** - * Called when a new text object should be started. Be sure to call setFont() before - * issuing any text painting commands. - */ - public void beginTextObject() { - if (inTextObject) { - throw new IllegalStateException("Already in text object"); - } - g2d.currentStream.write("BT\n"); - this.inTextObject = true; - } - - /** - * Called when a text object should be ended. - */ - public void endTextObject() { - checkInTextObject(); - g2d.currentStream.write("ET\n"); - this.inTextObject = false; - initValues(); - } - - private void initValues() { + /** {@inheritDoc} */ + protected void initValues() { + super.initValues(); this.font = null; - this.textRenderingMode = TR_FILL; - } - - /** - * Creates a "q" command, pushing a copy of the entire graphics state onto the stack. - */ - public void saveGraphicsState() { - g2d.currentStream.write("q\n"); - } - - /** - * Creates a "Q" command, restoring the entire graphics state to its former value by popping - * it from the stack. - */ - public void restoreGraphicsState() { - g2d.currentStream.write("Q\n"); - } - - /** - * Creates a "cm" command using the current transformation as the matrix. - */ - public void concatMatrixCurrentTransform() { - StringBuffer sb = new StringBuffer(); - if (!g2d.getTransform().isIdentity()) { - writeAffineTransform(g2d.getTransform(), sb); - sb.append(" cm\n"); - } - g2d.currentStream.write(sb.toString()); } /** @@ -193,64 +81,24 @@ public class PDFTextUtil { this.font = f; } + /** + * Determines whether the font with the given name is a multi-byte font. + * @param name the name of the font + * @return true if it's a multi-byte font + */ + protected boolean isMultiByteFont(String name) { + Typeface f = (Typeface)fontInfo.getFonts().get(name); + return f.isMultiByte(); + } + /** * Writes a "Tf" command, setting a new current font. * @param f the font to select */ public void writeTf(Font f) { - checkInTextObject(); String fontName = f.getFontName(); float fontSize = (float)f.getFontSize() / 1000f; - g2d.currentStream.write("/" + fontName + " " + PDFNumber.doubleOut(fontSize) + " Tf\n"); - - this.useMultiByte = g2d.isMultiByteFont(fontName); - this.startText = useMultiByte ? "<" : "("; - this.endText = useMultiByte ? ">" : ")"; - } - - /** - * Sets the text rendering mode. - * @param mode the rendering mode (value 0 to 7, see PDF Spec, constants: TR_*) - */ - public void setTextRenderingMode(int mode) { - if (mode < 0 || mode > 7) { - throw new IllegalArgumentException( - "Illegal value for text rendering mode. Expected: 0-7"); - } - if (mode != this.textRenderingMode) { - this.textRenderingMode = mode; - g2d.currentStream.write(this.textRenderingMode + " Tr\n"); - } - } - - /** - * Sets the text rendering mode. - * @param fill true if the text should be filled - * @param stroke true if the text should be stroked - * @param addToClip true if the path should be added for clipping - */ - public void setTextRenderingMode(boolean fill, boolean stroke, boolean addToClip) { - int mode; - if (fill) { - mode = (stroke ? 2 : 0); - } else { - mode = (stroke ? 1 : 3); - } - if (addToClip) { - mode += 4; - } - setTextRenderingMode(mode); - } - - /** - * Writes a "Tm" command, setting a new text transformation matrix. - * @param localTransform the new text transformation matrix - */ - public void writeTextMatrix(AffineTransform localTransform) { - StringBuffer sb = new StringBuffer(); - writeAffineTransform(localTransform, sb); - sb.append(" Tm\n"); - g2d.currentStream.write(sb.toString()); + updateTf(fontName, fontSize, isMultiByteFont(fontName)); } /** @@ -272,37 +120,8 @@ public class PDFTextUtil { * @param ch the unmapped character */ public void writeTJChar(char ch) { - if (bufTJ == null) { - bufTJ = new StringBuffer(); - } - if (bufTJ.length() == 0) { - bufTJ.append("[").append(startText); - } char mappedChar = font.mapChar(ch); - writeChar(mappedChar, bufTJ); - } - - /** - * Writes a glyph adjust value to the "TJ-Buffer". - * @param adjust the glyph adjust value in thousands of text unit space. - */ - public void adjustGlyphTJ(double adjust) { - bufTJ.append(endText).append(" "); - bufTJ.append(PDFNumber.doubleOut(adjust, DEC - 4)); - bufTJ.append(" "); - bufTJ.append(startText); - } - - /** - * Writes a "TJ" command, writing out the accumulated buffer with the characters and glyph - * positioning values. The buffer is reset afterwards. - */ - public void writeTJ() { - if (bufTJ != null && bufTJ.length() > 0) { - bufTJ.append(endText).append("] TJ\n"); - g2d.currentStream.write(bufTJ.toString()); - bufTJ.setLength(0); - } + writeTJMappedChar(mappedChar); } } diff --git a/status.xml b/status.xml index f618b0074..a008177c1 100644 --- a/status.xml +++ b/status.xml @@ -16,25 +16,159 @@ limitations under the License. --> + - + + + + + + + - - - - + + + + + + + + + + + - + + + Added SVG support for AFP (GOCA). + + + Added de-duplication and externalization support for IOCA and GOCA data resource objects. + + + When a JPEG image is embedded, an optionally embedded color profile is filtered out + as it's already embedded separately in the PDF file. + + + Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which + are not sRGB. The images drifted into yellow. The color profile is simply disabled in this + case. Please let us know if you know what the problem could be. + + + Added support for addressing all glyphs available in a Type 1 font, not just the ones + in the font's primary encoding. + + + + +

      + Notes +

      + Besides the important changes listed below, the most important areas with + improvements in this release are: +

      +
        +
      • + Many bugfixes in tables, plus some new features (full support for keeps and + breaks, border conditionality, background on columns and header/footer/body) +
      • +
      • + Improvements and bugfixes for font handling and font + auto-detection/-registration. +
      • +
      • + Performance improvements and memory optimizations for the property handling + in the FO tree. +
      • +
      +

      + Please note that with this release, we've dropped support for Java 1.3. + FOP will, from now on, require at least Java 1.4. +

      +

      + There have been a few changes in tables that make FOP both more strict and more + compliant to the Recommendation: +

        +
      • XSL-FO 1.1 explicitly states that a row-spanning fo:table-cell element is not + allowed to span further than its enclosing fo:table-header/footer/body element + (see bottom of section + 6.7.3). From now on FOP will give a validation error if a document + contains such an erroneous cell. +
      • +
      • +

        If an fo:table element contains explicit fo:table-column children, then those + elements set the total number of columns in the table. This means that a + validation error will now occur if a row contains more cells than available + columns. This change allows to improve performance, since the rendering of the + table may start as soon as the table-column elements have been parsed.

        +

        If more flexibility is needed, then the fo:table-column elements may be just + omitted. The final number of columns will then be set by the row that has the + most cells.

        +
      • +
      +

      +

      + The image libraries Jimi and JAI are no longer needed (and used) for image loading. + Instead we rely completely on the Image I/O API that has been introduced with + Java 1.4. If you still need support for bitmap image formats that do not work + out-of-the-box, we recommend adding + JAI Image I/O Tools + (an Image I/O compatible image codec package) to the classpath. JAI is still required + for building the FOP distribution but it is optional for normal builds and at run-time. +

      +
      + + + Bugfix: The before border of a block is no longer swallowed if its first child issues + a break-before. + + + Bugfix: When there was a forced break after a block with (conditional) borders the + border-after wasn't painted. + + + Bugfix: a forced break inside a cell was ignored when occurring before the minimum height + set on the enclosing row was set. + + + Fixed exceptions when lists, tables or block-container are children of an inline-level + FO. + + + Added support for background on fo:table-column and fo:table-header/footer/body elements. + + + Fixed the rendering of the area of a table corresponding to border-separation, which must + be filled with the background of the table, and not the rows. + + + Improved conformance: even if a table-cell spans several rows its background must + correspond to the first row spanned. + + + Slight improvement for thin lines in Java2D/AWT output. + Added full support for keep-with-previous on fo:table-row and in fo:table-cell elements. Turned on XInclude processing for the main source given on the command line. - + Improved the font auto-detection so fonts accessed using the font-family name are selected with higher accuracy. @@ -64,7 +198,7 @@ Bugfix for date formatting with negative time zones in the PDF's Info object. This affected PDF/A compliance. - + Added an option to disable the default sRGB profile in PDF output for those who don't care about color fidelity, but care about PDF file size. @@ -134,7 +268,7 @@ Added support for custom fonts in Java2DRenderer and derived renderers. - + Added new extension element: fox:external-document. It allows to add whole documents such as multi-page TIFF images to be inserted as peers to a page-sequence. Each image will make up an entire page. See the documentation for details. @@ -143,15 +277,12 @@ Added minimal support for the .minimum/.maximum components of block/inline-progression-dimension on fo:external-graphic and fo:instream-foreign-object. - + Added support for scale-down-to-fit and scale-up-to-fit (introduced in XSL 1.1). Bugfix: content of a row with zero height overriding the previous row - - Added SVG support for AFP (GOCA). - Bugfix: allow multiple bookmarks to point at the same destination. @@ -232,7 +363,7 @@ Added support for fo:markers in fo:inline and fo:basic-link. - + PDF Transcoder (SVG) text painting has been completely rewritten. Except for some special cases (with filters for example), all text (including flow text) is now painted using PDF text operators. @@ -279,31 +410,21 @@ Added a configuration setting for the renderer/device resolution to the AFP renderer. -

      - Facilitate the implementation for font-selection-strategy: -

      -
        -
      • Changed FontInfo.fontLookup to always return an array of FontTriplet
      • -
      • Changed CommonFont.getFontState to return an array of FontTriplet
      • -
      • Initial modifications to the related LMs: initialized with - the font corresponding to the first of the triplets
      • -
      + Facilitate the implementation for font-selection-strategy:
      + • Changed FontInfo.fontLookup to always return an array of FontTriplet.
      + • Changed CommonFont.getFontState to return an array of FontTriplet.
      + • Initial modifications to the related LMs: initialized with + the font corresponding to the first of the triplets.
      -

      PropertyCache phase 2:

      -
        -
      • - improvement of the PropertyCache itself should now guarantee acceptable + PropertyCache phase 2:
        + • improvement of the PropertyCache itself should now guarantee acceptable performance of the static caches in multi-session environments, which is - a possible problem with synchronizedMap -
      • -
      • - changed CommonFont to use the cache: + a possible problem with synchronizedMap.
        + • changed CommonFont to use the cache: added CachedCommonFont to contain the properties that are always cacheable - CommonFont itself is only cached if the remaining properties are absolutes -
      • -
      • changed CommonHyphenation, KeepProperty, ColorProperty and FontFamilyProperty to use the cache
      • -
      + CommonFont itself is only cached if the remaining properties are absolutes.
      + • changed CommonHyphenation, KeepProperty, ColorProperty and FontFamilyProperty to use the cache.
      Fixed swallowing PCDATA in text-node children of @@ -463,33 +584,36 @@ -

      This is the first production grade release of the new FOP - codebase.

      -
        -
      • It contains the new API first introduced in release 0.92 - beta. The preceding API has been removed. -
      • -
      • - See the compliance page for an - overview of the compliance of this release with the XSL 1.0 and - 1.1 recommendations. -
      • -
      • - This release again contains many bug fixes and new features. See - below for details. -
      • -
      • - See the known issues page - for an overview of the known issues with this release. -
      • -
      -

      Caveats:

      -
        -
      • - You may experience different behaviour compared to version 0.20.5. - Please consult the "Upgrading" page for details. -
      • -
      +
      + Notes +

      This is the first production grade release of the new FOP + codebase.

      +
        +
      • It contains the new API first introduced in release 0.92 + beta. The preceding API has been removed. +
      • +
      • + See the compliance page for an + overview of the compliance of this release with the XSL 1.0 and + 1.1 recommendations. +
      • +
      • + This release again contains many bug fixes and new features. See + below for details. +
      • +
      • + See the known issues page + for an overview of the known issues with this release. +
      • +
      +

      Caveats:

      +
        +
      • + You may experience different behaviour compared to version 0.20.5. + Please consult the "Upgrading" page for details. +
      • +
      +
      Added support for the use of Open Type fonts @@ -1064,9 +1188,18 @@ For the change log for the maintenance branch (where FOP 0.20.5 came from), please see the "CHANGES" file in the distribution, or - the CHANGES file in the SVN repository. + the CHANGES file in the SVN repository.
      + + + + + Improve the documentation. + + + + diff --git a/test/java/org/apache/fop/URIResolutionTestCase.java b/test/java/org/apache/fop/URIResolutionTestCase.java index 1277126bc..106ec0a2c 100644 --- a/test/java/org/apache/fop/URIResolutionTestCase.java +++ b/test/java/org/apache/fop/URIResolutionTestCase.java @@ -36,17 +36,19 @@ import javax.xml.transform.sax.TransformerHandler; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.w3c.dom.Document; + import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.xpath.XPathAPI; +import org.apache.xpath.objects.XObject; + 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.render.xml.XMLRenderer; -import org.apache.xpath.XPathAPI; -import org.apache.xpath.objects.XObject; -import org.w3c.dom.Document; /** * Tests URI resolution facilities. @@ -85,9 +87,6 @@ public class URIResolutionTestCase extends AbstractFOPTestCase { private void innerTestFO1(boolean withStream) throws Exception { FOUserAgent ua = fopFactory.newFOUserAgent(); - //Reset the image caches to force URI resolution! - ua.getFactory().getImageFactory().clearCaches(); - File foFile = new File(getBaseDir(), "test/xml/uri-resolution1.fo"); MyURIResolver resolver = new MyURIResolver(withStream); diff --git a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java index b29249f00..c9fba08c7 100644 --- a/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFEncodingTestCase.java @@ -65,7 +65,7 @@ public class PDFEncodingTestCase extends BasePDFTestCase { * The following array is used to look for these patterns */ final String[] testPatterns = { - TEST_MARKER + "1", "(Standard)", + TEST_MARKER + "1", "Standard", TEST_MARKER + "2", "XX_\\351_XX", TEST_MARKER + "3", "XX_\\342\\352\\356\\364\\373_XX" }; @@ -75,7 +75,9 @@ public class PDFEncodingTestCase extends BasePDFTestCase { /** * TODO test disabled for now, fails due (probably) do different PDF - * encoding when custom font is used + * 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 diff --git a/test/layoutengine/disabled-testcases.xml b/test/layoutengine/disabled-testcases.xml index 15ac8aa48..b4de16ef4 100644 --- a/test/layoutengine/disabled-testcases.xml +++ b/test/layoutengine/disabled-testcases.xml @@ -232,54 +232,6 @@ region-body_column-count_bug36356.xml Column balancing doesn't work as expected. - - No background-images on table-body - table-body_background-image.xml - The backgrounds of table-body, table-header, - table-footer and table-column are not painted, yet. - - - Collapsing Border Model NYI - table_border-collapse_collapse_1.xml - Border-collapse="collapse" is not yet - implemented. - - - Collapsing Border Model NYI - table_border-collapse_collapse_2.xml - Border-collapse="collapse" is not yet - implemented. - - - Problems with border and padding on tables - table_border_padding.xml - The element list seems to not be fully correct, yet, causing - the layout to look odd. - - - keep-with-previous doesn't work inside tables - table-cell_block_keep-with-previous.xml - Keep-with-previous doesn't work inside tables and - lists, yet. - - - Border and padding conditionality is NYI on table-cells - table-cell_border_padding_conditionality.xml - Border and padding conditionality are not supported - on table-cells, yet. - - - No background-images on table-header - table-header_background-image.xml - The backgrounds of table-body, table-header, - table-footer and table-column are not painted, yet. - - - keep-with-previous doesn't work on table-rows - table-row_keep-with-previous.xml - Keep-with-previous doesn't work inside tables and - lists, yet. - table-cell empty area with marker.xml table-cell_empty_area_with_marker.xml diff --git a/test/layoutengine/standard-testcases/block-container_absolute-position_no-height_3.xml b/test/layoutengine/standard-testcases/block-container_absolute-position_no-height_3.xml new file mode 100644 index 000000000..d2eba0d3c --- /dev/null +++ b/test/layoutengine/standard-testcases/block-container_absolute-position_no-height_3.xml @@ -0,0 +1,63 @@ + + + + + +

      + This test checks absolutely positioned block-containers with auto-height and shrinks. +

      +
      + + + + + + + + + + + + Lorem ipsum dolor sit amet. + + + Lorem ipsum dolor sit amet. + + + Lorem ipsum dolor sit amet. + + + + + + + + + + + + + + +
      diff --git a/test/layoutengine/standard-testcases/block-level_break-after_bug44412.xml b/test/layoutengine/standard-testcases/block-level_break-after_bug44412.xml new file mode 100644 index 000000000..523d22c6f --- /dev/null +++ b/test/layoutengine/standard-testcases/block-level_break-after_bug44412.xml @@ -0,0 +1,112 @@ + + + + + +

      + This test checks Bugzilla #44412 where the border-after of an fo:block wasn't painted in + case break-after is present. +

      +
      + + + + + + + + + + Before the block + A block with + borders and break-before and break-after. + After the block + + + + + + A block-container with borders and break-after. + + After the block-container + + + + + + + + + + + Blaaaaaah + + + + After the list-block + + + + + + + + + + + Blaaaaaah + + + + After the list-item + + + + + + + + + + Blaaaaah + + + + + After the table + + + + + + + + + + + + + + + + + + + + +
      diff --git a/test/layoutengine/standard-testcases/block_break-before_bug44412.xml b/test/layoutengine/standard-testcases/block_break-before_bug44412.xml new file mode 100644 index 000000000..9ef4150b5 --- /dev/null +++ b/test/layoutengine/standard-testcases/block_break-before_bug44412.xml @@ -0,0 +1,64 @@ + + + + + +

      + This test checks Bugzilla #44412 where a break-before on the first child of an otherwise + empty block is set. It is expected that the parent block creates two areas, the first with + only border-before on the first page and zero bpd. +

      +
      + + + + + + + + + + Before the block + + The break-before set on this block causes the parent + block to produce an empty block area with only a border before on the + first page. + + + + + + + + + + + + + + + + + + + + + 3 + + +
      diff --git a/test/layoutengine/standard-testcases/inline_block-level_nested_1.xml b/test/layoutengine/standard-testcases/inline_block-level_nested_1.xml new file mode 100644 index 000000000..6b6761dee --- /dev/null +++ b/test/layoutengine/standard-testcases/inline_block-level_nested_1.xml @@ -0,0 +1,104 @@ + + + + + +

      + This test checks fo:inline and nested block-level nodes. +

      +
      + + + + + + + + + + + before + + + + + + + Inline list item one. + + + + after + + + before + + " + + + + cell1 + + + cell2 + + + + + after + + + before + + block in block-container + + after + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + +
      diff --git a/test/layoutengine/standard-testcases/table-body_background-image.xml b/test/layoutengine/standard-testcases/table-body_background-image.xml deleted file mode 100644 index 2a9aa9362..000000000 --- a/test/layoutengine/standard-testcases/table-body_background-image.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - -

      - This test checks background image on a fo:table-body. -

      -
      - - ../../resources/images/bgimg300dpi.jpg - - - - - - - - - - - - - - - - - - Header Col 1 - - - Header Col 2 - - - Header Col 3 - - - - - - - Row 1 Col 1 - - - Row 1 Col 2 - - - Row 1 Col 3 - - - - - Row 2 Col 1 - - - Row 2 Col 2 - - - Row 2 Col 3 - - - - - Row 3 Col 1 - - - Row 3 Col 2 - - - Row 3 Col 3 - - - - - Row 4 Col 1 - - - Row 4 Col 2 - - - Row 4 Col 3 - - - - - Table with centered background image on body - - - - - - - -
      diff --git a/test/layoutengine/standard-testcases/table-cell_block_keep-with-previous.xml b/test/layoutengine/standard-testcases/table-cell_block_keep-with-previous.xml deleted file mode 100644 index 00257a10a..000000000 --- a/test/layoutengine/standard-testcases/table-cell_block_keep-with-previous.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - -

      - This test checks keep-with-previous on content inside tables. -

      -
      - - - - - - - - - - block1 - - - - - - - line1 - line2 - - - line1 - - - - - line1 - - - line1 - - - - - block2 - - - - - - - - - - - - - - - - - - - - - - - - 3 - - -
      diff --git a/test/layoutengine/standard-testcases/table-cell_conditional-spaces_2.xml b/test/layoutengine/standard-testcases/table-cell_conditional-spaces_2.xml index 1a9940e38..9a0920cf1 100644 --- a/test/layoutengine/standard-testcases/table-cell_conditional-spaces_2.xml +++ b/test/layoutengine/standard-testcases/table-cell_conditional-spaces_2.xml @@ -168,94 +168,108 @@ + - - - + + + - - + + + + - - + + + + - - - + + + - - + + + + - - - + + + + - - + + + - - + + + + - - - + + + - + + - + + - + +
      diff --git a/test/layoutengine/standard-testcases/table-footer_omit-footer-at-break.xml b/test/layoutengine/standard-testcases/table-footer_omit-footer-at-break.xml index 7b2cc6904..59c60f72e 100644 --- a/test/layoutengine/standard-testcases/table-footer_omit-footer-at-break.xml +++ b/test/layoutengine/standard-testcases/table-footer_omit-footer-at-break.xml @@ -97,35 +97,35 @@ - - - + + + - - - - - - + + + + + + - + - - - + + + - - + + - - - - + + + + diff --git a/test/layoutengine/standard-testcases/table-header_background-image.xml b/test/layoutengine/standard-testcases/table-header_background-image.xml deleted file mode 100644 index f74c13b0d..000000000 --- a/test/layoutengine/standard-testcases/table-header_background-image.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - -

      - This test checks background image on a fo:table-header and footer. -

      -
      - - ../../resources/images/bgimg300dpi.jpg - - - - - - - - - - - - - - - - - - Header Col 1 - - - Header Col 2 - - - Header Col 3 - - - - - - - Footer Col 1 - - - Footer Col 2 - - - Footer Col 3 - - - - - - - Row 1 Col 1 - - - Row 1 Col 2 - - - Row 1 Col 3 - - - - - Row 2 Col 1 - - - Row 2 Col 2 - - - Row 2 Col 3 - - - - - Table with centered background image in header and footer - - - - - - - -
      diff --git a/test/layoutengine/standard-testcases/table-header_omit-header-at-break.xml b/test/layoutengine/standard-testcases/table-header_omit-header-at-break.xml index 6834deeac..5ec211645 100644 --- a/test/layoutengine/standard-testcases/table-header_omit-header-at-break.xml +++ b/test/layoutengine/standard-testcases/table-header_omit-header-at-break.xml @@ -32,7 +32,7 @@ - + @@ -97,23 +97,23 @@ - - - + + + - - - - - - + + + + + + - - - - + + + + @@ -122,8 +122,8 @@ - - - + + + diff --git a/test/layoutengine/standard-testcases/table-header_table-footer_1.xml b/test/layoutengine/standard-testcases/table-header_table-footer_1.xml index df45e328b..00cbcde54 100644 --- a/test/layoutengine/standard-testcases/table-header_table-footer_1.xml +++ b/test/layoutengine/standard-testcases/table-header_table-footer_1.xml @@ -32,7 +32,7 @@ - + @@ -82,31 +82,41 @@ - + + + + + + - - - + + + - - - - + + + + - - - - - + - + + + + + + + + + + diff --git a/test/layoutengine/standard-testcases/table-header_table-footer_2.xml b/test/layoutengine/standard-testcases/table-header_table-footer_2.xml index 9cf3db4c0..7716dfe58 100644 --- a/test/layoutengine/standard-testcases/table-header_table-footer_2.xml +++ b/test/layoutengine/standard-testcases/table-header_table-footer_2.xml @@ -32,7 +32,7 @@ - + @@ -97,40 +97,40 @@ - - - + + + - - - - - - + + + + + + - - - - + + + + - - - + + + - - + + - - - - + + + + diff --git a/test/layoutengine/standard-testcases/table-row_background-image.xml b/test/layoutengine/standard-testcases/table-row_background-image.xml index fa29f1b8e..f4dc65ae7 100644 --- a/test/layoutengine/standard-testcases/table-row_background-image.xml +++ b/test/layoutengine/standard-testcases/table-row_background-image.xml @@ -34,10 +34,8 @@ - - - - + + @@ -82,8 +80,20 @@ - + + + + + + + + + + + + + diff --git a/test/layoutengine/standard-testcases/table-row_height.xml b/test/layoutengine/standard-testcases/table-row_height.xml index b158113f6..934afa69f 100644 --- a/test/layoutengine/standard-testcases/table-row_height.xml +++ b/test/layoutengine/standard-testcases/table-row_height.xml @@ -81,27 +81,37 @@ - - + + + - + + + + + - - - - + - + + + + + + + + + - - - - + + + + diff --git a/test/layoutengine/standard-testcases/table-row_keep-with-previous.xml b/test/layoutengine/standard-testcases/table-row_keep-with-previous.xml index 34a8be4c1..e6131308a 100644 --- a/test/layoutengine/standard-testcases/table-row_keep-with-previous.xml +++ b/test/layoutengine/standard-testcases/table-row_keep-with-previous.xml @@ -19,66 +19,236 @@

      - This test checks keep-with-previous on table-rows. + This test checks that keep-with-previous works on table-row.

      - + - - + + - + + + - block1 - - + 1. Before the table + + - - - line1 - line2 + + + Cell 1.1 Line 1 + Cell 1.1 Line 2 + + + Cell 1.2 Line 1 + Cell 1.2 Line 2 + + + + + Cell 2.1 Line 1 + Cell 2.1 Line 2 + + + Cell 3.1 Line 1 + Cell 3.1 Line 2 + + + + + After the table + + + + + + + 2. Before the table + + + + + + Cell 1.1 Line 1 + Cell 1.1 Line 2 + + + Cell 1.2 Line 1 + Cell 1.2 Line 2 - - line1 + + + + Cell 2.1 Line 1 + Cell 2.1 Line 2 - - - line1 + + + After the table + + + + + + + 3. Before the table + Before the table + + + + + + Cell 1.1 Line 1 + Cell 1.1 Line 2 - - line1 + + Cell 1.2 Line 1 + Cell 1.2 Line 2 + + + + + Cell 2.1 Line 1 + Cell 2.1 Line 2 - block2 + After the table + - - - - - - - - - - - - - - - - - - - 3 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      diff --git a/test/layoutengine/standard-testcases/table_backgrounds.xml b/test/layoutengine/standard-testcases/table_backgrounds.xml new file mode 100644 index 000000000..30564ecf7 --- /dev/null +++ b/test/layoutengine/standard-testcases/table_backgrounds.xml @@ -0,0 +1,392 @@ + + + + + +

      + This test checks backgrounds on table elements. +

      +
      + +
      ../../resources/images/fop-logo-gray-8bit.png
      +
      nonopartial  +
        +
      • [FOP Trunk] only has effect in PDF output, for external PDF destinations (links pointing to destinations + in another PDF), and only works reliably when the PDF is viewed in a standalone PDF viewer. +

        Adobe's browser plugin, for example, ignores the /NewWindow flag. +

        For links pointing to non-PDF destinations (e.g.

      • +
      +
      throwexceptionsControls 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 From c416edbaae9fe4ecd77ecd35e5bbd8edf524e489 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Thu, 31 Jul 2008 16:23:51 +0000 Subject: Merged revisions 681296,681307 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ................ r681296 | jeremias | 2008-07-31 09:07:42 +0100 (Thu, 31 Jul 2008) | 12 lines Blocked revisions 681286,681291 via svnmerge ........ r681286 | jeremias | 2008-07-31 09:15:23 +0200 (Do, 31 Jul 2008) | 1 line Move to XML Graphics Commons 1.3.1. ........ r681291 | jeremias | 2008-07-31 09:45:13 +0200 (Do, 31 Jul 2008) | 1 line Increase version number. ........ ................ r681307 | jeremias | 2008-07-31 10:06:10 +0100 (Thu, 31 Jul 2008) | 149 lines Merged revisions 636407-637074,637076-637118,637120-637790,637792-637856,637858-637992,637994-638047,638049-638307,638309-638315,638318-638936,638938-640888,640890-642905,642907-647402,647404-647536,647538-648983,648985-649005,649007-649013,649015-650549,650551-651301,651303-653536,653538-654452,654454-656285,656287-656523,656525-657519,657521-661579,661581-663481,663483-664691,664693-681285,681287-681290,681292-681298 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95 ........ r666635 | jeremias | 2008-06-11 14:18:53 +0200 (Mi, 11 Jun 2008) | 1 line Fixed resolution handling inside AWT preview dialog. ........ r666662 | jeremias | 2008-06-11 15:33:20 +0200 (Mi, 11 Jun 2008) | 1 line Some notes on RTF and print output. ........ r668533 | jeremias | 2008-06-17 09:57:55 +0200 (Di, 17 Jun 2008) | 2 lines Bugzilla #45151: Note on the "compiling" page that Ant 1.7 is required. The README file already points to this page. ........ r668534 | jeremias | 2008-06-17 09:58:40 +0200 (Di, 17 Jun 2008) | 2 lines Update known issues. Remove ApacheConEU logo. ........ r668550 | jeremias | 2008-06-17 10:05:22 +0200 (Di, 17 Jun 2008) | 2 lines Bugzilla #45146: Removed duplicate LICENSE.txt and Notice.txt from the JAR. ........ r668570 | jeremias | 2008-06-17 10:54:07 +0200 (Di, 17 Jun 2008) | 1 line Wrong line number reported in the case of a line overflow. ........ r668641 | jeremias | 2008-06-17 14:59:25 +0200 (Di, 17 Jun 2008) | 1 line Fixed potential NPE. ........ r669118 | jeremias | 2008-06-18 11:02:45 +0200 (Mi, 18 Jun 2008) | 4 lines Bugzilla #44412: Regression fix for empty pages caused by multiple collapsible breaks. No more empty block areas if a break-before occurs on the first child of an FO to match the behaviour of tables and other FO implementations (clarification by XSL WG pending). Added an accessor interface for break-before/-after to avoid long if..else lists in BlockStackingLayoutManager. ........ r669173 | jeremias | 2008-06-18 16:07:27 +0200 (Mi, 18 Jun 2008) | 7 lines Bugzilla #44887: Fixed potential multi-threading problem concerning the use of DecimalFormat. Results from performance measurements in a separate test (operation repeated 100'000 times, exemplary): shared static variable: ~220ms (old choice, problematic!) always create new instance: ~480ms ThreadLocal: ~220ms (new choice) ........ r669478 | jeremias | 2008-06-19 15:03:57 +0200 (Do, 19 Jun 2008) | 4 lines Bugzilla #44412: Improvements after Vincent's feedback: Removal of the somewhat ugly Reference. getBreakBefore() reduced to private visibility. ........ r670551 | jeremias | 2008-06-23 14:54:27 +0200 (Mo, 23 Jun 2008) | 3 lines Use configured source and target resolution for foreign objects in RTF output. Fixed intrinsic size calculation for SVG images when source resolution is not 72 dpi. Fixed calculation of px2mm values in the SVG to G2D converter (used by RTF output). ........ r673750 | adelmelle | 2008-07-03 20:25:01 +0200 (Do, 03 Jul 2008) | 1 line Fix for Bugzilla 45295 (already committed to the trunk with r672010, r672495 and r672496) ........ r674304 | jeremias | 2008-07-06 17:09:10 +0200 (So, 06 Jul 2008) | 18 lines Bugzilla #43606: column-width accepts percent values (proportional-column-width and % working) Table width accepts percent values (100% of the page width as standard) Nested tables are working It is also possible to make nested tables with a higher depth than 3 without causing word to crash Submitted by: Maximilan Aster Changes to the patch by Jeremias: - Patch simplified (reuse of ColumnSetup from the layoutmgr package) - Percentages and proportional-column-width didn't work properly in my tests -> fixed - Adjustments for FOP code conventions Bugzilla #43824: page-number-citation working but has to be refreshed inside word to show the correct values Submitted by: Maximilan Aster Changes to the patch by Jeremias: - Adjustments for FOP code conventions ........ r674314 | jeremias | 2008-07-06 18:40:08 +0200 (So, 06 Jul 2008) | 7 lines Bugzilla #43825: leader supports fixed percent values for leader-length, most other properties use-content, leader-pattern-width not implemented Submitted by: Maximilan Aster Changes to the patch by Jeremias: - Adjustments for FOP code conventions ........ r674317 | jeremias | 2008-07-06 18:44:43 +0200 (So, 06 Jul 2008) | 1 line Doc update after RTF changes. ........ r675106 | jeremias | 2008-07-09 09:03:46 +0200 (Mi, 09 Jul 2008) | 2 lines Bugzilla #45366: Document missing feature. ........ r675150 | jeremias | 2008-07-09 14:56:41 +0200 (Mi, 09 Jul 2008) | 2 lines Bugzilla #39980: Fixed image scaling for RTF output. ........ r675151 | jeremias | 2008-07-09 14:57:06 +0200 (Mi, 09 Jul 2008) | 1 line Removed unused code. ........ r675152 | jeremias | 2008-07-09 14:58:18 +0200 (Mi, 09 Jul 2008) | 1 line Don't generate commands for default values. ........ r675707 | jeremias | 2008-07-10 21:58:27 +0200 (Do, 10 Jul 2008) | 1 line Bugfix: -imagein didn't work because the stylesheet didn't get copied into fop.jar. ........ r680715 | jeremias | 2008-07-29 16:37:10 +0200 (Di, 29 Jul 2008) | 1 line Found a surplus "pop state" which somehow causes a regression (fill color doesn't get properly reset) between 0.94 and 0.95. Shows in Barcode4J's fop-extension-demo.fo. The line has already been there in 0.94 but only shows in 0.95 probably due to an additional save/restore state pair added in PDFRenderer for reference areas after the block-container area refactoring. ........ r680820 | jeremias | 2008-07-29 22:02:14 +0200 (Di, 29 Jul 2008) | 2 lines Bugzilla #41306: The AWT Renderer is really not out-of-order capable. ........ r681284 | jeremias | 2008-07-31 08:47:49 +0200 (Do, 31 Jul 2008) | 1 line Some updates to status.xml (I was not the only one working on the final release). ........ r681290 | jeremias | 2008-07-31 09:44:51 +0200 (Do, 31 Jul 2008) | 2 lines Website updates for the 0.95 release. The projectInfo plug-in of Forrest is not ideal for doing a bugfix release. It's not possible to combine the changes for two releases. ........ r681292 | jeremias | 2008-07-31 09:47:13 +0200 (Do, 31 Jul 2008) | 1 line Disabling the ApacheCon ad for the release build. ........ ................ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@681410 13f79535-47bb-0310-9956-ffa450edef68 --- README | 12 +- build.xml | 1 + known-issues.xml | 9 +- lib/avalon-framework-4.2.0.jar | Bin 86038 -> 81961 bytes src/documentation/content/xdocs/0.95/compiling.xml | 2 +- src/documentation/content/xdocs/0.95/output.xml | 28 ++ src/documentation/content/xdocs/knownissues.xml | 1 + src/documentation/content/xdocs/site.xml | 7 +- src/documentation/content/xdocs/tabs.xml | 2 +- .../content/xdocs/trunk/compiling.xml | 2 +- src/documentation/content/xdocs/trunk/output.xml | 29 ++ src/documentation/skinconf.xml | 2 + src/java/org/apache/fop/fo/flow/Block.java | 3 +- .../org/apache/fop/fo/flow/BlockContainer.java | 3 +- src/java/org/apache/fop/fo/flow/ListBlock.java | 3 +- src/java/org/apache/fop/fo/flow/ListItem.java | 3 +- src/java/org/apache/fop/fo/flow/table/Table.java | 3 +- .../apache/fop/fo/flow/table/TableAndCaption.java | 2 +- .../org/apache/fop/fo/flow/table/TableRow.java | 3 +- .../apache/fop/fo/properties/BreakPropertySet.java | 33 ++ src/java/org/apache/fop/fonts/MultiByteFont.java | 4 +- .../image/loader/batik/ImageConverterSVG2G2D.java | 4 +- .../fop/image/loader/batik/PreloaderSVG.java | 14 +- .../fop/layoutmgr/BlockContainerLayoutManager.java | 9 +- .../fop/layoutmgr/BlockStackingLayoutManager.java | 57 +-- .../org/apache/fop/layoutmgr/LayoutContext.java | 14 +- .../fop/layoutmgr/list/ListItemLayoutManager.java | 5 +- .../apache/fop/layoutmgr/table/ColumnSetup.java | 20 +- .../fop/layoutmgr/table/TableLayoutManager.java | 14 +- src/java/org/apache/fop/pdf/PDFNumber.java | 52 ++- .../fop/render/awt/viewer/PreviewDialog.java | 32 +- .../apache/fop/render/awt/viewer/PreviewPanel.java | 12 +- .../fop/render/pdf/PDFGraphics2DAdapter.java | 1 - .../fop/render/rtf/BorderAttributesConverter.java | 10 +- .../apache/fop/render/rtf/FoUnitsConverter.java | 7 +- .../fop/render/rtf/PageAttributesConverter.java | 5 +- src/java/org/apache/fop/render/rtf/RTFHandler.java | 452 ++++++++++----------- .../fop/render/rtf/TextAttributesConverter.java | 136 ++++++- .../render/rtf/rtflib/rtfdoc/RtfAttributes.java | 10 + .../rtf/rtflib/rtfdoc/RtfExternalGraphic.java | 66 ++- .../fop/render/rtf/rtflib/rtfdoc/RtfLeader.java | 219 ++++++++++ .../fop/render/rtf/rtflib/rtfdoc/RtfPage.java | 6 +- .../rtf/rtflib/rtfdoc/RtfPageNumberCitation.java | 8 +- .../fop/render/rtf/rtflib/rtfdoc/RtfTable.java | 21 +- .../fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java | 4 +- .../fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java | 20 +- .../render/rtf/rtflib/tools/PercentContext.java | 136 +++++++ src/java/org/apache/fop/util/BreakUtil.java | 3 +- status.xml | 107 ++++- .../image/loader/batik/ImageLoaderTestCase.java | 45 ++ .../block_break-before_bug44412.xml | 17 +- .../block_break-before_bug44412_2.xml | 151 +++++++ test/resources/images/circles.svg | 8 + 53 files changed, 1419 insertions(+), 398 deletions(-) create mode 100644 src/java/org/apache/fop/fo/properties/BreakPropertySet.java create mode 100644 src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLeader.java create mode 100644 src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java create mode 100644 test/layoutengine/standard-testcases/block_break-before_bug44412_2.xml create mode 100644 test/resources/images/circles.svg (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/README b/README index 133232276..37ede8930 100644 --- a/README +++ b/README @@ -90,11 +90,11 @@ http://xmlgraphics.apache.org/fop/stable/running.html RELEASE NOTES ============================================================================== -Version 0.95beta -================ +Version 0.95 +============ -This is a pre-version of the third production grade release of the new FOP -codebase. It contains many bug fixes and new features. See below for details. +This is a production grade release of Apache FOP. +It contains many bug fixes and new features. See below for details. Compliance ---------- @@ -128,6 +128,10 @@ http://xmlgraphics.apache.org/fop/0.95/changes_0.95.html. The long list of changes in this and earlier releases is available at http://xmlgraphics.apache.org/fop/changes.html. +Changes since Version 0.95beta +------------------------------ +Please refer to the list of changes on the web: +http://xmlgraphics.apache.org/fop/changes.html Version 0.94 diff --git a/build.xml b/build.xml index b55cabb2f..346125c14 100644 --- a/build.xml +++ b/build.xml @@ -401,6 +401,7 @@ list of possible build targets. + diff --git a/known-issues.xml b/known-issues.xml index 27ae55494..2ef4b7102 100644 --- a/known-issues.xml +++ b/known-issues.xml @@ -21,8 +21,9 @@ MIF and SVG output support have not been restored, yet. - Java2D/AWT support has been improved, but some problems remain, - for example with block-containers. + RTF output is inferior to other output formats supported by FOP. + For details, please see the "Output Targets" page of the release + you're using. Auto table layout is not implemented, yet. @@ -80,10 +81,6 @@ Not all FO elements can be referenced by their "id", most notably: table-body, table-header, table-footer and table-row. - - The backgrounds of table-body, table-header, table-footer and - table-column are not painted, yet. - Border and padding conditionality are not supported on table-cells, yet. diff --git a/lib/avalon-framework-4.2.0.jar b/lib/avalon-framework-4.2.0.jar index b1aa6d7c9..22a7ab341 100644 Binary files a/lib/avalon-framework-4.2.0.jar and b/lib/avalon-framework-4.2.0.jar differ diff --git a/src/documentation/content/xdocs/0.95/compiling.xml b/src/documentation/content/xdocs/0.95/compiling.xml index 57761429f..98a6dfb6d 100644 --- a/src/documentation/content/xdocs/0.95/compiling.xml +++ b/src/documentation/content/xdocs/0.95/compiling.xml @@ -66,7 +66,7 @@

      Apache Ant

      - Apache Ant must be installed in order to + Apache Ant (Version 1.7 or later) must be installed in order to build FOP. Following best practices we don't include Ant with FOP anymore. You can find the instructions to install Ant in the Ant manual on the web.

      diff --git a/src/documentation/content/xdocs/0.95/output.xml b/src/documentation/content/xdocs/0.95/output.xml index 628df1248..fbf277b90 100644 --- a/src/documentation/content/xdocs/0.95/output.xml +++ b/src/documentation/content/xdocs/0.95/output.xml @@ -703,6 +703,24 @@ out = proc.getOutputStream();]]> RTF output is currently unmaintained and lacks many features compared to other output formats. Using other editable formats like Open Document Format, instead of producing XSL-FO then RTF through FOP, might give better results. +

      + These are some known restrictions compared to other supported output formats (not a complete list): +

      +
        +
      • + Not supported/implemented: +
          +
        • break-before/after (supported by the RTF library but not tied into the RTFHandler)
        • +
        • fo:page-number-citation-last
        • +
        • keeps (supported by the RTF library but not tied into the RTFHandler)
        • +
        • region-start/end (RTF limitation)
        • +
        • multiple columns
        • +
        +
      • +
      • Only a single page-master is supported
      • +
      • Not all variations of fo:leader are supported (RTF limitation)
      • +
      • percentages are not supported everywhere
      • +
      XML (Area Tree XML) @@ -735,6 +753,16 @@ out = proc.getOutputStream();]]> It is possible to directly print the document from the command line. This is done with the same code that renders to the Java2D/AWT renderer.

      +
      Bitmap (TIFF/PNG) diff --git a/src/documentation/content/xdocs/knownissues.xml b/src/documentation/content/xdocs/knownissues.xml index caf96ceaa..ea39b2974 100644 --- a/src/documentation/content/xdocs/knownissues.xml +++ b/src/documentation/content/xdocs/knownissues.xml @@ -66,6 +66,7 @@
      Other known issues

      This section lists other known issues.

      +
      diff --git a/src/documentation/content/xdocs/site.xml b/src/documentation/content/xdocs/site.xml index b0a3214e7..5ebdef322 100644 --- a/src/documentation/content/xdocs/site.xml +++ b/src/documentation/content/xdocs/site.xml @@ -96,10 +96,11 @@ - + - - + + + diff --git a/src/documentation/content/xdocs/tabs.xml b/src/documentation/content/xdocs/tabs.xml index a42fc9bd7..3db01d4fa 100644 --- a/src/documentation/content/xdocs/tabs.xml +++ b/src/documentation/content/xdocs/tabs.xml @@ -22,7 +22,7 @@ - + diff --git a/src/documentation/content/xdocs/trunk/compiling.xml b/src/documentation/content/xdocs/trunk/compiling.xml index 57761429f..98a6dfb6d 100644 --- a/src/documentation/content/xdocs/trunk/compiling.xml +++ b/src/documentation/content/xdocs/trunk/compiling.xml @@ -66,7 +66,7 @@
      Apache Ant

      - Apache Ant must be installed in order to + Apache Ant (Version 1.7 or later) must be installed in order to build FOP. Following best practices we don't include Ant with FOP anymore. You can find the instructions to install Ant in the Ant manual on the web.

      diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml index d03041f19..5e1b09088 100644 --- a/src/documentation/content/xdocs/trunk/output.xml +++ b/src/documentation/content/xdocs/trunk/output.xml @@ -754,6 +754,24 @@ out = proc.getOutputStream();]]> RTF output is currently unmaintained and lacks many features compared to other output formats. Using other editable formats like Open Document Format, instead of producing XSL-FO then RTF through FOP, might give better results. +

      + These are some known restrictions compared to other supported output formats (not a complete list): +

      +
        +
      • + Not supported/implemented: +
          +
        • break-before/after (supported by the RTF library but not tied into the RTFHandler)
        • +
        • fo:page-number-citation-last
        • +
        • keeps (supported by the RTF library but not tied into the RTFHandler)
        • +
        • region-start/end (RTF limitation)
        • +
        • multiple columns
        • +
        +
      • +
      • Only a single page-master is supported
      • +
      • Not all variations of fo:leader are supported (RTF limitation)
      • +
      • percentages are not supported everywhere
      • +
      XML (Area Tree XML) @@ -786,6 +804,16 @@ out = proc.getOutputStream();]]> It is possible to directly print the document from the command line. This is done with the same code that renders to the Java2D/AWT renderer.

      +
      Bitmap (TIFF/PNG) @@ -937,3 +965,4 @@ out = proc.getOutputStream();]]> + diff --git a/src/documentation/skinconf.xml b/src/documentation/skinconf.xml index 20b12808e..b9a12fa59 100644 --- a/src/documentation/skinconf.xml +++ b/src/documentation/skinconf.xml @@ -378,6 +378,7 @@ which will be used to configure the chosen Forrest skin. 125 --> + PDF created by Apache FOP diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index d1df9c21d..4645734b2 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -32,6 +32,7 @@ import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.NullCharIterator; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonHyphenation; @@ -44,7 +45,7 @@ import org.apache.fop.fo.properties.SpaceProperty; * Class modelling the * fo:block object. */ -public class Block extends FObjMixed { +public class Block extends FObjMixed implements BreakPropertySet { // used for FO validation private boolean blockOrInlineItemFound = false; diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index 25b3f2a2a..b0bfb3a32 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java @@ -28,6 +28,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.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonAbsolutePosition; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; @@ -38,7 +39,7 @@ import org.apache.fop.fo.properties.LengthRangeProperty; * Class modelling the * fo:block-container object. */ -public class BlockContainer extends FObj { +public class BlockContainer extends FObj implements BreakPropertySet { // The value of properties relevant for fo:block-container. private CommonAbsolutePosition commonAbsolutePosition; private CommonBorderPaddingBackground commonBorderPaddingBackground; diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index dfadc9c02..8f72ded67 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -27,6 +27,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.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.KeepProperty; @@ -35,7 +36,7 @@ import org.apache.fop.fo.properties.KeepProperty; * Class modelling the * fo:list-block object. */ -public class ListBlock extends FObj { +public class ListBlock extends FObj implements BreakPropertySet { // The value of properties relevant for fo:list-block. private CommonBorderPaddingBackground commonBorderPaddingBackground; private CommonMarginBlock commonMarginBlock; diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index 95760c00b..f748bc15a 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -26,6 +26,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.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.KeepProperty; @@ -34,7 +35,7 @@ import org.apache.fop.fo.properties.KeepProperty; * Class modelling the * fo:list-item object. */ -public class ListItem extends FObj { +public class ListItem extends FObj implements BreakPropertySet { // The value of properties relevant for fo:list-item. private CommonBorderPaddingBackground commonBorderPaddingBackground; private CommonMarginBlock commonMarginBlock; 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 efd1f1c93..86196cb29 100644 --- a/src/java/org/apache/fop/fo/flow/table/Table.java +++ b/src/java/org/apache/fop/fo/flow/table/Table.java @@ -31,6 +31,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.StaticPropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.KeepProperty; @@ -42,7 +43,7 @@ import org.apache.fop.fo.properties.TableColLength; * Class modelling the * fo:table object. */ -public class Table extends TableFObj implements ColumnNumberManagerHolder { +public class Table extends TableFObj implements ColumnNumberManagerHolder, BreakPropertySet { /** properties */ private CommonBorderPaddingBackground commonBorderPaddingBackground; 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 548a9c4fa..919e73bfb 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java +++ b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java @@ -32,7 +32,7 @@ import org.apache.fop.fo.ValidationException; * fo:table-and-caption property. * @todo needs implementation */ -public class TableAndCaption extends FObj { +public class TableAndCaption extends FObj /*implements BreakPropertySet*/ { // The value of properties relevant for fo:table-and-caption. // Unused but valid items, commented out for performance: // private CommonAccessibility commonAccessibility; 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 4d11f8780..a40b550bc 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/table/TableRow.java @@ -27,6 +27,7 @@ import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.LengthRangeProperty; @@ -35,7 +36,7 @@ import org.apache.fop.fo.properties.LengthRangeProperty; * Class modelling the * fo:table-row object. */ -public class TableRow extends TableCellContainer { +public class TableRow extends TableCellContainer implements BreakPropertySet { // The value of properties relevant for fo:table-row. private LengthRangeProperty blockProgressionDimension; private CommonBorderPaddingBackground commonBorderPaddingBackground; diff --git a/src/java/org/apache/fop/fo/properties/BreakPropertySet.java b/src/java/org/apache/fop/fo/properties/BreakPropertySet.java new file mode 100644 index 000000000..2babe0f19 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/BreakPropertySet.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.fo.properties; + +/** + * Defines property access methods for the break-before and break-after properties. + */ +public interface BreakPropertySet { + + /** @return the "break-after" property. */ + int getBreakAfter(); + + /** @return the "break-before" property. */ + int getBreakBefore(); + +} diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java index 4843b308a..f25ca4e7e 100644 --- a/src/java/org/apache/fop/fonts/MultiByteFont.java +++ b/src/java/org/apache/fop/fonts/MultiByteFont.java @@ -29,7 +29,6 @@ import java.util.Map; 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"; @@ -58,7 +57,8 @@ public class MultiByteFont extends CIDFont { uniqueCounter = 0; //We need maximum 5 character then we start again } } - String cntString = COUNTER_FORMAT.format(uniqueCounter); + DecimalFormat counterFormat = new DecimalFormat("00000"); + String cntString = counterFormat.format(uniqueCounter); //Subset prefix as described in chapter 5.5.3 of PDF 1.4 StringBuffer sb = new StringBuffer("E"); 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 b7ea72bf0..624d99fc0 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java @@ -68,10 +68,10 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter { } //Prepare - float pxToMillimeter = (float)UnitConv.mm2in(72); //default: 72dpi + float pxToMillimeter = UnitConv.IN2MM / 72; //default: 72dpi Number ptm = (Number)hints.get(ImageProcessingHints.SOURCE_RESOLUTION); if (ptm != null) { - pxToMillimeter = (float)UnitConv.mm2in(ptm.doubleValue()); + pxToMillimeter = (float)(UnitConv.IN2MM / ptm.doubleValue()); } UserAgent ua = createBatikUserAgent(pxToMillimeter); GVTBuilder builder = new GVTBuilder(); 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 ce6cde9d9..916b80d02 100644 --- a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java +++ b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java @@ -46,6 +46,7 @@ import org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader; 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.xmlgraphics.util.UnitConv; import org.apache.fop.svg.SimpleSVGUserAgent; import org.apache.fop.util.UnclosableInputStream; @@ -119,7 +120,7 @@ public class PreloaderSVG extends AbstractImagePreloader { in.mark(length + 1); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory( getParserName()); - doc = (SVGDocument) factory.createSVGDocument(src.getSystemId(), in); + doc = factory.createSVGDocument(src.getSystemId(), in); } ImageInfo info = createImageInfo(uri, context, doc); @@ -154,7 +155,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 = UnitConv.IN2MM / context.getSourceResolution(); UserAgent userAg = new SimpleSVGUserAgent(pxUnitToMillimeter, new AffineTransform()) { @@ -184,9 +185,12 @@ public class PreloaderSVG extends AbstractImagePreloader { float height = UnitProcessor.svgVerticalLengthToUserSpace( s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx); + int widthMpt = (int)Math.round(px2mpt(width, context.getSourceResolution())); + int heightMpt = (int)Math.round(px2mpt(height, context.getSourceResolution())); + ImageInfo info = new ImageInfo(uri, MimeConstants.MIME_SVG); ImageSize size = new ImageSize(); - size.setSizeInMillipoints(Math.round(width * 1000), Math.round(height * 1000)); + size.setSizeInMillipoints(widthMpt, heightMpt); //Set the resolution to that of the FOUserAgent size.setResolution(context.getSourceResolution()); size.calcPixelsFromSize(); @@ -210,4 +214,8 @@ public class PreloaderSVG extends AbstractImagePreloader { } + private static double px2mpt(double px, double resolution) { + return px * 1000 * UnitConv.IN2PT / resolution; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index 17eb44049..b6dd4d082 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -251,12 +251,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager List returnList = new LinkedList(); if (!breakBeforeServed) { - try { + breakBeforeServed = true; + if (!context.suppressBreakBefore()) { if (addKnuthElementsForBreakBefore(returnList, context)) { return returnList; } - } finally { - breakBeforeServed = true; } } @@ -281,6 +280,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit)); childLC.setRefIPD(relDims.ipd); childLC.setWritingMode(getBlockContainerFO().getWritingMode()); + if (curLM == this.childLMs.get(0)) { + childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE); + //Handled already by the parent (break collapsing, see above) + } // get elements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index 1d6662cb2..8837b1a0f 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -31,11 +31,13 @@ import org.apache.fop.area.Area; import org.apache.fop.area.Block; import org.apache.fop.area.BlockParent; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.layoutmgr.inline.InlineLayoutManager; import org.apache.fop.layoutmgr.inline.LineLayoutManager; import org.apache.fop.traits.MinOptMax; +import org.apache.fop.util.BreakUtil; import org.apache.fop.util.ListUtil; /** @@ -255,12 +257,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager List returnList = new LinkedList(); if (!breakBeforeServed) { - try { + breakBeforeServed = true; + if (!context.suppressBreakBefore()) { if (addKnuthElementsForBreakBefore(returnList, context)) { return returnList; } - } finally { - breakBeforeServed = true; } } @@ -294,6 +295,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(referenceIPD); } + if (curLM == this.childLMs.get(0)) { + childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE); + //Handled already by the parent (break collapsing, see above) + } // get elements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); @@ -1004,18 +1009,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager */ protected boolean addKnuthElementsForBreakBefore(List returnList, LayoutContext context) { - int breakBefore = -1; - if (fobj instanceof org.apache.fop.fo.flow.Block) { - breakBefore = ((org.apache.fop.fo.flow.Block) fobj).getBreakBefore(); - } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) { - breakBefore = ((org.apache.fop.fo.flow.BlockContainer) fobj).getBreakBefore(); - } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) { - breakBefore = ((org.apache.fop.fo.flow.ListBlock) fobj).getBreakBefore(); - } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) { - breakBefore = ((org.apache.fop.fo.flow.ListItem) fobj).getBreakBefore(); - } else if (fobj instanceof org.apache.fop.fo.flow.table.Table) { - breakBefore = ((org.apache.fop.fo.flow.table.Table) fobj).getBreakBefore(); - } + int breakBefore = getBreakBefore(); if (breakBefore == EN_PAGE || breakBefore == EN_COLUMN || breakBefore == EN_EVEN_PAGE @@ -1029,6 +1023,27 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } + /** + * Returns the break-before value of the current formatting object. + * @return the break-before value (Constants.EN_*) + */ + private int getBreakBefore() { + int breakBefore = EN_AUTO; + if (fobj instanceof BreakPropertySet) { + breakBefore = ((BreakPropertySet)fobj).getBreakBefore(); + } + if (true /* uncomment to only partially merge: && breakBefore != EN_AUTO*/) { + LayoutManager lm = getChildLM(); + //It is assumed this is only called when the first LM is active. + if (lm instanceof BlockStackingLayoutManager) { + BlockStackingLayoutManager bslm = (BlockStackingLayoutManager)lm; + breakBefore = BreakUtil.compareBreakClasses( + breakBefore, bslm.getBreakBefore()); + } + } + return breakBefore; + } + /** * Creates Knuth elements for break-after and adds them to the return list. * @param returnList return list to add the additional elements to @@ -1038,16 +1053,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected boolean addKnuthElementsForBreakAfter(List returnList, LayoutContext context) { int breakAfter = -1; - if (fobj instanceof org.apache.fop.fo.flow.Block) { - breakAfter = ((org.apache.fop.fo.flow.Block) fobj).getBreakAfter(); - } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) { - breakAfter = ((org.apache.fop.fo.flow.BlockContainer) fobj).getBreakAfter(); - } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) { - breakAfter = ((org.apache.fop.fo.flow.ListBlock) fobj).getBreakAfter(); - } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) { - breakAfter = ((org.apache.fop.fo.flow.ListItem) fobj).getBreakAfter(); - } else if (fobj instanceof org.apache.fop.fo.flow.table.Table) { - breakAfter = ((org.apache.fop.fo.flow.table.Table) fobj).getBreakAfter(); + if (fobj instanceof BreakPropertySet) { + breakAfter = ((BreakPropertySet)fobj).getBreakAfter(); } if (breakAfter == EN_PAGE || breakAfter == EN_COLUMN diff --git a/src/java/org/apache/fop/layoutmgr/LayoutContext.java b/src/java/org/apache/fop/layoutmgr/LayoutContext.java index 1be89304b..8b716dfde 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutContext.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutContext.java @@ -47,12 +47,10 @@ public class LayoutContext { public static final int CHECK_REF_AREA = 0x08; /** - * If this flag is set, it indicates that any leading fo:character - * objects with suppress-at-line-break="suppress" should not generate - * areas. This is the case at the beginning of each new LineArea - * except the first. + * If this flag is set, it indicates that any break-before values other than "auto" should + * not cause a mandatory break as this break was already handled by a parent layout manager. */ - public static final int SUPPRESS_LEADING_SPACE = 0x10; + public static final int SUPPRESS_BREAK_BEFORE = 0x10; public static final int FIRST_AREA = 0x20; public static final int TRY_HYPHENATE = 0x40; public static final int LAST_AREA = 0x80; @@ -227,8 +225,8 @@ public class LayoutContext { return ((this.flags & LAST_AREA) != 0); } - public boolean suppressLeadingSpace() { - return ((this.flags & SUPPRESS_LEADING_SPACE) != 0); + public boolean suppressBreakBefore() { + return ((this.flags & SUPPRESS_BREAK_BEFORE) != 0); } /** @@ -655,7 +653,7 @@ public class LayoutContext { + "\nSpace Adjust: \t" + getSpaceAdjust() + "\nIPD Adjust: \t" + getIPDAdjust() + "\nResolve Leading Space: \t" + resolveLeadingSpace() - + "\nSuppress Leading Space: \t" + suppressLeadingSpace() + + "\nSuppress Break Before: \t" + suppressBreakBefore() + "\nIs First Area: \t" + isFirstArea() + "\nStarts New Area: \t" + startsNewArea() + "\nIs Last Area: \t" + isLastArea() diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index f027922f7..d83cca642 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -197,12 +197,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager List returnList = new LinkedList(); if (!breakBeforeServed) { - try { + breakBeforeServed = true; + if (!context.suppressBreakBefore()) { if (addKnuthElementsForBreakBefore(returnList, context)) { return returnList; } - } finally { - breakBeforeServed = true; } } diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index c32c6eb3d..c1fc19050 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -184,10 +184,22 @@ public class ColumnSetup { * @return the computed base unit (in millipoint) */ protected double computeTableUnit(TableLayoutManager tlm) { + return computeTableUnit(tlm, tlm.getContentAreaIPD()); + } + + /** + * Works out the base unit for resolving proportional-column-width() + * [p-c-w(x) = x * base_unit_ipd] + * + * @param percentBaseContext the percent base context for relative values + * @param contentAreaIPD the IPD of the available content area + * @return the computed base unit (in millipoints) + */ + public float computeTableUnit(PercentBaseContext percentBaseContext, int contentAreaIPD) { int sumCols = 0; float factors = 0; - double unit = 0; + float unit = 0; /* calculate the total width (specified absolute/percentages), * and work out the total number of factors to use to distribute @@ -196,7 +208,7 @@ public class ColumnSetup { for (Iterator i = colWidths.iterator(); i.hasNext();) { Length colWidth = (Length) i.next(); if (colWidth != null) { - sumCols += colWidth.getValue(tlm); + sumCols += colWidth.getValue(percentBaseContext); if (colWidth instanceof RelativeNumericProperty) { factors += ((RelativeNumericProperty) colWidth).getTableUnits(); } else if (colWidth instanceof TableColLength) { @@ -209,8 +221,8 @@ public class ColumnSetup { * factors (if any) */ if (factors > 0) { - if (sumCols < tlm.getContentAreaIPD()) { - unit = (tlm.getContentAreaIPD() - sumCols) / factors; + if (sumCols < contentAreaIPD) { + unit = (contentAreaIPD - sumCols) / factors; } else { log.warn("No space remaining to distribute over columns."); } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index 143c63bb9..dc2b3cc46 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -267,12 +267,14 @@ public class TableLayoutManager extends BlockStackingLayoutManager } addKnuthElementsForSpaceAfter(returnList, alignment); - //addKnuthElementsForBreakBefore(returnList, context); - int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(), - childLC.getBreakBefore()); - if (breakBefore != Constants.EN_AUTO) { - returnList.add(0, new BreakElement(getAuxiliaryPosition(), 0, - -KnuthElement.INFINITE, breakBefore, context)); + if (!context.suppressBreakBefore()) { + //addKnuthElementsForBreakBefore(returnList, context); + int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(), + childLC.getBreakBefore()); + if (breakBefore != Constants.EN_AUTO) { + returnList.add(0, new BreakElement(getAuxiliaryPosition(), 0, + -KnuthElement.INFINITE, breakBefore, context)); + } } //addKnuthElementsForBreakAfter(returnList, context); diff --git a/src/java/org/apache/fop/pdf/PDFNumber.java b/src/java/org/apache/fop/pdf/PDFNumber.java index 55834f529..c2fc704da 100644 --- a/src/java/org/apache/fop/pdf/PDFNumber.java +++ b/src/java/org/apache/fop/pdf/PDFNumber.java @@ -67,11 +67,33 @@ public class PDFNumber extends PDFObject { return doubleOut(doubleDown, 6); } - // 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.################"; + private static class DecimalFormatThreadLocal extends ThreadLocal { + + private int dec; + + public DecimalFormatThreadLocal(int dec) { + this.dec = dec; + } + + protected synchronized Object initialValue() { + String s = "0"; + if (dec > 0) { + s = BASE_FORMAT.substring(0, dec + 2); + } + DecimalFormat df = new DecimalFormat(s, new DecimalFormatSymbols(Locale.US)); + return df; + } + }; + //DecimalFormat is not thread-safe! + private static final ThreadLocal[] DECIMAL_FORMAT_CACHE = new DecimalFormatThreadLocal[17]; + static { + for (int i = 0, c = DECIMAL_FORMAT_CACHE.length; i < c; i++) { + DECIMAL_FORMAT_CACHE[i] = new DecimalFormatThreadLocal(i); + } + } + /** * Output a double value to a string suitable for PDF. * In this method it is possible to set the maximum @@ -82,29 +104,15 @@ public class PDFNumber extends PDFObject { * @return the value as a string */ public static String doubleOut(double doubleDown, int dec) { - if (dec < 0 || dec >= decimalFormatCache.length) { + if (dec < 0 || dec >= DECIMAL_FORMAT_CACHE.length) { throw new IllegalArgumentException("Parameter dec must be between 1 and " - + (decimalFormatCache.length + 1)); + + (DECIMAL_FORMAT_CACHE.length + 1)); } - if (decimalFormatCache[dec] == null) { - //We don't care about the rare case where a DecimalFormat might be replaced in - //a multi-threaded environment, so we don't synchronize the access to the static - //array (mainly for performance reasons). After all, the DecimalFormat instances - //read-only objects so it doesn't matter which instance is used as long as one - //is available. - String s = "0"; - if (dec > 0) { - s = BASE_FORMAT.substring(0, dec + 2); - } - DecimalFormat df = new DecimalFormat(s, new DecimalFormatSymbols(Locale.US)); - decimalFormatCache[dec] = df; - } - return decimalFormatCache[dec].format(doubleDown); + DecimalFormat df = (DecimalFormat)DECIMAL_FORMAT_CACHE[dec].get(); + return df.format(doubleDown); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected String toPDFString() { if (getNumber() == null) { throw new IllegalArgumentException( 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 7c4d66689..e3f510853 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java @@ -38,7 +38,6 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; - import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Locale; @@ -60,8 +59,8 @@ import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; -import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOPException; +import org.apache.fop.apps.FOUserAgent; import org.apache.fop.render.awt.AWTRenderer; /** @@ -76,6 +75,8 @@ public class PreviewDialog extends JFrame implements StatusListener { protected AWTRenderer renderer; /** The FOUserAgent associated with this window */ protected FOUserAgent foUserAgent; + /** The originally configured target resolution */ + protected float configuredTargetResolution; /** * Renderable instance that can be used to reload and re-render a document after * modifications. @@ -107,6 +108,7 @@ public class PreviewDialog extends JFrame implements StatusListener { public PreviewDialog(FOUserAgent foUserAgent, Renderable renderable) { renderer = (AWTRenderer) foUserAgent.getRendererOverride(); this.foUserAgent = foUserAgent; + this.configuredTargetResolution = this.foUserAgent.getTargetResolution(); this.renderable = renderable; translator = new Translator(); @@ -551,23 +553,23 @@ public class PreviewDialog extends JFrame implements StatusListener { } private void scaleActionPerformed(ActionEvent e) { - try { - int index = scale.getSelectedIndex(); - if (index == 0) { - setScale(previewPanel.getScaleToFitWindow() * 100); - } else if (index == 1) { - setScale(previewPanel.getScaleToFitWidth() * 100); - } else { - String item = (String)scale.getSelectedItem(); - setScale(Double.parseDouble(item.substring(0, item.indexOf('%')))); - } - } catch (FOPException fopEx) { - fopEx.printStackTrace(); + int index = scale.getSelectedIndex(); + if (index == 0) { + setScaleToFitWindow(); + } else if (index == 1) { + setScaleToFitWidth(); + } else { + String item = (String)scale.getSelectedItem(); + setScale(Double.parseDouble(item.substring(0, item.indexOf('%')))); } } /** Prints the document */ public void startPrinterJob(boolean showDialog) { + //Restore originally configured target resolution + float saveResolution = foUserAgent.getTargetResolution(); + foUserAgent.setTargetResolution(this.configuredTargetResolution); + PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPageable(renderer); if (!showDialog || pj.printDialog()) { @@ -577,6 +579,8 @@ public class PreviewDialog extends JFrame implements StatusListener { e.printStackTrace(); } } + + foUserAgent.setTargetResolution(saveResolution); } /** 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 05e03fda0..f8152a978 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java @@ -23,6 +23,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Point; +import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -36,11 +37,12 @@ import javax.swing.JViewport; import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; +import org.apache.xmlgraphics.util.UnitConv; + import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; import org.apache.fop.area.PageViewport; - import org.apache.fop.render.awt.AWTRenderer; @@ -155,6 +157,8 @@ public class PreviewPanel extends JPanel { this.renderable = renderable; this.renderer = renderer; this.foUserAgent = foUserAgent; + //Override target resolution for the computer screen + this.foUserAgent.setTargetResolution(Toolkit.getDefaultToolkit().getScreenResolution()); gridPanel = new JPanel(); gridPanel.setLayout(new GridLayout(0, 1)); // rows, cols @@ -393,8 +397,10 @@ public class PreviewPanel extends JPanel { public double getScaleToFit(double viewWidth, double viewHeight) throws FOPException { PageViewport pageViewport = renderer.getPageViewport(currentPage); Rectangle2D pageSize = pageViewport.getViewArea(); - double widthScale = viewWidth / (pageSize.getWidth() / 1000f); - double heightScale = viewHeight / (pageSize.getHeight() / 1000f); + float screenResolution = Toolkit.getDefaultToolkit().getScreenResolution(); + float screenFactor = screenResolution / UnitConv.IN2PT; + double widthScale = viewWidth / (pageSize.getWidth() / 1000f) / screenFactor; + double heightScale = viewHeight / (pageSize.getHeight() / 1000f) / screenFactor; return Math.min(displayMode == CONT_FACING ? widthScale / 2 : widthScale, heightScale); } diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java index b61ebc346..f05a16f1a 100644 --- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java @@ -115,7 +115,6 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { pdfInfo.currentStream.add(graphics.getString()); renderer.restoreGraphicsState(); - pdfInfo.pdfState.pop(); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java b/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java index 216802c8f..10c4a9c92 100644 --- a/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java @@ -75,10 +75,12 @@ public final class BorderAttributesConverter { // Add padding to corresponding space (space-before or space-after) // if side == START or END, do nothing - if (side == CommonBorderPaddingBackground.BEFORE) { - attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE); - } else if (side == CommonBorderPaddingBackground.AFTER) { - attributes.addIntegerValue(padding, RtfText.SPACE_AFTER); + if (padding != 0) { + if (side == CommonBorderPaddingBackground.BEFORE) { + attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE); + } else if (side == CommonBorderPaddingBackground.AFTER) { + attributes.addIntegerValue(padding, RtfText.SPACE_AFTER); + } } } } diff --git a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java index caf11323f..33a2ff904 100644 --- a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java +++ b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java @@ -19,10 +19,9 @@ package org.apache.fop.render.rtf; -import java.util.Map; import java.util.HashMap; +import java.util.Map; -//FOP import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.FixedLength; @@ -143,4 +142,8 @@ final class FoUnitsConverter { // RTF font size units are in half-points return (int)(result * 2.0); } + + public float convertMptToTwips(int width) { + return width * POINT_TO_TWIPS / 1000; + } } diff --git a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java index c7f97ef4f..d50a81656 100644 --- a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java @@ -21,6 +21,7 @@ package org.apache.fop.render.rtf; import org.apache.commons.logging.Log; import org.apache.commons.logging.impl.SimpleLog; + import org.apache.fop.datatypes.Length; import org.apache.fop.fo.Constants; import org.apache.fop.fo.expr.NumericOp; @@ -58,6 +59,8 @@ final class PageAttributesConverter { attrib.setTwips(RtfPage.PAGE_WIDTH, pagemaster.getPageWidth()); attrib.setTwips(RtfPage.PAGE_HEIGHT, pagemaster.getPageHeight()); + //Sets the document level property + attrib.set(RtfPage.ITAP, "0"); Object widthRaw = attrib.getValue(RtfPage.PAGE_WIDTH); Object heightRaw = attrib.getValue(RtfPage.PAGE_HEIGHT); @@ -102,7 +105,7 @@ final class PageAttributesConverter { if (after != null) { afterBottom = (Length) NumericOp.addition(pageBottom, after.getExtent()); } - attrib.setTwips(RtfPage.FOOTERY, beforeTop); + attrib.setTwips(RtfPage.FOOTERY, afterBottom); } catch (Exception e) { log.error("Exception in convertPageAttributes: " + e.getMessage() + "- page attributes ignored"); diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index 1adba9e2b..65c7bf681 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -20,6 +20,8 @@ package org.apache.fop.render.rtf; // Java +import java.awt.Dimension; +import java.awt.Rectangle; import java.awt.geom.Point2D; import java.io.FileNotFoundException; import java.io.IOException; @@ -51,12 +53,13 @@ import org.apache.xmlgraphics.image.loader.util.ImageUtil; 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.datatypes.PercentBaseContext; import org.apache.fop.events.ResourceEventProducer; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOText; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.XMLObj; import org.apache.fop.fo.flow.AbstractGraphics; import org.apache.fop.fo.flow.BasicLink; @@ -74,6 +77,7 @@ import org.apache.fop.fo.flow.ListItem; import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.PageNumber; +import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; import org.apache.fop.fo.flow.table.TableFooter; @@ -89,8 +93,10 @@ import org.apache.fop.fo.pagination.Region; import org.apache.fop.fo.pagination.SimplePageMaster; import org.apache.fop.fo.pagination.StaticContent; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.fo.properties.FixedLength; +import org.apache.fop.fo.properties.EnumLength; import org.apache.fop.fonts.FontSetup; +import org.apache.fop.layoutmgr.inline.ImageLayout; +import org.apache.fop.layoutmgr.table.ColumnSetup; import org.apache.fop.render.DefaultFontResolver; import org.apache.fop.render.RendererEventProducer; import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer; @@ -110,6 +116,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFootnote; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfHyperLink; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfPage; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; @@ -117,6 +124,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem.RtfListItemLabel; import org.apache.fop.render.rtf.rtflib.tools.BuilderContext; +import org.apache.fop.render.rtf.rtflib.tools.PercentContext; import org.apache.fop.render.rtf.rtflib.tools.TableContext; /** @@ -150,6 +158,10 @@ public class RTFHandler extends FOEventHandler { private SimplePageMaster pagemaster; + private int nestedTableDepth = 1; + + private PercentContext percentManager = new PercentContext(); + /** * Creates a new RTF structure handler. * @param userAgent the FOUserAgent for this process @@ -173,9 +185,7 @@ public class RTFHandler extends FOEventHandler { eventProducer.ioError(this, ioe); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startDocument() throws SAXException { // TODO sections should be created try { @@ -187,9 +197,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endDocument() throws SAXException { try { rtfFile.flush(); @@ -199,9 +207,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startPageSequence(PageSequence pageSeq) { try { //This is needed for region handling @@ -240,6 +246,14 @@ public class RTFHandler extends FOEventHandler { builderContext.pushContainer(sect); + //Calculate usable page width for this flow + int useAblePageWidth = pagemaster.getPageWidth().getValue() + - pagemaster.getCommonMarginBlock().marginLeft.getValue() + - pagemaster.getCommonMarginBlock().marginRight.getValue() + - sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_LEFT).intValue() + - sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_RIGHT).intValue(); + percentManager.setDimension(pageSeq, useAblePageWidth); + bHeaderSpecified = false; bFooterSpecified = false; } catch (IOException ioe) { @@ -247,9 +261,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endPageSequence(PageSequence pageSeq) { if (bDefer) { //If endBlock was called while SAX parsing, and the passed FO is Block @@ -267,9 +279,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startFlow(Flow fl) { if (bDefer) { return; @@ -357,9 +367,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endFlow(Flow fl) { if (bDefer) { return; @@ -384,9 +392,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startBlock(Block bl) { if (bDefer) { return; @@ -414,10 +420,7 @@ public class RTFHandler extends FOEventHandler { } } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endBlock(Block bl) { if (bDefer) { @@ -443,9 +446,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startBlockContainer(BlockContainer blc) { if (bDefer) { return; @@ -472,9 +473,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endBlockContainer(BlockContainer bl) { if (bDefer) { return; @@ -499,9 +498,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startTable(Table tbl) { if (bDefer) { return; @@ -519,6 +516,8 @@ public class RTFHandler extends FOEventHandler { = TableAttributesConverter.convertTableAttributes(tbl); RtfTable table = tc.newTable(atts, tableContext); + table.setNestedTableDepth(nestedTableDepth); + nestedTableDepth++; CommonBorderPaddingBackground border = tbl.getCommonBorderPaddingBackground(); RtfAttributes borderAttributes = new RtfAttributes(); @@ -545,53 +544,32 @@ public class RTFHandler extends FOEventHandler { builderContext.pushTableContext(tableContext); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endTable(Table tbl) { if (bDefer) { return; } + nestedTableDepth--; builderContext.popTableContext(); builderContext.popContainer(); } - /** - * - * @param tc TableColumn that is starting; - */ - + /** {@inheritDoc} */ public void startColumn(TableColumn tc) { if (bDefer) { return; } try { - /** - * Pass a SimplePercentBaseContext to getValue in order to - * avoid a NullPointerException, which occurs when you use - * proportional-column-width function in column-width attribute. - * Of course the results won't be correct, but at least the - * 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 - */ - SimplePercentBaseContext context - = new SimplePercentBaseContext(null, - LengthBase.TABLE_UNITS, - 100000); - - Integer iWidth - = new Integer(tc.getColumnWidth().getValue(context) / 1000); + int iWidth = tc.getColumnWidth().getValue(percentManager); + percentManager.setDimension(tc, iWidth); - String strWidth = iWidth.toString() + FixedLength.POINT; - Float width = new Float( - FoUnitsConverter.getInstance().convertToTwips(strWidth)); + //convert to twips + Float width = new Float(FoUnitsConverter.getInstance().convertMptToTwips(iWidth)); builderContext.getTableContext().setNextColumnWidth(width); builderContext.getTableContext().setNextColumnRowSpanning( - new Integer(0), null); + new Integer(0), null); builderContext.getTableContext().setNextFirstSpanningCol(false); } catch (Exception e) { log.error("startColumn: " + e.getMessage()); @@ -599,49 +577,34 @@ public class RTFHandler extends FOEventHandler { } } - /** - * - * @param tc TableColumn that is ending; - */ - + /** {@inheritDoc} */ public void endColumn(TableColumn tc) { if (bDefer) { return; } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startHeader(TableHeader header) { startPart(header); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endHeader(TableHeader header) { endPart(header); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startFooter(TableFooter footer) { startPart(footer); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endFooter(TableFooter footer) { endPart(footer); } - /** - * - * @param inl Inline that is starting. - */ + /** {@inheritDoc} */ public void startInline(Inline inl) { if (bDefer) { return; @@ -669,10 +632,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * - * @param inl Inline that is ending. - */ + /** {@inheritDoc} */ public void endInline(Inline inl) { if (bDefer) { return; @@ -735,10 +695,7 @@ public class RTFHandler extends FOEventHandler { startPart(body); } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endBody(TableBody body) { endPart(body); } @@ -775,9 +732,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endRow(TableRow tr) { if (bDefer) { return; @@ -814,9 +769,7 @@ public class RTFHandler extends FOEventHandler { builderContext.getTableContext().decreaseRowSpannings(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startCell(TableCell tc) { if (bDefer) { return; @@ -868,7 +821,6 @@ public class RTFHandler extends FOEventHandler { //process number-columns-spanned attribute if (numberColumnsSpanned > 0) { // Get the number of columns spanned - RtfTable table = row.getTable(); tctx.setCurrentFirstSpanningCol(true); // We widthdraw one cell because the first cell is already created @@ -876,6 +828,8 @@ public class RTFHandler extends FOEventHandler { for (int i = 0; i < numberColumnsSpanned - 1; ++i) { tctx.selectNextColumn(); + //aggregate width for further elements + width += tctx.getColumnWidth(); tctx.setCurrentFirstSpanningCol(false); RtfTableCell hCell = row.newTableCellMergedHorizontally( 0, null); @@ -890,10 +844,12 @@ public class RTFHandler extends FOEventHandler { cell.getRtfAttributes()); } else { tctx.setCurrentColumnRowSpanning( - new Integer(numberRowsSpanned), null); + new Integer(numberRowsSpanned), cell.getRtfAttributes()); } } } + //save width of the cell, convert from twips to mpt + percentManager.setDimension(tc, (int)width * 50); builderContext.pushContainer(cell); } catch (IOException ioe) { @@ -904,9 +860,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endCell(TableCell tc) { if (bDefer) { return; @@ -917,9 +871,7 @@ public class RTFHandler extends FOEventHandler { } // Lists - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startList(ListBlock lb) { if (bDefer) { return; @@ -944,9 +896,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endList(ListBlock lb) { if (bDefer) { return; @@ -955,9 +905,7 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startListItem(ListItem li) { if (bDefer) { return; @@ -995,9 +943,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endListItem(ListItem li) { if (bDefer) { return; @@ -1006,9 +952,7 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startListLabel() { if (bDefer) { return; @@ -1028,9 +972,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endListLabel() { if (bDefer) { return; @@ -1039,46 +981,32 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startListBody() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endListBody() { } // Static Regions - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startStatic() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endStatic() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startMarkup() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endMarkup() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startLink(BasicLink basicLink) { if (bDefer) { return; @@ -1109,9 +1037,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endLink() { if (bDefer) { return; @@ -1120,9 +1046,7 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void image(ExternalGraphic eg) { if (bDefer) { return; @@ -1153,16 +1077,14 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void foreignObject(InstreamForeignObject ifo) { if (bDefer) { return; } try { - XMLObj child = (XMLObj) ifo.getChildXMLObj(); + XMLObj child = ifo.getChildXMLObj(); Document doc = child.getDOMDocument(); String ns = child.getNamespaceURI(); @@ -1191,7 +1113,8 @@ public class RTFHandler extends FOEventHandler { FOUserAgent userAgent = ifo.getUserAgent(); ImageManager manager = userAgent.getFactory().getImageManager(); - Image converted = manager.convertImage(image, FLAVORS); + Map hints = ImageUtil.getDefaultHints(ua.getImageSessionContext()); + Image converted = manager.convertImage(image, FLAVORS, hints); putGraphic(ifo, converted); } catch (ImageException ie) { @@ -1242,7 +1165,7 @@ public class RTFHandler extends FOEventHandler { throws IOException { byte[] rawData = null; - ImageInfo info = image.getInfo(); + final ImageInfo info = image.getInfo(); if (image instanceof ImageRawStream) { ImageRawStream rawImage = (ImageRawStream)image; @@ -1261,6 +1184,25 @@ public class RTFHandler extends FOEventHandler { return; } + //Set up percentage calculations + this.percentManager.setDimension(abstractGraphic); + PercentBaseContext pContext = new PercentBaseContext() { + + public int getBaseLength(int lengthBase, FObj fobj) { + switch (lengthBase) { + case LengthBase.IMAGE_INTRINSIC_WIDTH: + return info.getSize().getWidthMpt(); + case LengthBase.IMAGE_INTRINSIC_HEIGHT: + return info.getSize().getHeightMpt(); + default: + return percentManager.getBaseLength(lengthBase, fobj); + } + } + + }; + ImageLayout layout = new ImageLayout(abstractGraphic, pContext, + image.getInfo().getSize().getDimensionMpt()); + final IRtfTextrunContainer c = (IRtfTextrunContainer)builderContext.getContainer( IRtfTextrunContainer.class, true, this); @@ -1273,63 +1215,23 @@ public class RTFHandler extends FOEventHandler { } rtfGraphic.setImageData(rawData); - //set scaling - if (abstractGraphic.getScaling() == Constants.EN_UNIFORM) { - rtfGraphic.setScaling ("uniform"); - } - - //get width - int width = 0; - if (abstractGraphic.getWidth().getEnum() == Constants.EN_AUTO) { - width = info.getSize().getWidthMpt(); - } else { - width = abstractGraphic.getWidth().getValue(); - } - - //get height - int height = 0; - if (abstractGraphic.getWidth().getEnum() == Constants.EN_AUTO) { - height = info.getSize().getHeightMpt(); - } else { - height = abstractGraphic.getHeight().getValue(); - } - - //get content-width - int contentwidth = 0; - if (abstractGraphic.getContentWidth().getEnum() - == Constants.EN_AUTO) { - contentwidth = info.getSize().getWidthMpt(); - } else if (abstractGraphic.getContentWidth().getEnum() - == Constants.EN_SCALE_TO_FIT) { - contentwidth = width; - } else { - //TODO: check, if the value is a percent value - contentwidth = abstractGraphic.getContentWidth().getValue(); - } - - //get content-width - int contentheight = 0; - if (abstractGraphic.getContentHeight().getEnum() - == Constants.EN_AUTO) { - - contentheight = info.getSize().getHeightMpt(); - - } else if (abstractGraphic.getContentHeight().getEnum() - == Constants.EN_SCALE_TO_FIT) { - - contentheight = height; - } else { - //TODO: check, if the value is a percent value - contentheight = abstractGraphic.getContentHeight().getValue(); - } - - //set width in rtf - //newGraphic.setWidth((long) (contentwidth / 1000f) + FixedLength.POINT); - rtfGraphic.setWidth((long) (contentwidth / 50f) + "twips"); - - //set height in rtf - //newGraphic.setHeight((long) (contentheight / 1000f) + FixedLength.POINT); - rtfGraphic.setHeight((long) (contentheight / 50f) + "twips"); + FoUnitsConverter converter = FoUnitsConverter.getInstance(); + Dimension viewport = layout.getViewportSize(); + Rectangle placement = layout.getPlacement(); + int cropLeft = Math.round(converter.convertMptToTwips(-placement.x)); + int cropTop = Math.round(converter.convertMptToTwips(-placement.y)); + int cropRight = Math.round(converter.convertMptToTwips( + -1 * (viewport.width - placement.x - placement.width))); + int cropBottom = Math.round(converter.convertMptToTwips( + -1 * (viewport.height - placement.y - placement.height))); + rtfGraphic.setCropping(cropLeft, cropTop, cropRight, cropBottom); + + int width = Math.round(converter.convertMptToTwips(viewport.width)); + int height = Math.round(converter.convertMptToTwips(viewport.height)); + width += cropLeft + cropRight; + height += cropTop + cropBottom; + rtfGraphic.setWidthTwips(width); + rtfGraphic.setHeightTwips(height); //TODO: make this configurable: // int compression = m_context.m_options.getRtfExternalGraphicCompressionRate (); @@ -1342,15 +1244,11 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void pageRef() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startFootnote(Footnote footnote) { if (bDefer) { return; @@ -1375,9 +1273,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endFootnote(Footnote footnote) { if (bDefer) { return; @@ -1386,9 +1282,7 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startFootnoteBody(FootnoteBody body) { if (bDefer) { return; @@ -1409,9 +1303,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endFootnoteBody(FootnoteBody body) { if (bDefer) { return; @@ -1432,10 +1324,28 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void leader(Leader l) { + if (bDefer) { + return; + } + + try { + percentManager.setDimension(l); + RtfAttributes rtfAttr = TextAttributesConverter.convertLeaderAttributes( + l, percentManager); + + IRtfTextrunContainer container + = (IRtfTextrunContainer)builderContext.getContainer( + IRtfTextrunContainer.class, true, this); + RtfTextrun textrun = container.getTextrun(); + + textrun.addLeader(rtfAttr); + + } catch (Exception e) { + log.error("startLeader: " + e.getMessage()); + throw new RuntimeException(e.getMessage()); + } } /** @@ -1469,10 +1379,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * - * @param pagenum PageNumber that is starting. - */ + /** {@inheritDoc} */ public void startPageNumber(PageNumber pagenum) { if (bDefer) { return; @@ -1497,16 +1404,64 @@ public class RTFHandler extends FOEventHandler { } } - /** - * - * @param pagenum PageNumber that is ending. - */ + /** {@inheritDoc} */ public void endPageNumber(PageNumber pagenum) { if (bDefer) { return; } } + /** {@inheritDoc} */ + public void startPageNumberCitation(PageNumberCitation l) { + if (bDefer) { + return; + } + try { + + IRtfTextrunContainer container + = (IRtfTextrunContainer)builderContext.getContainer( + IRtfTextrunContainer.class, true, this); + RtfTextrun textrun = container.getTextrun(); + + textrun.addPageNumberCitation(l.getRefId()); + + } catch (Exception e) { + log.error("startPageNumberCitation: " + e.getMessage()); + throw new RuntimeException(e.getMessage()); + } + } + + private void prepareTable(Table tab) { + // Allows to receive the available width of the table + percentManager.setDimension(tab); + + // Table gets expanded by half of the border on each side inside Word + // When using wide borders the table gets cut off + int tabDiff = tab.getCommonBorderPaddingBackground().getBorderStartWidth(false) / 2 + + tab.getCommonBorderPaddingBackground().getBorderEndWidth(false); + + // check for "auto" value + if (!(tab.getInlineProgressionDimension().getMaximum(null).getLength() + instanceof EnumLength)) { + // value specified + percentManager.setDimension(tab, + tab.getInlineProgressionDimension().getMaximum(null) + .getLength().getValue(percentManager) + - tabDiff); + } else { + // set table width again without border width + percentManager.setDimension(tab, percentManager.getBaseLength( + LengthBase.CONTAINING_BLOCK_WIDTH, tab) - tabDiff); + } + + ColumnSetup columnSetup = new ColumnSetup(tab); + //int sumOfColumns = columnSetup.getSumOfColumnWidths(percentManager); + float tableWidth = percentManager.getBaseLength(LengthBase.CONTAINING_BLOCK_WIDTH, tab); + float tableUnit = columnSetup.computeTableUnit(percentManager, Math.round(tableWidth)); + percentManager.setTableUnit(tab, Math.round(tableUnit)); + + } + /** * Calls the appropriate event handler for the passed FObj. * @@ -1659,6 +1614,16 @@ public class RTFHandler extends FOEventHandler { } else { endCell( (TableCell) foNode); } + } else if (foNode instanceof Leader) { + if (bStart) { + leader((Leader) foNode); + } + } else if (foNode instanceof PageNumberCitation) { + if (bStart) { + startPageNumberCitation((PageNumberCitation) foNode); + } else { + endPageNumberCitation((PageNumberCitation) foNode); + } } else { RTFEventProducer eventProducer = RTFEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); @@ -1701,9 +1666,12 @@ public class RTFHandler extends FOEventHandler { //recurse all table-columns if (table.getColumns() != null) { - for (Iterator it = table.getColumns().iterator(); it.hasNext();) { - recurseFONode( (FONode) it.next() ); - } + //Calculation for column-widths which are not set + prepareTable(table); + + for (Iterator it = table.getColumns().iterator(); it.hasNext();) { + recurseFONode( (FONode) it.next() ); + } } else { //TODO Implement implicit column setup handling! RTFEventProducer eventProducer = RTFEventProducer.Provider.get( diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index 792193b15..63c470b5d 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -21,25 +21,30 @@ package org.apache.fop.render.rtf; import java.awt.Color; -//FOP +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOText; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.BlockContainer; import org.apache.fop.fo.flow.Inline; +import org.apache.fop.fo.flow.Leader; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonTextDecoration; -import org.apache.fop.render.rtf.BorderAttributesConverter; +import org.apache.fop.fo.properties.PercentLength; import org.apache.fop.render.rtf.rtflib.rtfdoc.IBorderAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFontManager; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfLeader; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; /** Converts FO properties to RtfAttributes @@ -53,6 +58,8 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; */ final class TextAttributesConverter { + private static Log log = LogFactory.getLog(TextAttributesConverter.class); + /** * Constructor is private, because it's just a utility class. */ @@ -137,6 +144,131 @@ final class TextAttributesConverter { return attrib; } + + /** + * Converts FO properties used by RtfLeader to RtfAttributes. + * @param fobj Leader + * @param context PercentBaseContext + * @return RtfAttributes + * @throws FOPException + */ + public static RtfAttributes convertLeaderAttributes(Leader fobj, PercentBaseContext context) + throws FOPException { + boolean tab = false; + FOPRtfAttributes attrib = new FOPRtfAttributes(); + attrib.set(RtfText.ATTR_FONT_FAMILY, + RtfFontManager.getInstance().getFontNumber(fobj.getCommonFont().getFirstFontFamily())); + + if (fobj.getLeaderLength() != null) { + attrib.set(RtfLeader.LEADER_WIDTH, convertMptToTwips(fobj.getLeaderLength().getMaximum( + context).getLength().getValue(context))); + + if (fobj.getLeaderLength().getMaximum(context) instanceof PercentLength) { + if (((PercentLength)fobj.getLeaderLength().getMaximum(context)).getString().equals( + "100.0%")) { + // Use Tab instead of white spaces + attrib.set(RtfLeader.LEADER_USETAB, 1); + tab = true; + } + } + } + + attrFontColor(fobj.getColor(), attrib); + + if (fobj.getLeaderPatternWidth() != null) { + //TODO calculate pattern width not possible for white spaces, because its using + //underlines for tab it would work with LEADER_PATTERN_WIDTH (expndtw) + } + + switch(fobj.getLeaderPattern()) { + case Constants.EN_DOTS: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_DOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_DOTTED); + } + break; + case Constants.EN_SPACE: + //nothing has to be set for spaces + break; + case Constants.EN_RULE: + //Things like start-indent, space-after, ... not supported? + //Leader class does not offer these properties + //TODO aggregate them with the leader width or + // create a second - blank leader - before + + if (fobj.getRuleThickness() != null) { + //TODO See inside RtfLeader, better calculation for + //white spaces would be necessary + //attrib.set(RtfLeader.LEADER_RULE_THICKNESS, + // fobj.getRuleThickness().getValue(context)); + log.warn("RTF: fo:leader rule-thickness not supported"); + } + + switch (fobj.getRuleStyle()) { + case Constants.EN_SOLID: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_THICK); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_THICK); + } + break; + case Constants.EN_DASHED: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_MIDDLEDOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_MIDDLEDOTTED); + } + break; + case Constants.EN_DOTTED: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_DOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_DOTTED); + } + break; + case Constants.EN_DOUBLE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_EQUAL); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_EQUAL); + } + break; + case Constants.EN_GROOVE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_HYPHENS); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_HYPHENS); + } + break; + case Constants.EN_RIDGE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_UNDERLINE); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_UNDERLINE); + } + break; + default: + break; + } + break; + case Constants.EN_USECONTENT: + log.warn("RTF: fo:leader use-content not supported"); + break; + default: + break; + } + + if (fobj.getLeaderAlignment() == Constants.EN_REFERENCE_AREA) { + log.warn("RTF: fo:leader reference-area not supported"); + } + return attrib; + } + + private static int convertMptToTwips(int mpt) { + return Math.round(FoUnitsConverter.getInstance().convertMptToTwips(mpt)); + } + private static void attrFont(CommonFont font, FOPRtfAttributes rtfAttr) { rtfAttr.set(RtfText.ATTR_FONT_FAMILY, RtfFontManager.getInstance().getFontNumber(font.getFirstFontFamily())); 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 2eb95b587..5ec5e907e 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 @@ -28,6 +28,7 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; import java.util.HashMap; import java.util.Iterator; + import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributesImpl; @@ -163,6 +164,15 @@ implements java.lang.Cloneable { return values.get(name); } + /** + * Returns a value as an Integer. The value is simply cast to an Integer. + * @param name String containing attribute name + * @return the value of an attribute, null if not found + */ + public Integer getValueAsInteger(String name) { + return (Integer)values.get(name); + } + /** * @param name String containing attribute name * @return true if given attribute is set 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 182894ea5..6123ac563 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 @@ -269,6 +269,9 @@ public class RtfExternalGraphic extends RtfElement { */ protected boolean scaleUniform = false; + /** cropping on left/top/right/bottom edges for \piccrop*N */ + private int[] cropValues = new int[4]; + /** * Graphic compression rate */ @@ -406,6 +409,7 @@ public class RtfExternalGraphic extends RtfElement { computeImageSize(); writeSizeInfo(); + writeAttributes(getRtfAttributes(), null); for (int i = 0; i < imagedata.length; i++) { int iData = imagedata [i]; @@ -519,6 +523,19 @@ public class RtfExternalGraphic extends RtfElement { writeControlWord("picscaley" + widthDesired * 100 / width); } } + + if (this.cropValues[0] != 0) { + writeOneAttribute("piccropl", new Integer(this.cropValues[0])); + } + if (this.cropValues[1] != 0) { + writeOneAttribute("piccropt", new Integer(this.cropValues[1])); + } + if (this.cropValues[2] != 0) { + writeOneAttribute("piccropr", new Integer(this.cropValues[2])); + } + if (this.cropValues[3] != 0) { + writeOneAttribute("piccropb", new Integer(this.cropValues[3])); + } } ////////////////////////////////////////////////// @@ -545,6 +562,24 @@ public class RtfExternalGraphic extends RtfElement { this.perCentW = ImageUtil.isPercent(theWidth); } + /** + * Sets the desired width of the image. + * @param twips The desired image width (in twips) + */ + public void setWidthTwips(int twips) { + this.widthDesired = twips; + this.perCentW = false; + } + + /** + * Sets the desired height of the image. + * @param twips The desired image height (in twips) + */ + public void setHeightTwips(int twips) { + this.heightDesired = twips; + this.perCentH = false; + } + /** * Sets the flag whether the image size shall be adjusted. * @@ -553,9 +588,34 @@ public class RtfExternalGraphic extends RtfElement { * false no adjustment */ public void setScaling(String value) { - if (value.equalsIgnoreCase("uniform")) { - this.scaleUniform = true; - } + setUniformScaling("uniform".equalsIgnoreCase(value)); + } + + /** + * Sets the flag whether the image size shall be adjusted. + * + * @param uniform + * true image width or height shall be adjusted automatically\n + * false no adjustment + */ + public void setUniformScaling(boolean uniform) { + this.scaleUniform = uniform; + } + + /** + * Sets cropping values for all four edges for the \piccrop*N commands. + * A positive value crops toward the center of the picture; + * a negative value crops away from the center, adding a space border around the picture + * @param left left cropping value (in twips) + * @param top top cropping value (in twips) + * @param right right cropping value (in twips) + * @param bottom bottom cropping value (in twips) + */ + public void setCropping(int left, int top, int right, int bottom) { + this.cropValues[0] = left; + this.cropValues[1] = top; + this.cropValues[2] = right; + this.cropValues[3] = bottom; } /** diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLeader.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLeader.java new file mode 100644 index 000000000..b3f11bc0a --- /dev/null +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLeader.java @@ -0,0 +1,219 @@ +/* + * 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.rtflib.rtfdoc; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +/** + * Generates the leader in RTF. + */ +public class RtfLeader extends RtfContainer { + + /* + * Format : \tqr \style \tx## { \pard \format \tab } + * ## represents the width \style represents the style (tldot, tlth, ...) + * \format represents standard formats (color, fontsize, ...) + * + * + * \pard \zwnj {\fsxx } \zwnj + * + * : \\ulcN Underline color. \\uld Dotted underline. \\uldash Dashed + * underline. \\uldashd Dash-dotted underline. \\uldashdd Dash-dot-dotted + * underline. \\uldb Double underline. \\ulhwave Heavy wave underline. + * \\ulldash Long dashed underline. \\ulnone Stops all underlining. \\ulth + * Thick underline. \\ulthd Thick dotted underline. \\ulthdash Thick dashed + * underline. \\ulthdashd Thick dash-dotted underline. \\ulthdashdd Thick + * dash-dot-dotted underline. \\ulthldash Thick long dashed underline. + * \\ululdbwave Double wave underline. + */ + + private RtfAttributes attrs = null; + + /** Private attribute: tab style */ + public static final String LEADER_TABLEAD = "tablead"; + + /** Private attribute: tab usage indicator */ + public static final String LEADER_USETAB = "tabuse"; + + /** Private attribute: leader width */ + public static final String LEADER_WIDTH = "lwidth"; + + // +++++++++++++++ Styles Underline ++++++++++++++++++++++ + + /** Dotted underline */ + public static final String LEADER_DOTTED = "uld"; // dotted + + /** Dashed underline */ + public static final String LEADER_MIDDLEDOTTED = "uldash"; // dashed + + /** Heavy wave underline */ + public static final String LEADER_HYPHENS = "ulhwave"; // groove + + /** Dash-dot-dotted underline */ + public static final String LEADER_UNDERLINE = "ulthdashdd"; // ridge + + /** Double underline */ + public static final String LEADER_EQUAL = "uldb"; // double + + /** Thick underline */ + public static final String LEADER_THICK = "ulth"; // solid + + // +++++++++++++++ Styles Tabulator +++++++++++++++++++++++ + + /** Leader dots */ + public static final String LEADER_TAB_DOTTED = "tldot"; // dotted + + /** Leader middle dots */ + public static final String LEADER_TAB_MIDDLEDOTTED = "tlmdot"; // dashed + + /** Leader hyphens */ + public static final String LEADER_TAB_HYPHENS = "tlhyph"; // groove + + /** Leader underline */ + public static final String LEADER_TAB_UNDERLINE = "tlul"; // ridge + + /** Leader equal sign */ + public static final String LEADER_TAB_EQUAL = "tleq"; // double + + /** Leader thick line */ + public static final String LEADER_TAB_THICK = "tlth"; // solid + + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + /** Resets to default properties */ + public static final String LEADER_IGNORE_STYLE = "pard"; + + /** Font size determines rule thickness */ + public static final String LEADER_RULE_THICKNESS = "fs"; // thickness = fontsize + + /** Expansion or compression of the space between characters in twips */ + public static final String LEADER_PATTERN_WIDTH = "expndtw"; + + /** Zero-width break opportunity */ + public static final String LEADER_ZERO_WIDTH = "zwbo"; + + /** Standard leader width */ + public static final int LEADER_STANDARD_WIDTH = 30; + + /** Move up 4 half-points */ + public static final String LEADER_UP = "up4"; + + /** Negative expansion */ + public static final String LEADER_EXPAND = "expnd-2"; // negative value + // for compression + + /** Tab */ + public static final String LEADER_TAB_VALUE = "tab"; + + /** Right-aligned tab */ + public static final String LEADER_TAB_RIGHT = "tqr"; + + /** Tab width */ + public static final String LEADER_TAB_WIDTH = "tx"; + + RtfLeader(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException { + super(parent, w); + this.attrs = attrs; + } + + /** {@inheritDoc} */ + protected void writeRtfContent() throws IOException { + + int thickness = LEADER_STANDARD_WIDTH; + String tablead = null; + String tabwidth = null; + for (Iterator it = attrs.nameIterator(); it.hasNext();) { + final String name = (String)it.next(); + if (attrs.isSet(name)) { + if (name.equals(LEADER_TABLEAD)) { + tablead = attrs.getValue(LEADER_TABLEAD).toString(); + } else if (name.equals(LEADER_WIDTH)) { + tabwidth = attrs.getValue(LEADER_WIDTH).toString(); + } + } + } + + if (attrs.getValue(LEADER_RULE_THICKNESS) != null) { + thickness += Integer.parseInt(attrs.getValue(LEADER_RULE_THICKNESS).toString()) + / 1000 * 2; + attrs.unset(LEADER_RULE_THICKNESS); + } + + //Remove private attributes + attrs.unset(LEADER_WIDTH); + attrs.unset(LEADER_TABLEAD); + + // If leader is 100% we use a tabulator, because its more + // comfortable, specially for the table of content + if (attrs.getValue(LEADER_USETAB) != null) { + attrs.unset(LEADER_USETAB); + writeControlWord(LEADER_TAB_RIGHT); + + if (tablead != null) { + writeControlWord(tablead); + } + writeControlWord(LEADER_TAB_WIDTH + tabwidth); + + writeGroupMark(true); + + writeControlWord(LEADER_IGNORE_STYLE); + writeAttributes(attrs, null); + writeControlWord(LEADER_EXPAND); + writeControlWord(LEADER_TAB_VALUE); + + writeGroupMark(false); + + } + // Using white spaces with different underline formats + else { + writeControlWord(LEADER_IGNORE_STYLE); + writeControlWord(LEADER_ZERO_WIDTH); + writeGroupMark(true); + + writeControlWord(LEADER_RULE_THICKNESS + thickness); + + writeControlWord(LEADER_UP); + + super.writeAttributes(attrs, null); + if (tablead != null) { + writeControlWord(tablead); + } + + // Calculation for the necessary amount of white spaces + // Depending on font-size 15 -> 1cm = 7,5 spaces + // TODO for rule-thickness this has to be done better + + for (double d = (Integer.parseInt(tabwidth) / 560) * 7.5; d >= 1; d--) { + RtfStringConverter.getInstance().writeRtfString(writer, " "); + } + + writeGroupMark(false); + writeControlWord(LEADER_ZERO_WIDTH); + } + } + + /** {@inheritDoc} */ + public boolean isEmpty() { + return false; + } + +} 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 fb2df3fac..657900574 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 @@ -60,11 +60,13 @@ extends RtfContainer { public static final String HEADERY = "headery"; /** constant for footer position */ public static final String FOOTERY = "footery"; - + /** constant for itap level */ + public static final String ITAP = "itap"; + /** String array of RtfPage attributes */ public static final String[] PAGE_ATTR = new String[]{ PAGE_WIDTH, PAGE_HEIGHT, LANDSCAPE, MARGIN_TOP, MARGIN_BOTTOM, - MARGIN_LEFT, MARGIN_RIGHT, HEADERY, FOOTERY + MARGIN_LEFT, MARGIN_RIGHT, HEADERY, FOOTERY, ITAP }; /** RtfPage creates new page attributes with the parent container, the writer 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 92ba2bb7f..44c03c316 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 @@ -26,8 +26,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; * the FOP project. */ -import java.io.Writer; import java.io.IOException; +import java.io.Writer; /** * @author Christopher Scott, scottc@westinghouse.com @@ -50,9 +50,9 @@ public class RtfPageNumberCitation extends RtfContainer { private String id = null; /** Create an RTF page number citation as a child of given container with default attributes */ - RtfPageNumberCitation (IRtfPageNumberCitationContainer parent, Writer w, String id) + RtfPageNumberCitation (RtfContainer parent, Writer w, String id) throws IOException { - super((RtfContainer)parent, w); + super(parent, w); this.id = id; } @@ -92,7 +92,7 @@ public class RtfPageNumberCitation extends RtfContainer { writeStarControlWord(pageRef); writeGroupMark(false); writeGroupMark(true); - writeControlWord(RTF_FIELD_RESULT); + writeControlWord(RTF_FIELD_RESULT + '#'); //To see where the page-number would be writeGroupMark(false); writeGroupMark(false); } 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 eda5644a2..3747103d1 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 @@ -26,8 +26,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; * the FOP project. */ -import java.io.Writer; import java.io.IOException; +import java.io.Writer; /** Container for RtfRow elements * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch @@ -43,6 +43,9 @@ public class RtfTable extends RtfContainer { * number-columns-spanned attribute */ private ITableColumnsInfo tableContext; + /** Shows the table depth necessary for nested tables */ + private int nestedTableDepth = 0; + /** Create an RTF element as a child of given container */ RtfTable(IRtfTableContainer parent, Writer w, ITableColumnsInfo tc) throws IOException { @@ -212,6 +215,22 @@ public class RtfTable extends RtfContainer { return null; } + /** + * Sets the nested table depth. + * @param nestedTableDepth the nested table depth + */ + public void setNestedTableDepth(int nestedTableDepth) { + this.nestedTableDepth = nestedTableDepth; + } + + /** + * Returns the nested table depth. + * @return the nested table depth + */ + public int getNestedTableDepth() { + return this.nestedTableDepth; + } + /** * Sets the RtfAttributes for the borders of the table. * @param attributes Border attributes of the table. 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 fe936e3f5..f5e5978ec 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 @@ -133,11 +133,11 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { * @throws IOException for I/O problems */ protected void writeRtfContent() throws IOException { - if (getTable().isNestedTable()) { //nested table writeControlWord("intbl"); - writeControlWord("itap2"); + //itap is the depth (level) of the current nested table + writeControlWord("itap" + getTable().getNestedTableDepth()); } else { //normal (not nested) table writeRowAndCellsDefintions(); 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 e0703d7ba..a9ba432b1 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 @@ -22,8 +22,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; // Java import java.io.IOException; import java.io.Writer; -import java.util.List; import java.util.Iterator; +import java.util.List; import java.util.ListIterator; // FOP @@ -175,6 +175,15 @@ public class RtfTextrun extends RtfContainer { addOpenGroupMark(attrs); } + /** + * Inserts a page number citation. + * @param refId the identifier being referenced + * @throws IOException for I/O problems + */ + public void addPageNumberCitation(String refId) throws IOException { + RtfPageNumberCitation r = new RtfPageNumberCitation(this, writer, refId); + } + /** * Pop inline attributes. * @@ -242,6 +251,15 @@ public class RtfTextrun extends RtfContainer { } } + /** + * Inserts a leader. + * @param attrs Attributes for the leader + * @throws IOException for I/O problems + */ + public void addLeader(RtfAttributes attrs) throws IOException { + new RtfLeader(this, writer, attrs); + } + /** * Inserts a page number. * @param attr Attributes for the page number to insert. diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java new file mode 100644 index 000000000..ef9b248f1 --- /dev/null +++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.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.render.rtf.rtflib.tools; + +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.PercentBaseContext; +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.pagination.PageSequence; + +/** + * PercentBaseContext implementation to track base widths for percentage calculations. + */ +public class PercentContext implements PercentBaseContext { + private static Log log = LogFactory.getLog(PercentContext.class); + + /** Map containing the FObj and its width */ + private Map lengthMap = new java.util.HashMap(); + + /** Map containing the Tables and their table units */ + private Map tableUnitMap = new java.util.HashMap(); + + /** Variable to check if a base width is set */ + private boolean baseWidthSet = false; + + /** + * Returns the available width for a specific FObj + * + * @param lengthBase + * lengthBase not used + * @param fobj + * the FObj + * @return Available Width + */ + public int getBaseLength(int lengthBase, FObj fobj) { + if (fobj == null) { + return 0; + } + switch (lengthBase) { + case LengthBase.CONTAINING_BLOCK_WIDTH: + case LengthBase.PARENT_AREA_WIDTH: + case LengthBase.CONTAINING_REFAREA_WIDTH: + Object width = lengthMap.get(fobj); + if (width != null) { + return Integer.parseInt(width.toString()); + } else { + return -1; + } + case LengthBase.TABLE_UNITS: + Object unit = tableUnitMap.get(fobj); + return (unit != null) ? ((Integer)unit).intValue() : 0; + default: + log.error(new Exception("Unsupported base type for LengthBase:" + lengthBase)); + return 0; + } + } + + /** + * Elements having a width property can call this function if their width is + * calculated in RTFHandler + * + * @param fobj the FObj + * @param width width of the FObj (in millipoints) + */ + public void setDimension(FObj fobj, int width) { + // TODO ACCEPT only objects above for setting a width + if (fobj instanceof PageSequence) { + baseWidthSet = true; + } + // width in mpt + lengthMap.put(fobj, new Integer(width)); + } + + /** + * Records the calculated table unit for a given table. + * @param table the table for which the table unit is set + * @param tableUnit the table unit value (in millipoints) + */ + public void setTableUnit(Table table, int tableUnit) { + tableUnitMap.put(table, new Integer(tableUnit)); + } + + /** + * Searches for the parent object of fobj. + */ + private Integer findParent(FONode fobj) { + if (fobj.getRoot() != fobj) { + if (lengthMap.containsKey(fobj)) { + return new Integer(lengthMap.get(fobj).toString()); + } else { + return findParent(fobj.getParent()); + } + } else { + log.error("Base Value for element " + fobj.getName() + " not found"); + return new Integer(-1); + } + } + + /** + * Elements willing to use this context have to register themselves by + * calling this function. + * + * @param fobj the FObj + */ + public void setDimension(FObj fobj) { + if (baseWidthSet) { + Integer width = findParent(fobj.getParent()); + if (width.intValue() != -1) { + lengthMap.put(fobj, width); + } + } + } +} diff --git a/src/java/org/apache/fop/util/BreakUtil.java b/src/java/org/apache/fop/util/BreakUtil.java index 0e419016e..7302f270c 100644 --- a/src/java/org/apache/fop/util/BreakUtil.java +++ b/src/java/org/apache/fop/util/BreakUtil.java @@ -36,7 +36,8 @@ public final class BreakUtil { case Constants.EN_PAGE: return 2; case Constants.EN_EVEN_PAGE: return 3; case Constants.EN_ODD_PAGE: return 3; - default: throw new IllegalArgumentException(); + default: throw new IllegalArgumentException( + "Illegal value for breakClass: " + breakClass); } } diff --git a/status.xml b/status.xml index 17e88d5d6..cd5321ebf 100644 --- a/status.xml +++ b/status.xml @@ -175,12 +175,117 @@ + +
      + Notes +

      + Besides the important changes listed below, the most important areas with + improvements in this release are: +

      +
        +
      • + Many bugfixes in tables, plus some new features (full support for keeps and + breaks, border conditionality, background on columns and header/footer/body) +
      • +
      • + Improvements and bugfixes for font handling and font + auto-detection/-registration. +
      • +
      • + Performance improvements and memory optimizations for the property handling + in the FO tree. +
      • +
      +

      + Please note that with this release, we've dropped support for Java 1.3. + FOP will, from now on, require at least Java 1.4. +

      +

      + There have been a few changes in tables that make FOP both more strict and more + compliant to the Recommendation: +

        +
      • XSL-FO 1.1 explicitly states that a row-spanning fo:table-cell element is not + allowed to span further than its enclosing fo:table-header/footer/body element + (see bottom of section + 6.7.3). From now on FOP will give a validation error if a document + contains such an erroneous cell. +
      • +
      • +

        If an fo:table element contains explicit fo:table-column children, then those + elements set the total number of columns in the table. This means that a + validation error will now occur if a row contains more cells than available + columns. This change allows to improve performance, since the rendering of the + table may start as soon as the table-column elements have been parsed.

        +

        If more flexibility is needed, then the fo:table-column elements may be just + omitted. The final number of columns will then be set by the row that has the + most cells.

        +
      • +
      +

      +

      + The image libraries Jimi and JAI are no longer needed (and used) for image loading. + Instead we rely completely on the Image I/O API that has been introduced with + Java 1.4. If you still need support for bitmap image formats that do not work + out-of-the-box, we recommend adding + JAI Image I/O Tools + (an Image I/O compatible image codec package) to the classpath. JAI is still required + for building the FOP distribution but it is optional for normal builds and at run-time. +

      + + This final 0.95 release contains all the + changes made for Apache FOP 0.95beta. + +
      +
      - Fixed positioning of absolutely positioned block-containers in multi-column documents. + Fixed a color selection problem which occurred after an image has been painted + through the Graphics2DAdapter in PDF output. + + + Fixed page ordering problem with AWTRenderer. + + + Fixed image scaling for RTF output. + + + Fixed the -imagein command-line option. + + + Added support for fo:leader for RTF output (no full support!). Fixes problems with empty leaders + being used to force empty lines among other issues. + + + Added support for page-number-citation for RTF output. + + + Fixed handling of proportional-column-width() and percentages for table column in RTF + output. + + + Fixed NullPointerException when page-number-citations are used inside a marker. + + + Fixed two bugs concerning resolution handling with SVG images and their + conversion to bitmaps for RTF output. + + + Fixed potential multi-threading problem concerning the use of DecimalFormat. + + + Regression bugfix: Multiple collapsible breaks don't cause empty pages anymore. + Fixed resolution handling inside AWT preview dialog. + + + Fixed positioning of absolutely positioned block-containers in multi-column documents. + + Fixed rendering of fixed block-containers in AFP output. + + Various bugfixes for table layout. + Fixed regression causing bad positioning of block-containers if used as descendant of a table-cell. 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 c6c4015cc..457aa91d4 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java @@ -88,6 +88,51 @@ public class ImageLoaderTestCase extends TestCase { assertEquals(16000, info.getSize().getHeightMpt()); } + public void testSVGNoViewbox() throws Exception { + String uri = "test/resources/images/circles.svg"; + + FopFactory ff = FopFactory.newInstance(); + ff.setSourceResolution(96); + ff.setTargetResolution(300); + + FOUserAgent userAgent = ff.newFOUserAgent(); + + ImageManager manager = ff.getImageManager(); + ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); + assertNotNull("ImageInfo must not be null", info); + + Image img = manager.getImage(info, ImageFlavor.XML_DOM, + userAgent.getImageSessionContext()); + assertNotNull("Image must not be null", img); + assertEquals(ImageFlavor.XML_DOM, img.getFlavor()); + ImageXMLDOM imgDom = (ImageXMLDOM)img; + assertNotNull(imgDom.getDocument()); + assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); + info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image + assertEquals(96, info.getSize().getDpiHorizontal(), 0); + assertEquals(340158, info.getSize().getWidthMpt()); + assertEquals(340158, info.getSize().getHeightMpt()); + assertEquals(454, info.getSize().getWidthPx()); + assertEquals(454, info.getSize().getHeightPx()); + + img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, + userAgent.getImageSessionContext()); + assertNotNull("Image must not be null", img); + assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor()); + ImageRendered imgRed = (ImageRendered)img; + assertNotNull(imgRed.getRenderedImage()); + if (DEBUG_TARGET_DIR != null) { + ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(), + (int)userAgent.getTargetResolution(), + new File(DEBUG_TARGET_DIR, "circles.svg.png")); + } + assertEquals(1418, imgRed.getRenderedImage().getWidth()); + assertEquals(1418, imgRed.getRenderedImage().getHeight()); + info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image + assertEquals(340158, info.getSize().getWidthMpt()); + assertEquals(340158, info.getSize().getHeightMpt()); + } + public void testWMF() throws Exception { String uri = "test/resources/images/testChart.wmf"; diff --git a/test/layoutengine/standard-testcases/block_break-before_bug44412.xml b/test/layoutengine/standard-testcases/block_break-before_bug44412.xml index 9ef4150b5..cc5bcd3c8 100644 --- a/test/layoutengine/standard-testcases/block_break-before_bug44412.xml +++ b/test/layoutengine/standard-testcases/block_break-before_bug44412.xml @@ -20,8 +20,7 @@

      This test checks Bugzilla #44412 where a break-before on the first child of an otherwise - empty block is set. It is expected that the parent block creates two areas, the first with - only border-before on the first page and zero bpd. + empty block is set.

      @@ -44,20 +43,12 @@ - - - - - + + + - - - - - - 3 diff --git a/test/layoutengine/standard-testcases/block_break-before_bug44412_2.xml b/test/layoutengine/standard-testcases/block_break-before_bug44412_2.xml new file mode 100644 index 000000000..3f54f809a --- /dev/null +++ b/test/layoutengine/standard-testcases/block_break-before_bug44412_2.xml @@ -0,0 +1,151 @@ + + + + + +

      + This test checks for the correct behaviour of multiple breaks at the same break possibility. +

      +
      + + + + + + + + + + + page: + + + Before the break + + + This text should be on page 2. + + + + Inner block with break-after. + + + + This text should be on page 3. + + + + + page: + + + Before the break + + + This text should be on page 2. + + + + Inner block with break-after. + + + + This text should be on page 3. + + + + + page: + + + Before the break + + + + + + + This text should be on page 2. + + + + + + + + + + + Inner block in table with break-after. + + + + + + + This text should be on page 3. + + + + + page: + + + Before the break + + + + + + + + + This text should be on page 2. + + + + + + + + + Inner block in list-item with break-after. + + + + + This text should be on page 3. + + + + + + + + + + + + + + + + + + + + +
      diff --git a/test/resources/images/circles.svg b/test/resources/images/circles.svg new file mode 100644 index 000000000..8b71e8224 --- /dev/null +++ b/test/resources/images/circles.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 39f5b053cc82f71efa6014c36c0de2f36534bd19 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Thu, 14 Aug 2008 13:37:33 +0000 Subject: Merged revisions 685573,685785,685879,685885 via svnmerge from https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r685573 | jeremias | 2008-08-13 15:34:03 +0100 (Wed, 13 Aug 2008) | 1 line Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used. ........ r685785 | jeremias | 2008-08-14 07:32:52 +0100 (Thu, 14 Aug 2008) | 1 line Removed three unused classes in the traits package. ........ r685879 | jeremias | 2008-08-14 14:03:20 +0100 (Thu, 14 Aug 2008) | 2 lines Fixed the source for a NullPointerException when the content of an fo:leader with leader-pattern="use-content" collapses to zero width during layout. ........ r685885 | acumiskey | 2008-08-14 14:25:54 +0100 (Thu, 14 Aug 2008) | 1 line Moved static method lightenColor() from PrintRenderer to ColorUtil. Thats one less Renderer interface dependency to worry about :). ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@685891 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/layoutmgr/inline/LeaderLayoutManager.java | 26 ++++--- src/java/org/apache/fop/render/PrintRenderer.java | 24 ------ .../org/apache/fop/render/afp/AFPRenderer.java | 9 ++- .../apache/fop/render/java2d/Java2DRenderer.java | 15 ++-- .../org/apache/fop/render/pdf/PDFRenderer.java | 15 ++-- src/java/org/apache/fop/render/ps/PSRenderer.java | 15 ++-- src/java/org/apache/fop/traits/BlockProps.java | 36 --------- src/java/org/apache/fop/traits/BorderProps.java | 21 ++++-- src/java/org/apache/fop/traits/InlineProps.java | 35 --------- src/java/org/apache/fop/traits/LayoutProps.java | 88 ---------------------- src/java/org/apache/fop/util/ColorUtil.java | 23 ++++++ status.xml | 7 ++ .../org/apache/fop/traits/BorderPropsTestCase.java | 7 ++ .../leader_leader-pattern_use-content.xml | 8 ++ 14 files changed, 104 insertions(+), 225 deletions(-) delete mode 100644 src/java/org/apache/fop/traits/BlockProps.java delete mode 100644 src/java/org/apache/fop/traits/InlineProps.java delete mode 100644 src/java/org/apache/fop/traits/LayoutProps.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index 1e163bef8..f3bbc454a 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java @@ -183,17 +183,23 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { childContext.setAlignmentContext(context.getAlignmentContext()); contentList = clm.getNextKnuthElements(childContext, 0); int width = clm.getStackingSize(); - Space spacer = null; - if (fobj.getLeaderPatternWidth().getValue(this) > width) { - spacer = new Space(); - spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width); - width = fobj.getLeaderPatternWidth().getValue(this); - } - fa.setUnitWidth(width); - if (spacer != null) { - fa.addChildArea(spacer); + if (width != 0) { + Space spacer = null; + if (fobj.getLeaderPatternWidth().getValue(this) > width) { + spacer = new Space(); + spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width); + width = fobj.getLeaderPatternWidth().getValue(this); + } + fa.setUnitWidth(width); + if (spacer != null) { + fa.addChildArea(spacer); + } + leaderArea = fa; + } else { + //Content collapsed to nothing, so use a space + leaderArea = new Space(); + leaderArea.setBPD(1); } - leaderArea = fa; } TraitSetter.setProducerID(leaderArea, fobj.getId()); return leaderArea; diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java index 44b0a211d..56504ff53 100644 --- a/src/java/org/apache/fop/render/PrintRenderer.java +++ b/src/java/org/apache/fop/render/PrintRenderer.java @@ -20,7 +20,6 @@ package org.apache.fop.render; // FOP -import java.awt.Color; import java.awt.geom.Rectangle2D; import java.util.List; import java.util.Map; @@ -112,29 +111,6 @@ public abstract class PrintRenderer extends AbstractRenderer { return fontInfo.getFontInstance(triplet, size); } - /** - * Lightens up a color for groove, ridge, inset and outset border effects. - * @param col the color to lighten up - * @param factor factor by which to lighten up (negative values darken the color) - * @return the modified color - */ - public static Color lightenColor(Color col, float factor) { - // TODO: This function converts the color into the sRGB namespace. - // This should be avoided if possible. - float[] cols = new float[4]; - cols = col.getRGBComponents(cols); - if (factor > 0) { - cols[0] += (1.0 - cols[0]) * factor; - cols[1] += (1.0 - cols[1]) * factor; - cols[2] += (1.0 - cols[2]) * factor; - } else { - cols[0] -= cols[0] * -factor; - cols[1] -= cols[1] * -factor; - cols[2] -= cols[2] * -factor; - } - return new Color(cols[0], cols[1], cols[2], cols[3]); - } - /** * Creates a RendererContext for an image. * @param x the x coordinate (in millipoints) diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 94918f7ec..6d4e8fafd 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -78,6 +78,7 @@ import org.apache.fop.render.afp.fonts.AFPFont; import org.apache.fop.render.afp.fonts.AFPFontCollection; import org.apache.fop.render.afp.modca.AFPDataStream; import org.apache.fop.render.afp.modca.PageObject; +import org.apache.fop.util.ColorUtil; /** * This is an implementation of a FOP Renderer that renders areas to AFP. @@ -502,7 +503,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { float h3 = height / 3; - lineDataInfo.color = lightenColor(col, -colFactor); + lineDataInfo.color = ColorUtil.lightenColor(col, -colFactor); lineDataInfo.thickness = Math.round(h3); lineDataInfo.y1 = lineDataInfo.y2 = coords[Y1]; afpDataStream.createLine(lineDataInfo); @@ -511,7 +512,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { lineDataInfo.y1 = lineDataInfo.y2 = Math.round(dstPts[Y1] + h3); afpDataStream.createLine(lineDataInfo); - lineDataInfo.color = lightenColor(col, colFactor); + lineDataInfo.color = ColorUtil.lightenColor(col, colFactor); lineDataInfo.y1 = lineDataInfo.y2 = Math.round(dstPts[Y1] + h3 + h3); afpDataStream.createLine(lineDataInfo); @@ -524,7 +525,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { float w3 = width / 3; float xm1 = dstPts[X1] + (w3 / 2); - lineDataInfo.color = lightenColor(col, -colFactor); + lineDataInfo.color = ColorUtil.lightenColor(col, -colFactor); lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1); afpDataStream.createLine(lineDataInfo); @@ -532,7 +533,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1 + w3); afpDataStream.createLine(lineDataInfo); - lineDataInfo.color = lightenColor(col, colFactor); + lineDataInfo.color = ColorUtil.lightenColor(col, colFactor); lineDataInfo.x1 = lineDataInfo.x2 = Math.round(xm1 + w3 + w3); afpDataStream.createLine(lineDataInfo); } diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index 02b809ff7..1e396c247 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -77,6 +77,7 @@ import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.render.pdf.CTMHelper; import org.apache.fop.util.CharUtilities; +import org.apache.fop.util.ColorUtil; /** * The Java2DRenderer class provides the abstract technical @@ -625,8 +626,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem case Constants.EN_RIDGE: float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f); if (horz) { - Color uppercol = lightenColor(col, -colFactor); - Color lowercol = lightenColor(col, colFactor); + Color uppercol = ColorUtil.lightenColor(col, -colFactor); + Color lowercol = ColorUtil.lightenColor(col, colFactor); float h3 = h / 3; float ym1 = y1 + (h3 / 2); g2d.setStroke(new BasicStroke(h3)); @@ -637,8 +638,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem g2d.setColor(lowercol); g2d.draw(new Line2D.Float(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3)); } else { - Color leftcol = lightenColor(col, -colFactor); - Color rightcol = lightenColor(col, colFactor); + Color leftcol = ColorUtil.lightenColor(col, -colFactor); + Color rightcol = ColorUtil.lightenColor(col, colFactor); float w3 = w / 3; float xm1 = x1 + (w3 / 2); g2d.setStroke(new BasicStroke(w3)); @@ -654,13 +655,13 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem case Constants.EN_OUTSET: colFactor = (style == EN_OUTSET ? 0.4f : -0.4f); if (horz) { - col = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor); + col = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor); g2d.setStroke(new BasicStroke(h)); float ym1 = y1 + (h / 2); g2d.setColor(col); g2d.draw(new Line2D.Float(x1, ym1, x2, ym1)); } else { - col = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor); + col = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor); float xm1 = x1 + (w / 2); g2d.setStroke(new BasicStroke(w)); g2d.setColor(col); @@ -830,7 +831,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem case EN_RIDGE: float half = area.getRuleThickness() / 2000f; - state.updateColor(lightenColor(col, 0.6f)); + state.updateColor(ColorUtil.lightenColor(col, 0.6f)); moveTo(startx, starty); lineTo(endx, starty); lineTo(endx, starty + 2 * half); diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 27caf86b4..61ed1ff07 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -117,6 +117,7 @@ import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.util.CharUtilities; import org.apache.fop.util.ColorProfileUtil; +import org.apache.fop.util.ColorUtil; /** * Renderer that renders areas to PDF. @@ -939,8 +940,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f); currentStream.add("[] 0 d "); if (horz) { - Color uppercol = lightenColor(col, -colFactor); - Color lowercol = lightenColor(col, colFactor); + Color uppercol = ColorUtil.lightenColor(col, -colFactor); + Color lowercol = ColorUtil.lightenColor(col, colFactor); float h3 = h / 3; currentStream.add(format(h3) + " w\n"); float ym1 = y1 + (h3 / 2); @@ -954,8 +955,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(format(x1) + " " + format(ym1 + h3 + h3) + " m " + format(x2) + " " + format(ym1 + h3 + h3) + " l S\n"); } else { - Color leftcol = lightenColor(col, -colFactor); - Color rightcol = lightenColor(col, colFactor); + Color leftcol = ColorUtil.lightenColor(col, -colFactor); + Color rightcol = ColorUtil.lightenColor(col, colFactor); float w3 = w / 3; currentStream.add(format(w3) + " w\n"); float xm1 = x1 + (w3 / 2); @@ -978,14 +979,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add("[] 0 d "); Color c = col; if (horz) { - c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor); + c = ColorUtil.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor); currentStream.add(format(h) + " w\n"); float ym1 = y1 + (h / 2); setColor(c, false, null); currentStream.add(format(x1) + " " + format(ym1) + " m " + format(x2) + " " + format(ym1) + " l S\n"); } else { - c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor); + c = ColorUtil.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor); currentStream.add(format(w) + " w\n"); float xm1 = x1 + (w / 2); setColor(c, false, null); @@ -1773,7 +1774,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { case EN_RIDGE: float half = area.getRuleThickness() / 2000f; - setColor(lightenColor(col, 0.6f), true, null); + setColor(ColorUtil.lightenColor(col, 0.6f), true, null); currentStream.add(format(startx) + " " + format(starty) + " m\n"); currentStream.add(format(endx) + " " + format(starty) + " l\n"); currentStream.add(format(endx) + " " + format(starty + 2 * half) + " l\n"); diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index 9f8cdc771..4785ea14f 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -106,6 +106,7 @@ import org.apache.fop.render.ps.extensions.PSExtensionAttachment; import org.apache.fop.render.ps.extensions.PSSetPageDevice; import org.apache.fop.render.ps.extensions.PSSetupCode; import org.apache.fop.util.CharUtilities; +import org.apache.fop.util.ColorUtil; /** * Renderer that renders to PostScript. @@ -839,8 +840,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f); gen.useDash(null); if (horz) { - Color uppercol = lightenColor(col, -colFactor); - Color lowercol = lightenColor(col, colFactor); + Color uppercol = ColorUtil.lightenColor(col, -colFactor); + Color lowercol = ColorUtil.lightenColor(col, colFactor); float h3 = h / 3; gen.useLineWidth(h3); float ym1 = y1 + (h3 / 2); @@ -851,8 +852,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer gen.useColor(lowercol); drawLine(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3); } else { - Color leftcol = lightenColor(col, -colFactor); - Color rightcol = lightenColor(col, colFactor); + Color leftcol = ColorUtil.lightenColor(col, -colFactor); + Color rightcol = ColorUtil.lightenColor(col, colFactor); float w3 = w / 3; gen.useLineWidth(w3); float xm1 = x1 + (w3 / 2); @@ -869,13 +870,13 @@ public class PSRenderer extends AbstractPathOrientedRenderer colFactor = (style == EN_OUTSET ? 0.4f : -0.4f); gen.useDash(null); if (horz) { - Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor); + Color c = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor); gen.useLineWidth(h); float ym1 = y1 + (h / 2); gen.useColor(c); drawLine(x1, ym1, x2, ym1); } else { - Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor); + Color c = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor); gen.useLineWidth(w); float xm1 = x1 + (w / 2); gen.useColor(c); @@ -1570,7 +1571,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer case EN_RIDGE: float half = area.getRuleThickness() / 2000f; - gen.useColor(lightenColor(col, 0.6f)); + gen.useColor(ColorUtil.lightenColor(col, 0.6f)); moveTo(startx, starty); lineTo(endx, starty); lineTo(endx, starty + 2 * half); diff --git a/src/java/org/apache/fop/traits/BlockProps.java b/src/java/org/apache/fop/traits/BlockProps.java deleted file mode 100644 index 370a97982..000000000 --- a/src/java/org/apache/fop/traits/BlockProps.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.traits; - -import org.apache.fop.datatypes.Length; - -/** - * Store all block-level layout properties on an FO. - * Public "structure" allows direct member access. - */ -public class BlockProps { - - public Length firstIndent; // text-indent - public int lastIndent; // last-line-indent - public int textAlign; - public int textAlignLast; - public int lineStackType; // line-stacking-strategy (enum) - -} diff --git a/src/java/org/apache/fop/traits/BorderProps.java b/src/java/org/apache/fop/traits/BorderProps.java index 20e362674..338743538 100644 --- a/src/java/org/apache/fop/traits/BorderProps.java +++ b/src/java/org/apache/fop/traits/BorderProps.java @@ -21,7 +21,8 @@ package org.apache.fop.traits; import java.awt.Color; import java.io.Serializable; -import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.Constants; @@ -162,13 +163,19 @@ public class BorderProps implements Serializable { public static BorderProps valueOf(FOUserAgent foUserAgent, String s) { if (s.startsWith("(") && s.endsWith(")")) { s = s.substring(1, s.length() - 1); - StringTokenizer st = new StringTokenizer(s, ","); - String style = st.nextToken(); - String color = st.nextToken(); - int width = Integer.parseInt(st.nextToken()); + Pattern pattern = Pattern.compile("([^,\\(]+(?:\\(.*\\))?)"); + Matcher m = pattern.matcher(s); + boolean found; + found = m.find(); + String style = m.group(); + found = m.find(); + String color = m.group(); + found = m.find(); + int width = Integer.parseInt(m.group()); int mode = SEPARATE; - if (st.hasMoreTokens()) { - String ms = st.nextToken(); + found = m.find(); + if (found) { + String ms = m.group(); if ("collapse-inner".equalsIgnoreCase(ms)) { mode = COLLAPSE_INNER; } else if ("collapse-outer".equalsIgnoreCase(ms)) { diff --git a/src/java/org/apache/fop/traits/InlineProps.java b/src/java/org/apache/fop/traits/InlineProps.java deleted file mode 100644 index 06ca2553d..000000000 --- a/src/java/org/apache/fop/traits/InlineProps.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.traits; - -/** - * Store all inline "margin" related properties - * Public "structure" allows direct member access. - */ -public class InlineProps { - - public int marginTop; - public int marginBottom; - public int marginLeft; - public int marginRight; - public SpaceVal spaceStart; - public SpaceVal spaceEnd; - -} diff --git a/src/java/org/apache/fop/traits/LayoutProps.java b/src/java/org/apache/fop/traits/LayoutProps.java deleted file mode 100644 index eff218b37..000000000 --- a/src/java/org/apache/fop/traits/LayoutProps.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.traits; - -import org.apache.fop.datatypes.KeepValue; -import org.apache.fop.fo.Constants; - -/** - * Store properties affecting layout: break-before, break-after, keeps, span. - * for a block level FO. - * Public "structure" allows direct member access. - */ -public class LayoutProps { - - public int breakBefore; // enum constant BreakBefore.xxx - public int breakAfter; // enum constant BreakAfter.xxx - public KeepValue keepWithPrevious; /*LF*/ - public KeepValue keepWithNext; /*LF*/ - public KeepValue keepTogether; /*LF*/ - public int orphans; /*LF*/ - public int widows; /*LF*/ - public int blockProgressionUnit; /*LF*/ - public int lineStackingStrategy; /*LF*/ - public boolean bIsSpan; - public SpaceVal spaceBefore; - public SpaceVal spaceAfter; - - private static final int[] BREAK_PRIORITIES = - new int[]{ Constants.EN_AUTO, Constants.EN_COLUMN, Constants.EN_PAGE }; - - - public LayoutProps() { - breakBefore = breakAfter = Constants.EN_AUTO; - bIsSpan = false; - } - - // public static int higherBreak(int brkParent, int brkChild) { - // if (brkParent == brkChild) return brkChild; - // for (int i=0; i < s_breakPriorities.length; i++) { - // int bp = s_breakPriorities[i]; - // if (bp == brkParent) return brkChild; - // else if (bp == brkChild) return brkParent; - // } - // return brkChild; - // } - - public void combineWithParent(LayoutProps parentLP) { - if (parentLP.breakBefore != breakBefore) { - for (int i = 0; i < BREAK_PRIORITIES.length; i++) { - int bp = BREAK_PRIORITIES[i]; - if (bp == breakBefore) { - breakBefore = parentLP.breakBefore; - break; - } else if (bp == parentLP.breakBefore) { - break; - } - } - } - // Parent span always overrides child span - bIsSpan = parentLP.bIsSpan; - } - - public String toString() { - return "LayoutProps:\n" + - "breakBefore = " + breakBefore + "; breakAfter = " + breakAfter + "\n" + - "spaceBefore = " + ((spaceBefore != null) ? spaceBefore.toString() : "null") + "\n" + - "spaceAfter = " + ((spaceAfter != null) ? spaceAfter.toString() : "null") + "\n" + - "bIsSpan = " + bIsSpan + "\n"; - } -} - diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java index b85b0c017..9534bfba3 100644 --- a/src/java/org/apache/fop/util/ColorUtil.java +++ b/src/java/org/apache/fop/util/ColorUtil.java @@ -658,4 +658,27 @@ public final class ColorUtil { colorMap.put("transparent", new Color(0, 0, 0, 0)); } + /** + * Lightens up a color for groove, ridge, inset and outset border effects. + * @param col the color to lighten up + * @param factor factor by which to lighten up (negative values darken the color) + * @return the modified color + */ + public static Color lightenColor(Color col, float factor) { + // TODO: This function converts the color into the sRGB namespace. + // This should be avoided if possible. + float[] cols = new float[4]; + cols = col.getRGBComponents(cols); + if (factor > 0) { + cols[0] += (1.0 - cols[0]) * factor; + cols[1] += (1.0 - cols[1]) * factor; + cols[2] += (1.0 - cols[2]) * factor; + } else { + cols[0] -= cols[0] * -factor; + cols[1] -= cols[1] * -factor; + cols[2] -= cols[2] * -factor; + } + return new Color(cols[0], cols[1], cols[2], cols[3]); + } + } diff --git a/status.xml b/status.xml index d5ca1ac9f..c134fadc2 100644 --- a/status.xml +++ b/status.xml @@ -53,6 +53,13 @@ + + Fixed the source for a NullPointerException when the content of an fo:leader with + leader-pattern="use-content" collapses to zero width during layout. + + + Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used. + Fixed generation of "fonttbl" for RTF output to fix loading problem with AbiWord. diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java index 6aea38512..0c08e05af 100644 --- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java +++ b/test/java/org/apache/fop/traits/BorderPropsTestCase.java @@ -24,6 +24,8 @@ import java.awt.Color; import junit.framework.TestCase; import org.apache.fop.fo.Constants; +import org.apache.fop.util.CMYKColorSpace; +import org.apache.fop.util.ColorExt; import org.apache.fop.util.ColorUtil; /** @@ -46,6 +48,11 @@ public class BorderPropsTestCase extends TestCase { BorderProps b2 = BorderProps.valueOf(null, ser); assertEquals(b1, b2); + float[] cmyk = new float[] {1.0f, 1.0f, 0.5f, 1.0f}; + CMYKColorSpace cmykCs = CMYKColorSpace.getInstance(); + float[] rgb = cmykCs.toRGB(cmyk); + col = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], + null, "#CMYK", cmykCs, cmyk); b1 = new BorderProps(Constants.EN_INSET, 9999, col, BorderProps.SEPARATE); ser = b1.toString(); diff --git a/test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml b/test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml index c98bd4511..2a5c72c14 100644 --- a/test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml +++ b/test/layoutengine/standard-testcases/leader_leader-pattern_use-content.xml @@ -69,6 +69,10 @@ Content is svg 20 x 10 which is wider than the leader-length + + + Content is " " + @@ -172,5 +176,9 @@ + + + + -- cgit v1.2.3 From d9e4553fcf9567ef9674be9f8dcdc6ac92232b06 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Mon, 20 Oct 2008 13:42:28 +0000 Subject: Merged revisions 706272,706276 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r706272 | jeremias | 2008-10-20 14:14:03 +0100 (Mon, 20 Oct 2008) | 1 line Visually separated retroweaver part from hyphenation part. ........ r706276 | jeremias | 2008-10-20 14:20:26 +0100 (Mon, 20 Oct 2008) | 3 lines Fixed size of images when vector graphic images are painted using fox:conversion-mode="bitmap" (for PDF output). Added support for fox:conversion-mode="bitmap" for PS output. Avoid "unsupported target ImageFlavor" error after the fix in XML Graphics Commons (rev 706270). ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@706282 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 3 ++ .../fop/image/loader/batik/ImageLoaderSVG.java | 5 +- .../fop/render/AbstractGenericSVGHandler.java | 7 ++- .../fop/render/pdf/PDFGraphics2DAdapter.java | 4 +- .../apache/fop/render/ps/PSGraphics2DAdapter.java | 37 +++++++++++-- src/java/org/apache/fop/render/ps/PSRenderer.java | 60 +++++++++++----------- .../org/apache/fop/render/ps/PSSVGHandler.java | 19 +++++++ 7 files changed, 96 insertions(+), 39 deletions(-) (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/build.xml b/build.xml index 32b27c82b..7ab83df21 100644 --- a/build.xml +++ b/build.xml @@ -459,6 +459,9 @@ list of possible build targets. + + + 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 c5c113b04..bb9c7d395 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.Map; import org.apache.batik.dom.svg.SVGDOMImplementation; + import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; @@ -45,8 +46,8 @@ public class ImageLoaderSVG extends AbstractImageLoader { * @param targetFlavor the target flavor */ public ImageLoaderSVG(ImageFlavor targetFlavor) { - if (!(XMLNamespaceEnabledImageFlavor.SVG_DOM.equals(targetFlavor))) { - throw new IllegalArgumentException("Unsupported target ImageFlavor: " + targetFlavor); + if (!(XMLNamespaceEnabledImageFlavor.SVG_DOM.isCompatible(targetFlavor))) { + throw new IllegalArgumentException("Incompatible target ImageFlavor: " + targetFlavor); } this.targetFlavor = targetFlavor; } diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index a72c3ccb0..17b2b9d36 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -37,7 +37,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; +import org.apache.xmlgraphics.util.QName; +import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.render.RendererContext.RendererContextWrapper; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; @@ -50,8 +52,9 @@ import org.apache.fop.svg.SVGUserAgent; */ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererContextConstants { - /** logging instance */ - protected static Log log = LogFactory.getLog(AbstractGenericSVGHandler.class); + /** Qualified name for the "conversion-mode" extension attribute. */ + protected static final QName CONVERSION_MODE = new QName( + ExtensionElementMapping.URI, null, "conversion-mode"); /** {@inheritDoc} */ public void handleXML(RendererContext context, diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java index f05a16f1a..2aa11227a 100644 --- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java @@ -66,8 +66,8 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { float imw = (float)dim.getWidth() / 1000f; float imh = (float)dim.getHeight() / 1000f; - float sx = fwidth / (float)imw; - float sy = fheight / (float)imh; + float sx = pdfInfo.paintAsBitmap ? 1.0f : (fwidth / (float)imw); + float sy = pdfInfo.paintAsBitmap ? 1.0f : (fheight / (float)imh); renderer.saveGraphicsState(); renderer.setColor(Color.black, false, null); diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java index c17fe9e56..542a69a4a 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java @@ -22,21 +22,32 @@ package org.apache.fop.render.ps; import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; import java.io.IOException; +import java.util.Map; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; import org.apache.xmlgraphics.ps.PSGenerator; +import org.apache.xmlgraphics.util.QName; +import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.render.AbstractGraphics2DAdapter; import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; +import org.apache.fop.render.RendererContextConstants; +import org.apache.fop.render.RendererContext.RendererContextWrapper; +import org.apache.fop.render.pdf.PDFRenderer; /** * Graphics2DAdapter implementation for PostScript. */ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { + /** Qualified name for the "conversion-mode" extension attribute. */ + protected static final QName CONVERSION_MODE = new QName( + ExtensionElementMapping.URI, null, "conversion-mode"); + private PSGenerator gen; private boolean clip = true; @@ -72,8 +83,15 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { float imw = (float)dim.getWidth() / 1000f; float imh = (float)dim.getHeight() / 1000f; - float sx = fwidth / (float)imw; - float sy = fheight / (float)imh; + boolean paintAsBitmap = false; + if (context != null) { + Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); + paintAsBitmap = (foreign != null + && "bitmap".equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))); + } + + float sx = paintAsBitmap ? 1.0f : (fwidth / (float)imw); + float sy = paintAsBitmap ? 1.0f : (fheight / (float)imh); gen.commentln("%FOPBeginGraphics2D"); gen.saveGraphicsState(); @@ -96,8 +114,19 @@ public class PSGraphics2DAdapter extends AbstractGraphics2DAdapter { // scale to viewbox transform.translate(fx, fy); gen.getCurrentState().concatMatrix(transform); - Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh); - painter.paint(graphics, area); + if (paintAsBitmap) { + //Fallback solution: Paint to a BufferedImage + int resolution = (int)Math.round(context.getUserAgent().getTargetResolution()); + RendererContextWrapper ctx = RendererContext.wrapRendererContext(context); + BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false); + + float scale = PDFRenderer.NORMAL_PDF_RESOLUTION + / context.getUserAgent().getTargetResolution(); + graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null); + } else { + Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh); + painter.paint(graphics, area); + } gen.restoreGraphicsState(); gen.commentln("%FOPEndGraphics2D"); diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index 085ee8230..4ccb0bd52 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -40,6 +40,36 @@ import javax.xml.transform.Source; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + +import org.apache.xmlgraphics.image.loader.ImageException; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +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.image.loader.impl.ImageGraphics2D; +import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; +import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS; +import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; +import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; +import org.apache.xmlgraphics.image.loader.impl.ImageRendered; +import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; +import org.apache.xmlgraphics.image.loader.pipeline.ImageProviderPipeline; +import org.apache.xmlgraphics.image.loader.util.ImageUtil; +import org.apache.xmlgraphics.ps.DSCConstants; +import org.apache.xmlgraphics.ps.ImageEncoder; +import org.apache.xmlgraphics.ps.PSDictionary; +import org.apache.xmlgraphics.ps.PSDictionaryFormatException; +import org.apache.xmlgraphics.ps.PSGenerator; +import org.apache.xmlgraphics.ps.PSImageUtils; +import org.apache.xmlgraphics.ps.PSPageDeviceDictionary; +import org.apache.xmlgraphics.ps.PSProcSets; +import org.apache.xmlgraphics.ps.PSResource; +import org.apache.xmlgraphics.ps.PSState; +import org.apache.xmlgraphics.ps.dsc.DSCException; +import org.apache.xmlgraphics.ps.dsc.ResourceTracker; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox; +import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox; + import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.area.Area; @@ -77,34 +107,6 @@ import org.apache.fop.render.ps.extensions.PSSetPageDevice; import org.apache.fop.render.ps.extensions.PSSetupCode; import org.apache.fop.util.CharUtilities; import org.apache.fop.util.ColorUtil; -import org.apache.xmlgraphics.image.loader.ImageException; -import org.apache.xmlgraphics.image.loader.ImageFlavor; -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.image.loader.impl.ImageGraphics2D; -import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; -import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS; -import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; -import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; -import org.apache.xmlgraphics.image.loader.impl.ImageRendered; -import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; -import org.apache.xmlgraphics.image.loader.pipeline.ImageProviderPipeline; -import org.apache.xmlgraphics.image.loader.util.ImageUtil; -import org.apache.xmlgraphics.ps.DSCConstants; -import org.apache.xmlgraphics.ps.ImageEncoder; -import org.apache.xmlgraphics.ps.PSDictionary; -import org.apache.xmlgraphics.ps.PSDictionaryFormatException; -import org.apache.xmlgraphics.ps.PSGenerator; -import org.apache.xmlgraphics.ps.PSImageUtils; -import org.apache.xmlgraphics.ps.PSPageDeviceDictionary; -import org.apache.xmlgraphics.ps.PSProcSets; -import org.apache.xmlgraphics.ps.PSResource; -import org.apache.xmlgraphics.ps.PSState; -import org.apache.xmlgraphics.ps.dsc.DSCException; -import org.apache.xmlgraphics.ps.dsc.ResourceTracker; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox; -import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox; /** * Renderer that renders to PostScript. @@ -1610,7 +1612,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer * {@inheritDoc} */ public void renderImage(Image image, Rectangle2D pos) { - drawImage(image.getURL(), pos); + drawImage(image.getURL(), pos, image.getForeignAttributes()); } /** diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java index 1d293fa71..d4a478fa4 100644 --- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java +++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java @@ -22,6 +22,7 @@ package org.apache.fop.render.ps; // Java import java.awt.geom.AffineTransform; import java.io.IOException; +import java.util.Map; import org.w3c.dom.Document; @@ -39,6 +40,7 @@ import org.apache.fop.fonts.FontInfo; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; +import org.apache.fop.render.RendererContextConstants; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; @@ -226,6 +228,23 @@ public class PSSVGHandler extends AbstractGenericSVGHandler int yOffset = psInfo.currentYPosition; PSGenerator gen = psInfo.psGenerator; + boolean paintAsBitmap = false; + if (context != null) { + Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); + paintAsBitmap = (foreign != null + && "bitmap".equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))); + } + if (paintAsBitmap) { + try { + super.renderSVGDocument(context, doc); + } catch (IOException ioe) { + SVGEventProducer eventProducer = SVGEventProducer.Provider.get( + context.getUserAgent().getEventBroadcaster()); + eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc)); + } + return; + } + //Controls whether text painted by Batik is generated using text or path operations boolean strokeText = false; Configuration cfg = psInfo.getHandlerConfiguration(); -- cgit v1.2.3 From 17bc8aa0870e3d6043ea2865e44fc2433dd5b36b Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Mon, 27 Oct 2008 11:11:31 +0000 Subject: All AFP library classes without Renderer dependencies moved from org.apache.fop.renderer.afp.* to org.apache.fop.afp.*. AbstractNamedAFPObject now truncates names to the last x characters of the name string instead of the first x (where x is the name length of the structured field). Removed redundant package org.apache.fop.store. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@708134 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 2 +- src/java/org/apache/fop/AbstractState.java | 465 +++++++++++++ .../fop/afp/AFPAbstractGraphicsObjectPainter.java | 62 ++ src/java/org/apache/fop/afp/AFPBorderPainter.java | 195 ++++++ src/java/org/apache/fop/afp/AFPConstants.java | 53 ++ .../org/apache/fop/afp/AFPDataObjectFactory.java | 255 +++++++ src/java/org/apache/fop/afp/AFPDataObjectInfo.java | 206 ++++++ .../apache/fop/afp/AFPForeignAttributeReader.java | 126 ++++ src/java/org/apache/fop/afp/AFPGraphics2D.java | 612 +++++++++++++++++ .../apache/fop/afp/AFPGraphicsConfiguration.java | 155 +++++ src/java/org/apache/fop/afp/AFPGraphicsDevice.java | 81 +++ .../org/apache/fop/afp/AFPGraphicsObjectInfo.java | 105 +++ .../org/apache/fop/afp/AFPImageObjectInfo.java | 136 ++++ src/java/org/apache/fop/afp/AFPLineDataInfo.java | 192 ++++++ src/java/org/apache/fop/afp/AFPObjectAreaInfo.java | 172 +++++ src/java/org/apache/fop/afp/AFPPageFonts.java | 67 ++ .../org/apache/fop/afp/AFPRectanglePainter.java | 82 +++ src/java/org/apache/fop/afp/AFPResourceInfo.java | 141 ++++ src/java/org/apache/fop/afp/AFPResourceLevel.java | 201 ++++++ .../org/apache/fop/afp/AFPResourceManager.java | 188 +++++ src/java/org/apache/fop/afp/AFPState.java | 511 ++++++++++++++ src/java/org/apache/fop/afp/AFPStreamer.java | 216 ++++++ src/java/org/apache/fop/afp/AFPTextDataInfo.java | 202 ++++++ src/java/org/apache/fop/afp/AFPTextHandler.java | 104 +++ src/java/org/apache/fop/afp/AFPUnitConverter.java | 121 ++++ .../org/apache/fop/afp/AbstractAFPPainter.java | 51 ++ src/java/org/apache/fop/afp/BorderPaintInfo.java | 121 ++++ src/java/org/apache/fop/afp/Factory.java | 636 +++++++++++++++++ src/java/org/apache/fop/afp/PaintInfo.java | 27 + .../org/apache/fop/afp/RectanglePaintInfo.java | 84 +++ src/java/org/apache/fop/afp/Streamable.java | 38 ++ .../fop/afp/fonts/AFPBase12FontCollection.java | 157 +++++ src/java/org/apache/fop/afp/fonts/AFPFont.java | 113 +++ .../apache/fop/afp/fonts/AFPFontAttributes.java | 105 +++ .../apache/fop/afp/fonts/AFPFontCollection.java | 92 +++ src/java/org/apache/fop/afp/fonts/AFPFontInfo.java | 63 ++ .../org/apache/fop/afp/fonts/AFPFontReader.java | 592 ++++++++++++++++ .../org/apache/fop/afp/fonts/CharacterSet.java | 318 +++++++++ .../fop/afp/fonts/CharacterSetOrientation.java | 275 ++++++++ .../apache/fop/afp/fonts/FontRuntimeException.java | 48 ++ .../org/apache/fop/afp/fonts/FopCharacterSet.java | 141 ++++ src/java/org/apache/fop/afp/fonts/OutlineFont.java | 182 +++++ src/java/org/apache/fop/afp/fonts/RasterFont.java | 238 +++++++ .../apache/fop/afp/goca/AbstractGraphicsCoord.java | 137 ++++ src/java/org/apache/fop/afp/goca/GraphicsArea.java | 76 +++ src/java/org/apache/fop/afp/goca/GraphicsBox.java | 61 ++ .../fop/afp/goca/GraphicsChainedSegment.java | 148 ++++ src/java/org/apache/fop/afp/goca/GraphicsData.java | 128 ++++ .../org/apache/fop/afp/goca/GraphicsFillet.java | 42 ++ .../org/apache/fop/afp/goca/GraphicsFullArc.java | 78 +++ .../org/apache/fop/afp/goca/GraphicsImage.java | 117 ++++ src/java/org/apache/fop/afp/goca/GraphicsLine.java | 43 ++ .../fop/afp/goca/GraphicsSetArcParameters.java | 51 ++ .../fop/afp/goca/GraphicsSetCharacterSet.java | 53 ++ .../fop/afp/goca/GraphicsSetCurrentPosition.java | 40 ++ .../apache/fop/afp/goca/GraphicsSetLineType.java | 86 +++ .../apache/fop/afp/goca/GraphicsSetLineWidth.java | 53 ++ .../org/apache/fop/afp/goca/GraphicsSetMix.java | 55 ++ .../fop/afp/goca/GraphicsSetPatternSymbol.java | 105 +++ .../fop/afp/goca/GraphicsSetProcessColor.java | 89 +++ .../org/apache/fop/afp/goca/GraphicsString.java | 115 ++++ .../org/apache/fop/afp/ioca/ImageCellPosition.java | 174 +++++ src/java/org/apache/fop/afp/ioca/ImageContent.java | 277 ++++++++ .../apache/fop/afp/ioca/ImageInputDescriptor.java | 138 ++++ .../apache/fop/afp/ioca/ImageOutputControl.java | 200 ++++++ .../org/apache/fop/afp/ioca/ImageRasterData.java | 77 +++ .../apache/fop/afp/ioca/ImageRasterPattern.java | 759 +++++++++++++++++++++ src/java/org/apache/fop/afp/ioca/ImageSegment.java | 161 +++++ .../apache/fop/afp/ioca/ImageSizeParameter.java | 88 +++ .../apache/fop/afp/modca/AbstractAFPObject.java | 244 +++++++ .../apache/fop/afp/modca/AbstractDataObject.java | 108 +++ .../apache/fop/afp/modca/AbstractDescriptor.java | 64 ++ .../fop/afp/modca/AbstractEnvironmentGroup.java | 101 +++ .../fop/afp/modca/AbstractNamedAFPObject.java | 113 +++ .../apache/fop/afp/modca/AbstractPageObject.java | 346 ++++++++++ .../fop/afp/modca/AbstractPreparedAFPObject.java | 96 +++ .../afp/modca/AbstractPreparedObjectContainer.java | 84 +++ .../AbstractResourceEnvironmentGroupContainer.java | 99 +++ .../afp/modca/AbstractResourceGroupContainer.java | 167 +++++ .../fop/afp/modca/AbstractStructuredAFPObject.java | 324 +++++++++ .../fop/afp/modca/ActiveEnvironmentGroup.java | 221 ++++++ .../fop/afp/modca/ContainerDataDescriptor.java | 84 +++ src/java/org/apache/fop/afp/modca/DataStream.java | 593 ++++++++++++++++ src/java/org/apache/fop/afp/modca/Document.java | 100 +++ .../fop/afp/modca/GraphicsDataDescriptor.java | 152 +++++ .../org/apache/fop/afp/modca/GraphicsObject.java | 303 ++++++++ .../org/apache/fop/afp/modca/IMImageObject.java | 141 ++++ .../apache/fop/afp/modca/ImageDataDescriptor.java | 78 +++ src/java/org/apache/fop/afp/modca/ImageObject.java | 154 +++++ .../org/apache/fop/afp/modca/IncludeObject.java | 303 ++++++++ .../apache/fop/afp/modca/IncludePageOverlay.java | 129 ++++ .../apache/fop/afp/modca/IncludePageSegment.java | 91 +++ .../org/apache/fop/afp/modca/InterchangeSet.java | 115 ++++ .../org/apache/fop/afp/modca/InvokeMediumMap.java | 57 ++ .../org/apache/fop/afp/modca/MapCodedFont.java | 273 ++++++++ .../org/apache/fop/afp/modca/MapContainerData.java | 57 ++ .../org/apache/fop/afp/modca/MapDataResource.java | 58 ++ .../org/apache/fop/afp/modca/MapPageOverlay.java | 141 ++++ .../afp/modca/MaximumSizeExceededException.java | 37 + src/java/org/apache/fop/afp/modca/NoOperation.java | 100 +++ .../apache/fop/afp/modca/ObjectAreaDescriptor.java | 87 +++ .../apache/fop/afp/modca/ObjectAreaPosition.java | 112 +++ .../org/apache/fop/afp/modca/ObjectContainer.java | 124 ++++ .../fop/afp/modca/ObjectEnvironmentGroup.java | 173 +++++ src/java/org/apache/fop/afp/modca/Overlay.java | 87 +++ .../org/apache/fop/afp/modca/PageDescriptor.java | 88 +++ src/java/org/apache/fop/afp/modca/PageGroup.java | 105 +++ src/java/org/apache/fop/afp/modca/PageObject.java | 219 ++++++ src/java/org/apache/fop/afp/modca/PageSegment.java | 90 +++ .../apache/fop/afp/modca/PreparedAFPObject.java | 34 + .../afp/modca/PreprocessPresentationObject.java | 145 ++++ .../afp/modca/PresentationEnvironmentControl.java | 97 +++ .../apache/fop/afp/modca/PresentationTextData.java | 569 +++++++++++++++ .../fop/afp/modca/PresentationTextDescriptor.java | 101 +++ .../fop/afp/modca/PresentationTextObject.java | 169 +++++ src/java/org/apache/fop/afp/modca/Registry.java | 254 +++++++ .../fop/afp/modca/ResourceEnvironmentGroup.java | 134 ++++ .../org/apache/fop/afp/modca/ResourceGroup.java | 107 +++ .../org/apache/fop/afp/modca/ResourceObject.java | 168 +++++ .../fop/afp/modca/StreamedResourceGroup.java | 92 +++ .../apache/fop/afp/modca/TagLogicalElement.java | 130 ++++ .../fop/afp/modca/TagLogicalElementBean.java | 64 ++ .../ExtendedResourceLocalIdentifierTriplet.java | 55 ++ .../modca/triplets/FullyQualifiedNameTriplet.java | 191 ++++++ .../afp/modca/triplets/MappingOptionTriplet.java | 68 ++ .../modca/triplets/MeasurementUnitsTriplet.java | 54 ++ .../afp/modca/triplets/ObjectAreaSizeTriplet.java | 62 ++ .../modca/triplets/ObjectByteExtentTriplet.java | 39 ++ .../triplets/ObjectClassificationTriplet.java | 188 +++++ .../PresentationSpaceMixingRulesTriplet.java | 62 ++ .../PresentationSpaceResetMixingTriplet.java | 48 ++ .../modca/triplets/ResourceObjectTypeTriplet.java | 21 + .../org/apache/fop/afp/modca/triplets/Triplet.java | 162 +++++ src/java/org/apache/fop/afp/util/BinaryUtils.java | 135 ++++ .../org/apache/fop/afp/util/DTDEntityResolver.java | 120 ++++ src/java/org/apache/fop/afp/util/StringUtils.java | 81 +++ .../apache/fop/afp/util/StructuredFieldReader.java | 133 ++++ src/java/org/apache/fop/fonts/Base14Font.java | 1 + src/java/org/apache/fop/fonts/CustomFont.java | 1 + src/java/org/apache/fop/fonts/Font.java | 1 + src/java/org/apache/fop/fonts/FontCollection.java | 1 + src/java/org/apache/fop/fonts/FontDescriptor.java | 1 + .../org/apache/fop/fonts/FontEventListener.java | 1 - src/java/org/apache/fop/fonts/FontMetrics.java | 1 + src/java/org/apache/fop/fonts/FontTriplet.java | 1 + src/java/org/apache/fop/fonts/FontType.java | 28 +- src/java/org/apache/fop/fonts/FontUtil.java | 1 + src/java/org/apache/fop/fonts/MultiByteFont.java | 1 + src/java/org/apache/fop/fonts/MutableFont.java | 1 + .../layoutmgr/inline/PageNumberLayoutManager.java | 6 +- src/java/org/apache/fop/pdf/PDFState.java | 6 +- src/java/org/apache/fop/render/AbstractState.java | 433 ------------ src/java/org/apache/fop/render/StateStack.java | 50 -- .../afp/AFPAbstractGraphicsObjectPainter.java | 62 -- .../fop/render/afp/AFPAbstractImageFactory.java | 10 +- .../render/afp/AFPBatikGraphicsObjectPainter.java | 2 + .../apache/fop/render/afp/AFPBorderPainter.java | 195 ------ .../org/apache/fop/render/afp/AFPConstants.java | 53 -- .../fop/render/afp/AFPDataObjectFactory.java | 256 ------- .../apache/fop/render/afp/AFPDataObjectInfo.java | 206 ------ .../fop/render/afp/AFPDataObjectInfoFactory.java | 28 +- .../fop/render/afp/AFPDataObjectInfoProvider.java | 1 + .../apache/fop/render/afp/AFPFontAttributes.java | 107 --- .../fop/render/afp/AFPForeignAttributeReader.java | 126 ---- .../org/apache/fop/render/afp/AFPGraphics2D.java | 582 ---------------- .../fop/render/afp/AFPGraphics2DAdapter.java | 12 +- .../fop/render/afp/AFPGraphicsConfiguration.java | 155 ----- .../apache/fop/render/afp/AFPGraphicsDevice.java | 80 --- .../fop/render/afp/AFPGraphicsObjectInfo.java | 105 --- .../fop/render/afp/AFPImageGraphics2DFactory.java | 29 +- .../org/apache/fop/render/afp/AFPImageInfo.java | 97 --- .../apache/fop/render/afp/AFPImageObjectInfo.java | 137 ---- .../fop/render/afp/AFPImageRawStreamFactory.java | 13 +- .../fop/render/afp/AFPImageRenderedFactory.java | 12 +- src/java/org/apache/fop/render/afp/AFPInfo.java | 3 + .../org/apache/fop/render/afp/AFPLineDataInfo.java | 192 ------ .../apache/fop/render/afp/AFPObjectAreaInfo.java | 172 ----- .../org/apache/fop/render/afp/AFPPageFonts.java | 65 -- .../fop/render/afp/AFPRawCCITTFaxFactory.java | 10 +- .../apache/fop/render/afp/AFPRectanglePainter.java | 82 --- .../org/apache/fop/render/afp/AFPRenderer.java | 26 +- .../fop/render/afp/AFPRendererConfigurator.java | 10 +- .../fop/render/afp/AFPRendererImageInfo.java | 168 +++++ .../org/apache/fop/render/afp/AFPResourceInfo.java | 140 ---- .../apache/fop/render/afp/AFPResourceLevel.java | 201 ------ .../apache/fop/render/afp/AFPResourceManager.java | 189 ----- .../org/apache/fop/render/afp/AFPSVGHandler.java | 24 +- src/java/org/apache/fop/render/afp/AFPState.java | 511 -------------- .../org/apache/fop/render/afp/AFPStreamer.java | 217 ------ .../org/apache/fop/render/afp/AFPTextDataInfo.java | 202 ------ .../org/apache/fop/render/afp/AFPTextHandler.java | 105 --- .../org/apache/fop/render/afp/AFPTextPainter.java | 8 +- .../apache/fop/render/afp/AFPUnitConverter.java | 120 ---- .../apache/fop/render/afp/AbstractAFPPainter.java | 51 -- .../org/apache/fop/render/afp/BorderPaintInfo.java | 120 ---- src/java/org/apache/fop/render/afp/PaintInfo.java | 27 - .../apache/fop/render/afp/RectanglePaintInfo.java | 83 --- src/java/org/apache/fop/render/afp/Streamable.java | 38 -- .../afp/exceptions/FontRuntimeException.java | 46 -- .../render/afp/fonts/AFPBase12FontCollection.java | 157 ----- .../org/apache/fop/render/afp/fonts/AFPFont.java | 112 --- .../fop/render/afp/fonts/AFPFontCollection.java | 92 --- .../apache/fop/render/afp/fonts/AFPFontInfo.java | 62 -- .../apache/fop/render/afp/fonts/AFPFontReader.java | 591 ---------------- .../apache/fop/render/afp/fonts/CharacterSet.java | 318 --------- .../render/afp/fonts/CharacterSetOrientation.java | 275 -------- .../fop/render/afp/fonts/FopCharacterSet.java | 141 ---- .../apache/fop/render/afp/fonts/OutlineFont.java | 181 ----- .../apache/fop/render/afp/fonts/RasterFont.java | 237 ------- .../fop/render/afp/goca/AbstractGraphicsCoord.java | 137 ---- .../apache/fop/render/afp/goca/GraphicsArea.java | 76 --- .../apache/fop/render/afp/goca/GraphicsBox.java | 61 -- .../render/afp/goca/GraphicsChainedSegment.java | 148 ---- .../apache/fop/render/afp/goca/GraphicsData.java | 128 ---- .../apache/fop/render/afp/goca/GraphicsFillet.java | 42 -- .../fop/render/afp/goca/GraphicsFullArc.java | 78 --- .../apache/fop/render/afp/goca/GraphicsImage.java | 117 ---- .../apache/fop/render/afp/goca/GraphicsLine.java | 43 -- .../render/afp/goca/GraphicsSetArcParameters.java | 51 -- .../render/afp/goca/GraphicsSetCharacterSet.java | 53 -- .../afp/goca/GraphicsSetCurrentPosition.java | 41 -- .../fop/render/afp/goca/GraphicsSetLineType.java | 86 --- .../fop/render/afp/goca/GraphicsSetLineWidth.java | 53 -- .../apache/fop/render/afp/goca/GraphicsSetMix.java | 55 -- .../render/afp/goca/GraphicsSetPatternSymbol.java | 105 --- .../render/afp/goca/GraphicsSetProcessColor.java | 89 --- .../apache/fop/render/afp/goca/GraphicsString.java | 115 ---- .../fop/render/afp/ioca/ImageCellPosition.java | 174 ----- .../apache/fop/render/afp/ioca/ImageContent.java | 277 -------- .../fop/render/afp/ioca/ImageInputDescriptor.java | 138 ---- .../fop/render/afp/ioca/ImageOutputControl.java | 200 ------ .../fop/render/afp/ioca/ImageRasterData.java | 77 --- .../fop/render/afp/ioca/ImageRasterPattern.java | 759 --------------------- .../apache/fop/render/afp/ioca/ImageSegment.java | 161 ----- .../fop/render/afp/ioca/ImageSizeParameter.java | 88 --- .../fop/render/afp/modca/AbstractAFPObject.java | 244 ------- .../fop/render/afp/modca/AbstractDataObject.java | 107 --- .../fop/render/afp/modca/AbstractDescriptor.java | 64 -- .../render/afp/modca/AbstractEnvironmentGroup.java | 101 --- .../render/afp/modca/AbstractNamedAFPObject.java | 111 --- .../fop/render/afp/modca/AbstractPageObject.java | 345 ---------- .../afp/modca/AbstractPreparedAFPObject.java | 96 --- .../afp/modca/AbstractPreparedObjectContainer.java | 84 --- .../AbstractResourceEnvironmentGroupContainer.java | 97 --- .../afp/modca/AbstractResourceGroupContainer.java | 166 ----- .../afp/modca/AbstractStructuredAFPObject.java | 324 --------- .../render/afp/modca/ActiveEnvironmentGroup.java | 220 ------ .../render/afp/modca/ContainerDataDescriptor.java | 84 --- .../apache/fop/render/afp/modca/DataStream.java | 636 ----------------- .../org/apache/fop/render/afp/modca/Document.java | 98 --- .../org/apache/fop/render/afp/modca/Factory.java | 606 ---------------- .../render/afp/modca/GraphicsDataDescriptor.java | 152 ----- .../fop/render/afp/modca/GraphicsObject.java | 302 -------- .../apache/fop/render/afp/modca/IMImageObject.java | 141 ---- .../fop/render/afp/modca/ImageDataDescriptor.java | 77 --- .../apache/fop/render/afp/modca/ImageObject.java | 153 ----- .../apache/fop/render/afp/modca/IncludeObject.java | 303 -------- .../fop/render/afp/modca/IncludePageOverlay.java | 129 ---- .../fop/render/afp/modca/IncludePageSegment.java | 91 --- .../fop/render/afp/modca/InterchangeSet.java | 115 ---- .../fop/render/afp/modca/InvokeMediumMap.java | 57 -- .../apache/fop/render/afp/modca/MapCodedFont.java | 275 -------- .../fop/render/afp/modca/MapContainerData.java | 57 -- .../fop/render/afp/modca/MapDataResource.java | 58 -- .../fop/render/afp/modca/MapPageOverlay.java | 141 ---- .../afp/modca/MaximumSizeExceededException.java | 37 - .../apache/fop/render/afp/modca/NoOperation.java | 100 --- .../fop/render/afp/modca/ObjectAreaDescriptor.java | 87 --- .../fop/render/afp/modca/ObjectAreaPosition.java | 111 --- .../fop/render/afp/modca/ObjectContainer.java | 123 ---- .../render/afp/modca/ObjectEnvironmentGroup.java | 173 ----- .../org/apache/fop/render/afp/modca/Overlay.java | 85 --- .../fop/render/afp/modca/PageDescriptor.java | 87 --- .../org/apache/fop/render/afp/modca/PageGroup.java | 103 --- .../apache/fop/render/afp/modca/PageObject.java | 218 ------ .../apache/fop/render/afp/modca/PageSegment.java | 90 --- .../fop/render/afp/modca/PreparedAFPObject.java | 34 - .../afp/modca/PreprocessPresentationObject.java | 145 ---- .../afp/modca/PresentationEnvironmentControl.java | 97 --- .../fop/render/afp/modca/PresentationTextData.java | 569 --------------- .../afp/modca/PresentationTextDescriptor.java | 100 --- .../render/afp/modca/PresentationTextObject.java | 169 ----- .../org/apache/fop/render/afp/modca/Registry.java | 254 ------- .../render/afp/modca/ResourceEnvironmentGroup.java | 134 ---- .../apache/fop/render/afp/modca/ResourceGroup.java | 107 --- .../fop/render/afp/modca/ResourceObject.java | 168 ----- .../render/afp/modca/StreamedResourceGroup.java | 92 --- .../fop/render/afp/modca/TagLogicalElement.java | 130 ---- .../render/afp/modca/TagLogicalElementBean.java | 64 -- .../ExtendedResourceLocalIdentifierTriplet.java | 55 -- .../modca/triplets/FullyQualifiedNameTriplet.java | 191 ------ .../afp/modca/triplets/MappingOptionTriplet.java | 68 -- .../modca/triplets/MeasurementUnitsTriplet.java | 54 -- .../afp/modca/triplets/ObjectAreaSizeTriplet.java | 62 -- .../modca/triplets/ObjectByteExtentTriplet.java | 39 -- .../triplets/ObjectClassificationTriplet.java | 188 ----- .../PresentationSpaceMixingRulesTriplet.java | 62 -- .../PresentationSpaceResetMixingTriplet.java | 48 -- .../modca/triplets/ResourceObjectTypeTriplet.java | 21 - .../fop/render/afp/modca/triplets/Triplet.java | 162 ----- .../apache/fop/render/afp/tools/BinaryUtils.java | 135 ---- .../fop/render/afp/tools/DTDEntityResolver.java | 120 ---- .../apache/fop/render/afp/tools/StringUtils.java | 81 --- .../render/afp/tools/StructuredFieldReader.java | 133 ---- .../org/apache/fop/render/pdf/PDFRenderer.java | 2 +- .../org/apache/fop/render/ps/PSTextPainter.java | 6 +- src/java/org/apache/fop/store/FileStore.java | 166 ----- .../org/apache/fop/store/InputStreamStorer.java | 50 -- src/java/org/apache/fop/store/StoreRecord.java | 90 --- src/java/org/apache/fop/store/Storer.java | 87 --- src/java/org/apache/fop/store/Writable.java | 38 -- src/java/org/apache/fop/store/WritableStorer.java | 47 -- src/java/org/apache/fop/store/WriteSession.java | 109 --- .../org/apache/fop/svg/GraphicsConfiguration.java | 1 - src/java/org/apache/fop/svg/PDFBridgeContext.java | 2 +- .../apache/fop/svg/PDFGraphicsConfiguration.java | 1 + 316 files changed, 21132 insertions(+), 21510 deletions(-) create mode 100644 src/java/org/apache/fop/AbstractState.java create mode 100644 src/java/org/apache/fop/afp/AFPAbstractGraphicsObjectPainter.java create mode 100644 src/java/org/apache/fop/afp/AFPBorderPainter.java create mode 100644 src/java/org/apache/fop/afp/AFPConstants.java create mode 100644 src/java/org/apache/fop/afp/AFPDataObjectFactory.java create mode 100644 src/java/org/apache/fop/afp/AFPDataObjectInfo.java create mode 100644 src/java/org/apache/fop/afp/AFPForeignAttributeReader.java create mode 100644 src/java/org/apache/fop/afp/AFPGraphics2D.java create mode 100644 src/java/org/apache/fop/afp/AFPGraphicsConfiguration.java create mode 100644 src/java/org/apache/fop/afp/AFPGraphicsDevice.java create mode 100644 src/java/org/apache/fop/afp/AFPGraphicsObjectInfo.java create mode 100644 src/java/org/apache/fop/afp/AFPImageObjectInfo.java create mode 100644 src/java/org/apache/fop/afp/AFPLineDataInfo.java create mode 100644 src/java/org/apache/fop/afp/AFPObjectAreaInfo.java create mode 100644 src/java/org/apache/fop/afp/AFPPageFonts.java create mode 100644 src/java/org/apache/fop/afp/AFPRectanglePainter.java create mode 100644 src/java/org/apache/fop/afp/AFPResourceInfo.java create mode 100644 src/java/org/apache/fop/afp/AFPResourceLevel.java create mode 100644 src/java/org/apache/fop/afp/AFPResourceManager.java create mode 100644 src/java/org/apache/fop/afp/AFPState.java create mode 100644 src/java/org/apache/fop/afp/AFPStreamer.java create mode 100644 src/java/org/apache/fop/afp/AFPTextDataInfo.java create mode 100644 src/java/org/apache/fop/afp/AFPTextHandler.java create mode 100644 src/java/org/apache/fop/afp/AFPUnitConverter.java create mode 100644 src/java/org/apache/fop/afp/AbstractAFPPainter.java create mode 100644 src/java/org/apache/fop/afp/BorderPaintInfo.java create mode 100644 src/java/org/apache/fop/afp/Factory.java create mode 100644 src/java/org/apache/fop/afp/PaintInfo.java create mode 100644 src/java/org/apache/fop/afp/RectanglePaintInfo.java create mode 100644 src/java/org/apache/fop/afp/Streamable.java create mode 100644 src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java create mode 100644 src/java/org/apache/fop/afp/fonts/AFPFont.java create mode 100644 src/java/org/apache/fop/afp/fonts/AFPFontAttributes.java create mode 100644 src/java/org/apache/fop/afp/fonts/AFPFontCollection.java create mode 100644 src/java/org/apache/fop/afp/fonts/AFPFontInfo.java create mode 100644 src/java/org/apache/fop/afp/fonts/AFPFontReader.java create mode 100644 src/java/org/apache/fop/afp/fonts/CharacterSet.java create mode 100644 src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java create mode 100644 src/java/org/apache/fop/afp/fonts/FontRuntimeException.java create mode 100644 src/java/org/apache/fop/afp/fonts/FopCharacterSet.java create mode 100644 src/java/org/apache/fop/afp/fonts/OutlineFont.java create mode 100644 src/java/org/apache/fop/afp/fonts/RasterFont.java create mode 100644 src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsArea.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsBox.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsData.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsFillet.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsFullArc.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsImage.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsLine.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsSetArcParameters.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsSetCurrentPosition.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsSetMix.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsString.java create mode 100644 src/java/org/apache/fop/afp/ioca/ImageCellPosition.java create mode 100644 src/java/org/apache/fop/afp/ioca/ImageContent.java create mode 100644 src/java/org/apache/fop/afp/ioca/ImageInputDescriptor.java create mode 100644 src/java/org/apache/fop/afp/ioca/ImageOutputControl.java create mode 100644 src/java/org/apache/fop/afp/ioca/ImageRasterData.java create mode 100644 src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java create mode 100644 src/java/org/apache/fop/afp/ioca/ImageSegment.java create mode 100644 src/java/org/apache/fop/afp/ioca/ImageSizeParameter.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractAFPObject.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractDataObject.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractDescriptor.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractPageObject.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractPreparedAFPObject.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractResourceEnvironmentGroupContainer.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java create mode 100644 src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java create mode 100644 src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java create mode 100644 src/java/org/apache/fop/afp/modca/ContainerDataDescriptor.java create mode 100644 src/java/org/apache/fop/afp/modca/DataStream.java create mode 100644 src/java/org/apache/fop/afp/modca/Document.java create mode 100644 src/java/org/apache/fop/afp/modca/GraphicsDataDescriptor.java create mode 100644 src/java/org/apache/fop/afp/modca/GraphicsObject.java create mode 100644 src/java/org/apache/fop/afp/modca/IMImageObject.java create mode 100644 src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java create mode 100644 src/java/org/apache/fop/afp/modca/ImageObject.java create mode 100644 src/java/org/apache/fop/afp/modca/IncludeObject.java create mode 100644 src/java/org/apache/fop/afp/modca/IncludePageOverlay.java create mode 100644 src/java/org/apache/fop/afp/modca/IncludePageSegment.java create mode 100644 src/java/org/apache/fop/afp/modca/InterchangeSet.java create mode 100644 src/java/org/apache/fop/afp/modca/InvokeMediumMap.java create mode 100644 src/java/org/apache/fop/afp/modca/MapCodedFont.java create mode 100644 src/java/org/apache/fop/afp/modca/MapContainerData.java create mode 100644 src/java/org/apache/fop/afp/modca/MapDataResource.java create mode 100644 src/java/org/apache/fop/afp/modca/MapPageOverlay.java create mode 100644 src/java/org/apache/fop/afp/modca/MaximumSizeExceededException.java create mode 100644 src/java/org/apache/fop/afp/modca/NoOperation.java create mode 100644 src/java/org/apache/fop/afp/modca/ObjectAreaDescriptor.java create mode 100644 src/java/org/apache/fop/afp/modca/ObjectAreaPosition.java create mode 100644 src/java/org/apache/fop/afp/modca/ObjectContainer.java create mode 100644 src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java create mode 100644 src/java/org/apache/fop/afp/modca/Overlay.java create mode 100644 src/java/org/apache/fop/afp/modca/PageDescriptor.java create mode 100644 src/java/org/apache/fop/afp/modca/PageGroup.java create mode 100644 src/java/org/apache/fop/afp/modca/PageObject.java create mode 100644 src/java/org/apache/fop/afp/modca/PageSegment.java create mode 100644 src/java/org/apache/fop/afp/modca/PreparedAFPObject.java create mode 100644 src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java create mode 100644 src/java/org/apache/fop/afp/modca/PresentationEnvironmentControl.java create mode 100644 src/java/org/apache/fop/afp/modca/PresentationTextData.java create mode 100644 src/java/org/apache/fop/afp/modca/PresentationTextDescriptor.java create mode 100644 src/java/org/apache/fop/afp/modca/PresentationTextObject.java create mode 100644 src/java/org/apache/fop/afp/modca/Registry.java create mode 100644 src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java create mode 100644 src/java/org/apache/fop/afp/modca/ResourceGroup.java create mode 100644 src/java/org/apache/fop/afp/modca/ResourceObject.java create mode 100644 src/java/org/apache/fop/afp/modca/StreamedResourceGroup.java create mode 100644 src/java/org/apache/fop/afp/modca/TagLogicalElement.java create mode 100644 src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/FullyQualifiedNameTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/MappingOptionTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/MeasurementUnitsTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/ObjectAreaSizeTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/ObjectByteExtentTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceResetMixingTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java create mode 100644 src/java/org/apache/fop/afp/modca/triplets/Triplet.java create mode 100644 src/java/org/apache/fop/afp/util/BinaryUtils.java create mode 100644 src/java/org/apache/fop/afp/util/DTDEntityResolver.java create mode 100644 src/java/org/apache/fop/afp/util/StringUtils.java create mode 100644 src/java/org/apache/fop/afp/util/StructuredFieldReader.java delete mode 100644 src/java/org/apache/fop/render/AbstractState.java delete mode 100644 src/java/org/apache/fop/render/StateStack.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPAbstractGraphicsObjectPainter.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPBorderPainter.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPConstants.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPDataObjectFactory.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPDataObjectInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPFontAttributes.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPGraphics2D.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPGraphicsObjectInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPImageInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPImageObjectInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPLineDataInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPObjectAreaInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPPageFonts.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPRectanglePainter.java create mode 100644 src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPResourceInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPResourceLevel.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPResourceManager.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPState.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPStreamer.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPTextDataInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPTextHandler.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPUnitConverter.java delete mode 100644 src/java/org/apache/fop/render/afp/AbstractAFPPainter.java delete mode 100644 src/java/org/apache/fop/render/afp/BorderPaintInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/PaintInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/RectanglePaintInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/Streamable.java delete mode 100644 src/java/org/apache/fop/render/afp/exceptions/FontRuntimeException.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/AFPBase12FontCollection.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/AFPFont.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/AFPFontInfo.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/CharacterSet.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/OutlineFont.java delete mode 100644 src/java/org/apache/fop/render/afp/fonts/RasterFont.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/AbstractGraphicsCoord.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsArea.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsBox.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsData.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsFillet.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsFullArc.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsImage.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsLine.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsSetArcParameters.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsSetCharacterSet.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsSetCurrentPosition.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsSetLineType.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsSetLineWidth.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsSetMix.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsSetPatternSymbol.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsSetProcessColor.java delete mode 100644 src/java/org/apache/fop/render/afp/goca/GraphicsString.java delete mode 100644 src/java/org/apache/fop/render/afp/ioca/ImageCellPosition.java delete mode 100644 src/java/org/apache/fop/render/afp/ioca/ImageContent.java delete mode 100644 src/java/org/apache/fop/render/afp/ioca/ImageInputDescriptor.java delete mode 100644 src/java/org/apache/fop/render/afp/ioca/ImageOutputControl.java delete mode 100644 src/java/org/apache/fop/render/afp/ioca/ImageRasterData.java delete mode 100644 src/java/org/apache/fop/render/afp/ioca/ImageRasterPattern.java delete mode 100644 src/java/org/apache/fop/render/afp/ioca/ImageSegment.java delete mode 100644 src/java/org/apache/fop/render/afp/ioca/ImageSizeParameter.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/DataStream.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/Document.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/Factory.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/GraphicsObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/IMImageObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ImageObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/IncludeObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/InterchangeSet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/MapCodedFont.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/MapContainerData.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/MapDataResource.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/NoOperation.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ObjectContainer.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/Overlay.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PageDescriptor.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PageGroup.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PageObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PageSegment.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PreparedAFPObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PresentationEnvironmentControl.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PresentationTextData.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/Registry.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ResourceGroup.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/ResourceObject.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/MappingOptionTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/ObjectByteExtentTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/PresentationSpaceResetMixingTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/ResourceObjectTypeTriplet.java delete mode 100644 src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java delete mode 100644 src/java/org/apache/fop/render/afp/tools/BinaryUtils.java delete mode 100644 src/java/org/apache/fop/render/afp/tools/DTDEntityResolver.java delete mode 100644 src/java/org/apache/fop/render/afp/tools/StringUtils.java delete mode 100644 src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java delete mode 100644 src/java/org/apache/fop/store/FileStore.java delete mode 100644 src/java/org/apache/fop/store/InputStreamStorer.java delete mode 100644 src/java/org/apache/fop/store/StoreRecord.java delete mode 100644 src/java/org/apache/fop/store/Storer.java delete mode 100644 src/java/org/apache/fop/store/Writable.java delete mode 100644 src/java/org/apache/fop/store/WritableStorer.java delete mode 100644 src/java/org/apache/fop/store/WriteSession.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/build.xml b/build.xml index 7ab83df21..1b550b0b7 100644 --- a/build.xml +++ b/build.xml @@ -612,7 +612,7 @@ list of possible build targets. - + diff --git a/src/java/org/apache/fop/AbstractState.java b/src/java/org/apache/fop/AbstractState.java new file mode 100644 index 000000000..851c50e76 --- /dev/null +++ b/src/java/org/apache/fop/AbstractState.java @@ -0,0 +1,465 @@ +/* + * 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; + +import java.awt.Color; +import java.awt.geom.AffineTransform; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.Stack; + + +/** + * A base class which holds information about the current rendering state. + */ +public abstract class AbstractState implements Cloneable, Serializable { + + /** current state data */ + private AbstractData currentData = null; + + /** the state stack */ + private StateStack stateStack = null; + + /** + * Instantiates a new state data object + * + * @return a new state data object + */ + protected abstract AbstractData instantiateData(); + + /** + * Instantiates a new state object + * + * @return a new state object + */ + protected abstract AbstractState instantiateState(); + + /** + * Returns the currently valid state + * + * @return the currently valid state + */ + public AbstractData getData() { + if (currentData == null) { + currentData = instantiateData(); + } + return currentData; + } + + /** + * Set the current color. + * Check if the new color is a change and then set the current color. + * + * @param col the color to set + * @return true if the color has changed + */ + public boolean setColor(Color col) { + if (!col.equals(getData().color)) { + getData().color = col; + return true; + } + return false; + } + + /** + * Get the color. + * + * @return the color + */ + public Color getColor() { + if (getData().color == null) { + getData().color = Color.black; + } + return getData().color; + } + + /** + * Get the background color. + * + * @return the background color + */ + public Color getBackColor() { + if (getData().backColor == null) { + getData().backColor = Color.white; + } + return getData().backColor; + } + + /** + * Set the current background color. + * Check if the new background color is a change and then set the current background color. + * + * @param col the background color to set + * @return true if the color has changed + */ + public boolean setBackColor(Color col) { + if (!col.equals(getData().backColor)) { + getData().backColor = col; + return true; + } + return false; + } + + /** + * Set the current font name + * + * @param internalFontName the internal font name + * @return true if the font name has changed + */ + public boolean setFontName(String internalFontName) { + if (!internalFontName.equals(getData().fontName)) { + getData().fontName = internalFontName; + return true; + } + return false; + } + + /** + * Gets the current font name + * + * @return the current font name + */ + public String getFontName() { + return getData().fontName; + } + + /** + * Gets the current font size + * + * @return the current font size + */ + public int getFontSize() { + return getData().fontSize; + } + + /** + * Set the current font size. + * Check if the font size is a change and then set the current font size. + * + * @param size the font size to set + * @return true if the font size has changed + */ + public boolean setFontSize(int size) { + if (size != getData().fontSize) { + getData().fontSize = size; + return true; + } + return false; + } + + /** + * Set the current line width. + * + * @param width the line width in points + * @return true if the line width has changed + */ + public boolean setLineWidth(float width) { + if (getData().lineWidth != width) { + getData().lineWidth = width; + return true; + } + return false; + } + + /** + * Returns the current line width + * + * @return the current line width + */ + public float getLineWidth() { + return getData().lineWidth; + } + + /** + * Sets the dash array (line type) for the current basic stroke + * + * @param dash the line dash array + * @return true if the dash array has changed + */ + public boolean setDashArray(float[] dash) { + if (!Arrays.equals(dash, getData().dashArray)) { + getData().dashArray = dash; + return true; + } + return false; + } + + /** + * Get the current transform. + * This gets the combination of all transforms in the + * current state. + * + * @return the calculate combined transform for the current state + */ + public AffineTransform getTransform() { + AffineTransform at = new AffineTransform(); + for (Iterator iter = getStateStack().iterator(); iter.hasNext();) { + AbstractData data = (AbstractData)iter.next(); + AffineTransform stackTrans = data.getTransform(); + at.concatenate(stackTrans); + } + AffineTransform currentTrans = getData().getTransform(); + at.concatenate(currentTrans); + return at; + } + + /** + * Check the current transform. + * The transform for the current state is the combination of all + * transforms in the current state. The parameter is compared + * against this current transform. + * + * @param tf the transform the check against + * @return true if the new transform is different then the current transform + */ + public boolean checkTransform(AffineTransform tf) { + return !tf.equals(getData().getTransform()); + } + + /** + * Get a copy of the base transform for the page. Used to translate + * IPP/BPP values into X,Y positions when positioning is "fixed". + * + * @return the base transform, or null if the state stack is empty + */ + public AffineTransform getBaseTransform() { + if (getStateStack().isEmpty()) { + return null; + } else { + AbstractData baseData = (AbstractData)getStateStack().get(0); + return (AffineTransform) baseData.getTransform().clone(); + } + } + + /** + * Concatenates the given AffineTransform to the current one. + * + * @param at the transform to concatenate to the current level transform + */ + public void concatenate(AffineTransform at) { + getData().concatenate(at); + } + + /** + * Resets the current AffineTransform. + */ + public void resetTransform() { + getData().resetTransform(); + } + + /** + * Push the current state onto the stack. + * This call should be used when the Q operator is used + * so that the state is known when popped. + */ + public void push() { + AbstractData copy = (AbstractData)getData().clone(); + getStateStack().push(copy); + } + + /** + * Pop the state from the stack and set current values to popped state. + * This should be called when a Q operator is used so + * the state is restored to the correct values. + * + * @return the restored state, null if the stack is empty + */ + public AbstractData pop() { + if (!getStateStack().isEmpty()) { + this.currentData = (AbstractData)getStateStack().pop(); + return this.currentData; + } else { + return null; + } + } + + /** + * Clears the state stack + */ + public void clear() { + getStateStack().clear(); + currentData = null; + } + + /** + * Return the state stack + * + * @return the state stack + */ + protected Stack/**/ getStateStack() { + if (stateStack == null) { + stateStack = new StateStack(); + } + return stateStack; + } + + /** {@inheritDoc} */ + public Object clone() { + AbstractState state = instantiateState(); + state.stateStack = new StateStack(this.stateStack); + state.currentData = (AbstractData)this.currentData.clone(); + return state; + } + + /** {@inheritDoc} */ + public String toString() { + return ", stateStack=" + stateStack + + ", currentData=" + currentData; + } + + /** + * A base state data holding object + */ + public abstract class AbstractData implements Cloneable, Serializable { + + private static final long serialVersionUID = 5208418041189828624L; + + /** The current color */ + private Color color = null; + + /** The current background color */ + private Color backColor = null; + + /** The current font name */ + private String fontName = null; + + /** The current font size */ + private int fontSize = 0; + + /** The current line width */ + private float lineWidth = 0; + + /** The dash array for the current basic stroke (line type) */ + private float[] dashArray = null; + + /** The current transform */ + private AffineTransform transform = null; + + /** + * Concatenate the given AffineTransform with the current thus creating + * a new viewport. Note that all concatenation operations are logged + * so they can be replayed if necessary (ex. for block-containers with + * "fixed" positioning. + * + * @param at Transformation to perform + */ + public void concatenate(AffineTransform at) { + getTransform().concatenate(at); + } + + /** + * Get the current AffineTransform. + * + * @return the current transform + */ + public AffineTransform getTransform() { + if (transform == null) { + transform = new AffineTransform(); + } + return transform; + } + + /** + * Resets the current AffineTransform. + */ + public void resetTransform() { + transform = getBaseTransform(); +// transform = new AffineTransform(); + } + + /** + * Returns the derived rotation from the current transform + * + * @return the derived rotation from the current transform + */ + public int getDerivedRotation() { + AffineTransform at = getTransform(); + double sx = at.getScaleX(); + double sy = at.getScaleY(); + double shx = at.getShearX(); + double shy = at.getShearY(); + int rotation = 0; + if (sx == 0 && sy == 0 && shx > 0 && shy < 0) { + rotation = 270; + } else if (sx < 0 && sy < 0 && shx == 0 && shy == 0) { + rotation = 180; + } else if (sx == 0 && sy == 0 && shx < 0 && shy > 0) { + rotation = 90; + } else { + rotation = 0; + } + return rotation; + } + + /** {@inheritDoc} */ + public Object clone() { + AbstractData data = instantiateData(); + data.color = this.color; + data.backColor = this.backColor; + data.fontName = this.fontName; + data.fontSize = this.fontSize; + data.lineWidth = this.lineWidth; + data.dashArray = this.dashArray; + data.transform = new AffineTransform(this.transform); + return data; + } + + /** {@inheritDoc} */ + public String toString() { + return "color=" + color + + ", backColor=" + backColor + + ", fontName=" + fontName + + ", fontSize=" + fontSize + + ", lineWidth=" + lineWidth + + ", dashArray=" + dashArray + + ", transform=" + transform; + } + } + + /** + * No copy constructor for java.util.Stack so extended and implemented one. + */ + private class StateStack extends java.util.Stack { + + private static final long serialVersionUID = 4897178211223823041L; + + /** + * Default constructor + */ + public StateStack() { + super(); + } + + /** + * Copy constructor + * + * @param c initial contents of stack + */ + public StateStack(Collection c) { + elementCount = c.size(); + // 10% for growth + elementData = new Object[ + (int)Math.min((elementCount * 110L) / 100, Integer.MAX_VALUE)]; + c.toArray(elementData); + } + } +} diff --git a/src/java/org/apache/fop/afp/AFPAbstractGraphicsObjectPainter.java b/src/java/org/apache/fop/afp/AFPAbstractGraphicsObjectPainter.java new file mode 100644 index 000000000..8c5e84012 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPAbstractGraphicsObjectPainter.java @@ -0,0 +1,62 @@ +/* + * 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.afp; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.modca.GraphicsObject; +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; + +/** + * A simple AFP Graphics 2D painter + */ +public abstract class AFPAbstractGraphicsObjectPainter implements Graphics2DImagePainter { + /** Static logging instance */ + protected static Log log = LogFactory.getLog(AFPAbstractGraphicsObjectPainter.class); + + private final AFPGraphics2D graphics2D; + + /** + * Default constructor + */ + public AFPAbstractGraphicsObjectPainter() { + final boolean textAsShapes = false; + this.graphics2D = new AFPGraphics2D(textAsShapes); + } + + /** + * Constructor + * + * @param graphics the afp graphics 2d implementation + */ + public AFPAbstractGraphicsObjectPainter(AFPGraphics2D graphics) { + this.graphics2D = graphics; + } + + /** + * Sets the GOCA Graphics Object + * + * @param graphicsObject the GOCA Graphics Object + */ + public void setGraphicsObject(GraphicsObject graphicsObject) { + this.graphics2D.setGraphicsObject(graphicsObject); + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPBorderPainter.java b/src/java/org/apache/fop/afp/AFPBorderPainter.java new file mode 100644 index 000000000..96f9ae78f --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPBorderPainter.java @@ -0,0 +1,195 @@ +/* + * 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.afp; + +import java.awt.geom.AffineTransform; + +import org.apache.fop.afp.modca.DataStream; +import org.apache.fop.fo.Constants; +import org.apache.fop.util.ColorUtil; + +/** + * Handles the drawing of borders/lines in AFP + */ +public class AFPBorderPainter extends AbstractAFPPainter { + + /** + * Main constructor + * + * @param state the unit converter + * @param dataStream the afp datastream + */ + public AFPBorderPainter(AFPState state, DataStream dataStream) { + super(state, dataStream); + } + + /** {@inheritDoc} */ + public void paint(PaintInfo paintInfo) { + BorderPaintInfo borderPaintInfo = (BorderPaintInfo)paintInfo; + float w = borderPaintInfo.getX2() - borderPaintInfo.getX1(); + float h = borderPaintInfo.getY2() - borderPaintInfo.getY1(); + if ((w < 0) || (h < 0)) { + log.error("Negative extent received. Border won't be painted."); + return; + } + + int pageWidth = dataStream.getCurrentPage().getWidth(); + int pageHeight = dataStream.getCurrentPage().getHeight(); + AFPUnitConverter unitConv = state.getUnitConverter(); + AffineTransform at = state.getData().getTransform(); + + float x1 = unitConv.pt2units(borderPaintInfo.getX1()); + float y1 = unitConv.pt2units(borderPaintInfo.getY1()); + float x2 = unitConv.pt2units(borderPaintInfo.getX2()); + float y2 = unitConv.pt2units(borderPaintInfo.getY2()); + + switch (state.getRotation()) { + case 0: + x1 += at.getTranslateX(); + y1 += at.getTranslateY(); + x2 += at.getTranslateX(); + y2 += at.getTranslateY(); + break; + case 90: + x1 += at.getTranslateY(); + y1 += (float) (pageWidth - at.getTranslateX()); + x2 += at.getTranslateY(); + y2 += (float) (pageWidth - at.getTranslateX()); + break; + case 180: + x1 += (float) (pageWidth - at.getTranslateX()); + y1 += (float) (pageHeight - at.getTranslateY()); + x2 += (float) (pageWidth - at.getTranslateX()); + y2 += (float) (pageHeight - at.getTranslateY()); + break; + case 270: + x1 = (float) (pageHeight - at.getTranslateY()); + y1 += (float) at.getTranslateX(); + x2 += x1; + y2 += (float) at.getTranslateX(); + break; + } + + AFPLineDataInfo lineDataInfo = new AFPLineDataInfo(); + lineDataInfo.setColor(borderPaintInfo.getColor()); + lineDataInfo.setRotation(state.getRotation()); + lineDataInfo.x1 = Math.round(x1); + lineDataInfo.y1 = Math.round(y1); + if (borderPaintInfo.isHorizontal()) { + lineDataInfo.setThickness(Math.round(y2 - y1)); + } else { + lineDataInfo.setThickness(Math.round(x2 - x1)); + } + + // handle border-*-style + switch (borderPaintInfo.getStyle()) { + case Constants.EN_DOUBLE: + if (borderPaintInfo.isHorizontal()) { + lineDataInfo.x2 = Math.round(x2); + lineDataInfo.y2 = lineDataInfo.y1; + dataStream.createLine(lineDataInfo); + lineDataInfo.y1 += Math.round((lineDataInfo.thickness / 3) * 2); + dataStream.createLine(lineDataInfo); + } else { + lineDataInfo.x2 = lineDataInfo.x1; + lineDataInfo.y2 = Math.round(y2); + dataStream.createLine(lineDataInfo); + lineDataInfo.x1 += Math.round((lineDataInfo.thickness / 3) * 2); + dataStream.createLine(lineDataInfo); + } + break; + case Constants.EN_DASHED: + int thick = lineDataInfo.thickness * 3; + if (borderPaintInfo.isHorizontal()) { + lineDataInfo.x2 = lineDataInfo.x1 + thick; + lineDataInfo.y2 = lineDataInfo.y1; + int ex2 = Math.round(x2); + while (lineDataInfo.x1 + thick < ex2) { + dataStream.createLine(lineDataInfo); + lineDataInfo.x1 += 2 * thick; + lineDataInfo.x2 = lineDataInfo.x1 + thick; + } + } else { + lineDataInfo.x2 = lineDataInfo.x1; + lineDataInfo.y2 = lineDataInfo.y1 + thick; + int ey2 = Math.round(y2); + while (lineDataInfo.y1 + thick < ey2) { + dataStream.createLine(lineDataInfo); + lineDataInfo.y1 += 2 * thick; + lineDataInfo.y2 = lineDataInfo.y1 + thick; + } + } + break; + case Constants.EN_DOTTED: + if (borderPaintInfo.isHorizontal()) { + lineDataInfo.x2 = lineDataInfo.x1 + lineDataInfo.thickness; + lineDataInfo.y2 = lineDataInfo.y1; + int ex2 = Math.round(x2); + while (lineDataInfo.x1 + lineDataInfo.thickness < ex2) { + dataStream.createLine(lineDataInfo); + lineDataInfo.x1 += 3 * lineDataInfo.thickness; + lineDataInfo.x2 = lineDataInfo.x1 + lineDataInfo.thickness; + } + } else { + lineDataInfo.x2 = lineDataInfo.x1; + lineDataInfo.y2 = lineDataInfo.y1 + lineDataInfo.thickness; + int ey2 = Math.round(y2); + while (lineDataInfo.y1 + lineDataInfo.thickness < ey2) { + dataStream.createLine(lineDataInfo); + lineDataInfo.y1 += 3 * lineDataInfo.thickness; + lineDataInfo.y2 = lineDataInfo.y1 + lineDataInfo.thickness; + } + } + break; + case Constants.EN_GROOVE: + case Constants.EN_RIDGE: + //TODO + lineDataInfo.x2 = Math.round(x2); + float colFactor = (borderPaintInfo.getStyle() == Constants.EN_GROOVE ? 0.4f : -0.4f); + float h3 = (y2 - y1) / 3; + lineDataInfo.color = ColorUtil.lightenColor(borderPaintInfo.getColor(), -colFactor); + lineDataInfo.thickness = Math.round(h3); + lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1); + dataStream.createLine(lineDataInfo); + lineDataInfo.color = borderPaintInfo.getColor(); + lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1 + h3); + dataStream.createLine(lineDataInfo); + lineDataInfo.color = ColorUtil.lightenColor(borderPaintInfo.getColor(), colFactor); + lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1 + h3 + h3); + dataStream.createLine(lineDataInfo); + break; + case Constants.EN_HIDDEN: + break; + case Constants.EN_INSET: + case Constants.EN_OUTSET: + case Constants.EN_SOLID: + default: + if (borderPaintInfo.isHorizontal()) { + lineDataInfo.x2 = Math.round(x2); + lineDataInfo.y2 = lineDataInfo.y1; + } else { + lineDataInfo.x2 = lineDataInfo.x1; + lineDataInfo.y2 = Math.round(y2); + } + dataStream.createLine(lineDataInfo); + } + } + +} diff --git a/src/java/org/apache/fop/afp/AFPConstants.java b/src/java/org/apache/fop/afp/AFPConstants.java new file mode 100644 index 000000000..3462ddfe6 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPConstants.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.afp; + +/** + * Constants used by the AFP renderer. + * + */ +public interface AFPConstants { + + /** + * The encoding to use to convert to EBCIDIC + */ + String EBCIDIC_ENCODING = "Cp1146"; + + /** + * The encoding to use to convert to ASCII + */ + String ASCII_ENCODING = "Cp1252"; + + /** + * The encoding to use to convert to US ASCII (7 bit) + */ + String US_ASCII_ENCODING = "US-ASCII"; + + /** + * The scaling of the default transform is set to + * approximately 72 user space coordinates per square inch + */ + int DPI_72 = 72; + + /** + * 72dpi in millipoints + */ + int DPI_72_MPTS = DPI_72 * 1000; +} diff --git a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java new file mode 100644 index 000000000..d2e5a7a62 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java @@ -0,0 +1,255 @@ +/* + * 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.afp; + +import java.awt.geom.Rectangle2D; + +import org.apache.fop.afp.ioca.ImageContent; +import org.apache.fop.afp.modca.AbstractDataObject; +import org.apache.fop.afp.modca.AbstractNamedAFPObject; +import org.apache.fop.afp.modca.Document; +import org.apache.fop.afp.modca.GraphicsObject; +import org.apache.fop.afp.modca.ImageObject; +import org.apache.fop.afp.modca.IncludeObject; +import org.apache.fop.afp.modca.ObjectContainer; +import org.apache.fop.afp.modca.Overlay; +import org.apache.fop.afp.modca.PageSegment; +import org.apache.fop.afp.modca.Registry; +import org.apache.fop.afp.modca.ResourceObject; +import org.apache.fop.afp.modca.triplets.MappingOptionTriplet; +import org.apache.fop.afp.modca.triplets.ObjectClassificationTriplet; +import org.apache.xmlgraphics.image.codec.tiff.TIFFImage; +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; + +/** + * Factory for high level data objects (Image/Graphics etc) + */ +public class AFPDataObjectFactory { + + private final Factory factory; + + /** + * Main constructor + * + * @param factory an object factory + */ + public AFPDataObjectFactory(Factory factory) { + this.factory = factory; + } + + /** + * Creates and configures an ObjectContainer. + * + * @param dataObjectInfo the object container info + * @return a newly created Object Container + */ + public ObjectContainer createObjectContainer(AFPDataObjectInfo dataObjectInfo) { + ObjectContainer objectContainer = factory.createObjectContainer(); + + // set object classification + Registry.ObjectType objectType = dataObjectInfo.getObjectType(); + AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + AFPResourceLevel resourceLevel = resourceInfo.getLevel(); + final boolean dataInContainer = true; + final boolean containerHasOEG = resourceLevel.isInline(); + final boolean dataInOCD = true; + objectContainer.setObjectClassification( + ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, + objectType, dataInContainer, containerHasOEG, dataInOCD); + + objectContainer.setInputStream(dataObjectInfo.getInputStream()); + return objectContainer; + } + + /** + * Creates and configures an IOCA Image Object. + * + * @param imageObjectInfo the image object info + * @return a newly created IOCA Image Object + */ + public ImageObject createImage(AFPImageObjectInfo imageObjectInfo) { + // IOCA bitmap image + ImageObject imageObj = factory.createImageObject(); + if (imageObjectInfo.hasCompression()) { + int compression = imageObjectInfo.getCompression(); + switch (compression) { + case TIFFImage.COMP_FAX_G3_1D: + imageObj.setEncoding(ImageContent.COMPID_G3_MH); + break; + case TIFFImage.COMP_FAX_G3_2D: + imageObj.setEncoding(ImageContent.COMPID_G3_MR); + break; + case TIFFImage.COMP_FAX_G4_2D: + imageObj.setEncoding(ImageContent.COMPID_G3_MMR); + break; + default: + throw new IllegalStateException( + "Invalid compression scheme: " + compression); + } + } + + if (imageObjectInfo.isColor()) { + imageObj.setIDESize((byte) 24); + } else { + imageObj.setIDESize((byte) imageObjectInfo.getBitsPerPixel()); + } + imageObj.setData(imageObjectInfo.getData()); + + return imageObj; + } + + /** + * Creates and returns a new graphics object. + * + * @param graphicsObjectInfo the graphics object info + * @return a new graphics object + */ + public GraphicsObject createGraphic(AFPGraphicsObjectInfo graphicsObjectInfo) { + // set newly created graphics object in g2d + GraphicsObject graphicsObj = factory.createGraphicsObject(); + AFPGraphics2D g2d = graphicsObjectInfo.getGraphics2D(); + g2d.setGraphicsObject(graphicsObj); + + // paint to graphics object + Graphics2DImagePainter painter = graphicsObjectInfo.getPainter(); + Rectangle2D area = graphicsObjectInfo.getArea(); + painter.paint(g2d, area); + + // return painted graphics object + return graphicsObj; + } + + /** + * Creates and returns a new include object. + * + * @param includeName the include name + * @param dataObjectInfo a data object info + * + * @return a new include object + */ + public IncludeObject createInclude(String includeName, AFPDataObjectInfo dataObjectInfo) { + IncludeObject includeObj = factory.createInclude(includeName); + + if (dataObjectInfo instanceof AFPImageObjectInfo) { + // IOCA image object + includeObj.setObjectType(IncludeObject.TYPE_IMAGE); + } else if (dataObjectInfo instanceof AFPGraphicsObjectInfo) { + // graphics object + includeObj.setObjectType(IncludeObject.TYPE_GRAPHIC); + } else { + // object container + includeObj.setObjectType(IncludeObject.TYPE_OTHER); + + // set mandatory object classification (type other) + Registry.ObjectType objectType = dataObjectInfo.getObjectType(); + if (objectType != null) { + // set object classification + final boolean dataInContainer = true; + final boolean containerHasOEG = false; // environment parameters set in include + final boolean dataInOCD = true; + includeObj.setObjectClassification( + // object scope not defined + ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT, + objectType, dataInContainer, containerHasOEG, dataInOCD); + } else { + throw new IllegalStateException( + "Failed to set Object Classification Triplet on Object Container."); + } + } + + AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + + int xOffset = objectAreaInfo.getX(); + int yOffset = objectAreaInfo.getY(); + includeObj.setObjectAreaOffset(xOffset, yOffset); + + int width = objectAreaInfo.getWidth(); + int height = objectAreaInfo.getHeight(); + includeObj.setObjectAreaSize(width, height); + + int rotation = objectAreaInfo.getRotation(); + includeObj.setObjectAreaOrientation(rotation); + + int widthRes = objectAreaInfo.getWidthRes(); + int heightRes = objectAreaInfo.getHeightRes(); + includeObj.setMeasurementUnits(widthRes, heightRes); + + includeObj.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT); + + return includeObj; + } + + /** + * Creates a resource object wrapper for named includable data objects + * + * @param namedObj an named object + * @param resourceInfo resource information + * @param objectType the object type + * @return a new resource object wrapper + */ + public ResourceObject createResource(AbstractNamedAFPObject namedObj, + AFPResourceInfo resourceInfo, Registry.ObjectType objectType) { + ResourceObject resourceObj = null; + String resourceName = resourceInfo.getName(); + if (resourceName != null) { + resourceObj = factory.createResource(resourceName); + } else { + resourceObj = factory.createResource(); + } + + if (namedObj instanceof Document) { + resourceObj.setType(ResourceObject.TYPE_DOCUMENT); + } else if (namedObj instanceof PageSegment) { + resourceObj.setType(ResourceObject.TYPE_PAGE_SEGMENT); + } else if (namedObj instanceof Overlay) { + resourceObj.setType(ResourceObject.TYPE_OVERLAY_OBJECT); + } else if (namedObj instanceof AbstractDataObject) { + AbstractDataObject dataObj = (AbstractDataObject)namedObj; + if (namedObj instanceof ObjectContainer) { + resourceObj.setType(ResourceObject.TYPE_OBJECT_CONTAINER); + + // set object classification + final boolean dataInContainer = true; + final boolean containerHasOEG = false; // must be included + final boolean dataInOCD = true; + // mandatory triplet for object container + resourceObj.setObjectClassification( + ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, + objectType, dataInContainer, containerHasOEG, dataInOCD); + } else if (namedObj instanceof ImageObject) { + // ioca image type + resourceObj.setType(ResourceObject.TYPE_IMAGE); + } else if (namedObj instanceof GraphicsObject) { + resourceObj.setType(ResourceObject.TYPE_GRAPHIC); + } else { + throw new UnsupportedOperationException( + "Unsupported resource object for data object type " + dataObj); + } + } else { + throw new UnsupportedOperationException( + "Unsupported resource object type " + namedObj); + } + + // set the resource information/classification on the data object + resourceObj.setDataObject(namedObj); + return resourceObj; + } + +} diff --git a/src/java/org/apache/fop/afp/AFPDataObjectInfo.java b/src/java/org/apache/fop/afp/AFPDataObjectInfo.java new file mode 100644 index 000000000..c618a53fc --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPDataObjectInfo.java @@ -0,0 +1,206 @@ +/* + * 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.afp; + +import java.io.InputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.modca.Registry; + +/** + * A list of parameters associated with an AFP data objects + */ +public class AFPDataObjectInfo { + private static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); + + /** the object area info */ + private AFPObjectAreaInfo objectAreaInfo; + + /** resource info */ + private AFPResourceInfo resourceInfo; + + /** the data object width */ + private int dataWidth; + + /** the data object height */ + private int dataHeight; + + /** the object data in an inputstream */ + private InputStream inputStream; + + /** the object registry mimetype */ + private String mimeType; + + /** + * Default constructor + */ + public AFPDataObjectInfo() { + } + + /** + * Sets the image mime type + * + * @param mimeType the image mime type + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + /** + * Returns the mime type of this data object + * + * @return the mime type of this data object + */ + public String getMimeType() { + return mimeType; + } + + /** + * Convenience method to return the object type + * + * @return the object type + */ + public Registry.ObjectType getObjectType() { + return Registry.getInstance().getObjectType(getMimeType()); + } + + /** + * Returns the resource level at which this data object should reside + * + * @return the resource level at which this data object should reside + */ + public AFPResourceInfo getResourceInfo() { + if (resourceInfo == null) { + this.resourceInfo = new AFPResourceInfo(); + } + return resourceInfo; + } + + /** + * Sets the resource level at which this object should reside + * + * @param resourceInfo the resource level at which this data object should reside + */ + public void setResourceInfo(AFPResourceInfo resourceInfo) { + this.resourceInfo = resourceInfo; + } + + /** + * Sets the object area info + * + * @param objectAreaInfo the object area info + */ + public void setObjectAreaInfo(AFPObjectAreaInfo objectAreaInfo) { + this.objectAreaInfo = objectAreaInfo; + } + + /** + * Returns the object area info + * + * @return the object area info + */ + public AFPObjectAreaInfo getObjectAreaInfo() { + return this.objectAreaInfo; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPDataObjectInfo{" + + "mimeType=" + mimeType + + ", dataWidth=" + dataWidth + + ", dataHeight=" + dataHeight + + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "") + + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : ""); + } + + /** + * Returns the uri of this data object + * + * @return the uri of this data object + */ + public String getUri() { + return getResourceInfo().getUri(); + } + + /** + * Sets the data object uri + * + * @param uri the data object uri + */ + public void setUri(String uri) { + getResourceInfo().setUri(uri); + } + + /** + * Returns the image data width + * + * @return the image data width + */ + public int getDataWidth() { + return dataWidth; + } + + /** + * Sets the image data width + * + * @param imageDataWidth the image data width + */ + public void setDataWidth(int imageDataWidth) { + this.dataWidth = imageDataWidth; + } + + /** + * Returns the image data height + * + * @return the image data height + */ + public int getDataHeight() { + return dataHeight; + } + + /** + * Sets the image data height + * + * @param imageDataHeight the image data height + */ + public void setDataHeight(int imageDataHeight) { + this.dataHeight = imageDataHeight; + } + + /** + * Sets the object data inputstream + * + * @param inputStream the object data inputstream + */ + public void setInputStream(InputStream inputStream) { + this.inputStream = inputStream; + } + + /** + * Returns the object data inputstream + * + * @return the object data inputstream + */ + public InputStream getInputStream() { + return this.inputStream; + } + +} diff --git a/src/java/org/apache/fop/afp/AFPForeignAttributeReader.java b/src/java/org/apache/fop/afp/AFPForeignAttributeReader.java new file mode 100644 index 000000000..710c24533 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPForeignAttributeReader.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.afp; + +import java.io.File; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.render.afp.extensions.AFPElementMapping; +import org.apache.xmlgraphics.util.QName; + +/** + * Parses any AFP foreign attributes + */ +public class AFPForeignAttributeReader { + private static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); + + /** the resource-name attribute */ + public static final String RESOURCE_NAME = "afp:resource-name"; + + /** the resource-level attribute */ + public static final String RESOURCE_LEVEL = "afp:resource-level"; + + /** the resource-group-file attribute */ + public static final String RESOURCE_GROUP_FILE = "afp:resource-group-file"; + + /** + * Main constructor + */ + public AFPForeignAttributeReader() { + } + + /** + * Returns the resource information + * + * @param foreignAttributes the foreign attributes + * @return the resource information + */ + public AFPResourceInfo getResourceInfo(Map/**/ foreignAttributes) { + AFPResourceInfo resourceInfo = new AFPResourceInfo(); + if (foreignAttributes != null && !foreignAttributes.isEmpty()) { + QName resourceNameKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_NAME); + String resourceName = (String)foreignAttributes.get(resourceNameKey); + if (resourceName != null) { + resourceInfo.setName(resourceName); + } + AFPResourceLevel level = getResourceLevel(foreignAttributes); + if (level != null) { + resourceInfo.setLevel(level); + } + } + return resourceInfo; + } + + /** + * Returns the resource level + * + * @param foreignAttributes the foreign attributes + * @return the resource level + */ + public AFPResourceLevel getResourceLevel(Map/**/ foreignAttributes) { + AFPResourceLevel resourceLevel = null; + if (foreignAttributes != null && !foreignAttributes.isEmpty()) { + QName resourceLevelKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_LEVEL); + if (foreignAttributes.containsKey(resourceLevelKey)) { + String levelString = (String)foreignAttributes.get(resourceLevelKey); + resourceLevel = AFPResourceLevel.valueOf(levelString); + // if external get resource group file attributes + if (resourceLevel != null && resourceLevel.isExternal()) { + QName resourceGroupFileKey = new QName(AFPElementMapping.NAMESPACE, + RESOURCE_GROUP_FILE); + String resourceGroupFile + = (String)foreignAttributes.get(resourceGroupFileKey); + if (resourceGroupFile == null) { + String msg = RESOURCE_GROUP_FILE + " not specified"; + log.error(msg); + throw new UnsupportedOperationException(msg); + } + File resourceExternalGroupFile = new File(resourceGroupFile); + SecurityManager security = System.getSecurityManager(); + try { + if (security != null) { + security.checkWrite(resourceExternalGroupFile.getPath()); + } + } catch (SecurityException ex) { + String msg = "unable to gain write access to external resource file: " + + resourceGroupFile; + log.error(msg); + } + + try { + boolean exists = resourceExternalGroupFile.exists(); + if (exists) { + log.warn("overwriting external resource file: " + + resourceGroupFile); + } + resourceLevel.setExternalFilePath(resourceGroupFile); + } catch (SecurityException ex) { + String msg = "unable to gain read access to external resource file: " + + resourceGroupFile; + log.error(msg); + } + } + } + } + return resourceLevel; + } +} diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java new file mode 100644 index 000000000..21114bb88 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java @@ -0,0 +1,612 @@ +/* + * 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.afp; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.AffineTransform; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +import java.awt.geom.PathIterator; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.awt.image.ImageObserver; +import java.awt.image.RenderedImage; +import java.awt.image.renderable.RenderableImage; +import java.io.IOException; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.goca.GraphicsSetLineType; +import org.apache.fop.afp.modca.GraphicsObject; +import org.apache.fop.fonts.FontInfo; +import org.apache.xmlgraphics.image.loader.ImageInfo; +import org.apache.xmlgraphics.image.loader.ImageSize; +import org.apache.xmlgraphics.image.loader.impl.ImageRendered; +import org.apache.xmlgraphics.java2d.AbstractGraphics2D; +import org.apache.xmlgraphics.java2d.GraphicContext; +import org.apache.xmlgraphics.java2d.StrokingTextHandler; +import org.apache.xmlgraphics.java2d.TextHandler; +import org.apache.xmlgraphics.ps.ImageEncodingHelper; +import org.apache.xmlgraphics.util.MimeConstants; + +/** + * This is a concrete implementation of AbstractGraphics2D (and + * therefore of Graphics2D) which is able to generate GOCA byte + * codes. + * + * @see org.apache.xmlgraphics.java2d.AbstractGraphics2D + */ +public class AFPGraphics2D extends AbstractGraphics2D { + + private static final Log log = LogFactory.getLog(AFPGraphics2D.class); + + private static final int X = 0; + + private static final int Y = 1; + + private static final int X1 = 0; + + private static final int Y1 = 1; + + private static final int X2 = 2; + + private static final int Y2 = 3; + + + /** graphics object */ + private GraphicsObject graphicsObj = null; + + /** Fallback text handler */ + protected TextHandler fallbackTextHandler = new StrokingTextHandler(this); + + /** Custom text handler */ + protected TextHandler customTextHandler = null; + + /** AFP resource manager */ + private AFPResourceManager resourceManager = null; + + /** AFP resource info */ + private AFPResourceInfo resourceInfo = null; + + /** Current AFP state */ + private AFPState state = null; + + /** The AFP FontInfo */ + private FontInfo fontInfo; + + /** + * Main constructor + * + * @param textAsShapes + * if true, all text is turned into shapes in the convertion. No + * text is output. + * + */ + public AFPGraphics2D(boolean textAsShapes) { + super(textAsShapes); + } + + /** + * Copy Constructor + * + * @param g2d + * a AFPGraphics2D whose properties should be copied + */ + public AFPGraphics2D(AFPGraphics2D g2d) { + super(g2d); + this.graphicsObj = g2d.graphicsObj; + this.fallbackTextHandler = g2d.fallbackTextHandler; + this.customTextHandler = g2d.customTextHandler; + this.resourceManager = g2d.resourceManager; + this.resourceInfo = g2d.resourceInfo; + this.state = g2d.state; + } + + /** + * Sets the AFP resource manager + * + * @param resourceManager the AFP resource manager + */ + public void setResourceManager(AFPResourceManager resourceManager) { + this.resourceManager = resourceManager; + } + + /** + * Sets the AFP resource info + * + * @param resourceInfo the AFP resource info + */ + public void setResourceInfo(AFPResourceInfo resourceInfo) { + this.resourceInfo = resourceInfo; + } + + /** + * Sets the GraphicContext + * + * @param gc + * GraphicContext to use + */ + public void setGraphicContext(GraphicContext gc) { + this.gc = gc; + } + + /** + * Apply the stroke to the AFP graphics object. + * This takes the java stroke and outputs the appropriate settings + * to the AFP graphics object so that the stroke attributes are handled. + * + * @param stroke the java stroke + */ + protected void applyStroke(Stroke stroke) { + if (stroke instanceof BasicStroke) { + BasicStroke basicStroke = (BasicStroke) stroke; + float lineWidth = basicStroke.getLineWidth(); + if (state.setLineWidth(lineWidth)) { + getGraphicsObject().setLineWidth(Math.round(lineWidth * 2)); + } + // note: this is an approximation at best! + float[] dashArray = basicStroke.getDashArray(); + if (state.setDashArray(dashArray)) { + byte type = GraphicsSetLineType.DEFAULT; // normally SOLID + if (dashArray != null) { + type = GraphicsSetLineType.DOTTED; // default to plain DOTTED if dashed line + // float offset = basicStroke.getDashPhase(); + if (dashArray.length == 2) { + if (dashArray[0] < dashArray[1]) { + type = GraphicsSetLineType.SHORT_DASHED; + } else if (dashArray[0] > dashArray[1]) { + type = GraphicsSetLineType.LONG_DASHED; + } + } else if (dashArray.length == 4) { + if (dashArray[0] > dashArray[1] + && dashArray[2] < dashArray[3]) { + type = GraphicsSetLineType.DASH_DOT; + } else if (dashArray[0] < dashArray[1] + && dashArray[2] < dashArray[3]) { + type = GraphicsSetLineType.DOUBLE_DOTTED; + } + } else if (dashArray.length == 6) { + if (dashArray[0] > dashArray[1] + && dashArray[2] < dashArray[3] + && dashArray[4] < dashArray[5]) { + type = GraphicsSetLineType.DASH_DOUBLE_DOTTED; + } + } + } + getGraphicsObject().setLineType(type); + } + } else { + log.warn("Unsupported Stroke: " + stroke.getClass().getName()); + } + } + + /** + * Handle the Batik drawing event + * + * @param shape + * the shape to draw + * @param fill + * true if the shape is to be drawn filled + */ + private void doDrawing(Shape shape, boolean fill) { + getGraphicsObject(); + if (!fill) { + graphicsObj.newSegment(); + } + + Color color = getColor(); + if (state.setColor(color)) { + graphicsObj.setColor(color); + } + + Stroke stroke = getStroke(); + applyStroke(stroke); + + if (fill) { + graphicsObj.beginArea(); + } + AffineTransform trans = super.getTransform(); + + PathIterator iter = shape.getPathIterator(trans); + double[] dstPts = new double[6]; + int[] coords = null; + if (shape instanceof Line2D) { + iter.currentSegment(dstPts); + coords = new int[4]; + coords[X1] = (int) Math.round(dstPts[X]); + coords[Y1] = (int) Math.round(dstPts[Y]); + iter.next(); + iter.currentSegment(dstPts); + coords[X2] = (int) Math.round(dstPts[X]); + coords[Y2] = (int) Math.round(dstPts[Y]); + graphicsObj.addLine(coords); + } else if (shape instanceof Rectangle2D) { + iter.currentSegment(dstPts); + coords = new int[4]; + coords[X2] = (int) Math.round(dstPts[X]); + coords[Y2] = (int) Math.round(dstPts[Y]); + iter.next(); + iter.next(); + iter.currentSegment(dstPts); + coords[X1] = (int) Math.round(dstPts[X]); + coords[Y1] = (int) Math.round(dstPts[Y]); + graphicsObj.addBox(coords); + } else if (shape instanceof Ellipse2D) { + Ellipse2D elip = (Ellipse2D) shape; + double scale = trans.getScaleX(); + double radiusWidth = elip.getWidth() / 2; + double radiusHeight = elip.getHeight() / 2; + graphicsObj.setArcParams( + (int)Math.round(radiusWidth * scale), + (int)Math.round(radiusHeight * scale), + 0, + 0 + ); + double[] srcPts = new double[] {elip.getCenterX(), elip.getCenterY()}; + trans.transform(srcPts, 0, dstPts, 0, 1); + final int mh = 1; + final int mhr = 0; + graphicsObj.addFullArc( + (int)Math.round(dstPts[X]), + (int)Math.round(dstPts[Y]), + mh, + mhr + ); + } else { + // graphics segment opening coordinates (x,y) + // current position coordinates (x,y) + for (int[] openingCoords = new int[2], currCoords = new int[2]; + !iter.isDone(); iter.next()) { + // round the coordinate values and combine with current position + // coordinates + int type = iter.currentSegment(dstPts); + if (type == PathIterator.SEG_MOVETO) { + openingCoords[X] = currCoords[X] = (int)Math.round(dstPts[X]); + openingCoords[Y] = currCoords[Y] = (int)Math.round(dstPts[Y]); + } else { + int numCoords; + if (type == PathIterator.SEG_LINETO) { + numCoords = 2; + } else if (type == PathIterator.SEG_QUADTO) { + numCoords = 4; + } else if (type == PathIterator.SEG_CUBICTO) { + numCoords = 6; + } else { + // close of the graphics segment + if (type == PathIterator.SEG_CLOSE) { + coords = new int[] { + coords[coords.length - 2], //prev X + coords[coords.length - 1], //prev Y + openingCoords[X], + openingCoords[Y] + }; + graphicsObj.addLine(coords); + } else { + log.debug("Unrecognised path iterator type: " + + type); + } + continue; + } + // combine current position coordinates with new graphics + // segment coordinates + coords = new int[numCoords + 2]; + coords[X] = currCoords[X]; + coords[Y] = currCoords[Y]; + for (int i = 0; i < numCoords; i++) { + coords[i + 2] = (int) Math.round(dstPts[i]); + } + if (type == PathIterator.SEG_LINETO) { + graphicsObj.addLine(coords); + } else if (type == PathIterator.SEG_QUADTO + || type == PathIterator.SEG_CUBICTO) { + graphicsObj.addFillet(coords); + } + // update current position coordinates + currCoords[X] = coords[coords.length - 2]; + currCoords[Y] = coords[coords.length - 1]; + } + } + } + if (fill) { + graphicsObj.endArea(); + } + } + + /** {@inheritDoc} */ + public void draw(Shape shape) { +// log.debug("draw() shape=" + shape); + doDrawing(shape, false); + } + + /** {@inheritDoc} */ + public void fill(Shape shape) { +// log.debug("fill() shape=" + shape); + doDrawing(shape, true); + } + + /** + * Central handler for IOExceptions for this class. + * + * @param ioe + * IOException to handle + */ + public void handleIOException(IOException ioe) { + // TODO Surely, there's a better way to do this. + log.error(ioe.getMessage()); + ioe.printStackTrace(); + } + + /** {@inheritDoc} */ + public void drawString(String str, float x, float y) { + try { + if (customTextHandler != null && !textAsShapes) { + customTextHandler.drawString(str, x, y); + } else { + fallbackTextHandler.drawString(str, x, y); + } + } catch (IOException ioe) { + handleIOException(ioe); + } + } + + /** {@inheritDoc} */ + public GraphicsConfiguration getDeviceConfiguration() { + return new AFPGraphicsConfiguration(); + } + + /** {@inheritDoc} */ + public void copyArea(int x, int y, int width, int height, int dx, int dy) { + log.debug("copyArea() NYI: "); + } + + /** {@inheritDoc} */ + public Graphics create() { + return new AFPGraphics2D(this); + } + + /** {@inheritDoc} */ + public void dispose() { + this.graphicsObj = null; + } + + /** {@inheritDoc} */ + public boolean drawImage(Image img, int x, int y, ImageObserver observer) { + return drawImage(img, x, y, img.getWidth(observer), img.getHeight(observer), observer); + } + + private BufferedImage buildBufferedImage(Dimension size) { + return new BufferedImage(size.width, size.height, + BufferedImage.TYPE_INT_ARGB); + } + + private AFPImageObjectInfo getImageObjectInfo( + RenderedImage img, int x, int y, int width, int height) throws IOException { + ImageInfo imageInfo = new ImageInfo(null, "image/unknown"); + ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), 72); + imageInfo.setSize(size); + + ImageRendered imageRendered = new ImageRendered(imageInfo, img, null); + RenderedImage renderedImage = imageRendered.getRenderedImage(); + + // create image object info + AFPImageObjectInfo imageObjectInfo = new AFPImageObjectInfo(); + + imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); + + imageObjectInfo.setBitsPerPixel(state.getBitsPerPixel()); + + imageObjectInfo.setResourceInfo(resourceInfo); + + int dataHeight = renderedImage.getHeight(); + imageObjectInfo.setDataHeight(dataHeight); + + int dataWidth = renderedImage.getWidth(); + imageObjectInfo.setDataWidth(dataWidth); + + boolean colorImages = state.isColorImages(); + imageObjectInfo.setColor(colorImages); + + ByteArrayOutputStream boas = new ByteArrayOutputStream(); + ImageEncodingHelper.encodeRenderedImageAsRGB(renderedImage, boas); + byte[] imageData = boas.toByteArray(); + + // convert to grayscale + if (!colorImages) { + boas.reset(); + int bitsPerPixel = state.getBitsPerPixel(); + imageObjectInfo.setBitsPerPixel(bitsPerPixel); + ImageEncodingHelper.encodeRGBAsGrayScale( + imageData, dataWidth, dataHeight, bitsPerPixel, boas); + imageData = boas.toByteArray(); + } + imageObjectInfo.setData(imageData); + + if (imageInfo != null) { + imageObjectInfo.setUri(imageInfo.getOriginalURI()); + } + + // create object area info + AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); + + AffineTransform at = gc.getTransform(); + float[] srcPts = new float[] {x, y}; + float[] dstPts = new float[srcPts.length]; + at.transform(srcPts, 0, dstPts, 0, 1); + objectAreaInfo.setX(Math.round(dstPts[X])); + objectAreaInfo.setY(Math.round(dstPts[Y])); + + AFPUnitConverter unitConv = state.getUnitConverter(); + + int w = Math.round(unitConv.pt2units(width)); + objectAreaInfo.setWidth(w); + + int h = Math.round(unitConv.pt2units(height)); + objectAreaInfo.setHeight(h); + + int resolution = state.getResolution(); + objectAreaInfo.setWidthRes(resolution); + objectAreaInfo.setHeightRes(resolution); + + imageObjectInfo.setObjectAreaInfo(objectAreaInfo); + + return imageObjectInfo; + } + + /** {@inheritDoc} */ + public boolean drawImage(Image img, int x, int y, int width, int height, + ImageObserver observer) { + + // draw with AWT Graphics2D + Dimension size = new Dimension(width, height); + BufferedImage bufferedImage = buildBufferedImage(size); + + java.awt.Graphics2D g2d = bufferedImage.createGraphics(); + g2d.setComposite(AlphaComposite.SrcOver); + + Color color = new Color(1, 1, 1, 0); + g2d.setBackground(color); + g2d.setPaint(color); + + g2d.fillRect(0, 0, width, height); + + int bufferedWidth = bufferedImage.getWidth(); + int bufferedHeight = bufferedImage.getHeight(); + Rectangle clipRect = new Rectangle(0, 0, bufferedWidth, bufferedHeight); + g2d.clip(clipRect); + + g2d.setComposite(gc.getComposite()); + + boolean drawn = g2d.drawImage(img, 0, 0, bufferedWidth, bufferedHeight, observer); + g2d.dispose(); + + if (drawn) { + try { + // get image object info + AFPImageObjectInfo imageObjectInfo = getImageObjectInfo(bufferedImage, x, y, width, height); + + // create image resource + resourceManager.createObject(imageObjectInfo); + return true; + } catch (IOException ioe) { + handleIOException(ioe); + } + } + return false; + } + + /** {@inheritDoc} */ + public void drawRenderableImage(RenderableImage img, AffineTransform xform) { + log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform); + } + + /** {@inheritDoc} */ + public void drawRenderedImage(RenderedImage img, AffineTransform xform) { + log.debug("drawRenderedImage() NYI: img=" + img + ", xform=" + xform); + } + + /** {@inheritDoc} */ + public FontMetrics getFontMetrics(Font f) { + log.debug("getFontMetrics() NYI: f=" + f); + return null; + } + + /** {@inheritDoc} */ + public void setXORMode(Color col) { + log.debug("setXORMode() NYI: col=" + col); + } + + /** + * Sets a custom TextHandler implementation that is responsible for painting + * text. The default TextHandler paints all text as shapes. A custom + * implementation can implement text painting using text painting operators. + * + * @param handler + * the custom TextHandler implementation + */ + public void setCustomTextHandler(TextHandler handler) { + this.customTextHandler = handler; + } + + /** + * Returns the GOCA graphics object + * + * @return the GOCA graphics object + */ + public GraphicsObject getGraphicsObject() { + return this.graphicsObj; + } + + /** + * Sets the GOCA graphics object + * + * @param obj the GOCA graphics object + */ + public void setGraphicsObject(GraphicsObject obj) { + this.graphicsObj = obj; + } + + /** + * Sets the AFP state + * + * @param state the AFP state + */ + public void setState(AFPState state) { + this.state = state; + } + + /** + * Returns the AFP state + * + * @return the AFP state + */ + public AFPState getState() { + return this.state; + } + + /** + * Sets the FontInfo + * + * @param the FontInfo + */ + public void setFontInfo(FontInfo fontInfo) { + this.fontInfo = fontInfo; + } + + /** + * Returns the FontInfo + * + * @return the FontInfo + */ + public FontInfo getFontInfo() { + return this.fontInfo; + } +} diff --git a/src/java/org/apache/fop/afp/AFPGraphicsConfiguration.java b/src/java/org/apache/fop/afp/AFPGraphicsConfiguration.java new file mode 100644 index 000000000..6c6d92098 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPGraphicsConfiguration.java @@ -0,0 +1,155 @@ +/* + * 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.afp; + +import java.awt.GraphicsDevice; +import java.awt.Rectangle; +import java.awt.Transparency; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.svg.GraphicsConfiguration; + +/** + * Our implementation of the class that returns information about + * roughly what we can handle and want to see (alpha for example). + */ +public class AFPGraphicsConfiguration extends GraphicsConfiguration { + // We use this to get a good colormodel.. + private static final BufferedImage BI_WITH_ALPHA + = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); + // We use this to get a good colormodel.. + private static final BufferedImage BI_WITHOUT_ALPHA + = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + + /** + * Construct a buffered image with an alpha channel, unless + * transparencty is OPAQUE (no alpha at all). + * + * @param width the width of the image + * @param height the height of the image + * @param transparency the alpha value of the image + * @return the new buffered image + */ + public BufferedImage createCompatibleImage(int width, int height, + int transparency) { + if (transparency == Transparency.OPAQUE) { + return new BufferedImage(width, height, + BufferedImage.TYPE_INT_RGB); + } else { + return new BufferedImage(width, height, + BufferedImage.TYPE_INT_ARGB); + } + } + + /** + * Construct a buffered image with an alpha channel. + * + * @param width the width of the image + * @param height the height of the image + * @return the new buffered image + */ + public BufferedImage createCompatibleImage(int width, int height) { + return new BufferedImage(width, height, + BufferedImage.TYPE_INT_ARGB); + } + + /** + * TODO: This should return the page bounds in Pts, + * I couldn't figure out how to get this for the current + * page from the PDFDocument (this still works for now, + * but it should be fixed...). + * + * @return the bounds of the PDF document page + */ + public Rectangle getBounds() { + return null; + } + + /** + * Return a good default color model for this 'device'. + * @return the colour model for the configuration + */ + public ColorModel getColorModel() { + return BI_WITH_ALPHA.getColorModel(); + } + + /** + * Return a good color model given transparency + * + * @param transparency the alpha value for the colour model + * @return the colour model for the configuration + */ + public ColorModel getColorModel(int transparency) { + if (transparency == Transparency.OPAQUE) { + return BI_WITHOUT_ALPHA.getColorModel(); + } else { + return BI_WITH_ALPHA.getColorModel(); + } + } + + private static final Log log = LogFactory.getLog(AFPGraphicsConfiguration.class); + + private AffineTransform defaultTransform = null; + private AffineTransform normalizingTransform = null; + private GraphicsDevice graphicsDevice = null; + + /** + * The default transform (1:1). + * + * @return the default transform for the configuration + */ + public AffineTransform getDefaultTransform() { + log.debug("getDefaultTransform()"); + if (defaultTransform == null) { + defaultTransform = new AffineTransform(); + } + return defaultTransform; + } + + /** + * The normalizing transform (1:1) (since we currently + * render images at 72dpi, which we might want to change + * in the future). + * + * @return the normalizing transform for the configuration + */ + public AffineTransform getNormalizingTransform() { + log.debug("getNormalizingTransform()"); + if (normalizingTransform == null) { + normalizingTransform = new AffineTransform(2, 0, 0, 2, 0, 0); + } + return normalizingTransform; + } + + /** + * {@inheritDoc} + */ + public GraphicsDevice getDevice() { + log.debug("getDevice()"); + if (graphicsDevice == null) { + graphicsDevice = new AFPGraphicsDevice(this); + } + return graphicsDevice; + } +} diff --git a/src/java/org/apache/fop/afp/AFPGraphicsDevice.java b/src/java/org/apache/fop/afp/AFPGraphicsDevice.java new file mode 100644 index 000000000..20270e426 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPGraphicsDevice.java @@ -0,0 +1,81 @@ +/* + * 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.afp; + +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; + + +/** + * This implements the GraphicsDevice interface as appropriate for + * an AFPGraphics2D. + */ +public class AFPGraphicsDevice extends GraphicsDevice { + + /** + * The Graphics Config that created us... + */ + protected GraphicsConfiguration gc; + + /** + * Create a new AF{ graphics device. + * + * @param gc The graphics configuration we should reference + */ + public AFPGraphicsDevice(AFPGraphicsConfiguration gc) { + this.gc = gc; + } + + /** + * Return an array of our one GraphicsConfig + * + * @return an array containing the one graphics configuration + */ + public GraphicsConfiguration[] getConfigurations() { + return new GraphicsConfiguration[] {gc}; + } + + /** + * Return out sole GraphicsConfig. + * + * @return the graphics configuration that created this object + */ + public GraphicsConfiguration getDefaultConfiguration() { + return this.gc; + } + + /** + * Generate an IdString.. + * + * @return the ID string for this device, uses toString + */ + public String getIDstring() { + return toString(); + } + + /** + * Let the caller know that we are "a printer" + * + * @return the type which is always printer + */ + public int getType() { + return GraphicsDevice.TYPE_PRINTER; + } +} diff --git a/src/java/org/apache/fop/afp/AFPGraphicsObjectInfo.java b/src/java/org/apache/fop/afp/AFPGraphicsObjectInfo.java new file mode 100644 index 000000000..df0ef55c5 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPGraphicsObjectInfo.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.afp; + +import java.awt.geom.Rectangle2D; + +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; +import org.apache.xmlgraphics.util.MimeConstants; + +/** + * A graphics object info which contains necessary painting objects + */ +public class AFPGraphicsObjectInfo extends AFPDataObjectInfo { + + /** the graphics object painter implementation */ + private Graphics2DImagePainter painter; + + /** the graphics object area */ + private Rectangle2D area; + + /** the AFP graphics 2d implementation */ + private AFPGraphics2D g2d; + + /** + * Returns the graphics painter + * + * @return the graphics painter + */ + public Graphics2DImagePainter getPainter() { + return this.painter; + } + + /** + * Sets the graphics painter + * + * @param graphicsPainter the graphics painter + */ + public void setPainter(Graphics2DImagePainter graphicsPainter) { + this.painter = graphicsPainter; + } + + /** + * Returns the graphics area + * + * @return the graphics area + */ + public Rectangle2D getArea() { + return this.area; + } + + /** + * Sets the graphics area area + * + * @param area the graphics object area + */ + public void setArea(Rectangle2D area) { + this.area = area; + } + + /** + * Sets the AFP graphics 2D implementation + * + * @param g2d the AFP graphics 2D implementation + */ + public void setGraphics2D(AFPGraphics2D g2d) { + this.g2d = g2d; + } + + /** + * Returns the AFP graphics 2D implementation + * + * @return the AFP graphics 2D implementation + */ + public AFPGraphics2D getGraphics2D() { + return this.g2d; + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsObjectInfo{" + super.toString() + "}"; + } + + /** {@inheritDoc} */ + public String getMimeType() { + return MimeConstants.MIME_SVG; + } + +} diff --git a/src/java/org/apache/fop/afp/AFPImageObjectInfo.java b/src/java/org/apache/fop/afp/AFPImageObjectInfo.java new file mode 100644 index 000000000..561ad438b --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPImageObjectInfo.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.afp; + + +/** + * A list of parameters associated with an image + */ +public class AFPImageObjectInfo extends AFPDataObjectInfo { + /** number of bits per pixel used */ + private int bitsPerPixel; + + /** is this a color image? */ + private boolean color; + + /** compression type if any */ + private int compression = -1; + + /** the object data in a byte array */ + private byte[] data; + + /** + * Default constructor + */ + public AFPImageObjectInfo() { + super(); + } + + /** + * Sets the number of bits per pixel + * + * @param bitsPerPixel the number of bits per pixel + */ + public void setBitsPerPixel(int bitsPerPixel) { + this.bitsPerPixel = bitsPerPixel; + } + + /** + * Sets if this image is color + * + * @param color true if this is a color image + */ + public void setColor(boolean color) { + this.color = color; + } + + /** + * Returns the number of bits used per pixel + * + * @return the number of bits used per pixel + */ + public int getBitsPerPixel() { + return bitsPerPixel; + } + + /** + * Returns true if this is a color image + * + * @return true if this is a color image + */ + public boolean isColor() { + return color; + } + + /** + * Returns true if this image uses compression + * + * @return true if this image uses compression + */ + public boolean hasCompression() { + return compression > -1; + } + + /** + * Returns the compression type + * + * @return the compression type + */ + public int getCompression() { + return compression; + } + + /** + * Sets the compression used with this image + * + * @param compression the type of compression used with this image + */ + public void setCompression(int compression) { + this.compression = compression; + } + + /** + * Sets the object data + * + * @param data the object data + */ + public void setData(byte[] data) { + this.data = data; + } + + /** + * Returns the object data + * + * @return the object data + */ + public byte[] getData() { + return this.data; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPImageObjectInfo{" + super.toString() + + ", compression=" + compression + + ", color=" + color + + ", bitsPerPixel=" + bitsPerPixel + + "}"; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPLineDataInfo.java b/src/java/org/apache/fop/afp/AFPLineDataInfo.java new file mode 100644 index 000000000..f3acf4f71 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPLineDataInfo.java @@ -0,0 +1,192 @@ +/* + * 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.afp; + +import java.awt.Color; + +/** Line data information */ +public class AFPLineDataInfo { + + /** the x1 coordinate */ + int x1; + + /** the y1 coordinate */ + int y1; + + /** the x2 coordinate */ + int x2; + + /** the y2 coordinate */ + int y2; + + /** the thickness */ + int thickness; + + /** the painting color */ + Color color; + + /** the rotation */ + int rotation = 0; + + /** + * Default constructor + */ + public AFPLineDataInfo() { + } + + /** + * Returns the X1 coordinate + * + * @return the X1 coordinate + */ + public int getX1() { + return x1; + } + + /** + * Sets the X1 coordinate + * + * @param x1 the X1 coordinate + */ + public void setX1(int x1) { + this.x1 = x1; + } + + /** + * Returns the Y1 coordinate + * + * @return the Y1 coordinate + */ + public int getY1() { + return y1; + } + + /** + * Sets the Y1 coordinate + * + * @param y1 the Y1 coordinate + */ + public void setY1(int y1) { + this.y1 = y1; + } + + /** + * Returns the X2 coordinate + * + * @return the X2 coordinate + */ + public int getX2() { + return x2; + } + + /** + * Sets the X2 coordinate + * + * @param x2 the X2 coordinate + */ + public void setX2(int x2) { + this.x2 = x2; + } + + /** + * Returns the Y2 coordinate + * + * @return the Y2 coordinate + */ + public int getY2() { + return y2; + } + + /** + * Sets the Y2 coordinate + * + * @param y2 the Y2 coordinate + */ + public void setY2(int y2) { + this.y2 = y2; + } + + /** + * Returns the line thickness + * + * @return the line thickness + */ + public int getThickness() { + return thickness; + } + + /** + * Sets the line thickness + * + * @param thickness the line thickness + */ + public void setThickness(int thickness) { + this.thickness = thickness; + } + + /** + * Returns line color + * + * @return the line color + */ + public Color getColor() { + return color; + } + + /** + * Sets the line color + * + * @param color the line color + */ + public void setColor(Color color) { + this.color = color; + } + + /** + * Returns line rotation + * + * @return the line rotation + */ + public int getRotation() { + return rotation; + } + + /** + * Sets the line rotation + * + * @param rotation the line rotation + */ + public void setRotation(int rotation) { + this.rotation = rotation; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPLineDataInfo{x1=" + x1 + + ", y1=" + y1 + + ", x2=" + x2 + + ", y2=" + y2 + + ", thickness=" + thickness + + ", color=" + color + + ", rotation=" + rotation + + "}"; + } + +} diff --git a/src/java/org/apache/fop/afp/AFPObjectAreaInfo.java b/src/java/org/apache/fop/afp/AFPObjectAreaInfo.java new file mode 100644 index 000000000..963424470 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPObjectAreaInfo.java @@ -0,0 +1,172 @@ +/* + * 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.afp; + +/** + * A common class used to convey locations, + * dimensions and resolutions of data objects. + */ +public class AFPObjectAreaInfo { + private int x; + private int y; + private int width; + private int height; + private int widthRes; + private int heightRes; + private int rotation = 0; + + /** + * Sets the x position of the data object + * + * @param x the x position of the data object + */ + public void setX(int x) { + this.x = x; + } + + /** + * Sets the y position of the data object + * + * @param y the y position of the data object + */ + public void setY(int y) { + this.y = y; + } + + /** + * Sets the data object width + * + * @param width the width of the data object + */ + public void setWidth(int width) { + this.width = width; + } + + /** + * Sets the data object height + * + * @param height the height of the data object + */ + public void setHeight(int height) { + this.height = height; + } + + /** + * Sets the width resolution + * + * @param widthRes the width resolution + */ + public void setWidthRes(int widthRes) { + this.widthRes = widthRes; + } + + /** + * Sets the height resolution + * + * @param heightRes the height resolution + */ + public void setHeightRes(int heightRes) { + this.heightRes = heightRes; + } + + /** + * Returns the x coordinate of this data object + * + * @return the x coordinate of this data object + */ + public int getX() { + return x; + } + + /** + * Returns the y coordinate of this data object + * + * @return the y coordinate of this data object + */ + public int getY() { + return y; + } + + /** + * Returns the width of this data object + * + * @return the width of this data object + */ + public int getWidth() { + return width; + } + + /** + * Returns the height of this data object + * + * @return the height of this data object + */ + public int getHeight() { + return height; + } + + /** + * Returns the width resolution of this data object + * + * @return the width resolution of this data object + */ + public int getWidthRes() { + return widthRes; + } + + /** + * Returns the height resolution of this data object + * + * @return the height resolution of this data object + */ + public int getHeightRes() { + return heightRes; + } + + /** + * Returns the rotation of this data object + * + * @return the rotation of this data object + */ + public int getRotation() { + return rotation; + } + + /** + * Sets the data object rotation + * + * @param rotation the data object rotation + */ + public void setRotation(int rotation) { + this.rotation = rotation; + } + + /** {@inheritDoc} */ + public String toString() { + return "x=" + x + + ", y=" + y + + ", width=" + width + + ", height=" + height + + ", widthRes=" + widthRes + + ", heightRes=" + heightRes + + ", rotation=" + rotation; + } + +} diff --git a/src/java/org/apache/fop/afp/AFPPageFonts.java b/src/java/org/apache/fop/afp/AFPPageFonts.java new file mode 100644 index 000000000..41fce731d --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPPageFonts.java @@ -0,0 +1,67 @@ +/* + * 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.afp; + +import org.apache.fop.afp.fonts.AFPFont; +import org.apache.fop.afp.fonts.AFPFontAttributes; + + +/** + * Holds the current page fonts + */ +public class AFPPageFonts extends java.util.HashMap { + private static final long serialVersionUID = -4991896259427109041L; + + /** + * Default constructor + */ + public AFPPageFonts() { + super(); + } + + /** + * Parameterized constructor + * + * @param fonts an existing set of afp page fonts + */ + public AFPPageFonts(AFPPageFonts fonts) { + super(fonts); + } + + /** + * Registers a font on the current page and returns font attributes + * + * @param fontName the internal font name + * @param font the AFPFont + * @param fontSize the font point size + * @return newly registered AFPFontAttributes + */ + public AFPFontAttributes registerFont(String fontName, AFPFont font, int fontSize) { + String pageFontKey = fontName + "_" + fontSize; + AFPFontAttributes afpFontAttributes = (AFPFontAttributes)super.get(pageFontKey); + // Add to page font mapping if not already present + if (afpFontAttributes == null) { + afpFontAttributes = new AFPFontAttributes(fontName, font, fontSize); + super.put(pageFontKey, afpFontAttributes); + afpFontAttributes.setFontReference(super.size()); + } + return afpFontAttributes; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPRectanglePainter.java b/src/java/org/apache/fop/afp/AFPRectanglePainter.java new file mode 100644 index 000000000..56c60b440 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPRectanglePainter.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.afp; + +import java.awt.geom.AffineTransform; + +import org.apache.fop.afp.modca.DataStream; + +public class AFPRectanglePainter extends AbstractAFPPainter { + + /** + * Main constructor + * + * @param state the afp state + * @param dataStream the afp datastream + */ + public AFPRectanglePainter(AFPState state, DataStream dataStream) { + super(state, dataStream); + } + + /** {@inheritDoc} */ + public void paint(PaintInfo paintInfo) { + RectanglePaintInfo rectanglePaintInfo = (RectanglePaintInfo)paintInfo; + int pageWidth = dataStream.getCurrentPage().getWidth(); + int pageHeight = dataStream.getCurrentPage().getHeight(); + + AFPUnitConverter unitConv = state.getUnitConverter(); + float width = unitConv.pt2units(rectanglePaintInfo.getWidth()); + float height = unitConv.pt2units(rectanglePaintInfo.getHeight()); + float x = unitConv.pt2units(rectanglePaintInfo.getX()); + float y = unitConv.pt2units(rectanglePaintInfo.getY()); + + AffineTransform at = state.getData().getTransform(); + + AFPLineDataInfo lineDataInfo = new AFPLineDataInfo(); + lineDataInfo.color = state.getColor(); + lineDataInfo.rotation = state.getRotation(); + lineDataInfo.thickness = Math.round(height); + + switch (lineDataInfo.rotation) { + case 0: + lineDataInfo.x1 = Math.round((float)at.getTranslateX() + x); + lineDataInfo.y1 = lineDataInfo.y2 = Math.round((float)at.getTranslateY() + y); + lineDataInfo.x2 = Math.round((float)at.getTranslateX() + x + width); + break; + case 90: + lineDataInfo.x1 = Math.round((float)at.getTranslateY() + x); + lineDataInfo.y1 = lineDataInfo.y2 + = pageWidth - Math.round((float)at.getTranslateX()) + Math.round(y); + lineDataInfo.x2 = Math.round(width + (float)at.getTranslateY() + x); + break; + case 180: + lineDataInfo.x1 = pageWidth - Math.round((float)at.getTranslateX() - x); + lineDataInfo.y1 = lineDataInfo.y2 = pageHeight - Math.round((float)at.getTranslateY() - y); + lineDataInfo.x2 = pageWidth - Math.round((float)at.getTranslateX() - x - width); + break; + case 270: + lineDataInfo.x1 = pageHeight - Math.round((float)at.getTranslateY() - x); + lineDataInfo.y1 = lineDataInfo.y2 = Math.round((float)at.getTranslateX() + y); + lineDataInfo.x2 = lineDataInfo.x1 + Math.round(width - x); + break; + } + dataStream.createLine(lineDataInfo); + } +} diff --git a/src/java/org/apache/fop/afp/AFPResourceInfo.java b/src/java/org/apache/fop/afp/AFPResourceInfo.java new file mode 100644 index 000000000..729339fa4 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPResourceInfo.java @@ -0,0 +1,141 @@ +/* + * 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.afp; + + +/** + * The level at which a resource is to reside in the AFP output + */ +public class AFPResourceInfo { + private static final AFPResourceLevel DEFAULT_LEVEL + = new AFPResourceLevel(AFPResourceLevel.PRINT_FILE); + + /** the uri of this resource */ + private String uri = null; + + /** the reference name of this resource */ + private String name = null; + + /** the resource level of this resource */ + private AFPResourceLevel level = DEFAULT_LEVEL; + + /** true when the resource level was changed */ + private boolean levelChanged = false; + + /** + * Sets the data object uri + * + * @param uri the data object uri + */ + public void setUri(String uri) { + this.uri = uri; + } + + /** + * Returns the uri of this data object + * + * @return the uri of this data object + */ + public String getUri() { + return uri; + } + + /** + * Sets the resource reference name + * + * @param resourceName the resource reference name + */ + public void setName(String resourceName) { + this.name = resourceName; + } + + /** + * Returns the resource reference name + * + * @return the resource reference name + */ + public String getName() { + return this.name; + } + + /** + * Returns the resource level + * + * @return the resource level + */ + public AFPResourceLevel getLevel() { + if (level == null) { + return DEFAULT_LEVEL; + } + return this.level; + } + + /** + * Sets the resource level + * + * @param resourceLevel the resource level + */ + public void setLevel(AFPResourceLevel resourceLevel) { + this.level = resourceLevel; + levelChanged = true; + } + + /** + * Returns true when the resource level was set + * + * @return true when the resource level was set + */ + public boolean levelChanged() { + return levelChanged; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPResourceInfo{uri=" + uri + + (name != null ? ", name=" + name : "") + + (level != null ? ", level=" + level : "") + + "}"; + + } + + /** {@inheritDoc} */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if ((obj == null) || !(obj instanceof AFPResourceInfo)) { + return false; + } + + AFPResourceInfo ri = (AFPResourceInfo)obj; + return (uri == ri.uri || uri != null && uri.equals(ri.uri)) + && (name == ri.name || name != null && name.equals(ri.name)) + && (level == ri.level || level != null && level.equals(ri.level)); + } + + /** {@inheritDoc} */ + public int hashCode() { + int hash = 7; + hash = 31 * hash + (null == uri ? 0 : uri.hashCode()); + hash = 31 * hash + (null == name ? 0 : name.hashCode()); + hash = 31 * hash + (null == level ? 0 : level.hashCode()); + return hash; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPResourceLevel.java b/src/java/org/apache/fop/afp/AFPResourceLevel.java new file mode 100644 index 000000000..85cdefb4b --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPResourceLevel.java @@ -0,0 +1,201 @@ +/* + * 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.afp; + +/** + * A resource level + */ +public class AFPResourceLevel { + + /** directly in page **/ + public static final int INLINE = 0; + + /** page level **/ + public static final int PAGE = 1; + + /** page group level **/ + public static final int PAGE_GROUP = 2; + + /** document level **/ + public static final int DOCUMENT = 3; + + /** print file level **/ + public static final int PRINT_FILE = 4; + + /** external level **/ + public static final int EXTERNAL = 5; + + private static final String NAME_INLINE = "inline"; + private static final String NAME_PAGE = "page"; + private static final String NAME_PAGE_GROUP = "page-group"; + private static final String NAME_DOCUMENT = "document"; + private static final String NAME_PRINT_FILE = "print-file"; + private static final String NAME_EXTERNAL = "external"; + + private static final String[] NAMES = new String[] { + NAME_INLINE, NAME_PAGE, NAME_PAGE_GROUP, NAME_DOCUMENT, NAME_PRINT_FILE, NAME_EXTERNAL + }; + + + /** where the resource will reside in the AFP output */ + private int level = PRINT_FILE; // default is print-file level + + /** the external resource group file path */ + private String extFilePath = null; + + /** + * Sets the resource placement level within the AFP output + * + * @param levelString the resource level (page, page-group, document, print-file or external) + * @return true if the resource level was successfully set + */ + public static AFPResourceLevel valueOf(String levelString) { + if (levelString != null) { + levelString = levelString.toLowerCase(); + AFPResourceLevel resourceLevel = null; + for (int i = 0; i < NAMES.length; i++) { + if (NAMES[i].equals(levelString)) { + resourceLevel = new AFPResourceLevel(i); + break; + } + } + return resourceLevel; + } + return null; + } + + /** + * Main constructor + * + * @param level the resource level + */ + public AFPResourceLevel(int level) { + setLevel(level); + } + + /** + * Sets the resource level + * + * @param level the resource level + */ + public void setLevel(int level) { + this.level = level; + } + + /** + * Returns true if this is at page level + * + * @return true if this is at page level + */ + public boolean isPage() { + return level == PAGE; + } + + /** + * Returns true if this is at page group level + * + * @return true if this is at page group level + */ + public boolean isPageGroup() { + return level == PAGE_GROUP; + } + + /** + * Returns true if this is at document level + * + * @return true if this is at document level + */ + public boolean isDocument() { + return level == DOCUMENT; + } + + /** + * Returns true if this is at external level + * + * @return true if this is at external level + */ + public boolean isExternal() { + return level == EXTERNAL; + } + + /** + * Returns true if this is at print-file level + * + * @return true if this is at print-file level + */ + public boolean isPrintFile() { + return level == PRINT_FILE; + } + + /** + * Returns true if this resource level is inline + * + * @return true if this resource level is inline + */ + public boolean isInline() { + return level == INLINE; + } + + /** + * Returns the destination file path of the external resource group file + * + * @return the destination file path of the external resource group file + */ + public String getExternalFilePath() { + return this.extFilePath; + } + + /** + * Sets the external destination of the resource + * + * @param filePath the external resource group file + */ + public void setExternalFilePath(String filePath) { + this.extFilePath = filePath; + } + + /** {@inheritDoc} */ + public String toString() { + return NAMES[level] + (isExternal() ? ", file=" + extFilePath : ""); + } + + /** {@inheritDoc} */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if ((obj == null) || !(obj instanceof AFPResourceLevel)) { + return false; + } + + AFPResourceLevel rl = (AFPResourceLevel)obj; + return (level == level) + && (extFilePath == rl.extFilePath + || extFilePath != null && extFilePath.equals(rl.extFilePath)); + } + + /** {@inheritDoc} */ + public int hashCode() { + int hash = 7; + hash = 31 * hash + level; + hash = 31 * hash + (null == extFilePath ? 0 : extFilePath.hashCode()); + return hash; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java new file mode 100644 index 000000000..111238be8 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPResourceManager.java @@ -0,0 +1,188 @@ +/* + * 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.afp; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.modca.AbstractDataObject; +import org.apache.fop.afp.modca.AbstractNamedAFPObject; +import org.apache.fop.afp.modca.DataStream; +import org.apache.fop.afp.modca.IncludeObject; +import org.apache.fop.afp.modca.Registry; +import org.apache.fop.afp.modca.ResourceGroup; + +/** + * Manages the creation and storage of document resources + */ +public class AFPResourceManager { + /** Static logging instance */ + private static final Log log = LogFactory.getLog(AFPResourceManager.class); + + /** The AFP datastream (document tree) */ + private DataStream dataStream; + + /** Resource creation factory */ + private final Factory factory; + + private final AFPStreamer streamer; + + private final AFPDataObjectFactory dataObjectFactory; + + /** Maintain a reference count of instream objects for referencing purposes */ + private int instreamObjectCount = 0; + + /** a mapping of resourceInfo --> include name */ + private final Map/**/ includeNameMap + = new java.util.HashMap()/**/; + + /** + * Main constructor + */ + public AFPResourceManager() { + this.factory = new Factory(); + this.streamer = new AFPStreamer(factory); + this.dataObjectFactory = new AFPDataObjectFactory(factory); + } + + /** + * Sets the outputstream + * + * @param state the afp state + * @param outputStream the outputstream + */ + public void createDataStream(AFPState state, OutputStream outputStream) { + this.dataStream = streamer.createDataStream(state); + streamer.setOutputStream(outputStream); + } + + /** + * Returns the AFP DataStream + * + * @return the AFP DataStream + */ + public DataStream getDataStream() { + return this.dataStream; + } + + /** + * Tells the streamer to write + * + * @throws IOException thrown if an I/O exception of some sort has occurred. + */ + public void writeToStream() throws IOException { + streamer.close(); + } + + /** + * Sets the default resource group file path + * + * @param filePath the default resource group file path + */ + + public void setDefaultResourceGroupFilePath(String filePath) { + streamer.setDefaultResourceGroupFilePath(filePath); + } + + /** + * Creates a new data object in the AFP datastream + * + * @param dataObjectInfo the data object info + * + * @throws IOException thrown if an I/O exception of some sort has occurred. + */ + public void createObject(AFPDataObjectInfo dataObjectInfo) throws IOException { + AbstractNamedAFPObject namedObj = null; + + AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + String uri = resourceInfo.getUri(); + if (uri == null) { + uri = "/"; + } + // if this is an instream data object adjust the uri to ensure that its unique + if (uri.endsWith("/")) { + uri += "#" + (++instreamObjectCount); + resourceInfo.setUri(uri); + } + + String objectName = (String)includeNameMap.get(resourceInfo); + if (objectName == null) { + boolean useInclude = true; + Registry.ObjectType objectType = null; + + // new resource so create + if (dataObjectInfo instanceof AFPImageObjectInfo) { + AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)dataObjectInfo; + namedObj = dataObjectFactory.createImage(imageObjectInfo); + } else if (dataObjectInfo instanceof AFPGraphicsObjectInfo) { + AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)dataObjectInfo; + namedObj = dataObjectFactory.createGraphic(graphicsObjectInfo); + } else { + // natively embedded object + namedObj = dataObjectFactory.createObjectContainer(dataObjectInfo); + objectType = dataObjectInfo.getObjectType(); + useInclude = objectType != null && objectType.isIncludable(); + } + + // set data object viewport (i.e. position, rotation, dimension, resolution) + if (namedObj instanceof AbstractDataObject) { + AbstractDataObject dataObj = (AbstractDataObject)namedObj; + dataObj.setViewport(dataObjectInfo); + } + + AFPResourceLevel resourceLevel = resourceInfo.getLevel(); + ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel); + useInclude &= resourceGroup != null; + if (useInclude) { + // if it is to reside within a resource group at print-file or external level + if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) { + // wrap newly created data object in a resource object + namedObj = dataObjectFactory.createResource(namedObj, resourceInfo, objectType); + } + + // add data object into its resource group destination + resourceGroup.addObject(namedObj); + + // create the include object + objectName = namedObj.getName(); + IncludeObject includeObject + = dataObjectFactory.createInclude(objectName, dataObjectInfo); + + // add an include to the current page + dataStream.getCurrentPage().addObject(includeObject); + + // record mapping of resource info to data object resource name + includeNameMap.put(resourceInfo, objectName); + } else { + // not to be included so inline data object directly into the current page + dataStream.getCurrentPage().addObject(namedObj); + } + } else { + // an existing data resource so reference it by adding an include to the current page + IncludeObject includeObject + = dataObjectFactory.createInclude(objectName, dataObjectInfo); + dataStream.getCurrentPage().addObject(includeObject); + } + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPState.java b/src/java/org/apache/fop/afp/AFPState.java new file mode 100644 index 000000000..9de3a0c05 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPState.java @@ -0,0 +1,511 @@ +/* + * 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.afp; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.AbstractState; + +/** + * This keeps information about the current state when writing to an AFP datastream. + */ +public class AFPState extends org.apache.fop.AbstractState implements Cloneable { + + private static final long serialVersionUID = 8206711712452344473L; + + private static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); + + /** the portrait rotation */ + private int portraitRotation = 0; + + /** the landscape rotation */ + private int landscapeRotation = 270; + + /** color image support */ + private boolean colorImages = false; + + /** images are supported in this AFP environment */ + private boolean nativeImages = false; + + /** default value for image depth */ + private int bitsPerPixel = 8; + + /** the output resolution */ + private int resolution = 240; // 240 dpi + + /** the current page */ + private AFPPageState pageState = new AFPPageState(); + +// /** reference orientation */ +// private int orientation = 0; + + /** a unit converter */ + private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this); + + /** + * Sets the rotation to be used for portrait pages, valid values are 0 + * (default), 90, 180, 270. + * + * @param rotation + * The rotation in degrees. + */ + public void setPortraitRotation(int rotation) { + if (rotation == 0 || rotation == 90 || rotation == 180 + || rotation == 270) { + portraitRotation = rotation; + } else { + throw new IllegalArgumentException( + "The portrait rotation must be one" + + " of the values 0, 90, 180, 270"); + + } + } + + /** + * Returns the rotation to be used for portrait pages + * + * @return the rotation to be used for portrait pages + */ + protected int getPortraitRotation() { + return this.portraitRotation; + } + + /** + * Sets the rotation to be used for landscape pages, valid values are 0, 90, + * 180, 270 (default). + * + * @param rotation + * The rotation in degrees. + */ + public void setLandscapeRotation(int rotation) { + if (rotation == 0 || rotation == 90 || rotation == 180 + || rotation == 270) { + landscapeRotation = rotation; + } else { + throw new IllegalArgumentException( + "The landscape rotation must be one" + + " of the values 0, 90, 180, 270"); + } + } + + /** + * Returns the landscape rotation + * + * @return the landscape rotation + */ + protected int getLandscapeRotation() { + return this.landscapeRotation; + } + + /** + * Sets the number of bits used per pixel + * + * @param bitsPerPixel + * number of bits per pixel + */ + public void setBitsPerPixel(int bitsPerPixel) { + switch (bitsPerPixel) { + case 1: + case 4: + case 8: + this.bitsPerPixel = bitsPerPixel; + break; + default: + log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8."); + this.bitsPerPixel = 8; + break; + } + } + + /** + * Returns the number of bits per pixel + * + * @return the number of bits per pixel + */ + public int getBitsPerPixel() { + return this.bitsPerPixel; + } + + /** + * Sets whether images are color or not + * + * @param colorImages + * color image output + */ + public void setColorImages(boolean colorImages) { + this.colorImages = colorImages; + } + + /** + * Returns true if color images are to be used + * + * @return true if color images are to be used + */ + public boolean isColorImages() { + return this.colorImages; + } + + /** + * Sets whether images are natively supported or not in the AFP environment + * + * @param nativeImages true if images are natively supported in this AFP environment + */ + public void setNativeImages(boolean nativeImages) { + this.nativeImages = nativeImages; + } + + /** + * Returns true if images are supported natively in this AFP environment + * + * @return true if images are supported natively in this AFP environment + */ + public boolean isNativeImages() { + return this.nativeImages; + } + + /** + * Sets the output/device resolution + * + * @param resolution + * the output resolution (dpi) + */ + public void setResolution(int resolution) { + if (log.isDebugEnabled()) { + log.debug("renderer-resolution set to: " + resolution + "dpi"); + } + this.resolution = resolution; + } + + /** + * Returns the output/device resolution. + * + * @return the resolution in dpi + */ + public int getResolution() { + return this.resolution; + } + + /** {@inheritDoc} */ + protected AbstractData instantiateData() { + return new AFPData(); + } + + /** {@inheritDoc} */ + protected AbstractState instantiateState() { + return new AFPState(); + } + + /** + * Returns the state of the current page + * + * @return the state of the current page + */ + protected AFPPageState getPageState() { + return this.pageState; + } + + /** + * Sets if the current painted shape is to be filled + * + * @param fill true if the current painted shape is to be filled + * @return true if the fill value has changed + */ + protected boolean setFill(boolean fill) { + if (fill != ((AFPData)getData()).filled) { + ((AFPData)getData()).filled = fill; + return true; + } + return false; + } + + /** + * Gets the current page fonts + * + * @return the current page fonts + */ + public AFPPageFonts getPageFonts() { + return pageState.getFonts(); + } + + /** + * Increments and returns the page font count + * + * @return the page font count + */ + public int incrementPageFontCount() { + return pageState.incrementFontCount(); + } + + /** + * Sets the page width + * + * @param pageWidth the page width + */ + public void setPageWidth(int pageWidth) { + pageState.setWidth(pageWidth); + } + + /** + * Returns the page width + * + * @return the page width + */ + public int getPageWidth() { + return pageState.getWidth(); + } + + /** + * Sets the page height + * + * @param pageHeight the page height + */ + public void setPageHeight(int pageHeight) { + pageState.setHeight(pageHeight); + } + + /** + * Returns the page height + * + * @return the page height + */ + public int getPageHeight() { + return pageState.getHeight(); + } + + /** + * Returns the page rotation + * + * @return the page rotation + */ + public int getPageRotation() { + return pageState.getOrientation(); + } + + /** + * Sets the uri of the current image + * + * @param uri the uri of the current image + */ + public void setImageUri(String uri) { + ((AFPData)getData()).imageUri = uri; + } + + /** + * Gets the uri of the current image + * + * @return the uri of the current image + */ + public String getImageUri() { + return ((AFPData)getData()).imageUri; + } + + /** + * Returns the currently derived rotation + * + * @return the currently derived rotation + */ + public int getRotation() { + return getData().getDerivedRotation(); + } + + /** + * Returns the unit converter + * + * @return the unit converter + */ + public AFPUnitConverter getUnitConverter() { + return this.unitConv; + } + + /** {@inheritDoc} */ + public Object clone() { + AFPState state = (AFPState)super.clone(); + state.pageState = (AFPPageState)this.pageState.clone(); + state.portraitRotation = this.portraitRotation; + state.landscapeRotation = this.landscapeRotation; + state.bitsPerPixel = this.bitsPerPixel; + state.colorImages = this.colorImages; + state.resolution = this.resolution; + return state; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPState{" + "portraitRotation=" + portraitRotation + + ", landscapeRotation=" + landscapeRotation + + ", colorImages=" + colorImages + + ", bitsPerPixel=" + bitsPerPixel + + ", resolution=" + resolution + + ", pageState=" + pageState + + super.toString() + + "}"; + } + + /** + * Page level state data + */ + private class AFPPageState implements Cloneable { + /** page width */ + private int width = 0; + + /** page height */ + private int height = 0; + + /** page fonts */ + private AFPPageFonts fonts = new AFPPageFonts(); + + /** page font count */ + private int fontCount = 0; + + /** page orientation */ + private int orientation = 0; + + /** + * Returns the page width + * + * @return the page width + */ + protected int getWidth() { + return width; + } + + /** + * Sets the page width + * + * @param width the page width + */ + protected void setWidth(int width) { + this.width = width; + } + + /** + * Returns the page height + * + * @return the page height + */ + protected int getHeight() { + return height; + } + + /** + * Sets the page height + * + * @param height the page height + */ + protected void setHeight(int height) { + this.height = height; + } + + /** + * Returns the page fonts + * + * @return the page fonts + */ + protected AFPPageFonts getFonts() { + return fonts; + } + + /** + * Sets the current page fonts + * + * @param fonts the current page fonts + */ + protected void setFonts(AFPPageFonts fonts) { + this.fonts = fonts; + } + + /** + * Increments and returns the current page font count + * + * @return increment and return the current page font count + */ + protected int incrementFontCount() { + return ++fontCount; + } + + /** + * Returns the current page orientation + * + * @return the current page orientation + */ + protected int getOrientation() { + return orientation; + } + + /** + * Sets the current page orientation + * + * @param orientation the current page orientation + */ + protected void setOrientation(int orientation) { + this.orientation = orientation; + } + + /** {@inheritDoc} */ + public Object clone() { + AFPPageState state = new AFPPageState(); + state.width = this.width; + state.height = this.height; + state.orientation = this.orientation; + state.fonts = new AFPPageFonts(this.fonts); + state.fontCount = this.fontCount; + return state; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPPageState{width=" + width + + ", height=" + height + + ", orientation=" + orientation + + ", fonts=" + fonts + + ", fontCount=" + fontCount + + "}"; + } + } + + /** + * Block level state data + */ + private class AFPData extends org.apache.fop.AbstractState.AbstractData { + private static final long serialVersionUID = -1789481244175275686L; + + /** The current fill status */ + private boolean filled = false; + + private String imageUri = null; + + /** {@inheritDoc} */ + public Object clone() { + AFPData obj = (AFPData)super.clone(); + obj.filled = this.filled; + obj.imageUri = this.imageUri; + return obj; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPData{" + super.toString() + + ", filled=" + filled + + ", imageUri=" + imageUri + + "}"; + } + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java new file mode 100644 index 000000000..42dcf4412 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPStreamer.java @@ -0,0 +1,216 @@ +/* + * 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.afp; + +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.io.RandomAccessFile; +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.modca.DataStream; +import org.apache.fop.afp.modca.ResourceGroup; +import org.apache.fop.afp.modca.StreamedResourceGroup; + +/** + * Manages the streaming of the AFP output + */ +public class AFPStreamer implements Streamable { + /** Static logging instance */ + private static final Log log = LogFactory.getLog(AFPStreamer.class); + + private static final String AFPDATASTREAM_TEMP_FILE_PREFIX = "AFPDataStream_"; + + private static final int BUFFER_SIZE = 4096; + + private static final String DEFAULT_EXTERNAL_RESOURCE_FILENAME = "resources.afp"; + + + private final Factory factory; + + /** A mapping of external resource destinations to resource groups */ + private final Map/**/pathResourceGroupMap + = new java.util.HashMap/**/(); + + private StreamedResourceGroup printFileResourceGroup; + + /** Sets the default resource group file path */ + private String defaultResourceGroupFilePath = DEFAULT_EXTERNAL_RESOURCE_FILENAME; + + private File tempFile; + + /** temporary document outputstream */ + private OutputStream documentOutputStream; + + /** the final outputstream */ + private OutputStream outputStream; + + private RandomAccessFile documentFile; + + private DataStream dataStream; + + /** + * Main constructor + * + * @param factory a factory + */ + public AFPStreamer(Factory factory) { + this.factory = factory; + } + + /** + * Creates a new DataStream + * @param state the afp state + * + * @return a new {@link DataStream} + */ + public DataStream createDataStream(AFPState state) { + try { + this.tempFile = File.createTempFile(AFPDATASTREAM_TEMP_FILE_PREFIX, null); + this.documentFile = new RandomAccessFile(tempFile, "rw"); + this.documentOutputStream = new BufferedOutputStream( + new FileOutputStream(documentFile.getFD())); + this.dataStream = factory.createDataStream(state, documentOutputStream); + } catch (IOException e) { + log.error(e.getMessage()); + } + return dataStream; + } + + /** + * Sets the default resource group file path + * + * @param filePath the default resource group file path + */ + public void setDefaultResourceGroupFilePath(String filePath) { + this.defaultResourceGroupFilePath = filePath; + } + + /** + * Returns the resource group for a given resource info + * + * @param level a resource level + * @return a resource group for the given resource info + */ + public ResourceGroup getResourceGroup(AFPResourceLevel level) { + ResourceGroup resourceGroup = null; + if (level.isInline()) { // no resource group for inline level + return null; + } + if (level.isExternal()) { + String filePath = level.getExternalFilePath(); + if (filePath == null) { + log.warn("No file path provided for external resource, using default."); + filePath = defaultResourceGroupFilePath; + } + resourceGroup = (ResourceGroup)pathResourceGroupMap.get(filePath); + if (resourceGroup == null) { + OutputStream os = null; + try { + os = new BufferedOutputStream(new FileOutputStream(filePath)); + } catch (FileNotFoundException fnfe) { + log.error("Failed to create/open external resource group file '" + + filePath + "'"); + } finally { + if (os != null) { + resourceGroup = factory.createStreamedResourceGroup(os); + pathResourceGroupMap.put(filePath, resourceGroup); + } + } + } + } else if (level.isPrintFile()) { + if (printFileResourceGroup == null) { + // use final outputstream for print-file resource group + printFileResourceGroup = factory.createStreamedResourceGroup(outputStream); + } + resourceGroup = printFileResourceGroup; + } else { + // resource group in afp document datastream + resourceGroup = dataStream.getResourceGroup(level); + } + return resourceGroup; + } + + /** + * Closes off the AFP stream writing the document stream + * + * @throws IOException if an an I/O exception of some sort has occurred + */ + public void close() throws IOException { + // write out any external resource groups + Iterator it = pathResourceGroupMap.entrySet().iterator(); + while (it.hasNext()) { + StreamedResourceGroup resourceGroup = (StreamedResourceGroup)it.next(); + resourceGroup.close(); + } + + // close any open print-file resource group + if (printFileResourceGroup != null) { + printFileResourceGroup.close(); + } + + // write out document + writeToStream(outputStream); + + outputStream.close(); + + // delete temporary file + tempFile.delete(); + } + + /** + * Sets the final outputstream + * + * @param outputStream an outputstream + */ + public void setOutputStream(OutputStream outputStream) { + this.outputStream = outputStream; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + int len = (int)documentFile.length(); + int numChunks = len / BUFFER_SIZE; + int remainingChunkSize = len % BUFFER_SIZE; + byte[] buffer; + + documentFile.seek(0); + if (numChunks > 0) { + buffer = new byte[BUFFER_SIZE]; + for (int i = 0; i < numChunks; i++) { + documentFile.read(buffer, 0, BUFFER_SIZE); + os.write(buffer, 0, BUFFER_SIZE); + } + } else { + buffer = new byte[remainingChunkSize]; + } + if (remainingChunkSize > 0) { + documentFile.read(buffer, 0, remainingChunkSize); + os.write(buffer, 0, remainingChunkSize); + } + os.flush(); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPTextDataInfo.java b/src/java/org/apache/fop/afp/AFPTextDataInfo.java new file mode 100644 index 000000000..3e87fc473 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPTextDataInfo.java @@ -0,0 +1,202 @@ +/* + * 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.afp; + +import java.awt.Color; + +/** + * Text data information + */ +public class AFPTextDataInfo { + + private int fontReference; + + private int x; + + private int y; + + private Color color; + + private int variableSpaceCharacterIncrement; + + private int interCharacterAdjustment; + + private byte[] data; + + private int rotation; + + /** + * Returns the font reference + * + * @return the font reference + */ + public int getFontReference() { + return fontReference; + } + + /** + * Sets the font reference + * + * @param fontReference the font reference + */ + public void setFontReference(int fontReference) { + this.fontReference = fontReference; + } + + /** + * Returns the x coordinate + * + * @return the x coordinate + */ + public int getX() { + return x; + } + + /** + * Sets the X coordinate + * + * @param x the X coordinate + */ + public void setX(int x) { + this.x = x; + } + + /** + * Returns the y coordinate + * + * @return the y coordinate + */ + public int getY() { + return y; + } + + /** + * Sets the Y coordinate + * + * @param y the Y coordinate + */ + public void setY(int y) { + this.y = y; + } + + /** + * Returns the color + * + * @return the color + */ + public Color getColor() { + return color; + } + + /** + * Sets the color + * + * @param color the color + */ + public void setColor(Color color) { + this.color = color; + } + + /** + * Return the variable space character increment + * + * @return the variable space character increment + */ + public int getVariableSpaceCharacterIncrement() { + return variableSpaceCharacterIncrement; + } + + /** + * Sets the variable space character increment + * + * @param variableSpaceCharacterIncrement the variable space character increment + */ + public void setVariableSpaceCharacterIncrement( + int variableSpaceCharacterIncrement) { + this.variableSpaceCharacterIncrement = variableSpaceCharacterIncrement; + } + + /** + * Return the inter character adjustment + * + * @return the inter character adjustment + */ + public int getInterCharacterAdjustment() { + return interCharacterAdjustment; + } + + /** + * Sets the inter character adjustment + * + * @param interCharacterAdjustment the inter character adjustment + */ + public void setInterCharacterAdjustment(int interCharacterAdjustment) { + this.interCharacterAdjustment = interCharacterAdjustment; + } + + /** + * Return the text data + * + * @return the text data + */ + public byte[] getData() { + return data; + } + + /** + * Sets the text data + * + * @param data the text orientation + */ + public void setData(byte[] data) { + this.data = data; + } + + /** + * Sets the text orientation + * + * @param rotation the text rotation + */ + public void setRotation(int rotation) { + this.rotation = rotation; + } + + /** + * Returns the text rotation + * + * @return the text rotation + */ + public int getRotation() { + return this.rotation; + } + + /** {@inheritDoc} */ + public String toString() { + return "TextDataInfo{fontReference=" + fontReference + + ", x=" + x + + ", y=" + y + + ", color=" + color + + ", vsci=" + variableSpaceCharacterIncrement + + ", ica=" + interCharacterAdjustment + + ", orientation=" + rotation + + ", data=" + data + + "}"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPTextHandler.java b/src/java/org/apache/fop/afp/AFPTextHandler.java new file mode 100644 index 000000000..3dee6ca2e --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPTextHandler.java @@ -0,0 +1,104 @@ +/* + * 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.afp; + +import java.awt.Color; +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.fonts.AFPFont; +import org.apache.fop.afp.fonts.AFPFontAttributes; +import org.apache.fop.afp.modca.GraphicsObject; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontInfo; +import org.apache.xmlgraphics.java2d.TextHandler; + +/** + * Specialized TextHandler implementation that the AFPGraphics2D class delegates to to paint text + * using AFP GOCA text operations. + */ +public class AFPTextHandler implements TextHandler { + + /** logging instance */ + private static Log log = LogFactory.getLog(AFPTextHandler.class); + + private AFPGraphics2D g2d = null; + + /** Overriding FontState */ + protected Font overrideFont = null; + + /** + * Main constructor. + * @param g2d the PSGraphics2D instance this instances is used by + */ + public AFPTextHandler(AFPGraphics2D g2d) { + this.g2d = g2d; + } + + /** + * Return the font information associated with this object + * @return the FontInfo object + */ + public FontInfo getFontInfo() { + return g2d.getFontInfo(); + } + + /** + * Add a text string to the current data object of the AFP datastream. + * The text is painted using text operations. + * {@inheritDoc} + */ + public void drawString(String str, float x, float y) throws IOException { + log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y); + GraphicsObject graphicsObj = g2d.getGraphicsObject(); + Color col = g2d.getColor(); + + AFPState state = g2d.getState(); + if (state.setColor(col)) { + graphicsObj.setColor(col); + } + if (overrideFont != null) { + FontInfo fontInfo = getFontInfo(); + AFPPageFonts pageFonts = state.getPageFonts(); + String internalFontName = overrideFont.getFontName(); + int fontSize = overrideFont.getFontSize(); + if (state.setFontName(internalFontName) || state.setFontSize(fontSize)) { + AFPFont font = (AFPFont)fontInfo.getFonts().get(internalFontName); + AFPFontAttributes afpFontAttributes = pageFonts.registerFont( + internalFontName, + font, + fontSize + ); + int fontReference = afpFontAttributes.getFontReference(); + graphicsObj.setCharacterSet(fontReference); + } + } + graphicsObj.addString(str, Math.round(x), Math.round(y)); + } + + /** + * Sets the overriding font. + * @param overrideFont Overriding Font to set + */ + public void setOverrideFont(Font overrideFont) { + this.overrideFont = overrideFont; + } +} diff --git a/src/java/org/apache/fop/afp/AFPUnitConverter.java b/src/java/org/apache/fop/afp/AFPUnitConverter.java new file mode 100644 index 000000000..69282fc18 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPUnitConverter.java @@ -0,0 +1,121 @@ +/* + * 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.afp; + +import java.awt.geom.AffineTransform; + + + +/** + * AFP Unit converter + */ +public class AFPUnitConverter { + + /** the AFP state */ + private final AFPState state; + + /** + * Unit converter + * + * @param state the AFP state + */ + public AFPUnitConverter(AFPState state) { + this.state = state; + } + + /** + * Converts millipoints to units + * + * @param srcPts source points + * @param dstPts destination points + * @return transformed points + */ + public int[] mpts2units(float[] srcPts, float[] dstPts) { + return transformPoints(srcPts, dstPts, true); + } + + /** + * Converts points to units + * + * @param srcPts source points + * @param dstPts destination points + * @return transformed points + */ + public int[] pts2units(float[] srcPts, float[] dstPts) { + return transformPoints(srcPts, dstPts, false); + } + + /** + * Converts millipoints to units + * + * @param srcPts source points + * @return transformed points + */ + public int[] mpts2units(float[] srcPts) { + return transformPoints(srcPts, null, true); + } + + /** + * Converts points to units + * + * @param srcPts source points + * @return transformed points + */ + public int[] pts2units(float[] srcPts) { + return transformPoints(srcPts, null, false); + } + + /** + * Converts point to unit + * + * @param pt point + * @return transformed point + */ + public float pt2units(float pt) { + return pt / ((float)AFPConstants.DPI_72 / state.getResolution()); + } + + /** + * Converts millipoint to unit + * + * @param mpt millipoint + * @return transformed point + */ + public float mpt2units(float mpt) { + return mpt / ((float)AFPConstants.DPI_72_MPTS / state.getResolution()); + } + + private int[] transformPoints(float[] srcPts, float[] dstPts, boolean milli) { + if (dstPts == null) { + dstPts = new float[srcPts.length]; + } + AffineTransform at = state.getData().getTransform(); + at.transform(srcPts, 0, dstPts, 0, srcPts.length / 2); + int[] coords = new int[srcPts.length]; + for (int i = 0; i < srcPts.length; i++) { + if (!milli) { + dstPts[i] *= 1000; + } + coords[i] = Math.round(dstPts[i]); + } + return coords; + } + +} diff --git a/src/java/org/apache/fop/afp/AbstractAFPPainter.java b/src/java/org/apache/fop/afp/AbstractAFPPainter.java new file mode 100644 index 000000000..ba6d49fc6 --- /dev/null +++ b/src/java/org/apache/fop/afp/AbstractAFPPainter.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.afp; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.modca.DataStream; + +public abstract class AbstractAFPPainter { + + /** Static logging instance */ + protected static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); + + protected final DataStream dataStream; + protected final AFPState state; + + /** + * Main constructor + * + * @param state the afp state + * @param dataStream the afp datastream + */ + public AbstractAFPPainter(AFPState state, DataStream dataStream) { + this.state = state; + this.dataStream = dataStream; + } + + /** + * Paints the painting item + * + * @param paintInfo the painting information + */ + public abstract void paint(PaintInfo paintInfo); +} diff --git a/src/java/org/apache/fop/afp/BorderPaintInfo.java b/src/java/org/apache/fop/afp/BorderPaintInfo.java new file mode 100644 index 000000000..74252b7b9 --- /dev/null +++ b/src/java/org/apache/fop/afp/BorderPaintInfo.java @@ -0,0 +1,121 @@ +/* + * 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.afp; + +import java.awt.Color; + + +/** + * Border painting information + */ +public class BorderPaintInfo implements PaintInfo { + private final float x1; + private final float y1; + private final float x2; + private final float y2; + private final boolean isHorizontal; + private final int style; + private final Color color; + + /** + * Main constructor + * + * @param x1 the x1 coordinate + * @param y1 the y1 coordinate + * @param x2 the x2 coordinate + * @param y2 the y2 coordinate + * @param isHorizontal true when the border line is horizontal + * @param style the border style + * @param color the border color + */ + public BorderPaintInfo(float x1, float y1, float x2, float y2, + boolean isHorizontal, int style, Color color) { + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + this.isHorizontal = isHorizontal; + this.style = style; + this.color = color; + } + + /** + * Returns the x1 coordinate + * + * @return the x1 coordinate + */ + public float getX1() { + return x1; + } + + /** + * Returns the y1 coordinate + * + * @return the y1 coordinate + */ + public float getY1() { + return y1; + } + + /** + * Returns the x2 coordinate + * + * @return the x2 coordinate + */ + public float getX2() { + return x2; + } + + /** + * Returns the y2 coordinate + * + * @return the y2 coordinate + */ + public float getY2() { + return y2; + } + + /** + * Returns true when this is a horizontal line + * + * @return true when this is a horizontal line + */ + public boolean isHorizontal() { + return isHorizontal; + } + + /** + * Returns the style + * + * @return the style + */ + public int getStyle() { + return style; + } + + /** + * Returns the color + * + * @return the color + */ + public Color getColor() { + return color; + } +} diff --git a/src/java/org/apache/fop/afp/Factory.java b/src/java/org/apache/fop/afp/Factory.java new file mode 100644 index 000000000..840d7b4e8 --- /dev/null +++ b/src/java/org/apache/fop/afp/Factory.java @@ -0,0 +1,636 @@ +/* + * 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.afp; + +import java.io.OutputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.goca.GraphicsData; +import org.apache.fop.afp.ioca.ImageContent; +import org.apache.fop.afp.ioca.ImageRasterData; +import org.apache.fop.afp.ioca.ImageSegment; +import org.apache.fop.afp.ioca.ImageSizeParameter; +import org.apache.fop.afp.modca.ActiveEnvironmentGroup; +import org.apache.fop.afp.modca.ContainerDataDescriptor; +import org.apache.fop.afp.modca.DataStream; +import org.apache.fop.afp.modca.Document; +import org.apache.fop.afp.modca.GraphicsDataDescriptor; +import org.apache.fop.afp.modca.GraphicsObject; +import org.apache.fop.afp.modca.IMImageObject; +import org.apache.fop.afp.modca.ImageDataDescriptor; +import org.apache.fop.afp.modca.ImageObject; +import org.apache.fop.afp.modca.IncludeObject; +import org.apache.fop.afp.modca.IncludePageSegment; +import org.apache.fop.afp.modca.InvokeMediumMap; +import org.apache.fop.afp.modca.MapCodedFont; +import org.apache.fop.afp.modca.MapContainerData; +import org.apache.fop.afp.modca.MapDataResource; +import org.apache.fop.afp.modca.ObjectAreaDescriptor; +import org.apache.fop.afp.modca.ObjectAreaPosition; +import org.apache.fop.afp.modca.ObjectContainer; +import org.apache.fop.afp.modca.ObjectEnvironmentGroup; +import org.apache.fop.afp.modca.Overlay; +import org.apache.fop.afp.modca.PageDescriptor; +import org.apache.fop.afp.modca.PageGroup; +import org.apache.fop.afp.modca.PageObject; +import org.apache.fop.afp.modca.PresentationEnvironmentControl; +import org.apache.fop.afp.modca.PresentationTextDescriptor; +import org.apache.fop.afp.modca.PresentationTextObject; +import org.apache.fop.afp.modca.ResourceEnvironmentGroup; +import org.apache.fop.afp.modca.ResourceGroup; +import org.apache.fop.afp.modca.ResourceObject; +import org.apache.fop.afp.modca.StreamedResourceGroup; +import org.apache.fop.afp.modca.TagLogicalElement; +import org.apache.fop.afp.util.StringUtils; + +/** + * Creator of MO:DCA data objects (mostly) + */ +public class Factory { + + /** Static logging instance */ + private static final Log log = LogFactory.getLog(Factory.class); + + private static final String OBJECT_ENVIRONMENT_GROUP_NAME_PREFIX = "OEG"; + + private static final String ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX = "AEG"; + + private static final String IMAGE_NAME_PREFIX = "IMG"; + + private static final String GRAPHIC_NAME_PREFIX = "GRA"; + + private static final String BARCODE_NAME_PREFIX = "BAR"; + +// private static final String OTHER_NAME_PREFIX = "OTH"; + + private static final String OBJECT_CONTAINER_NAME_PREFIX = "OC"; + + private static final String RESOURCE_NAME_PREFIX = "RES"; + + private static final String RESOURCE_GROUP_NAME_PREFIX = "RG"; + + private static final String PAGE_GROUP_NAME_PREFIX = "PGP"; + + private static final String PAGE_NAME_PREFIX = "PGN"; + + private static final String OVERLAY_NAME_PREFIX = "OVL"; + + private static final String PRESENTATION_TEXT_NAME_PREFIX = "PT"; + + private static final String DOCUMENT_NAME_PREFIX = "DOC"; + + private static final String IM_IMAGE_NAME_PREFIX = "IMIMG"; + + private static final String IMAGE_SEGMENT_NAME_PREFIX = "IS"; + + + /** the page group count */ + private int pageGroupCount = 0; + + /** the page count */ + private int pageCount = 0; + + /** the image count */ + private int imageCount = 0; + + /** the im image count */ + private int imImageCount = 0; + + /** the image segment count */ + private int imageSegmentCount = 0; + + /** the graphic count */ + private int graphicCount = 0; + + /** the object container count */ + private int objectContainerCount = 0; + + /** the resource count */ + private int resourceCount = 0; + + /** the resource group count */ + private int resourceGroupCount = 0; + + /** the overlay count */ + private int overlayCount = 0; + + /** the presentation text object count */ + private int textObjectCount = 0; + + /** the active environment group count */ + private int activeEnvironmentGroupCount = 0; + + /** the document count */ + private int documentCount = 0; + + /** the object environment group count */ + private int objectEnvironmentGroupCount = 0; + + /** + * Main constructor + */ + public Factory() { + } + + /** + * Creates a new IOCA {@link ImageObject} + * + * @return a new {@link ImageObject} + */ + public ImageObject createImageObject() { + String name = IMAGE_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++imageCount), '0', 5); + ImageObject imageObject = new ImageObject(this, name); + return imageObject; + } + + /** + * Creates an IOCA {@link IMImageObject} + * + * @return a new {@link IMImageObject} + */ + public IMImageObject createIMImageObject() { + String name = IM_IMAGE_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++imImageCount), '0', 3); + IMImageObject imImageObject = new IMImageObject(name); + return imImageObject; + } + + /** + * Creates a new GOCA {@link GraphicsObject} + * + * @return a new {@link GraphicsObject} + */ + public GraphicsObject createGraphicsObject() { + String name = GRAPHIC_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++graphicCount), '0', 5); + GraphicsObject graphicsObj = new GraphicsObject(this, name); + return graphicsObj; + } + + /** + * Creates a new MO:DCA {@link ObjectContainer} + * + * @return a new {@link ObjectContainer} + */ + public ObjectContainer createObjectContainer() { + String name = OBJECT_CONTAINER_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++objectContainerCount), '0', 6); + return new ObjectContainer(this, name); + } + + /** + * Creates a new MO:DCA {@link ResourceObject} + * + * @param resourceName the resource object name + * @return a new {@link ResourceObject} + */ + public ResourceObject createResource(String resourceName) { + return new ResourceObject(resourceName); + } + + /** + * Creates a new MO:DCA {@link ResourceObject} + * + * @return a new {@link ResourceObject} + */ + public ResourceObject createResource() { + String name = RESOURCE_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++resourceCount), '0', 5); + return createResource(name); + } + + /** + * Creates a new MO:DCA {@link PageGroup} + * + * @return a new {@link PageGroup} + */ + public PageGroup createPageGroup() { + String name = PAGE_GROUP_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++pageGroupCount), '0', 5); + return new PageGroup(this, name); + } + + /** + * Creates a new MO:DCA {@link ActiveEnvironmentGroup} + * + * @param width the page width + * @param height the page height + * @param widthRes the page width resolution + * @param heightRes the page height resolution + * @return a new {@link ActiveEnvironmentGroup} + */ + public ActiveEnvironmentGroup createActiveEnvironmentGroup( + int width, int height, int widthRes, int heightRes) { + String name = ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++activeEnvironmentGroupCount ), '0', 5); + return new ActiveEnvironmentGroup(this, name, width, height, widthRes, heightRes); + } + + /** + * Creates a new MO:DCA {@link ResourceGroup} + * + * @return a new {@link ResourceGroup} + */ + public ResourceGroup createResourceGroup() { + String name = RESOURCE_GROUP_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++resourceGroupCount), '0', 6); + return new ResourceGroup(name); + } + + /** + * Creates a new MO:DCA {@link StreamedResourceGroup} + * + * @param os the outputstream of the streamed resource group + * @return a new {@link StreamedResourceGroup} + */ + public StreamedResourceGroup createStreamedResourceGroup(OutputStream os) { + String name = RESOURCE_GROUP_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++resourceGroupCount), '0', 6); + return new StreamedResourceGroup(name, os); + } + + /** + * Creates a new MO:DCA {@link PageObject}. + * + * @param pageWidth + * the width of the page + * @param pageHeight + * the height of the page + * @param pageRotation + * the rotation of the page + * @param pageWidthRes + * the width resolution of the page + * @param pageHeightRes + * the height resolution of the page + * + * @return a new {@link PageObject} + */ + public PageObject createPage(int pageWidth, int pageHeight, int pageRotation, + int pageWidthRes, int pageHeightRes) { + String pageName = PAGE_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++pageCount), '0', 5); + return new PageObject(this, pageName, pageWidth, pageHeight, + pageRotation, pageWidthRes, pageHeightRes); + } + + + /** + * Creates a new MO:DCA {@link PresentationTextObject}. + * + * @return a new {@link PresentationTextObject} + */ + public PresentationTextObject createPresentationTextObject() { + String textObjectName = PRESENTATION_TEXT_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++textObjectCount), '0', 6); + return new PresentationTextObject(textObjectName); + } + + + /** + * Creates a new MO:DCA {@link Overlay}. + * + * @param width + * the width of the overlay + * @param height + * the height of the overlay + * @param widthRes + * the width resolution of the overlay + * @param heightRes + * the height resolution of the overlay + * @param overlayRotation + * the rotation of the overlay + * + * @return a new {@link Overlay}. + */ + public Overlay createOverlay(int width, int height, + int widthRes, int heightRes, int overlayRotation) { + String overlayName = OVERLAY_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++overlayCount), '0', 5); + Overlay overlay = new Overlay(this, overlayName, width, height, + overlayRotation, widthRes, heightRes); + return overlay; + } + + /** + * Creates a MO:DCA {@link Document} + * + * @return a new {@link Document} + */ + public Document createDocument() { + String documentName = DOCUMENT_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++documentCount), '0', 5); + Document document = new Document(this, documentName); + return document; + } + + /** + * Creates a MO:DCA {@link MapCodedFont} + * + * @return a new {@link MapCodedFont} + */ + public MapCodedFont createMapCodedFont() { + MapCodedFont mapCodedFont = new MapCodedFont(); + return mapCodedFont; + } + + /** + * Creates a MO:DCA {@link IncludePageSegment} + * + * @param name the page segment name + * @param x the x coordinate + * @param y the y coordinate + * + * @return a new {@link IncludePageSegment} + */ + public IncludePageSegment createIncludePageSegment(String name, int x, int y) { + IncludePageSegment includePageSegment = new IncludePageSegment(name, x, y); + return includePageSegment; + } + + /** + * Creates a MO:DCA {@link IncludeObject} + * + * @param name the name of this include object + * @return a new {@link IncludeObject} + */ + public IncludeObject createInclude(String name) { + IncludeObject includeObject = new IncludeObject(name); + return includeObject; + } + + /** + * Creates a MO:DCA {@link TagLogicalElement} + * + * @param name name of the element + * @param value value of the element + * @return a new {@link TagLogicalElement} + */ + public TagLogicalElement createTagLogicalElement(String name, String value) { + TagLogicalElement tle = new TagLogicalElement(name, value); + return tle; + } + + /** + * Creates a new {@link DataStream} + * + * @param state the afp state + * @param outputStream an outputstream to write to + * @return a new {@link DataStream} + */ + public DataStream createDataStream(AFPState state, OutputStream outputStream) { + DataStream dataStream = new DataStream(this, state, outputStream); + return dataStream; + } + + /** + * Creates a new MO:DCA {@link PageDescriptor} + * + * @param width the page width. + * @param height the page height. + * @param widthRes the page width resolution. + * @param heightRes the page height resolution. + * @return a new {@link PageDescriptor} + */ + public PageDescriptor createPageDescriptor(int width, int height, int widthRes, int heightRes) { + PageDescriptor pageDescriptor = new PageDescriptor(width, height, widthRes, heightRes); + return pageDescriptor; + } + + /** + * Returns a new MO:DCA {@link ObjectEnvironmentGroup} + * + * @return a new {@link ObjectEnvironmentGroup} + */ + public ObjectEnvironmentGroup createObjectEnvironmentGroup() { + String oegName = OBJECT_ENVIRONMENT_GROUP_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++objectEnvironmentGroupCount), '0', 5); + ObjectEnvironmentGroup objectEnvironmentGroup = new ObjectEnvironmentGroup(oegName); + return objectEnvironmentGroup; + } + + /** + * Creates a new GOCA {@link GraphicsData} + * + * @return a new {@link GraphicsData} + */ + public GraphicsData createGraphicsData() { + GraphicsData graphicsData = new GraphicsData(); + return graphicsData; + } + + /** + * Creates a new {@link ObjectAreaDescriptor} + * + * @param width the object width. + * @param height the object height. + * @param widthRes the object width resolution. + * @param heightRes the object height resolution. + * @return a new {@link ObjectAreaDescriptor} + */ + public ObjectAreaDescriptor createObjectAreaDescriptor( + int width, int height, int widthRes, int heightRes) { + ObjectAreaDescriptor objectAreaDescriptor + = new ObjectAreaDescriptor(width, height, widthRes, heightRes); + return objectAreaDescriptor; + } + + /** + * Creates a new {@link ObjectAreaPosition} + * + * @param x the x coordinate. + * @param y the y coordinate. + * @param rotation the coordinate system rotation (must be 0, 90, 180, 270). + * @return a new {@link ObjectAreaPosition} + */ + public ObjectAreaPosition createObjectAreaPosition(int x, int y, + int rotation) { + ObjectAreaPosition objectAreaPosition = new ObjectAreaPosition( + x, y, rotation); + return objectAreaPosition; + } + + /** + * Creates a new {@link ImageDataDescriptor} + * + * @param width the image width + * @param height the image height + * @param widthRes the x resolution of the image + * @param heightRes the y resolution of the image + * @return a new {@link ImageDataDescriptor} + */ + public ImageDataDescriptor createImageDataDescriptor( + int width, int height, int widthRes, int heightRes) { + ImageDataDescriptor imageDataDescriptor = new ImageDataDescriptor( + width, height, widthRes, heightRes); + return imageDataDescriptor; + } + + /** + * Creates a new GOCA {@link GraphicsDataDescriptor} + * + * @param xlwind the left edge of the graphics window + * @param xrwind the right edge of the graphics window + * @param ybwind the top edge of the graphics window + * @param ytwind the bottom edge of the graphics window + * @param widthRes the x resolution of the graphics window + * @param heightRes the y resolution of the graphics window + * @return a new {@link GraphicsDataDescriptor} + */ + public GraphicsDataDescriptor createGraphicsDataDescriptor( + int xlwind, int xrwind, int ybwind, int ytwind, int widthRes, int heightRes) { + GraphicsDataDescriptor graphicsDataDescriptor = new GraphicsDataDescriptor( + xlwind, xrwind, ybwind, ytwind, widthRes, heightRes); + return graphicsDataDescriptor; + } + + /** + * Creates a new MO:DCA {@link ContainerDataDescriptor} + * + * @param dataWidth the container data width + * @param dataHeight the container data height + * @param widthRes the container data width resolution + * @param heightRes the container data height resolution + * @return a new {@link ContainerDataDescriptor} + */ + public ContainerDataDescriptor createContainerDataDescriptor( + int dataWidth, int dataHeight, int widthRes, int heightRes) { + ContainerDataDescriptor containerDataDescriptor + = new ContainerDataDescriptor(dataWidth, dataHeight, widthRes, heightRes); + return containerDataDescriptor; + } + + /** + * Creates a new MO:DCA {@link MapContainerData} + * + * @param optionValue the option value + * @return a new {@link MapContainerData} + */ + public MapContainerData createMapContainerData(byte optionValue) { + MapContainerData mapContainerData = new MapContainerData(optionValue); + return mapContainerData; + } + + /** + * Creates a new MO:DCA {@link MapDataResource} + * + * @return a new {@link MapDataResource} + */ + public MapDataResource createMapDataResource() { + MapDataResource mapDataResource = new MapDataResource(); + return mapDataResource; + } + + /** + * Creates a new PTOCA {@link PresentationTextDescriptor} + * + * @return a new {@link PresentationTextDescriptor} + */ + public PresentationTextDescriptor createPresentationTextDataDescriptor( + int width, int height, int widthRes, int heightRes) { + PresentationTextDescriptor presentationTextDescriptor + = new PresentationTextDescriptor(width, height, + widthRes, heightRes); + return presentationTextDescriptor; + } + + /** + * Creates a new MO:DCA {@link PresentationEnvironmentControl} + * + * @return a new {@link PresentationEnvironmentControl} + */ + public PresentationEnvironmentControl createPresentationEnvironmentControl() { + PresentationEnvironmentControl presentationEnvironmentControl + = new PresentationEnvironmentControl(); + return presentationEnvironmentControl; + } + + /** + * Creates a new MO:DCA {@link InvokeMediumMap} + * + * @param name the object name + * @return a new {@link InvokeMediumMap} + */ + public InvokeMediumMap createInvokeMediumMap(String name) { + InvokeMediumMap invokeMediumMap = new InvokeMediumMap(name); + return invokeMediumMap; + } + + /** + * Creates a new MO:DCA {@link ResourceEnvironmentGroup} + * + * @return a new {@link ResourceEnvironmentGroup} + */ + public ResourceEnvironmentGroup createResourceEnvironmentGroup() { + ResourceEnvironmentGroup resourceEnvironmentGroup = new ResourceEnvironmentGroup(); + return resourceEnvironmentGroup; + } + + /** + * Creates a new IOCA {@link ImageSegment} + * + * @return a new {@link ImageSegment} + */ + public ImageSegment createImageSegment() { + String name = IMAGE_SEGMENT_NAME_PREFIX + + StringUtils.lpad(String.valueOf(++imageSegmentCount), '0', 2); + ImageSegment imageSegment = new ImageSegment(this, name); + return imageSegment; + } + + /** + * Creates an new IOCA {@link ImageContent} + * + * @return an {@link ImageContent} + */ + public ImageContent createImageContent() { + ImageContent imageContent = new ImageContent(); + return imageContent; + } + + /** + * Creates a new IOCA {@link ImageRasterData} + * + * @param rasterData raster data + * @return a new {@link ImageRasterData} + */ + public ImageRasterData createImageRasterData(byte[] rasterData) { + ImageRasterData imageRasterData = new ImageRasterData(rasterData); + return imageRasterData; + } + + /** + * Creates an new IOCA {@link ImageSizeParameter}. + * + * @param hsize The horizontal size of the image. + * @param vsize The vertical size of the image. + * @param hresol The horizontal resolution of the image. + * @param vresol The vertical resolution of the image. + * @return a new {@link ImageSizeParameter} + */ + public ImageSizeParameter createImageSizeParameter(int hsize, int vsize, + int hresol, int vresol) { + ImageSizeParameter imageSizeParameter + = new ImageSizeParameter(hsize, vsize, hresol, vresol); + return imageSizeParameter; + } + +} diff --git a/src/java/org/apache/fop/afp/PaintInfo.java b/src/java/org/apache/fop/afp/PaintInfo.java new file mode 100644 index 000000000..2b11d0e3e --- /dev/null +++ b/src/java/org/apache/fop/afp/PaintInfo.java @@ -0,0 +1,27 @@ +/* + * 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.afp; + +/** + * Generic painting information interface + */ +public interface PaintInfo { + +} diff --git a/src/java/org/apache/fop/afp/RectanglePaintInfo.java b/src/java/org/apache/fop/afp/RectanglePaintInfo.java new file mode 100644 index 000000000..f0fae0317 --- /dev/null +++ b/src/java/org/apache/fop/afp/RectanglePaintInfo.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.afp; + + +/** + * Filled rectangle painting information + */ +public class RectanglePaintInfo implements PaintInfo { + + private final float x; + private final float y; + private final float width; + private final float height; + + /** + * Main constructor + * + * @param x the x coordinate + * @param y the y coordinate + * @param width the width + * @param height the height + */ + public RectanglePaintInfo(float x, float y, float width, float height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + /** + * Returns the x coordinate + * + * @return the x coordinate + */ + protected float getX() { + return x; + } + + /** + * Returns the y coordinate + * + * @return the y coordinate + */ + protected float getY() { + return y; + } + + /** + * Returns the width + * + * @return the width + */ + protected float getWidth() { + return width; + } + + /** + * Returns the height + * + * @return the height + */ + protected float getHeight() { + return height; + } + +} diff --git a/src/java/org/apache/fop/afp/Streamable.java b/src/java/org/apache/fop/afp/Streamable.java new file mode 100644 index 000000000..cd731ab47 --- /dev/null +++ b/src/java/org/apache/fop/afp/Streamable.java @@ -0,0 +1,38 @@ +/* + * 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.afp; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * Implementing object is able to write to an OutputStream + */ +public interface Streamable { + + /** + * DataStream objects must implement the writeToStream() + * method to write its data to the given OutputStream + * + * @param os the outputsteam stream + * @throws java.io.IOException an I/O exception of some sort has occurred. + */ + void writeToStream(OutputStream os) throws IOException; +} diff --git a/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java b/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java new file mode 100644 index 000000000..c39bf5e1e --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java @@ -0,0 +1,157 @@ +/* + * 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.afp.fonts; + +import org.apache.fop.fonts.Base14Font; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontCollection; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.base14.Courier; +import org.apache.fop.fonts.base14.CourierBold; +import org.apache.fop.fonts.base14.CourierBoldOblique; +import org.apache.fop.fonts.base14.CourierOblique; +import org.apache.fop.fonts.base14.Helvetica; +import org.apache.fop.fonts.base14.HelveticaBold; +import org.apache.fop.fonts.base14.HelveticaOblique; +import org.apache.fop.fonts.base14.TimesBold; +import org.apache.fop.fonts.base14.TimesBoldItalic; +import org.apache.fop.fonts.base14.TimesItalic; +import org.apache.fop.fonts.base14.TimesRoman; + +/** + * Sets up a typical Base 12 font configuration for AFP + */ +public class AFPBase12FontCollection implements FontCollection { + + /** standard raster font sizes */ + private static final int[] RASTER_SIZES = {6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 30, 36}; + + /** standard raster font charset references */ + private static final String[] CHARSET_REF = { + "60", "70", "80", "90", "00", "A0", "B0", "D0", "F0", "H0", "J0", "N0", "T0", "Z0"}; + + private void addCharacterSet(RasterFont font, String charsetName, Base14Font base14) { + for (int i = 0; i < RASTER_SIZES.length; i++) { + int size = RASTER_SIZES[i]; + FopCharacterSet characterSet = new FopCharacterSet( + CharacterSet.DEFAULT_CODEPAGE, CharacterSet.DEFAULT_ENCODING, + charsetName + CHARSET_REF[i], size, base14); + font.addCharacterSet(size, characterSet); + } + } + + private int addFontProperties(FontInfo fontInfo, AFPFont font, + String[] names, String style, int weight, int num) { + String internalFontKey = "F" + num; + fontInfo.addMetrics(internalFontKey, font); + fontInfo.addFontProperties(internalFontKey, names, style, weight); + num++; + return num; + } + + /** {@inheritDoc} */ + public int setup(int start, FontInfo fontInfo) { + + /** + * Add the base 12 fonts (Helvetica, Times and Courier) + * + * Note: this default font configuration may not be available + * on your AFP environment. + */ + int num = start; + RasterFont font = null; + + /** standard font family reference names for Helvetica font */ + final String[] helveticaNames = {"Helvetica", "Arial", "sans-serif"}; + font = new RasterFont("Helvetica"); + addCharacterSet(font, "C0H200", new Helvetica()); + num = addFontProperties(fontInfo, font, helveticaNames, + Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, num); + + font = new RasterFont("Helvetica Italic"); + addCharacterSet(font, "C0H300", new HelveticaOblique()); + num = addFontProperties(fontInfo, font, helveticaNames, + Font.STYLE_ITALIC, Font.WEIGHT_NORMAL, num); + + font = new RasterFont("Helvetica (Semi) Bold"); + addCharacterSet(font, "C0H400", new HelveticaBold()); + num = addFontProperties(fontInfo, font, helveticaNames, + Font.STYLE_NORMAL, Font.WEIGHT_BOLD, num); + + font = new RasterFont("Helvetica Italic (Semi) Bold"); + addCharacterSet(font, "C0H500", new HelveticaOblique()); + num = addFontProperties(fontInfo, font, helveticaNames, + Font.STYLE_ITALIC, Font.WEIGHT_BOLD, num); + + + /** standard font family reference names for Times font */ + + /** any is treated as serif */ + final String[] timesNames = {"Times", "TimesRoman", "Times Roman", "Times-Roman", + "Times New Roman", "TimesNewRoman", "serif", "any"}; + + font = new RasterFont("Times Roman"); + addCharacterSet(font, "CON200", new TimesRoman()); + num = addFontProperties(fontInfo, font, timesNames, + Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, num); + + font = new RasterFont("Times Roman Italic"); + addCharacterSet(font, "CON300", new TimesItalic()); + num = addFontProperties(fontInfo, font, timesNames, + Font.STYLE_ITALIC, Font.WEIGHT_NORMAL, num); + + font = new RasterFont("Times Roman Bold"); + addCharacterSet(font, "CON400", new TimesBold()); + num = addFontProperties(fontInfo, font, timesNames, + Font.STYLE_NORMAL, Font.WEIGHT_BOLD, num); + + font = new RasterFont("Times Roman Italic Bold"); + addCharacterSet(font, "CON500", new TimesBoldItalic()); + num = addFontProperties(fontInfo, font, timesNames, + Font.STYLE_ITALIC, Font.WEIGHT_BOLD, num); + + + /** standard font family reference names for Courier font */ + final String[] courierNames = {"Courier", "monospace"}; + + font = new RasterFont("Courier"); + addCharacterSet(font, "C04200", new Courier()); + num = addFontProperties(fontInfo, font, courierNames, + Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, num); + + font = new RasterFont("Courier Italic"); + addCharacterSet(font, "C04300", new CourierOblique()); + num = addFontProperties(fontInfo, font, courierNames, + Font.STYLE_ITALIC, Font.WEIGHT_NORMAL, num); + + font = new RasterFont("Courier Bold"); + addCharacterSet(font, "C04400", new CourierBold()); + num = addFontProperties(fontInfo, font, courierNames, + Font.STYLE_NORMAL, Font.WEIGHT_BOLD, num); + + font = new RasterFont("Courier Italic Bold"); + addCharacterSet(font, "C04500", new CourierBoldOblique()); + num = addFontProperties(fontInfo, font, courierNames, + Font.STYLE_ITALIC, Font.WEIGHT_BOLD, num); + + return num; + } + +} diff --git a/src/java/org/apache/fop/afp/fonts/AFPFont.java b/src/java/org/apache/fop/afp/fonts/AFPFont.java new file mode 100644 index 000000000..dc8f9c315 --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/AFPFont.java @@ -0,0 +1,113 @@ +/* + * 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.afp.fonts; + +import java.util.Map; +import java.util.Set; + +import org.apache.fop.fonts.FontType; +import org.apache.fop.fonts.Typeface; + + +/** + * All implementations of AFP fonts should extend this base class, + * the object implements the FontMetrics information. + *

      + */ +public abstract class AFPFont extends Typeface { + + /** The font name */ + protected String name; + + /** + * Constructor for the base font requires the name. + * @param name the name of the font + */ + public AFPFont(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + public String getFontName() { + return this.name; + } + + /** {@inheritDoc} */ + public String getEmbedFontName() { + return this.name; + } + + /** {@inheritDoc} */ + public String getFullName() { + return getFontName(); + } + + /** {@inheritDoc} */ + public Set getFamilyNames() { + Set s = new java.util.HashSet(); + s.add(this.name); + return s; + } + + /** + * Returns the type of the font. + * @return the font type + */ + public FontType getFontType() { + return FontType.OTHER; + } + + /** + * Indicates if the font has kerning information. + * @return True, if kerning is available. + */ + public boolean hasKerningInfo() { + return false; + } + + /** + * Returns the kerning map for the font. + * @return the kerning map + */ + public Map getKerningInfo() { + return null; + } + + /** + * Returns the character set for a given size + * @param size the font size + * @return the character set object + */ + public abstract CharacterSet getCharacterSet(int size); + + /** + * Determines whether this font contains a particular character/glyph. + * @param c character to check + * @return True if the character is supported, False otherwise + */ + public boolean hasChar(char c) { + return true; + } + + /** {@inheritDoc} */ + public String toString() { + return "name=" + name; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/fonts/AFPFontAttributes.java b/src/java/org/apache/fop/afp/fonts/AFPFontAttributes.java new file mode 100644 index 000000000..1dd22c66a --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/AFPFontAttributes.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.afp.fonts; + +/** + * This class encapsulates the font attributes that need to be included + * in the AFP data stream. This class does not assist in converting the + * font attributes to AFP code pages and character set values. + * + */ +public class AFPFontAttributes { + + /** + * The font reference + */ + private int fontReference; + + /** + * The font key + */ + private final String fontKey; + + /** + * The font + */ + private final AFPFont font; + + /** + * The point size + */ + private final int pointSize; + + /** + * Constructor for the AFPFontAttributes + * @param fontKey the font key + * @param font the font + * @param pointSize the point size + */ + public AFPFontAttributes(String fontKey, AFPFont font, int pointSize) { + this.fontKey = fontKey; + this.font = font; + this.pointSize = pointSize; + } + + /** + * @return the font + */ + public AFPFont getFont() { + return font; + } + + /** + * @return the FontKey attribute + */ + public String getFontKey() { + return fontKey + pointSize; + } + + /** + * @return the point size attribute + */ + public int getPointSize() { + return pointSize; + } + + /** + * @return the FontReference attribute + */ + public int getFontReference() { + return fontReference; + } + + /** + * Sets the FontReference attribute + * @param fontReference the FontReference to set + */ + public void setFontReference(int fontReference) { + this.fontReference = fontReference; + } + + /** {@inheritDoc} */ + public String toString() { + return "fontReference=" + fontReference + + ", fontKey=" + fontKey + + ", font=" + font + + ", pointSize=" + pointSize; + } +} diff --git a/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java b/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java new file mode 100644 index 000000000..f7216eb11 --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/AFPFontCollection.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.afp.fonts; + +import java.util.Iterator; +import java.util.List; + +import org.apache.fop.events.EventBroadcaster; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontCollection; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontTriplet; +import org.apache.fop.render.afp.AFPEventProducer; + +/** + * A base collection of AFP fonts + */ +public class AFPFontCollection implements FontCollection { + + private final EventBroadcaster eventBroadcaster; + + private final List/**/ fontInfoList; + + /** + * Main constructor + * + * @param eventBroadcaster the event broadcaster + * @param fontInfoList the font info list + */ + public AFPFontCollection(EventBroadcaster eventBroadcaster, + List/**/ fontInfoList) { + this.eventBroadcaster = eventBroadcaster; + this.fontInfoList = fontInfoList; + } + + /** {@inheritDoc} */ + public int setup(int start, FontInfo fontInfo) { + int num = 1; + AFPEventProducer eventProducer = AFPEventProducer.Provider.get(eventBroadcaster); + if (fontInfoList != null && fontInfoList.size() > 0) { + for (Iterator it = fontInfoList.iterator(); it.hasNext();) { + AFPFontInfo afpFontInfo = (AFPFontInfo)it.next(); + AFPFont afpFont = afpFontInfo.getAFPFont(); + List/**/ tripletList = afpFontInfo.getFontTriplets(); + for (Iterator it2 = tripletList.iterator(); it2.hasNext();) { + FontTriplet triplet = (FontTriplet)it2.next(); + fontInfo.addFontProperties("F" + num, + triplet.getName(), triplet.getStyle(), triplet.getWeight()); + fontInfo.addMetrics("F" + num, afpFont); + num++; + } + } + if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL) == null) { + eventProducer.warnMissingDefaultFont(this, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL); + } + if (fontInfo.fontLookup("any", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL) == null) { + eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_NORMAL); + } + if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_BOLD) == null) { + eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_BOLD); + } + if (fontInfo.fontLookup("any", Font.STYLE_ITALIC, Font.WEIGHT_BOLD) == null) { + eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_BOLD); + } + } else { + eventProducer.warnDefaultFontSetup(this); + + // Go with a default base 12 configuration for AFP environments + FontCollection base12FontCollection = new AFPBase12FontCollection(); + num = base12FontCollection.setup(num, fontInfo); + } + return num; + } + +} diff --git a/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java b/src/java/org/apache/fop/afp/fonts/AFPFontInfo.java new file mode 100644 index 000000000..0259435c6 --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/AFPFontInfo.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.afp.fonts; + +import java.util.List; + + +/** + * FontInfo contains meta information on fonts + */ +public class AFPFontInfo { + + private AFPFont font; + private List/**/ tripletList; + + /** + * Main constructor + * + * @param afpFont The AFP Font + * @param tripletList List of font triplets to associate with this font + */ + public AFPFontInfo(AFPFont afpFont, List/**/ tripletList) { + this.font = afpFont; + this.tripletList = tripletList; + } + + /** + * Returns the afp font + * + * @return the afp font + */ + public AFPFont getAFPFont() { + return font; + } + + /** + * Returns the list of font triplets associated with this font. + * + * @return List of font triplets + */ + public List/**/ getFontTriplets() { + return tripletList; + } + +} + diff --git a/src/java/org/apache/fop/afp/fonts/AFPFontReader.java b/src/java/org/apache/fop/afp/fonts/AFPFontReader.java new file mode 100644 index 000000000..16c341ac4 --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/AFPFontReader.java @@ -0,0 +1,592 @@ +/* + * 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.afp.fonts; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.util.StructuredFieldReader; + +/** + * The AFPFontReader is responsible for reading the font attributes from binary + * code page files and the character set metric files. In IBM font structure, a + * code page maps each character of text to the characters in a character set. + * Each character is translated into a code point. When the character is + * printed, each code point is matched to a character ID on the code page + * specified. The character ID is then matched to the image (raster pattern or + * outline pattern) of the character in the character set specified. The image + * in the character set is the image that is printed in the document. To be a + * valid code page for a particular character set, all character IDs in the code + * page must be included in that character set.

      This class will read the + * font information from the binary code page files and character set metric + * files in order to determine the correct metrics to use when rendering the + * formatted object.

      + * + * @author Pete Townsend + */ +public final class AFPFontReader { + + /** + * Static logging instance + */ + protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp.fonts"); + + /** + * Template used to convert lists to arrays. + */ + private static final CharacterSetOrientation[] EMPTY_CSO_ARRAY = new CharacterSetOrientation[0]; + + /** Codepage MO:DCA structured field. */ + private static final byte[] CODEPAGE_SF = new byte[] { + (byte) 0xD3, (byte) 0xA8, (byte) 0x87}; + + /** Character table MO:DCA structured field. */ + private static final byte[] CHARACTER_TABLE_SF = new byte[] { + (byte) 0xD3, (byte) 0x8C, (byte) 0x87}; + + /** Font control MO:DCA structured field. */ + private static final byte[] FONT_CONTROL_SF = new byte[] { + (byte) 0xD3, (byte) 0xA7, (byte) 0x89 }; + + /** Font orientation MO:DCA structured field. */ + private static final byte[] FONT_ORIENTATION_SF = new byte[] { + (byte) 0xD3, (byte) 0xAE, (byte) 0x89 }; + + /** Font position MO:DCA structured field. */ + private static final byte[] FONT_POSITION_SF = new byte[] { + (byte) 0xD3, (byte) 0xAC, (byte) 0x89 }; + + /** Font index MO:DCA structured field. */ + private static final byte[] FONT_INDEX_SF = new byte[] { + (byte) 0xD3, (byte) 0x8C, (byte) 0x89 }; + + /** + * The conversion factor to millipoints for 240 dpi + */ + private static final int FOP_100_DPI_FACTOR = 1; + + /** + * The conversion factor to millipoints for 240 dpi + */ + private static final int FOP_240_DPI_FACTOR = 300000; + + /** + * The conversion factor to millipoints for 300 dpi + */ + private static final int FOP_300_DPI_FACTOR = 240000; + + /** + * The encoding to use to convert from EBCIDIC to ASCII + */ + private static final String ASCII_ENCODING = "UTF8"; + + /** + * The collection of code pages + */ + private final Map/*>*/ codePages + = new java.util.HashMap/*>*/(); + + /** + * Returns an InputStream to a given file path and filename + * + * @param path the file path + * @param filename the file name + * @return an inputStream + * + * @throws IOException in the event that an I/O exception of some sort has occurred + */ + private InputStream openInputStream(String path, String filename) throws IOException { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader == null) { + classLoader = AFPFontReader.class.getClassLoader(); + } + + URL url = classLoader.getResource(path); + + if (url == null) { + try { + File file = new File(path); + url = file.toURI().toURL(); + if (url == null) { + String msg = "file not found " + filename + " in classpath: " + path; + log.error(msg); + throw new FileNotFoundException(msg); + } + } catch (MalformedURLException ex) { + String msg = "file not found " + filename + " in classpath: " + path; + log.error(msg); + throw new FileNotFoundException(msg); + } + } + + File directory = new File(url.getPath()); + if (!directory.canRead()) { + String msg = "Failed to read directory " + url.getPath(); + log.error(msg); + throw new FileNotFoundException(msg); + } + + final String filterpattern = filename.trim(); + FilenameFilter filter = new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.startsWith(filterpattern); + } + }; + + File[] files = directory.listFiles(filter); + + if (files.length < 1) { + String msg = "file search for " + filename + " located " + + files.length + " files"; + log.error(msg); + throw new FileNotFoundException(msg); + } else if (files.length > 1) { + String msg = "file search for " + filename + " located " + + files.length + " files"; + log.warn(msg); + } + + InputStream inputStream = files[0].toURI().toURL().openStream(); + + if (inputStream == null) { + String msg = "AFPFontReader:: getInputStream():: file not found for " + filename; + log.error(msg); + throw new FileNotFoundException(msg); + } + + return inputStream; + } + + /** + * Closes the inputstream + * + * @param inputStream the inputstream to close + */ + private void closeInputStream(InputStream inputStream) { + try { + if (inputStream != null) { + inputStream.close(); + } + } catch (Exception ex) { + // Lets log at least! + log.error(ex.getMessage()); + } + } + + /** + * Load the font details and metrics into the CharacterSetMetric object, + * this will use the actual afp code page and character set files to load + * the object with the necessary metrics. + * + * @param characterSet the CharacterSetMetric object to populate + * @throws IOException if an I/O exception of some sort has occurred. + */ + public void loadCharacterSetMetric(CharacterSet characterSet) throws IOException { + + InputStream inputStream = null; + + try { + + /** + * Get the code page which contains the character mapping + * information to map the unicode character id to the graphic + * chracter global identifier. + */ + String codePageId = new String(characterSet.getCodePage()); + String path = characterSet.getPath(); + + Map/**/ codePage = (Map/**/)codePages.get(codePageId); + + if (codePage == null) { + codePage = loadCodePage(codePageId, characterSet.getEncoding(), path); + codePages.put(codePageId, codePage); + } + + /** + * Load the character set metric information, no need to cache this + * information as it should be cached by the objects that wish to + * load character set metric information. + */ + final String characterSetName = characterSet.getName(); + + inputStream = openInputStream(path, characterSetName); + + StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream); + + // Process D3A789 Font Control + FontControl fontControl = processFontControl(structuredFieldReader); + + if (fontControl != null) { + //process D3AE89 Font Orientation + CharacterSetOrientation[] characterSetOrientations + = processFontOrientation(structuredFieldReader); + + int dpi = fontControl.getDpi(); + + //process D3AC89 Font Position + processFontPosition(structuredFieldReader, characterSetOrientations, dpi); + + //process D38C89 Font Index (per orientation) + for (int i = 0; i < characterSetOrientations.length; i++) { + processFontIndex(structuredFieldReader, + characterSetOrientations[i], codePage, dpi); + characterSet.addCharacterSetOrientation(characterSetOrientations[i]); + } + } else { + throw new IOException( + "Failed to read font control structured field in character set " + + characterSetName); + } + + } finally { + closeInputStream(inputStream); + } + + } + + /** + * Load the code page information from the appropriate file. The file name + * to load is determined by the code page name and the file extension 'CDP'. + * + * @param codePage + * the code page identifier + * @param encoding + * the encoding to use for the character decoding + * @returns a code page mapping + */ + private Map/**/ loadCodePage(String codePage, String encoding, + String path) throws IOException { + + // Create the HashMap to store code page information + Map/**/ codePages = new java.util.HashMap/**/(); + + InputStream inputStream = null; + try { + inputStream = openInputStream(path, codePage.trim()); + + StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream); + byte[] data = structuredFieldReader.getNext(CHARACTER_TABLE_SF); + + int position = 0; + byte[] gcgiBytes = new byte[8]; + byte[] charBytes = new byte[1]; + + // Read data, ignoring bytes 0 - 2 + for (int index = 3; index < data.length; index++) { + if (position < 8) { + // Build the graphic character global identifier key + gcgiBytes[position] = data[index]; + position++; + } else if (position == 9) { + position = 0; + // Set the character + charBytes[0] = data[index]; + String gcgiString = new String(gcgiBytes, + AFPConstants.EBCIDIC_ENCODING); + String charString = new String(charBytes, encoding); +// int value = charString.charAt(0); + codePages.put(gcgiString, charString); + } else { + position++; + } + } + } finally { + closeInputStream(inputStream); + } + + return codePages; + } + + /** + * Process the font control details using the structured field reader. + * + * @param structuredFieldReader + * the structured field reader + */ + private FontControl processFontControl(StructuredFieldReader structuredFieldReader) + throws IOException { + + byte[] fncData = structuredFieldReader.getNext(FONT_CONTROL_SF); + +// int position = 0; + FontControl fontControl = null; + if (fncData != null) { + fontControl = new FontControl(); + + if (fncData[7] == (byte) 0x02) { + fontControl.setRelative(true); + } + + int dpi = (((fncData[9] & 0xFF) << 8) + (fncData[10] & 0xFF)) / 10; + + fontControl.setDpi(dpi); + } + return fontControl; + } + + /** + * Process the font orientation details from using the structured field + * reader. + * + * @param structuredFieldReader + * the structured field reader + */ + private CharacterSetOrientation[] processFontOrientation( + StructuredFieldReader structuredFieldReader) throws IOException { + + byte[] data = structuredFieldReader.getNext(FONT_ORIENTATION_SF); + + int position = 0; + byte[] fnoData = new byte[26]; + + List orientations = new java.util.ArrayList(); + + // Read data, ignoring bytes 0 - 2 + for (int index = 3; index < data.length; index++) { + // Build the font orientation record + fnoData[position] = data[index]; + position++; + + if (position == 26) { + + position = 0; + + int orientation = 0; + + switch (fnoData[2]) { + case 0x00: + orientation = 0; + break; + case 0x2D: + orientation = 90; + break; + case 0x5A: + orientation = 180; + break; + case (byte) 0x87: + orientation = 270; + break; + default: + System.out.println("ERROR: Oriantation"); + } + + CharacterSetOrientation cso = new CharacterSetOrientation( + orientation); + orientations.add(cso); + + } + } + + return (CharacterSetOrientation[]) orientations + .toArray(EMPTY_CSO_ARRAY); + } + + /** + * Populate the CharacterSetOrientation object in the suplied array with the + * font position details using the supplied structured field reader. + * + * @param structuredFieldReader + * the structured field reader + * @param characterSetOrientations + * the array of CharacterSetOrientation objects + */ + private void processFontPosition(StructuredFieldReader structuredFieldReader, + CharacterSetOrientation[] characterSetOrientations, int dpi) throws IOException { + + byte[] data = structuredFieldReader.getNext(FONT_POSITION_SF); + + int position = 0; + byte[] fpData = new byte[26]; + + int characterSetOrientationIndex = 0; + int fopFactor = 0; + + switch (dpi) { + case 100: + fopFactor = FOP_100_DPI_FACTOR; + break; + case 240: + fopFactor = FOP_240_DPI_FACTOR; + break; + case 300: + fopFactor = FOP_300_DPI_FACTOR; + break; + default: + String msg = "Unsupported font resolution of " + dpi + " dpi."; + log.error(msg); + throw new IOException(msg); + } + + // Read data, ignoring bytes 0 - 2 + for (int index = 3; index < data.length; index++) { + if (position < 22) { + // Build the font orientation record + fpData[position] = data[index]; + } else if (position == 22) { + + position = 0; + + CharacterSetOrientation characterSetOrientation + = characterSetOrientations[characterSetOrientationIndex]; + + int xHeight = ((fpData[2] & 0xFF) << 8) + (fpData[3] & 0xFF); + int capHeight = ((fpData[4] & 0xFF) << 8) + (fpData[5] & 0xFF); + int ascHeight = ((fpData[6] & 0xFF) << 8) + (fpData[7] & 0xFF); + int dscHeight = ((fpData[8] & 0xFF) << 8) + (fpData[9] & 0xFF); + + dscHeight = dscHeight * -1; + + characterSetOrientation.setXHeight(xHeight * fopFactor); + characterSetOrientation.setCapHeight(capHeight * fopFactor); + characterSetOrientation.setAscender(ascHeight * fopFactor); + characterSetOrientation.setDescender(dscHeight * fopFactor); + + characterSetOrientationIndex++; + + fpData[position] = data[index]; + + } + + position++; + } + + } + + /** + * Process the font index details for the character set orientation. + * + * @param structuredFieldReader + * the structured field reader + * @param cso + * the CharacterSetOrientation object to populate + * @param codepage + * the map of code pages + */ + private void processFontIndex(StructuredFieldReader structuredFieldReader, + CharacterSetOrientation cso, Map/**/ codepage, int dpi) + throws IOException { + + byte[] data = structuredFieldReader.getNext(FONT_INDEX_SF); + + int fopFactor = 0; + + switch (dpi) { + case 100: + fopFactor = FOP_100_DPI_FACTOR; + break; + case 240: + fopFactor = FOP_240_DPI_FACTOR; + break; + case 300: + fopFactor = FOP_300_DPI_FACTOR; + break; + default: + String msg = "Unsupported font resolution of " + dpi + " dpi."; + log.error(msg); + throw new IOException(msg); + } + + int position = 0; + + byte[] gcgid = new byte[8]; + byte[] fiData = new byte[20]; + + int lowest = 255; + int highest = 0; + + // Read data, ignoring bytes 0 - 2 + for (int index = 3; index < data.length; index++) { + if (position < 8) { + gcgid[position] = data[index]; + position++; + } else if (position < 27) { + fiData[position - 8] = data[index]; + position++; + } else if (position == 27) { + + fiData[position - 8] = data[index]; + + position = 0; + + String gcgiString = new String(gcgid, AFPConstants.EBCIDIC_ENCODING); + + String idx = (String) codepage.get(gcgiString); + + if (idx != null) { + + int cidx = idx.charAt(0); + int width = ((fiData[0] & 0xFF) << 8) + (fiData[1] & 0xFF); + + if (cidx < lowest) { + lowest = cidx; + } + + if (cidx > highest) { + highest = cidx; + } + + int a = (width * fopFactor); + + cso.setWidth(cidx, a); + + } + + } + } + + cso.setFirstChar(lowest); + cso.setLastChar(highest); + + } + + private class FontControl { + + private int dpi; + + private boolean isRelative = false; + + public int getDpi() { + return dpi; + } + + public void setDpi(int i) { + dpi = i; + } + + public boolean isRelative() { + return isRelative; + } + + public void setRelative(boolean b) { + isRelative = b; + } + } + +} diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/afp/fonts/CharacterSet.java new file mode 100644 index 000000000..31b53bf08 --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/CharacterSet.java @@ -0,0 +1,318 @@ +/* + * 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.afp.fonts; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.util.StringUtils; + +/** + * The IBM Font Object Content Architecture (FOCA) supports presentation + * of character shapes by defining their characteristics, which include + * font description information for identifying the characters, font metric + * information for positioning the characters, and character shape information + * for presenting the character images. + *

      + * Presenting a graphic character on a presentation surface requires + * information on the rotation and position of character on the physical + * or logical page. + *

      + * This class proivdes font metric information for a particular font + * as identified by the character set name. This information is obtained + * directly from the AFP font files which must be installed in the path + * specified in the afp-fonts xml definition file. + *

      + */ +public class CharacterSet { + + /** Static logging instance */ + protected static final Log log = LogFactory.getLog(CharacterSet.class.getName()); + + /** default codepage */ + public static final String DEFAULT_CODEPAGE = "T1V10500"; + + /** default encoding */ + public static final String DEFAULT_ENCODING = "Cp500"; + + private static final int MAX_NAME_LEN = 8; + + + /** The code page to which the character set relates */ + protected String codePage; + + /** The encoding used for the code page */ + protected String encoding; + + /** The character set relating to the font */ + protected String name; + + /** The path to the installed fonts */ + protected String path; + + /** Indicator as to whether to metrics have been loaded */ + private boolean isMetricsLoaded = false; + + /** The current orientation (currently only 0 is supported by FOP) */ + private final String currentOrientation = "0"; + + /** The collection of objects for each orientation */ + private Map characterSetOrientations = null; + + /** + * 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 + * @param path the path to the installed afp fonts + */ + public CharacterSet(String codePage, String encoding, String name, String path) { + if (name.length() > MAX_NAME_LEN) { + String msg = "Character set name '" + name + "' must be a maximum of " + + MAX_NAME_LEN + " characters"; + log.error("Constructor:: " + msg); + throw new IllegalArgumentException(msg); + } + + if (name.length() < MAX_NAME_LEN) { + this.name = StringUtils.rpad(name, ' ', MAX_NAME_LEN); + } else { + this.name = name; + } + this.codePage = codePage; + this.encoding = encoding; + this.path = path; + + this.characterSetOrientations = new java.util.HashMap(4); + } + + /** + * Add character set metric information for the different orientations + * + * @param cso the metrics for the orientation + */ + public void addCharacterSetOrientation(CharacterSetOrientation cso) { + characterSetOrientations.put( + String.valueOf(cso.getOrientation()), + cso); + } + + /** + * Ascender height is the distance from the character baseline to the + * top of the character box. A negative ascender height signifies that + * all of the graphic character is below the character baseline. For + * a character rotation other than 0, ascender height loses its + * meaning when the character is lying on its side or is upside down + * with respect to normal viewing orientation. For the general case, + * 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() { + load(); + return getCharacterSetOrientation().getAscender(); + } + + /** + * 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() { + load(); + return getCharacterSetOrientation().getCapHeight(); + } + + /** + * 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() { + load(); + return getCharacterSetOrientation().getDescender(); + } + + /** + * Returns the first character in the character set + * + * @return the first character in the character set + */ + public int getFirstChar() { + load(); + return getCharacterSetOrientation().getFirstChar(); + } + + /** + * Returns the last character in the character set + * + * @return the last character in the character set + */ + public int getLastChar() { + load(); + return getCharacterSetOrientation().getLastChar(); + } + + /** + * Returns the path where the font resources are installed + * + * @return the path where the font resources are installed + */ + public String getPath() { + return path; + } + + /** + * Get the width (in 1/1000ths of a point size) of all characters + * + * @return the widths of all characters + */ + public int[] getWidths() { + load(); + return getCharacterSetOrientation().getWidths(); + } + + /** + * XHeight refers to the height of the lower case letters above the baseline. + * + * @return the typical height of characters + */ + public int getXHeight() { + load(); + return getCharacterSetOrientation().getXHeight(); + } + + /** + * 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 + */ + public int getWidth(int character) { + load(); + return getCharacterSetOrientation().getWidth(character); + } + + /** + * Lazy creation of the character metrics, the afp font file will only + * be processed on a method call requiring the metric information. + */ + private void load() { + if (!isMetricsLoaded) { + AFPFontReader afpFontReader = new AFPFontReader(); + try { + afpFontReader.loadCharacterSetMetric(this); + isMetricsLoaded = true; + } catch (IOException e) { + String msg = "Failed to load the character set metrics for code page " + codePage; + log.error(msg); + throw new RuntimeException(e.getMessage()); + } + } + } + + /** + * Returns the AFP character set identifier + * + * @return the AFP character set identifier + */ + public String getName() { + return name; + } + + /** + * Returns the AFP character set identifier as a byte array + * + * @return the AFP character set identifier as a byte array + */ + public byte[] getNameBytes() { + byte[] nameBytes = null; + try { + nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); + } catch (UnsupportedEncodingException usee) { + nameBytes = name.getBytes(); + log.warn( + "UnsupportedEncodingException translating the name " + name); + } + return nameBytes; + } + + /** + * Returns the AFP code page identifier + * + * @return the AFP code page identifier + */ + public String getCodePage() { + return codePage; + } + + /** + * Returns the AFP code page encoding + * + * @return the AFP code page encoding + */ + public String getEncoding() { + return encoding; + } + + /** + * Helper method to return the current CharacterSetOrientation, note + * that FOP does not yet implement the "reference-orientation" + * attribute therefore we always use the orientation zero degrees, + * Other orientation information is captured for use by a future + * implementation (whenever FOP implement the mechanism). This is also + * 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() { + CharacterSetOrientation c + = (CharacterSetOrientation) characterSetOrientations.get(currentOrientation); + return c; + } + + /** + * 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 + */ + public char mapChar(char c) { + return c; + } + +} diff --git a/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java b/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java new file mode 100644 index 000000000..88e99eccf --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java @@ -0,0 +1,275 @@ +/* + * 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.afp.fonts; + +/** + * The IBM Font Object Content Architecture (FOCA) supports presentation + * of character shapes by defining their characteristics, which include + * Font-Description information for identifying the characters, Font-Metric + * information for positioning the characters, and Character-Shape + * information for presenting the character images. + * + * Presenting a graphic character on a presentation surface requires + * that you communicate this information clearly to rotate and position + * characters correctly on the physical or logical page. + * + * This class provides font metric information for a particular font + * as by the orientation. + * + * This information is obtained directly from the AFP font files which must + * be installed in the classpath under in the location specified by the path + * attribute in the afp-font.xml file. + *

      + */ +public class CharacterSetOrientation { + + /** + * The code page to which the character set relates + */ + private String codePage; + + /** + * The encoding used for the code page + */ + private String encoding; + + /** + * The ascender height for the character set + */ + private int ascender; + + /** + * The descender depth for the character set + */ + private int descender; + + /** + * The height of capital letters + */ + private int capHeight; + + /** + * The characters in the charcater set + */ + private int[] chars = new int[256]; + + /** + * The height of lowercase letters + */ + private int xHeight; + + /** + * The first character + */ + private int firstChar; + + /** + * The last character + */ + private int lastChar; + + + /** + * The character set orientation + */ + private int orientation = 0; + + /** + * Constructor for the CharacterSetOrientation, the orientation is + * expressed as the degrees rotation (i.e 0, 90, 180, 270) + * @param orientation the character set orientation + */ + public CharacterSetOrientation(int orientation) { + this.orientation = orientation; + } + + /** + * Ascender height is the distance from the character baseline to the + * top of the character box. A negative ascender height signifies that + * all of the graphic character is below the character baseline. For + * a character rotation other than 0, ascender height loses its + * meaning when the character is lying on its side or is upside down + * with respect to normal viewing orientation. For the general case, + * Ascender Height is the character�s 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() { + return ascender; + } + + /** + * 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() { + return capHeight; + } + + /** + * 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() { + return descender; + } + + /** + * The first character in the character set + * @return the first character + */ + public int getFirstChar() { + return firstChar; + } + + /** + * The last character in the character set + * @return the last character + */ + public int getLastChar() { + return lastChar; + } + + /** + * The orientation for these metrics in the character set + * @return the orientation + */ + public int getOrientation() { + return orientation; + } + + /** + * Get the width (in 1/1000ths of a point size) of all characters + * in this character set. + * @return the widths of all characters + */ + public int[] getWidths() { + int arr[] = new int[(getLastChar() - getFirstChar()) + 1]; + System.arraycopy(chars, getFirstChar(), arr, 0, (getLastChar() - getFirstChar()) + 1); + return arr; + } + + /** + * XHeight refers to the height of the lower case letters above + * the baseline. + * @return heightX the typical height of characters + */ + public int getXHeight() { + return xHeight; + } + + /** + * Get the width (in 1/1000ths of a point size) of the character + * identified by the parameter passed. + * @param characterIndex the character to evaluate + * @return the widths of the character + */ + public int getWidth(int characterIndex) { + if (characterIndex >= chars.length) { + throw new IllegalArgumentException("Invalid character index: " + + characterIndex + ", maximum is " + (chars.length - 1)); + } + return chars[characterIndex]; + } + + /** + * Ascender height is the distance from the character baseline to the + * top of the character box. A negative ascender height signifies that + * all of the graphic character is below the character baseline. For + * a character rotation other than 0, ascender height loses its + * meaning when the character is lying on its side or is upside down + * with respect to normal viewing orientation. For the general case, + * Ascender Height is the character�s most positive y-axis value. + * For bounded character boxes, for a given character having an + * ascender, ascender height and baseline offset are equal. + * @param ascender the ascender to set + */ + public void setAscender(int ascender) { + this.ascender = ascender; + } + + /** + * 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. + * @param capHeight the cap height to set + */ + public void setCapHeight(int capHeight) { + this.capHeight = capHeight; + } + + /** + * 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. + * @param descender the descender value in millipoints + */ + public void setDescender(int descender) { + this.descender = descender; + } + + /** + * The first character in the character set + * @param firstChar the first character + */ + public void setFirstChar(int firstChar) { + this.firstChar = firstChar; + } + + /** + * The last character in the character set + * @param lastChar the last character + */ + public void setLastChar(int lastChar) { + this.lastChar = lastChar; + } + + /** + * Set the width (in 1/1000ths of a point size) of the character + * identified by the parameter passed. + * @param character the character for which the width is being set + * @param width the widths of the character + */ + public void setWidth(int character, int width) { + + if (character >= chars.length) { + // Increase the size of the array if necessary + int arr[] = new int[(character - firstChar) + 1]; + System.arraycopy(chars, 0, arr, 0, chars.length); + chars = arr; + } + chars[character] = width; + + } + + /** + * XHeight refers to the height of the lower case letters above + * the baseline. + * @param xHeight the typical height of characters + */ + public void setXHeight(int xHeight) { + this.xHeight = xHeight; + } +} diff --git a/src/java/org/apache/fop/afp/fonts/FontRuntimeException.java b/src/java/org/apache/fop/afp/fonts/FontRuntimeException.java new file mode 100644 index 000000000..86e41707f --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/FontRuntimeException.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.afp.fonts; + +/** + * A runtime exception for handling fatal errors in processing fonts. + *

      + */ +public class FontRuntimeException extends RuntimeException { + + private static final long serialVersionUID = -2217420523816384707L; + + /** + * Constructs a FontRuntimeException with the specified message. + * @param msg the exception mesaage + */ + public FontRuntimeException(String msg) { + super(msg); + } + + /** + * Constructs a FontRuntimeException with the specified message + * wrapping the underlying exception. + * @param msg the exception mesaage + * @param t the underlying exception + */ + public FontRuntimeException(String msg, Throwable t) { + super(msg, t); + } + +} diff --git a/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java b/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java new file mode 100644 index 000000000..49e536eab --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/FopCharacterSet.java @@ -0,0 +1,141 @@ +/* + * 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.afp.fonts; + +import org.apache.fop.fonts.Typeface; + +/** + * A Character set for a normal FOP font

      + */ +public class FopCharacterSet extends CharacterSet { + + /** The character set for this font */ + private Typeface charSet = null; + private int size = 0; + + /** + * 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 + * @param size the font size + * @param charSet the fop character set + */ + public FopCharacterSet( + String codePage, + String encoding, + String name, + int size, + Typeface charSet) { + + super(codePage, encoding, name, null); + this.charSet = charSet; + this.size = size * 1000; + } + + /** + * Ascender height is the distance from the character baseline to the + * top of the character box. A negative ascender height signifies that + * all of the graphic character is below the character baseline. For + * a character rotation other than 0, ascender height loses its + * meaning when the character is lying on its side or is upside down + * with respect to normal viewing orientation. For the general case, + * Ascender Height is the character�s 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() { + return charSet.getAscender(size); + } + + /** + * 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() { + return charSet.getCapHeight(size); + } + + /** + * 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() { + return charSet.getDescender(size); + } + + /** + * The first character in the character set + * @return the first character + */ + public int getFirstChar() { + return 0; + } + + /** + * The last character in the character set + * @return the last character + */ + public int getLastChar() { + return 0; + } + + /** + * Get the width (in 1/1000ths of a point size) of all characters + * @return the widths of all characters + */ + public int[] getWidths() { + return charSet.getWidths(); + } + + /** + * XHeight refers to the height of the lower case letters above the baseline. + * @return the typical height of characters + */ + public int getXHeight() { + return charSet.getXHeight(size); + } + + /** + * 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 + */ + public int getWidth(int character) { + return charSet.getWidth(character, size); + } + + /** + * Map a Unicode character to a code point in the font. + * @param c character to map + * @return the mapped character + */ + public char mapChar(char c) { + return charSet.mapChar(c); + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/fonts/OutlineFont.java b/src/java/org/apache/fop/afp/fonts/OutlineFont.java new file mode 100644 index 000000000..28f2df6c4 --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/OutlineFont.java @@ -0,0 +1,182 @@ +/* + * 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.afp.fonts; + + +/** + * A font defined as a set of lines and curves as opposed to a bitmap font. An + * outline font can be scaled to any size and otherwise transformed more easily + * than a bitmap font, and with more attractive results.

      + * + */ +public class OutlineFont extends AFPFont { + + /** The character set for this font */ + private CharacterSet charSet = null; + + /** + * Constructor for an outline font. + * + * @param name + * the name of the font + * @param charSet + * the chracter set + */ + public OutlineFont(String name, CharacterSet charSet) { + super(name); + this.charSet = charSet; + } + + /** + * Get the character set metrics. + * + * @return the character set + */ + public CharacterSet getCharacterSet() { + + return charSet; + + } + + /** + * Get the character set metrics. + * @param size ignored + * @return the character set + */ + public CharacterSet getCharacterSet(int size) { + + return charSet; + + } + + /** + * Get the first character in this font. + * @return the first character in this font + */ + public int getFirstChar() { + return charSet.getFirstChar(); + } + + /** + * Get the last character in this font. + * @return the last character in this font + */ + public int getLastChar() { + return charSet.getLastChar(); + } + + /** + * The ascender is the part of a lowercase letter that extends above the + * "x-height" (the height of the letter "x"), such as "d", "t", or "h". Also + * used to denote the part of the letter extending above the x-height. + * + * @param size + * the point size + * @return the ascender for the given size + */ + public int getAscender(int size) { + return charSet.getAscender() / 1000 * size; + } + + /** + * Obtains the height of capital letters for the specified point size. + * + * @param size + * the point size + * @return the cap height for the given size + */ + public int getCapHeight(int size) { + return charSet.getCapHeight() / 1000 * size; + } + + /** + * The descender is the part of a lowercase letter that extends below the + * base line, such as "g", "j", or "p". Also used to denote the part of the + * letter extending below the base line. + * + * @param size + * the point size + * @return the descender for the given size + */ + public int getDescender(int size) { + return charSet.getDescender() / 1000 * size; + } + + /** + * The "x-height" (the height of the letter "x"). + * + * @param size + * the point size + * @return the x height for the given size + */ + public int getXHeight(int size) { + return charSet.getXHeight() / 1000 * size; + } + + /** + * Obtain the width of the character for the specified point size. + * @param character the character + * @param size point size + * @return the width of the character for the specified point size + */ + public int getWidth(int character, int size) { + return charSet.getWidth(character) / 1000 * size; + } + + /** + * Get the getWidth (in 1/1000ths of a point size) of all characters in this + * character set. + * + * @param size + * the point size + * @return the widths of all characters + */ + public int[] getWidths(int size) { + int[] widths = charSet.getWidths(); + for (int i = 0; i < widths.length; i++) { + widths[i] = widths[i] / 1000 * size; + } + return widths; + } + + /** + * Get the getWidth (in 1/1000ths of a point size) of all characters in this + * character set. + * + * @return the widths of all characters + */ + public int[] getWidths() { + return getWidths(1000); + } + + /** + * Map a Unicode character to a code point in the font. + * @param c character to map + * @return the mapped character + */ + public char mapChar(char c) { + return charSet.mapChar(c); + } + + /** {@inheritDoc} */ + public String getEncodingName() { + return charSet.getEncoding(); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/fonts/RasterFont.java b/src/java/org/apache/fop/afp/fonts/RasterFont.java new file mode 100644 index 000000000..7582159c5 --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/RasterFont.java @@ -0,0 +1,238 @@ +/* + * 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.afp.fonts; + +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A font where each character is stored as an array of pixels (a bitmap). Such + * fonts are not easily scalable, in contrast to vectored fonts. With this type + * of font, the font metrics information is held in character set files (one for + * each size and style).

      + * + */ +public class RasterFont extends AFPFont { + + /** Static logging instance */ + protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp.fonts"); + + private final Map/**/ charSets + = new java.util.HashMap/**/(); + + private CharacterSet charSet = null; + + /** + * Constructor for the raster font requires the name, weight and style + * attribute to be available as this forms the key to the font. + * + * @param name + * the name of the font + */ + public RasterFont(String name) { + super(name); + } + + /** + * Adds the character set for the given point size + * @param size point size + * @param characterSet character set + */ + public void addCharacterSet(int size, CharacterSet characterSet) { + this.charSets.put(String.valueOf(size), characterSet); + this.charSet = characterSet; + } + + /** Describes the unit millipoint. */ + public static final String MPT = "mpt"; + + /** + * Get the character set metrics for the specified point size. + * + * @param size the point size + * @return the character set metrics + */ + public CharacterSet getCharacterSet(int size) { + + String pointsize = String.valueOf(size / 1000); + CharacterSet csm = (CharacterSet) charSets.get(pointsize); + if (csm == null) { + csm = (CharacterSet) charSets.get(size + MPT); + } + if (csm == null) { + // Get char set with nearest font size + int distance = Integer.MAX_VALUE; + for (Iterator it = charSets.entrySet().iterator(); it.hasNext();) { + Map.Entry me = (Map.Entry)it.next(); + String key = (String)me.getKey(); + if (!key.endsWith(MPT)) { + int mpt = Integer.parseInt(key) * 1000; + if (Math.abs(size - mpt) < distance) { + distance = Math.abs(size - mpt); + pointsize = (String)me.getKey(); + csm = (CharacterSet)me.getValue(); + } + } + } + if (csm != null) { + charSets.put(size + MPT, csm); + String msg = "No " + (size / 1000) + "pt font " + getFontName() + + " found, substituted with " + pointsize + "pt font"; + log.warn(msg); + } + } + if (csm == null) { + String msg = "No font found for font " + getFontName() + + " with point size " + pointsize; + log.error(msg); + throw new FontRuntimeException(msg); + } + return csm; + + } + + /** + * Get the first character in this font. + * @return the first character in this font. + */ + public int getFirstChar() { + Iterator it = charSets.values().iterator(); + if (it.hasNext()) { + CharacterSet csm = (CharacterSet) it.next(); + return csm.getFirstChar(); + } else { + String msg = "getFirstChar() - No character set found for font:" + getFontName(); + log.error(msg); + throw new FontRuntimeException(msg); + } + } + + /** + * Get the last character in this font. + * @return the last character in this font. + */ + public int getLastChar() { + + Iterator it = charSets.values().iterator(); + if (it.hasNext()) { + CharacterSet csm = (CharacterSet) it.next(); + return csm.getLastChar(); + } else { + String msg = "getLastChar() - No character set found for font:" + getFontName(); + log.error(msg); + throw new FontRuntimeException(msg); + } + + } + + /** + * The ascender is the part of a lowercase letter that extends above the + * "x-height" (the height of the letter "x"), such as "d", "t", or "h". Also + * used to denote the part of the letter extending above the x-height. + * + * @param size the point size + * @return the ascender for the given point size + */ + public int getAscender(int size) { + return getCharacterSet(size).getAscender(); + } + + /** + * Obtains the height of capital letters for the specified point size. + * + * @param size the point size + * @return the cap height for the specified point size + */ + public int getCapHeight(int size) { + return getCharacterSet(size).getCapHeight(); + } + + /** + * The descender is the part of a lowercase letter that extends below the + * base line, such as "g", "j", or "p". Also used to denote the part of the + * letter extending below the base line. + * + * @param size the point size + * @return the descender for the specified point size + */ + public int getDescender(int size) { + return getCharacterSet(size).getDescender(); + } + + /** + * The "x-height" (the height of the letter "x"). + * + * @param size the point size + * @return the x height for the given point size + */ + public int getXHeight(int size) { + return getCharacterSet(size).getXHeight(); + } + + /** + * Obtain the width of the character for the specified point size. + * @param character the character + * @param size the point size + * @return the width for the given point size + */ + public int getWidth(int character, int size) { + return getCharacterSet(size).getWidth(character); + } + + /** + * Get the getWidth (in 1/1000ths of a point size) of all characters in this + * character set. + * + * @param size + * the point size + * @return the widths of all characters + */ + public int[] getWidths(int size) { + return getCharacterSet(size).getWidths(); + } + + /** + * Get the getWidth (in 1/1000ths of a point size) of all characters in this + * character set. + * + * @return the widths of all characters + */ + public int[] getWidths() { + return getWidths(1000); + } + + /** + * Map a Unicode character to a code point in the font. + * @param c character to map + * @return the mapped character + */ + public char mapChar(char c) { + return charSet.mapChar(c); + } + + /** {@inheritDoc} */ + public String getEncodingName() { + return charSet.getEncoding(); + } + +} diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java new file mode 100644 index 000000000..6f993b840 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java @@ -0,0 +1,137 @@ +/* + * 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.afp.goca; + +import org.apache.fop.afp.modca.AbstractPreparedAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * A base class encapsulating the structure of coordinate based GOCA objects + */ +public abstract class AbstractGraphicsCoord extends AbstractPreparedAFPObject { + + /** array of x/y coordinates */ + protected int[] coords = null; + + /** + * Constructor + * + * @param coords the x/y coordinates for this object + */ + public AbstractGraphicsCoord(int[] coords) { + this.coords = coords; + prepareData(); + } + + /** + * Constructor + * + * @param x the x coordinate for this object + * @param y the y coordinate for this object + */ + public AbstractGraphicsCoord(int x, int y) { + this(new int[] {x, y}); + } + + /** + * Constructor + * + * @param x1 the x1 coordinate for this object + * @param y1 the y1 coordinate for this object + * @param x2 the x2 coordinate for this object + * @param y2 the y2 coordinate for this object + */ + public AbstractGraphicsCoord(int x1, int y1, int x2, int y2) { + this(new int[] {x1, y1, x2, y2}); + } + + /** + * Returns the order code to use + * + * @return the order code to use + */ + protected abstract byte getOrderCode(); + + /** + * Returns the length of this order code (typically this is the same as the coordinate length) + * + * @return the length of this order code + * + */ + protected int getLength() { + return this.coords.length * 2; + } + + /** + * Creates a newly created and initialized byte data + * + * @return a newly created and initialized byte data + */ + protected byte[] createData() { + int len = getLength(); + byte[] data = new byte[len + 2]; + data[0] = getOrderCode(); // ORDER CODE + data[1] = (byte)len; // LENGTH + return data; + } + + /** {@inheritDoc} */ + protected void prepareData() { + super.data = createData(); + int fromIndex = data.length - getLength(); + addCoords(data, fromIndex); + } + + /** + * Adds the coordinates to the structured field data + * + * @param data the structured field data + * @param fromIndex the start index + */ + protected void addCoords(byte[] data, int fromIndex) { + // X/Y POS + for (int i = 0; i < coords.length; i++, fromIndex += 2) { + byte[] coord = BinaryUtils.convert(coords[i], 2); + data[fromIndex] = coord[0]; + data[fromIndex + 1] = coord[1]; + } + } + + /** + * Returns the short name of this GOCA object + * + * @return the short name of this GOCA object + */ + public String getName() { + String className = getClass().getName(); + return className.substring(className.lastIndexOf(".") + 1); + } + + /** {@inheritDoc} */ + public String toString() { + String coordsStr = ""; + for (int i = 0; i < coords.length; i++) { + coordsStr += (i % 2 == 0) ? "x" : "y"; + coordsStr += (i / 2) + "=" + coords[i] + ","; + } + coordsStr = coordsStr.substring(0, coordsStr.length() - 1); + return getName() + "{" + coordsStr + "}"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsArea.java b/src/java/org/apache/fop/afp/goca/GraphicsArea.java new file mode 100644 index 000000000..2b6d8a804 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsArea.java @@ -0,0 +1,76 @@ +/* + * 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.afp.goca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractPreparedObjectContainer; + +/** + * A GOCA graphics area (container for filled shapes/objects) + */ +public final class GraphicsArea extends AbstractPreparedObjectContainer { + + private static final int RES1 = 1; + private static final int BOUNDARY = 2; + private static final int NO_BOUNDARY = 0; + + /** draw boundary lines around this area */ + private boolean drawBoundary = false; + + /** + * Sets whether boundary lines are drawn + * + * @param drawBoundaryLines whether boundary lines are drawn + */ + public void setDrawBoundaryLines(boolean drawBoundaryLines) { + this.drawBoundary = drawBoundaryLines; + } + + /** {@inheritDoc} */ + public int getDataLength() { + // start len + end len + data len + return 4 + super.getDataLength(); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[] { + (byte)0x68, // GBAR order code + (byte)(RES1 + (drawBoundary ? BOUNDARY : NO_BOUNDARY)) + }; + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] endData = new byte[] { + (byte)0x60, // GEAR order code + 0x00, // LENGTH + }; + os.write(endData); + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsArea{drawBoundary=" + drawBoundary + "}"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsBox.java b/src/java/org/apache/fop/afp/goca/GraphicsBox.java new file mode 100644 index 000000000..4f4947000 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsBox.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.afp.goca; + +/** + * A GOCA graphics rectangular box + */ +public final class GraphicsBox extends AbstractGraphicsCoord { + + /** + * Constructor + * + * @param coords the x/y coordinates for this object + */ + public GraphicsBox(int[] coords) { + super(coords); + } + + /** {@inheritDoc} */ + protected byte getOrderCode() { + return (byte)0xC0; + } + + /** {@inheritDoc} */ + protected int getLength() { + return 10; + } + + /** {@inheritDoc} */ + protected void prepareData() { + super.data = createData(); + final int fromIndex = 4; + addCoords(data, fromIndex); + } + + /** {@inheritDoc} */ + protected byte[] createData() { + byte[] data = super.createData(); + data[2] = (byte)0x20; // CONTROL draw control flags + data[3] = 0x00; // reserved + return data; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java b/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java new file mode 100644 index 000000000..8dab3d922 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java @@ -0,0 +1,148 @@ +/* + * 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.afp.goca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractPreparedObjectContainer; +import org.apache.fop.afp.modca.PreparedAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * A GOCA graphics segment + */ +public final class GraphicsChainedSegment extends AbstractPreparedObjectContainer { + + /** The maximum segment data length */ + protected static final int MAX_DATA_LEN = 8192; + + /** the current area */ + private GraphicsArea currentArea = null; + + /** the previous segment in the chain */ + private GraphicsChainedSegment previous = null; + + /** the next segment in the chain */ + private GraphicsChainedSegment next = null; + + /** + * Main constructor + * + * @param name + * the name of this graphics segment + */ + public GraphicsChainedSegment(String name) { + super(name); + } + + /** + * Constructor + * + * @param name + * the name of this graphics segment + * @param previous + * the previous graphics segment in this chain + */ + public GraphicsChainedSegment(String name, GraphicsChainedSegment previous) { + super(name); + previous.next = this; + this.previous = previous; + } + + /** {@inheritDoc} */ + public int getDataLength() { + return 14 + super.getDataLength(); + } + + private static final byte APPEND_NEW_SEGMENT = 0; +// private static final byte PROLOG = 4; +// private static final byte APPEND_TO_EXISING = 48; + + private static final int NAME_LENGTH = 4; + + /** {@inheritDoc} */ + protected int getNameLength() { + return NAME_LENGTH; + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + super.writeStart(os); + + byte[] data = new byte[14]; + data[0] = 0x70; // BEGIN_SEGMENT + data[1] = 0x0C; // Length of following parameters + + // segment name + byte[] nameBytes = getNameBytes(); + System.arraycopy(nameBytes, 0, data, 2, NAME_LENGTH); + + data[6] = 0x00; // FLAG1 (ignored) + data[7] = APPEND_NEW_SEGMENT; + + int dataLength = super.getDataLength(); + byte[] len = BinaryUtils.convert(dataLength, 2); + data[8] = len[0]; // SEGL + data[9] = len[1]; + + // P/S NAME (predecessor name) + if (previous != null) { + nameBytes = previous.getNameBytes(); + System.arraycopy(nameBytes, 0, data, 10, NAME_LENGTH); + } + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + // I am the first segment in the chain so write out the rest + if (previous == null) { + for (GraphicsChainedSegment segment = next; segment != null; segment = segment.next) { + segment.writeToStream(os); + } + } // else nothing todo + } + + /** Begins a graphics area (start of fill) */ + protected void beginArea() { + this.currentArea = new GraphicsArea(); + super.addObject(currentArea); + } + + /** Ends a graphics area (end of fill) */ + protected void endArea() { + this.currentArea = null; + } + + /** {@inheritDoc} */ + public void addObject(PreparedAFPObject drawingOrder) { + if (currentArea != null) { + currentArea.addObject(drawingOrder); + } else { + super.addObject(drawingOrder); + } + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsChainedSegment(name=" + super.getName() + ")"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsData.java b/src/java/org/apache/fop/afp/goca/GraphicsData.java new file mode 100644 index 000000000..ca5fef3f4 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsData.java @@ -0,0 +1,128 @@ +/* + * 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.afp.goca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractPreparedObjectContainer; +import org.apache.fop.afp.modca.PreparedAFPObject; +import org.apache.fop.afp.util.BinaryUtils; +import org.apache.fop.afp.util.StringUtils; + +/** + * A GOCA graphics data + */ +public final class GraphicsData extends AbstractPreparedObjectContainer { + + /** The maximum graphics data length */ + public static final int MAX_DATA_LEN = 32767; + + /** The graphics segment */ + private GraphicsChainedSegment currentSegment = null; + + /** {@inheritDoc} */ + public int getDataLength() { + return 8 + super.getDataLength(); + } + + /** + * Begins a graphics area (start of fill) + */ + public void beginArea() { + getSegment().beginArea(); + } + + /** + * Ends a graphics area (end of fill) + */ + public void endArea() { + getSegment().endArea(); + } + + /** + * Returns a new segment name + * + * @return a new segment name + */ + private String createSegmentName() { + return StringUtils.lpad(String.valueOf( + (super.objects != null ? super.objects.size() : 0) + 1), + '0', 4); + } + + /** + * Returns the current graphics segment, creating one if one does not exist + * + * @return the current graphics chained segment + */ + private GraphicsChainedSegment getSegment() { + if (currentSegment == null) { + newSegment(); + } + return this.currentSegment; + } + + /** + * Creates a new graphics segment + * + * @return a newly created graphics segment + */ + public GraphicsChainedSegment newSegment() { + String name = createSegmentName(); + if (currentSegment == null) { + this.currentSegment = new GraphicsChainedSegment(name); + } else { + this.currentSegment = new GraphicsChainedSegment(name, currentSegment); + } + super.addObject(currentSegment); + return currentSegment; + } + + /** {@inheritDoc} */ + public void addObject(PreparedAFPObject drawingOrder) { + if (currentSegment == null + || (currentSegment.getDataLength() + drawingOrder.getDataLength()) + >= GraphicsChainedSegment.MAX_DATA_LEN) { + newSegment(); + } + currentSegment.addObject(drawingOrder); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[9]; + copySF(data, SF_CLASS, Type.DATA, Category.GRAPHICS); + int dataLength = getDataLength(); + byte[] len = BinaryUtils.convert(dataLength, 2); + data[1] = len[0]; // Length byte 1 + data[2] = len[1]; // Length byte 2 + os.write(data); + + // get first segment in chain and write (including all its connected segments) + GraphicsChainedSegment firstSegment = (GraphicsChainedSegment)objects.get(0); + firstSegment.writeToStream(os); + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsData"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsFillet.java b/src/java/org/apache/fop/afp/goca/GraphicsFillet.java new file mode 100644 index 000000000..40b98b0d3 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsFillet.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.afp.goca; + +/** + * A GOCA graphics curved tangential line to a specified set of + * straight lines drawn from the given position or current position + */ +public final class GraphicsFillet extends AbstractGraphicsCoord { + + /** + * Constructor + * + * @param coords the x/y coordinates for this object + */ + public GraphicsFillet(int[] coords) { + super(coords); + } + + /** {@inheritDoc} */ + protected byte getOrderCode() { + return (byte)0xC5; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsFullArc.java b/src/java/org/apache/fop/afp/goca/GraphicsFullArc.java new file mode 100644 index 000000000..9d511e142 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsFullArc.java @@ -0,0 +1,78 @@ +/* + * 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.afp.goca; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * A GOCA graphics arc (circle/ellipse) + */ +public class GraphicsFullArc extends AbstractGraphicsCoord { + /** the integer portion of the multiplier */ + private final int mh; + + /** the fractional portion of the multiplier */ + private final int mhr; + + /** + * Constructor + * + * @param x the x coordinate of the center of the circle/ellipse + * @param y the y coordinate of the center of the circle/ellipse + * @param mh the integer portion of the multiplier + * @param mhr the fractional portion of the multiplier + */ + public GraphicsFullArc(int x, int y, int mh, int mhr) { + super(x, y); + this.mh = mh; + this.mhr = mhr; + // integer portion of multiplier + data[data.length - 2] = BinaryUtils.convert(mh, 1)[0]; + // fractional portion of multiplier + data[data.length - 1] = BinaryUtils.convert(mhr, 1)[0]; + } + + /** {@inheritDoc} */ + protected byte getOrderCode() { + return (byte)0xC7; + } + + /** {@inheritDoc} */ + protected int getLength() { + return super.getLength() + 2; + } + + /** {@inheritDoc} */ + protected void prepareData() { + super.data = super.createData(); + final int fromIndex = 2; + super.addCoords(data, fromIndex); + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsFullArc{" + + ", centerx=" + coords[0] + + ", centery=" + coords[1] + + ", mh=" + mh + + ", mhr=" + mhr + + "}"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsImage.java b/src/java/org/apache/fop/afp/goca/GraphicsImage.java new file mode 100644 index 000000000..24d4c78f8 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsImage.java @@ -0,0 +1,117 @@ +/* + * 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.afp.goca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractStructuredAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * A GOCA Image + */ +public class GraphicsImage extends AbstractStructuredAFPObject { + + /** x coordinate */ + private final int x; + + /** y coordinate */ + private final int y; + + /** width */ + private final int width; + + /** height */ + private final int height; + + /** image data */ + private final byte[] imageData; + + /** + * Main constructor + * + * @param x the x coordinate of the image + * @param y the y coordinate of the image + * @param width the image width + * @param height the image height + * @param imageData the image data + */ + public GraphicsImage(int x, int y, int width, int height, byte[] imageData) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.imageData = imageData; + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] xcoord = BinaryUtils.convert(x, 2); + byte[] ycoord = BinaryUtils.convert(y, 2); + byte[] w = BinaryUtils.convert(width, 2); + byte[] h = BinaryUtils.convert(height, 2); + byte[] data = new byte[] { + (byte) 0xD1, // GBIMG order code + (byte) 0x0A, // LENGTH + xcoord[0], + xcoord[1], + ycoord[0], + ycoord[1], + 0x00, // FORMAT + 0x00, // RES + w[0], // WIDTH + w[1], // + h[0], // HEIGHT + h[1] // + }; + os.write(data); + } + + /** the maximum image data length */ + public static final short MAX_DATA_LEN = 255; + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + byte[] dataHeader = new byte[] { + (byte) 0x92 // GIMD + }; + final int lengthOffset = 1; + writeChunksToStream(imageData, dataHeader, lengthOffset, MAX_DATA_LEN, os); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[] { + (byte) 0x93, // GEIMG order code + 0x00 // LENGTH + }; + os.write(data); + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsImage{x=" + x + + ", y=" + y + + ", width=" + width + + ", height=" + height + + "}"; + } +} diff --git a/src/java/org/apache/fop/afp/goca/GraphicsLine.java b/src/java/org/apache/fop/afp/goca/GraphicsLine.java new file mode 100644 index 000000000..319a9a122 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsLine.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.afp.goca; + + +/** + * A GOCA graphics straight line drawn from the + * given position or current position. + */ +public class GraphicsLine extends AbstractGraphicsCoord { + + /** + * Constructor + * + * @param coords the x/y coordinates for this object + */ + public GraphicsLine(int[] coords) { + super(coords); + } + + /** {@inheritDoc} */ + protected byte getOrderCode() { + return (byte)0xC1; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetArcParameters.java b/src/java/org/apache/fop/afp/goca/GraphicsSetArcParameters.java new file mode 100644 index 000000000..693cf21a9 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetArcParameters.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.afp.goca; + +/** + * Sets the arc parameters for a GOCA graphics arc (circle/ellipse) + */ +public class GraphicsSetArcParameters extends AbstractGraphicsCoord { + + /** + * Constructor + * + * @param xmaj x coordinate of the major axis point + * @param ymin y coordinate of the minor axis point + * @param xmin x coordinate of the minor axis point + * @param ymaj y coordinate of the major axis point + */ + public GraphicsSetArcParameters(int xmaj, int ymin, int xmin, int ymaj) { + super(xmaj, ymin, xmin, ymaj); + } + + /** {@inheritDoc} */ + protected byte getOrderCode() { + return 0x22; + } + + /** {@inheritDoc} */ + public String toString() { + return getName() + "{xmaj=" + coords[0] + + ",ymin=" + coords[1] + + ",xmin=" + coords[2] + + ",ymaj=" + coords[3] + "}"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java b/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java new file mode 100644 index 000000000..f4d04910a --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.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.afp.goca; + +import org.apache.fop.afp.modca.AbstractPreparedAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * Sets the current character set (font) to be used for following graphics strings + */ +public class GraphicsSetCharacterSet extends AbstractPreparedAFPObject { + + /** font character set reference */ + private final int fontReference; + + /** + * @param fontReference character set font reference + */ + public GraphicsSetCharacterSet(int fontReference) { + this.fontReference = fontReference; + prepareData(); + } + + /** {@inheritDoc} */ + protected void prepareData() { + super.data = new byte[] { + 0x38, // GSCS order code + BinaryUtils.convert(fontReference)[0] + }; + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsSetCharacterSet(" + fontReference + ")"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetCurrentPosition.java b/src/java/org/apache/fop/afp/goca/GraphicsSetCurrentPosition.java new file mode 100644 index 000000000..675c2f034 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetCurrentPosition.java @@ -0,0 +1,40 @@ +/* + * 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.afp.goca; + +/** + * Sets the current painting position of the graphics object + */ +public class GraphicsSetCurrentPosition extends AbstractGraphicsCoord { + + /** + * Constructor + * + * @param coords the x/y coordinates for this object + */ + public GraphicsSetCurrentPosition(int[] coords) { + super(coords); + } + + /** {@inheritDoc} */ + protected byte getOrderCode() { + return (byte)0x21; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java b/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java new file mode 100644 index 000000000..0093885a6 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java @@ -0,0 +1,86 @@ +/* + * 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.afp.goca; + +import org.apache.fop.afp.modca.AbstractPreparedAFPObject; + +/** + * Sets the value of the current line type attribute when stroking GOCA shapes (structured fields) + */ +public class GraphicsSetLineType extends AbstractPreparedAFPObject { + + /** the default line type */ + public static final byte DEFAULT = 0x00; // normally SOLID + + /** the default line type */ + public static final byte DOTTED = 0x01; + + /** short dashed line type */ + public static final byte SHORT_DASHED = 0x02; + + /** dashed dotted line type */ + public static final byte DASH_DOT = 0x03; + + /** double dotted line type */ + public static final byte DOUBLE_DOTTED = 0x04; + + /** long dashed line type */ + public static final byte LONG_DASHED = 0x05; + + /** dash double dotted line type */ + public static final byte DASH_DOUBLE_DOTTED = 0x06; + + /** solid line type */ + public static final byte SOLID = 0x07; + + /** invisible line type */ + public static final byte INVISIBLE = 0x08; + + /** line type */ + private byte type = DEFAULT; + + /** + * Main constructor + * + * @param type line type + */ + public GraphicsSetLineType(byte type) { + this.type = type; + prepareData(); + } + + /** {@inheritDoc} */ + protected void prepareData() { + super.data = new byte[] { + 0x18, // GSLW order code + type // line type + }; + } + + private static final String[] TYPES = { + "default (solid)", "dotted", "short dashed", "dash dotted", "double dotted", + "long dashed", "dash double dotted", "solid", "invisible" + }; + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsSetLineType{type=" + TYPES[type] + "}"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java b/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java new file mode 100644 index 000000000..863cbf50d --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.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.afp.goca; + +import org.apache.fop.afp.modca.AbstractPreparedAFPObject; + +/** + * Sets the line width to use when stroking GOCA shapes (structured fields) + */ +public class GraphicsSetLineWidth extends AbstractPreparedAFPObject { + /** line width multiplier */ + private int multiplier = 1; + + /** + * Main constructor + * + * @param multiplier the line width multiplier + */ + public GraphicsSetLineWidth(int multiplier) { + this.multiplier = multiplier; + prepareData(); + } + + /** {@inheritDoc} */ + protected void prepareData() { + super.data = new byte[] { + 0x19, // GSLW order code + (byte)multiplier // MH (line-width) + }; + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsSetLineWidth{multiplier=" + multiplier + "}"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java b/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java new file mode 100644 index 000000000..339620271 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java @@ -0,0 +1,55 @@ +/* + * 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.afp.goca; + +import org.apache.fop.afp.modca.AbstractPreparedAFPObject; + +public class GraphicsSetMix extends AbstractPreparedAFPObject { + + public static final byte MODE_DEFAULT = 0x00; + public static final byte MODE_OVERPAINT = 0x02; + + /** the mix mode value */ + private final byte mode; + + /** + * Main constructor + * + * @param mode the mix mode value + */ + public GraphicsSetMix(byte mode) { + this.mode = mode; + prepareData(); + } + + /** {@inheritDoc} */ + protected void prepareData() { + super.data = new byte[] { + 0x0C, // GSMX order code + mode // MODE (mix mode value) + }; + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsSetMix{mode=" + mode + "}"; + } + +} diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java b/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java new file mode 100644 index 000000000..f0e6845be --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.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.afp.goca; + +import org.apache.fop.afp.modca.AbstractPreparedAFPObject; + +/** + * Sets the pattern symbol to use when filling following GOCA structured fields + */ +public class GraphicsSetPatternSymbol extends AbstractPreparedAFPObject { + /** dotted density 1 */ + public static final byte DOTTED_DENSITY_1 = 0x01; + + /** dotted density 2 */ + public static final byte DOTTED_DENSITY_2 = 0x02; + + /** dotted density 3 */ + public static final byte DOTTED_DENSITY_3 = 0x03; + + /** dotted density 4 */ + public static final byte DOTTED_DENSITY_4 = 0x04; + + /** dotted density 5 */ + public static final byte DOTTED_DENSITY_5 = 0x05; + + /** dotted density 6 */ + public static final byte DOTTED_DENSITY_6 = 0x06; + + /** dotted density 7 */ + public static final byte DOTTED_DENSITY_7 = 0x07; + + /** dotted density 8 */ + public static final byte DOTTED_DENSITY_8 = 0x08; + + /** dotted density 9 */ + public static final byte VERTICAL_LINES = 0x09; + + /** horizontal lines */ + public static final byte HORIZONTAL_LINES = 0x0A; + + /** diagonal lines, bottom left to top right 1 */ + public static final byte DIAGONAL_LINES_BLTR_1 = 0x0B; + + /** diagonal lines, bottom left to top right 2 */ + public static final byte DIAGONAL_LINES_BLTR_2 = 0x0C; + + /** diagonal lines, top left to bottom right 1 */ + public static final byte DIAGONAL_LINES_TLBR_1 = 0x0D; + + /** diagonal lines, top left to bottom right 2 */ + public static final byte DIAGONAL_LINES_TLBR_2 = 0x0E; + + /** no fill */ + public static final byte NO_FILL = 0x0F; + + /** solid fill */ + public static final byte SOLID_FILL = 0x10; + + /** blank (same as no fill) */ + public static final byte BLANK = 0x40; // processed same as NO_FILL + + /** the graphics pattern symbol to use */ + private final byte symbol; + + /** + * Main constructor + * + * @param symb the pattern symbol to use + */ + public GraphicsSetPatternSymbol(byte symb) { + this.symbol = symb; + prepareData(); + } + + /** {@inheritDoc} */ + protected void prepareData() { + super.data = new byte[] { + 0x28, // GSPT order code + symbol + }; + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsSetPatternSymbol(fill=" + + (symbol == SOLID_FILL ? true : false) + ")"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java new file mode 100644 index 000000000..6ec1e50ee --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.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.afp.goca; + +import java.awt.Color; +import java.awt.color.ColorSpace; + +import org.apache.fop.afp.modca.AbstractPreparedAFPObject; + +/** + * Sets the current processing color for the following GOCA structured fields + */ +public class GraphicsSetProcessColor extends AbstractPreparedAFPObject { + /** the color to set */ + private final Color color; + + /** + * Main constructor + * + * @param color the color to set + */ + public GraphicsSetProcessColor(Color color) { + this.color = color; + prepareData(); + } + + /** {@inheritDoc} */ + protected void prepareData() { + // COLSPCE + byte colspace; + int colSpaceType = color.getColorSpace().getType(); + if (colSpaceType == ColorSpace.TYPE_CMYK) { + colspace = 0x04; + } else if (colSpaceType == ColorSpace.TYPE_RGB) { + colspace = 0x01; + } else { + log.error("unsupported colorspace " + colSpaceType); + colspace = 0x01; + } + + // COLSIZE(S) + float[] colcomp = color.getColorComponents(null); + byte[] colsizes = new byte[] {0x00, 0x00, 0x00, 0x00}; + for (int i = 0; i < colcomp.length; i++) { + colsizes[i] = (byte)8; + } + + int len = 10 + colcomp.length; + super.data = new byte[len + 2]; + data[0] = (byte)0xB2; // GSPCOL order code + data[1] = (byte)len; // LEN + data[2] = 0x00; // reserved; must be zero + data[3] = colspace; // COLSPCE + data[4] = 0x00; // reserved; must be zero + data[5] = 0x00; // reserved; must be zero + data[6] = 0x00; // reserved; must be zero + data[7] = 0x00; // reserved; must be zero + data[8] = colsizes[0]; // COLSIZE(S) + data[9] = colsizes[1]; + data[10] = colsizes[2]; + data[11] = colsizes[3]; + // COLVALUE(S) + for (int i = 0; i < colcomp.length; i++) { + data[i + 12] = (byte)(colcomp[i] * 255); + } + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsSetProcessColor(col=" + color + ")"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsString.java b/src/java/org/apache/fop/afp/goca/GraphicsString.java new file mode 100644 index 000000000..0fa14bb6d --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsString.java @@ -0,0 +1,115 @@ +/* + * 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.afp.goca; + +import java.io.UnsupportedEncodingException; + +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.modca.AbstractPreparedAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * A GOCA graphics string + */ +public class GraphicsString extends AbstractPreparedAFPObject { + /** Up to 255 bytes of character data */ + private static final int MAX_STR_LEN = 255; + + /** drawn from the current position */ + private boolean fromCurrentPosition = false; + + /** the string to draw */ + private String str = null; + + /** x coordinate */ + private int x; + + /** y coordinate */ + private int y; + + /** + * Constructor + * + * @param str the character string + */ + public GraphicsString(String str) { + this.str = str; + fromCurrentPosition = true; + prepareData(); + } + + /** + * Constructor + * + * @param str the character string + * @param x the x coordinate + * @param y the y coordinate + */ + public GraphicsString(String str, int x, int y) { + this.str = str; + this.x = x; + this.y = y; + prepareData(); + } + + /** {@inheritDoc} */ + protected void prepareData() { + int maxStrLen = MAX_STR_LEN - (fromCurrentPosition ? 0 : 4); + if (str.length() > maxStrLen) { + str = str.substring(0, maxStrLen); + log.warn("truncated character string, longer than " + maxStrLen + " chars"); + } + byte[] strData = null; + try { + strData = str.getBytes(AFPConstants.EBCIDIC_ENCODING); + } catch (UnsupportedEncodingException ex) { + log.error("unsupported encoding: " + ex.getMessage()); + } + int len = strData.length; + if (fromCurrentPosition) { + data = new byte[len + 2]; + data[0] = (byte)0x83; + data[1] = (byte)len; + System.arraycopy(strData, 0, data, 2, strData.length); + } else { + len += 4; // x/y coordinates + byte[] osx = BinaryUtils.convert(x, 2); + byte[] osy = BinaryUtils.convert(y, 2); + data = new byte[len + 2]; + data[0] = (byte)0xC3; + data[1] = (byte)len; + data[2] = osx[0]; + data[3] = osx[1]; + data[4] = osy[0]; + data[5] = osy[1]; + System.arraycopy(strData, 0, data, 6, strData.length); + } + } + + /** {@inheritDoc} */ + public String toString() { + String string = "GraphicsString{str='" + str + "'"; + if (!fromCurrentPosition) { + string += ",x=" + x + ",y=" + y; + } + string += "}"; + return string; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/ImageCellPosition.java b/src/java/org/apache/fop/afp/ioca/ImageCellPosition.java new file mode 100644 index 000000000..0728ad98f --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/ImageCellPosition.java @@ -0,0 +1,174 @@ +/* + * 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.afp.ioca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The IM Image Cell Position structured field specifies the placement, + * size, and replication of IM image cells. + */ +public class ImageCellPosition extends AbstractAFPObject { + + /** + * Offset of image cell in X direction + */ + private int xOffset = 0; + + /** + * Offset of image cell in Y direction + */ + private int yOffset = 0; + + /** + * Size of image cell in X direction + */ + private final byte[] xSize = new byte[] {(byte)0xFF, (byte)0xFF}; + + /** + * Size of image cell in Y direction + */ + private final byte[] ySize = new byte[] {(byte)0xFF, (byte)0xFF}; + + /** + * Size of fill rectangle in X direction + */ + private final byte[] xFillSize = new byte[] {(byte)0xFF, (byte)0xFF}; + + /** + * Size of fill rectangle in Y direction + */ + private final byte[] yFillSize = new byte[] {(byte)0xFF, (byte)0xFF}; + + /** + * Constructor for the ImageCellPosition + * @param x The offset of image cell in X direction + * @param y The offset of image cell in Y direction + */ + public ImageCellPosition(int x, int y) { + xOffset = x; + yOffset = y; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[21]; + copySF(data, Type.POSITION, Category.IM_IMAGE); + + data[1] = 0x00; // length + data[2] = 0x14; + + /** + * Specifies the offset along the Xp direction, in image points, + * of this image cell from the IM image object area origin. + */ + byte[] x1 = BinaryUtils.convert(xOffset, 2); + data[9] = x1[0]; + data[10] = x1[1]; + + /** + * Specifies the offset along the Yp direction, in image points, + * of this image cell from the IM image object area origin. + */ + byte[] x2 = BinaryUtils.convert(yOffset, 2); + data[11] = x2[0]; + data[12] = x2[1]; + + data[13] = xSize[0]; + data[14] = xSize[1]; + + data[15] = ySize[0]; + data[16] = ySize[1]; + + data[17] = xFillSize[0]; + data[18] = xFillSize[1]; + + data[19] = yFillSize[0]; + data[20] = yFillSize[1]; + + os.write(data); + } + + /** + * Specifies the extent in the X direction, in image points, + * of this image cell. A value of X'FFFF' indicates that the + * default extent specified in bytes 28 and 29 of the Image + * Input Descriptor (IID) is to be used. + * + * @param xcSize The size to set. + */ + public void setXSize(int xcSize) { + byte[] x = BinaryUtils.convert(xcSize, 2); + xSize[0] = x[0]; + xSize[1] = x[1]; + } + + /** + * Specifies the extent of the fill rectangle in the X direction, + * in image points. This value can be smaller than, equal to, or + * larger than the image cell extent in the X direction (XCSize). + * A value of X'FFFF' indicates that the image cell X-extent should + * be used as the fill rectangle X-extent. The fill rectangle is + * filled in the X direction by repeating the image cell in the + * X direction. The image cell can be truncated to fit the rectangle. + * + * @param size The size to set. + */ + public void setXFillSize(int size) { + byte[] x = BinaryUtils.convert(size, 2); + this.xFillSize[0] = x[0]; + this.xFillSize[1] = x[1]; + } + + /** + * Specifies the extent in the Y direction, in image points, + * of this image cell. A value of X'FFFF' indicates that the + * default extent specified in bytes 30 and 31 of the Image + * Input Descriptor (IID) is to be used. + * + * @param size The size to set. + */ + public void setYSize(int size) { + byte[] x = BinaryUtils.convert(size, 2); + this.ySize[0] = x[0]; + this.ySize[1] = x[1]; + } + + /** + * Specifies the extent of the fill rectangle in the Y direction, + * in image points. This value can be smaller than, equal to, or + * larger than the image cell extent in the Y direction (YCSize). + * A value of X'FFFF' indicates that the image cell Y-extent should + * be used as the fill rectangle Y-extent. The fill rectangle is + * filled in the Y direction by repeating the image cell in the + * Y direction. The image cell can be truncated to fit the rectangle. + * + * @param size The size to set. + */ + public void setYFillSize(int size) { + byte[] x = BinaryUtils.convert(size, 2); + this.yFillSize[0] = x[0]; + this.yFillSize[1] = x[1]; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/ImageContent.java b/src/java/org/apache/fop/afp/ioca/ImageContent.java new file mode 100644 index 000000000..27147d511 --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/ImageContent.java @@ -0,0 +1,277 @@ +/* + * 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.afp.ioca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractStructuredAFPObject; + +/** + */ +public class ImageContent extends AbstractStructuredAFPObject { + + /** + * The CCITT T.4 Group 3 Coding Standard (G3 MH-Modified Huffman) is a + * compression method standardized by the International Telegraph and + * Telephone Consultative Committee (CCITT) for facsimile. It enables + * one-dimensional compression. + */ + public static final byte COMPID_G3_MH = (byte)0x80; + + /** + * The CCITT T.4 Group 3 Coding Option (G3 MR-Modified READ) is a + * compression method standardized by the International Telegraph and + * Telephone Consultative Committee (CCITT) for facsimile. It enables + * two-dimensional compression. + */ + public static final byte COMPID_G3_MR = (byte)0x81; + + /** + * The CCITT T.6 Group 4 Coding Standard (G4 MMR-Modified Modified READ) is a + * compression method standardized by the International Telegraph and + * Telephone Consultative Committee (CCITT) for facsimile. It enables + * two-dimensional compression. + */ + public static final byte COMPID_G3_MMR = (byte)0x82; + + /** + * The image size parameter + */ + private ImageSizeParameter imageSizeParameter = null; + + /** + * The image encoding + */ + private byte encoding = (byte)0x03; + + /** + * The image ide size + */ + private byte size = 1; + + /** + * The image compression + */ + private byte compression = (byte)0xC0; + + /** + * The image color model + */ + private byte colorModel = (byte)0x01; + + /** + * The image data + */ + private byte[] data; + + /** + * Constructor for the image content + */ + public ImageContent() { + } + + /** + * Sets the image size parameter + * + * @param imageSizeParameter the image size parameter. + */ + public void setImageSizeParameter(ImageSizeParameter imageSizeParameter) { + this.imageSizeParameter = imageSizeParameter; + } + + /** + * Sets the image encoding. + * + * @param enc The image encoding. + */ + public void setImageEncoding(byte enc) { + this.encoding = enc; + } + + /** + * Sets the image compression. + * + * @param comp The image compression. + */ + public void setImageCompression(byte comp) { + this.compression = comp; + } + + /** + * Sets the image IDE size. + * + * @param s The IDE size. + */ + public void setImageIDESize(byte s) { + this.size = s; + } + + /** + * Sets the image IDE color model. + * + * @param color the IDE color model. + */ + public void setImageIDEColorModel(byte color) { + this.colorModel = color; + } + + /** + * Set the data image store information. + * + * @param imageData the image data + */ + public void setImageData(byte[] imageData) { + this.data = imageData; + } + + private static final int MAX_DATA_LEN = 65535; + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + if (imageSizeParameter != null) { + imageSizeParameter.writeToStream(os); + } + + // TODO convert to triplet/parameter class + os.write(getImageEncodingParameter()); + + os.write(getImageIDESizeParameter()); + + os.write(getIDEStructureParameter()); + + os.write(getExternalAlgorithmParameter()); + + // Image Data + if (data != null) { + final byte[] dataHeader = new byte[] { + (byte)0xFE, // ID + (byte)0x92, // ID + 0x00, // length + 0x00 // length + }; + final int lengthOffset = 2; + writeChunksToStream(this.data, dataHeader, lengthOffset, MAX_DATA_LEN, os); + } + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + final byte[] startData = new byte[] { + (byte)0x91, // ID + 0x01, // Length + (byte)0xff, // Object Type = IOCA Image Object + }; + os.write(startData); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + final byte[] endData = new byte[] { + (byte)0x93, // ID + 0x00, // Length + }; + os.write(endData); + } + + /** + * Helper method to return the image encoding parameter. + * + * @return byte[] The data stream. + */ + private byte[] getImageEncodingParameter() { + final byte[] encodingData = new byte[] { + (byte)0x95, // ID + 0x02, // Length + encoding, + 0x01, // RECID + }; + return encodingData; + } + + /** + * Helper method to return the external algorithm parameter. + * + * @return byte[] The data stream. + */ + private byte[] getExternalAlgorithmParameter() { + if (encoding == (byte)0x83 && compression != 0) { + final byte[] extAlgData = new byte[] { + (byte)0x95, // ID + 0x00, // Length + 0x10, // ALGTYPE = Compression Algorithm + 0x00, // Reserved + (byte)0x83, // COMPRID = JPEG + 0x00, // Reserved + 0x00, // Reserved + 0x00, // Reserved + compression, // MARKER + 0x00, // Reserved + 0x00, // Reserved + 0x00, // Reserved + }; + extAlgData[1] = (byte)(extAlgData.length - 2); + return extAlgData; + } + return new byte[0]; + } + + /** + * Helper method to return the image encoding parameter. + * + * @return byte[] The data stream. + */ + private byte[] getImageIDESizeParameter() { + final byte[] ideSizeData = new byte[] { + (byte)0x96, // ID + 0x01, // Length + size, + }; + return ideSizeData; + } + + /** + * Helper method to return the external algorithm parameter. + * + * @return byte[] The data stream. + */ + private byte[] getIDEStructureParameter() { + if (colorModel != 0 && size == 24) { + final byte bits = (byte)(size / 3); + final byte[] ideStructData = new byte[] { + (byte)0x9B, // ID + 0x00, // Length + 0x00, // FLAGS + 0x00, // Reserved + colorModel, // COLOR MODEL + 0x00, // Reserved + 0x00, // Reserved + 0x00, // Reserved + bits, + bits, + bits, + }; + ideStructData[1] = (byte)(ideStructData.length - 2); + return ideStructData; + } + return new byte[0]; + } + +} diff --git a/src/java/org/apache/fop/afp/ioca/ImageInputDescriptor.java b/src/java/org/apache/fop/afp/ioca/ImageInputDescriptor.java new file mode 100644 index 000000000..f3351933c --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/ImageInputDescriptor.java @@ -0,0 +1,138 @@ +/* + * 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.afp.ioca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The IM Image Input Descriptor structured field contains the + * descriptor data for an IM image data object. This data specifies + * the resolution, size, and color of the IM image. + */ +public class ImageInputDescriptor extends AbstractAFPObject { + + /** + * The resolution of the raster image (default 240) + */ + private int resolution = 240; + + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + + byte[] data = new byte[45]; + copySF(data, Type.DESCRIPTOR, Category.IM_IMAGE); + + data[1] = 0x00; // length + data[2] = 0x2C; + + // Constant data. + data[9] = 0x00; + data[10] = 0x00; + data[11] = 0x09; + data[12] = 0x60; + data[13] = 0x09; + data[14] = 0x60; + data[15] = 0x00; + data[16] = 0x00; + data[17] = 0x00; + data[18] = 0x00; + data[19] = 0x00; + data[20] = 0x00; + + // X Base (Fixed x00) + data[21] = 0x00; + // Y Base (Fixed x00) + data[22] = 0x00; + + byte[] imagepoints = BinaryUtils.convert(resolution * 10, 2); + + /** + * Specifies the number of image points per unit base for the X axis + * of the image. This value is ten times the resolution of the image + * in the X direction. + */ + data[23] = imagepoints[0]; + data[24] = imagepoints[1]; + + /** + * Specifies the number of image points per unit base for the Y axis + * of the image. This value is ten times the resolution of the image + * in the Y direction. + */ + data[25] = imagepoints[0]; + data[26] = imagepoints[1]; + + /** + * Specifies the extent in the X direction, in image points, of an + * non-celled (simple) image. + */ + data[27] = 0x00; + data[28] = 0x01; + + /** + * Specifies the extent in the Y direction, in image points, of an + * non-celled (simple) image. + */ + data[29] = 0x00; + data[30] = 0x01; + + // Constant Data + data[31] = 0x00; + data[32] = 0x00; + data[33] = 0x00; + data[34] = 0x00; + data[35] = 0x2D; + data[36] = 0x00; + + // Default size of image cell in X direction + data[37] = 0x00; + data[38] = 0x01; + + // Default size of image cell in Y direction + data[39] = 0x00; + data[40] = 0x01; + + // Constant Data + data[41] = 0x00; + data[42] = 0x01; + + // Image Color + data[43] = (byte)0xFF; + data[44] = (byte)0xFF; + + os.write(data); + } + + /** + * Sets the resolution information for the raster image + * the default value is a resolution of 240 dpi. + * + * @param resolution The resolution value + */ + public void setResolution(int resolution) { + this.resolution = resolution; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/ImageOutputControl.java b/src/java/org/apache/fop/afp/ioca/ImageOutputControl.java new file mode 100644 index 000000000..8574f445b --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/ImageOutputControl.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.afp.ioca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The IM Image Output Control structured field specifies the position and + * orientation of the IM image object area and the mapping of the image points + * to presentation device pels. + * + */ +public class ImageOutputControl extends AbstractAFPObject { + + /** + * The orientation of the image + */ + private int orientation = 0; + + /** + * Specifies the offset, along the X-axis, of the IM image object area + * origin to the origin of the including page + */ + private int xCoord = 0; + + /** + * Specifies the offset, along the Y-axis, of the IM image object area + * origin to the origin of the including page + */ + private int yCoord = 0; + + /** + * Map an image point to a single presentation device + */ + private boolean singlePoint = true; + + /** + * Constructor for the ImageOutputControl The x parameter specifies the + * offset, along the X-axis, of the IM image object area origin to the + * origin of the including page and the y parameter specifies the offset + * along the Y-axis. The offset is specified in image points and is resolved + * using the units of measure specified for the image in the IID structured + * field. + * + * @param x + * The X-axis offset. + * @param y + * The Y-axis offset. + */ + public ImageOutputControl(int x, int y) { + xCoord = x; + yCoord = y; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + + byte[] data = new byte[33]; + + data[0] = 0x5A; + data[1] = 0x00; + data[2] = 0x20; + data[3] = (byte) 0xD3; + data[4] = (byte) 0xA7; + data[5] = (byte) 0x7B; + data[6] = 0x00; + data[7] = 0x00; + data[8] = 0x00; + + // XoaOset + byte[] x1 = BinaryUtils.convert(xCoord, 3); + data[9] = x1[0]; + data[10] = x1[1]; + data[11] = x1[2]; + + // YoaOset + byte[] x2 = BinaryUtils.convert(yCoord, 3); + data[12] = x2[0]; + data[13] = x2[1]; + data[14] = x2[2]; + + switch (orientation) { + case 0: + // 0 and 90 degrees respectively + data[15] = 0x00; + data[16] = 0x00; + data[17] = 0x2D; + data[18] = 0x00; + break; + case 90: + // 90 and 180 degrees respectively + data[15] = 0x2D; + data[16] = 0x00; + data[17] = 0x5A; + data[18] = 0x00; + break; + case 180: + // 180 and 270 degrees respectively + data[15] = 0x5A; + data[16] = 0x00; + data[17] = (byte) 0x87; + data[18] = 0x00; + break; + case 270: + // 270 and 0 degrees respectively + data[15] = (byte) 0x87; + data[16] = 0x00; + data[17] = 0x00; + data[18] = 0x00; + break; + default: + // 0 and 90 degrees respectively + data[15] = 0x00; + data[16] = 0x00; + data[17] = 0x2D; + data[18] = 0x00; + break; + + } + + // Constant Data + data[19] = 0x00; + data[20] = 0x00; + data[21] = 0x00; + data[22] = 0x00; + data[23] = 0x00; + data[24] = 0x00; + data[25] = 0x00; + data[26] = 0x00; + + if (singlePoint) { + data[27] = 0x03; + data[28] = (byte) 0xE8; + data[29] = 0x03; + data[30] = (byte) 0xE8; + } else { + data[27] = 0x07; + data[28] = (byte) 0xD0; + data[29] = 0x07; + data[30] = (byte) 0xD0; + } + + // Constant Data + data[31] = (byte) 0xFF; + data[32] = (byte) 0xFF; + + os.write(data); + } + + /** + * Sets the orientation which specifies the amount of clockwise rotation of + * the IM image object area. + * + * @param orientation + * The orientation to set. + */ + public void setOrientation(int orientation) { + + if (orientation == 0 || orientation == 90 || orientation == 180 + || orientation == 270) { + this.orientation = orientation; + } else { + throw new IllegalArgumentException( + "The orientation must be one of the values 0, 90, 180, 270"); + } + } + + /** + * Sets the singlepoint, if true map an image point to a single presentation + * device pel in the IM image object area. If false map an image point to + * two presentation device pels in the IM image object area (double-dot) + * + * @param singlepoint + * Use the singlepoint basis when true. + */ + public void setSinglepoint(boolean singlepoint) { + singlePoint = singlepoint; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/ImageRasterData.java b/src/java/org/apache/fop/afp/ioca/ImageRasterData.java new file mode 100644 index 000000000..115472bd8 --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/ImageRasterData.java @@ -0,0 +1,77 @@ +/* + * 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.afp.ioca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractAFPObject; +import org.apache.fop.afp.modca.AbstractAFPObject.Category; +import org.apache.fop.afp.modca.AbstractAFPObject.Type; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * Contains the image points that define the IM image raster pattern. + * + * A raster pattern is the array of presentation device pels that forms + * the image. The image data is uncompressed. Bits are grouped into + * bytes and are ordered from left to right within each byte. Each bit + * in the image data represents an image point and is mapped to + * presentation device pels as specified in the IOC structured field. + * A bit with value B'1' indicates a significant image point; a bit + * with value B'0' indicates an insignificant image point. + * Image points are recorded from left to right in rows that represents + * scan lines (X direction), and rows representing scan lines are + * recorded from top to bottom (Y direction). When the image is + * presented, all image points in a row are presented before any + * image points in the next sequential row are presented, and all rows + * have the same number of image points. If the total number of image + * points is not a multiple of 8, the last byte of the image data is + * padded to a byte boundary. The padding bits do not represent image + * points and are ignored by presentation devices. + */ +public class ImageRasterData extends AbstractAFPObject { + + /** + * The image raster data + */ + private final byte[] rasterData; + + /** + * Constructor for the image raster data object + * @param data The raster image data + */ + public ImageRasterData(byte[] data) { + this.rasterData = data; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[9]; + copySF(data, Type.DATA, Category.IM_IMAGE); + // The size of the structured field + byte[] len = BinaryUtils.convert(rasterData.length + 8, 2); + data[1] = len[0]; + data[2] = len[1]; + os.write(data); + + os.write(rasterData); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java b/src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java new file mode 100644 index 000000000..789eeb950 --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/ImageRasterPattern.java @@ -0,0 +1,759 @@ +/* + * 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.afp.ioca; + +/** + * Raster data is a grid of cells covering an area of interest. + * Each pixel, the smallest unit of information in the grid, displays + * a unique attribute. This static class generates raster data for different + * shades of grey (betweeen 0 and 16) the lower the number being the + * darker the shade. The image data dimensions are 64 x 8. + */ +public class ImageRasterPattern { + + /** + * The Raster Pattern for Greyscale 16 + */ + private static final byte[] GREYSCALE16 = new byte[] { + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + }; + + /** + * The Raster Pattern for Greyscale 15 + */ + private static final byte[] GREYSCALE15 = new byte[] { + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + }; + + /** + * The Raster Pattern for Greyscale 14 + */ + private static final byte[] GREYSCALE14 = new byte[] { + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + }; + + + /** + * The Raster Pattern for Greyscale 13 + */ + private static final byte[] GREYSCALE13 = new byte[] { + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + }; + + /** + * The Raster Pattern for Greyscale 12 + */ + private static final byte[] GREYSCALE12 = new byte[] { + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + }; + + /** + * The Raster Pattern for Greyscale 11 + */ + private static final byte[] GREYSCALE11 = new byte[] { + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + }; + + /** + * The Raster Pattern for Greyscale 10 + */ + private static final byte[] GREYSCALE10 = new byte[] { + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + 0x44, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + }; + + /** + * The Raster Pattern for Greyscale 9 + */ + private static final byte[] GREYSCALE09 = new byte[] { + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + 0x11, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + }; + + /** + * The Raster Pattern for Greyscale 8 + */ + private static final byte[] GREYSCALE08 = new byte[] { + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + }; + + + /** + * The Raster Pattern for Greyscale 7 + */ + private static final byte[] GREYSCALE07 = new byte[] { + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + }; + + + /** + * The Raster Pattern for Greyscale 6 + */ + private static final byte[] GREYSCALE06 = new byte[] { + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + }; + + /** + * The Raster Pattern for Greyscale 5 + */ + private static final byte[] GREYSCALE05 = new byte[] { + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xEE, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + }; + + + /** + * The Raster Pattern for Greyscale 4 + */ + private static final byte[] GREYSCALE04 = new byte[] { + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xAA, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + }; + + /** + * The Raster Pattern for Greyscale 3 + */ + private static final byte[] GREYSCALE03 = new byte[] { + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + 0x55, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xBB, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + }; + + /** + * The Raster Pattern for Greyscale 2 + */ + private static final byte[] GREYSCALE02 = new byte[] { + 0x77, + 0x77, + 0x77, + 0x77, + 0x77, + 0x77, + 0x77, + 0x77, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xDD, + (byte)0xDD, + (byte)0xDD, + (byte)0xDD, + (byte)0xDD, + (byte)0xDD, + (byte)0xDD, + (byte)0xDD, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + }; + + + /** + * The Raster Pattern for Greyscale 1 + */ + private static final byte[] GREYSCALE01 = new byte[] { + 0x77, + 0x77, + 0x77, + 0x77, + 0x77, + 0x77, + 0x77, + 0x77, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + }; + + + /** + * The Raster Pattern for Greyscale 00 + */ + private static final byte[] GREYSCALE00 = new byte[] { + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + (byte)0xFF, + }; + + /** + * Static method to return the raster image data for the + * grey scale specified. The scale should be between 0 (darkest) + * and 16 (lightest). + * @param greyscale The grey scale value (0 - 16) + * @return the raster data byte array for the given greyscale value + */ + public static byte[] getRasterData(int greyscale) { + + int repeat = 16; + + byte[] greypattern = new byte[32]; + byte[] rasterdata = new byte[32 * repeat]; + + switch (greyscale) { + case 0: + System.arraycopy(GREYSCALE00, 0, greypattern, 0, 32); + break; + case 1: + System.arraycopy(GREYSCALE01, 0, greypattern, 0, 32); + break; + case 2: + System.arraycopy(GREYSCALE02, 0, greypattern, 0, 32); + break; + case 3: + System.arraycopy(GREYSCALE03, 0, greypattern, 0, 32); + break; + case 4: + System.arraycopy(GREYSCALE04, 0, greypattern, 0, 32); + break; + case 5: + System.arraycopy(GREYSCALE05, 0, greypattern, 0, 32); + break; + case 6: + System.arraycopy(GREYSCALE06, 0, greypattern, 0, 32); + break; + case 7: + System.arraycopy(GREYSCALE07, 0, greypattern, 0, 32); + break; + case 8: + System.arraycopy(GREYSCALE08, 0, greypattern, 0, 32); + break; + case 9: + System.arraycopy(GREYSCALE09, 0, greypattern, 0, 32); + break; + case 10: + System.arraycopy(GREYSCALE10, 0, greypattern, 0, 32); + break; + case 11: + System.arraycopy(GREYSCALE11, 0, greypattern, 0, 32); + break; + case 12: + System.arraycopy(GREYSCALE12, 0, greypattern, 0, 32); + break; + case 13: + System.arraycopy(GREYSCALE13, 0, greypattern, 0, 32); + break; + case 14: + System.arraycopy(GREYSCALE14, 0, greypattern, 0, 32); + break; + case 15: + System.arraycopy(GREYSCALE15, 0, greypattern, 0, 32); + break; + case 16: + System.arraycopy(GREYSCALE16, 0, greypattern, 0, 32); + break; + default : + System.arraycopy(GREYSCALE00, 0, greypattern, 0, 32); + break; + } + + for (int i = 0; i < repeat; i++) { + System.arraycopy(greypattern, 0, rasterdata, i * 32, 32); + } + return rasterdata; + } +} diff --git a/src/java/org/apache/fop/afp/ioca/ImageSegment.java b/src/java/org/apache/fop/afp/ioca/ImageSegment.java new file mode 100644 index 000000000..eab8b931a --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/ImageSegment.java @@ -0,0 +1,161 @@ +/* + * 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.afp.ioca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.modca.AbstractNamedAFPObject; + +/** + * An Image Segment is represented by a set of self-defining fields, fields + * that describe their own contents. It starts with a Begin Segment, and + * ends with an End Segment. + * + * Between the Begin Segment and End Segment is the image information to + * be processed, called the Image Content. + * + * Only one Image Content can exist within a single IOCA Image Segment. + */ +public class ImageSegment extends AbstractNamedAFPObject { + + /** + * The ImageContent for the image segment + */ + private ImageContent imageContent = null; + + private final Factory factory; + + /** + * Constructor for the image segment with the specified name, + * the name must be a fixed length of eight characters. + * @param factory the object factory + * + * @param name the name of the image. + */ + public ImageSegment(Factory factory, String name) { + super(name); + this.factory = factory; + } + + private ImageContent getImageContent() { + if (imageContent == null) { + this.imageContent = factory.createImageContent(); + } + return imageContent; + } + + /** + * Sets the image size parameters resolution, hsize and vsize. + * + * @param hsize The horizontal size of the image. + * @param vsize The vertical size of the image. + * @param hresol The horizontal resolution of the image. + * @param vresol The vertical resolution of the image. + */ + public void setImageSize(int hsize, int vsize, int hresol, int vresol) { + ImageSizeParameter imageSizeParameter + = factory.createImageSizeParameter(hsize, vsize, hresol, vresol); + getImageContent().setImageSizeParameter(imageSizeParameter); + } + + /** + * Sets the image encoding. + * + * @param encoding The image encoding. + */ + public void setEncoding(byte encoding) { + getImageContent().setImageEncoding(encoding); + } + + /** + * Sets the image compression. + * + * @param compression The image compression. + */ + public void setCompression(byte compression) { + getImageContent().setImageCompression(compression); + } + + /** + * Sets the image IDE size. + * + * @param size The IDE size. + */ + public void setIDESize(byte size) { + getImageContent().setImageIDESize(size); + } + + /** + * Sets the image IDE color model. + * + * @param colorModel the IDE color model. + */ + public void setIDEColorModel(byte colorModel) { + getImageContent().setImageIDEColorModel(colorModel); + } + + /** + * Set the data image data. + * + * @param data the image data + */ + public void setData(byte[] data) { + getImageContent().setImageData(data); + } + + /** {@inheritDoc} */ + public void writeContent(OutputStream os) throws IOException { + if (imageContent != null) { + imageContent.writeToStream(os); + } + } + + private static final int NAME_LENGTH = 4; + + /** {@inheritDoc} */ + protected int getNameLength() { + return NAME_LENGTH; + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] nameBytes = getNameBytes(); + byte[] data = new byte[] { + 0x70, // ID + 0x04, // Length + nameBytes[0], // Name byte 1 + nameBytes[1], // Name byte 2 + nameBytes[2], // Name byte 3 + nameBytes[3], // Name byte 4 + }; + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[] { + 0x71, // ID + 0x00, // Length + }; + os.write(data); + } +} diff --git a/src/java/org/apache/fop/afp/ioca/ImageSizeParameter.java b/src/java/org/apache/fop/afp/ioca/ImageSizeParameter.java new file mode 100644 index 000000000..38e7d9e56 --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/ImageSizeParameter.java @@ -0,0 +1,88 @@ +/* + * 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.afp.ioca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.AbstractAFPObject; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * Describes the measurement characteristics of the image when it is created. + */ +public class ImageSizeParameter extends AbstractAFPObject { + + private int hSize = 0; + private int vSize = 0; + private int hRes = 0; + private int vRes = 0; + + /** + * Constructor for a ImageSizeParameter for the specified + * resolution, hsize and vsize. + * + * @param hsize The horizontal size of the image. + * @param vsize The vertical size of the image. + * @param hresol The horizontal resolution of the image. + * @param vresol The vertical resolution of the image. + */ + public ImageSizeParameter(int hsize, int vsize, int hresol, int vresol) { + this.hSize = hsize; + this.vSize = vsize; + this.hRes = hresol; + this.vRes = vresol; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[] { + (byte)0x94, // ID = Image Size Parameter + 0x09, // Length + 0x00, // Unit base - 10 Inches + 0x00, // HRESOL + 0x00, // + 0x00, // VRESOL + 0x00, // + 0x00, // HSIZE + 0x00, // + 0x00, // VSIZE + 0x00, // + }; + + byte[] x = BinaryUtils.convert(hRes, 2); + data[3] = x[0]; + data[4] = x[1]; + + byte[] y = BinaryUtils.convert(vRes, 2); + data[5] = y[0]; + data[6] = y[1]; + + byte[] w = BinaryUtils.convert(hSize, 2); + data[7] = w[0]; + data[8] = w[1]; + + byte[] h = BinaryUtils.convert(vSize, 2); + data[9] = h[0]; + data[10] = h[1]; + + os.write(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java new file mode 100644 index 000000000..9e1e107f3 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java @@ -0,0 +1,244 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Collection; +import java.util.Iterator; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.Streamable; + +/** + * This is the base class for all data stream objects. Page objects are + * responsible for building and generating the binary datastream in an + * AFP format. + */ +public abstract class AbstractAFPObject implements Streamable { + + /** Static logging instance */ + protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp.modca"); + + /** the structured field class id */ + protected static final byte SF_CLASS = (byte)0xD3; + + private static final byte[] SF_HEADER = new byte[] { + 0x5A, // Structured field identifier + 0x00, // Length byte 1 + 0x10, // Length byte 2 + SF_CLASS, // Structured field id byte 1 + (byte) 0x00, // Structured field id byte 2 + (byte) 0x00, // Structured field id byte 3 + 0x00, // Flags + 0x00, // Reserved + 0x00, // Reserved + }; + + /** + * Copies the template structured field data array to the given byte array + * + * @param data the structured field data byte array + * @param type the type code + * @param category the category code + */ + protected void copySF(byte[] data, byte type, byte category) { + copySF(data, SF_CLASS, type, category); + } + + /** + * Copies the template structured field data array to the given byte array + * + * @param data the structured field data byte array + * @param clazz the class code + * @param type the type code + * @param category the category code + */ + protected static void copySF(byte[] data, byte clazz, byte type, byte category) { + System.arraycopy(SF_HEADER, 0, data, 0, SF_HEADER.length); + data[3] = clazz; + data[4] = type; + data[5] = category; + } + + /** + * Help method to write a set of AFPObjects to the AFP datastream. + * + * @param objects a list of AFPObjects + * @param os The stream to write to + * @throws java.io.IOException an I/O exception of some sort has occurred. + */ + protected void writeObjects(Collection/**/ objects, OutputStream os) + throws IOException { + if (objects != null && objects.size() > 0) { + Iterator it = objects.iterator(); + while (it.hasNext()) { + Object object = it.next(); + if (object instanceof Streamable) { + ((Streamable)object).writeToStream(os); + it.remove(); // once written, immediately remove the object + } + } + } + } + + /** structured field type codes */ + public interface Type { + + /** Attribute */ + byte ATTRIBUTE = (byte)0x0A; + + /** Copy Count */ + byte COPY_COUNT = (byte)0xA2; + + /** Descriptor */ + byte DESCRIPTOR = (byte)0xA6; + + /** Control */ + byte CONTROL = (byte)0xA7; + + /** Begin */ + byte BEGIN = (byte)0xA8; + + /** End */ + byte END = (byte)0xA9; + + /** Map */ + byte MAP = (byte)0xAB; + + /** Position */ + byte POSITION = (byte)0xAC; + + /** Process */ + byte PROCESS = (byte)0xAD; + + /** Include */ + byte INCLUDE = (byte)0xAF; + + /** Table */ + byte TABLE = (byte)0xB0; + + /** Migration */ + byte MIGRATION = (byte)0xB1; + + /** Variable */ + byte VARIABLE = (byte)0xB2; + + /** Link */ + byte LINK = (byte)0xB4; + + /** Data */ + byte DATA = (byte)0xEE; + } + + /** structured field category codes */ + public interface Category { + + /** Page Segment */ + byte PAGE_SEGMENT = (byte)0x5F; + + /** Object Area */ + byte OBJECT_AREA = (byte)0x6B; + + /** Color Attribute Table */ + byte COLOR_ATTRIBUTE_TABLE = (byte)0x77; + + /** IM Image */ + byte IM_IMAGE = (byte)0x7B; + + /** Medium */ + byte MEDIUM = (byte)0x88; + + /** Coded Font */ + byte CODED_FONT = (byte)0x8A; + + /** Process Element */ + byte PROCESS_ELEMENT = (byte)0x90; + + /** Object Container */ + byte OBJECT_CONTAINER = (byte)0x92; + + /** Presentation Text */ + byte PRESENTATION_TEXT = (byte)0x9B; + + /** Index */ + byte INDEX = (byte)0xA7; + + /** Document */ + byte DOCUMENT = (byte)0xA8; + + /** Page Group */ + byte PAGE_GROUP = (byte)0xAD; + + /** Page */ + byte PAGE = (byte)0xAF; + + /** Graphics */ + byte GRAPHICS = (byte)0xBB; + + /** Data Resource */ + byte DATA_RESOURCE = (byte)0xC3; + + /** Document Environment Group (DEG) */ + byte DOCUMENT_ENVIRONMENT_GROUP = (byte)0xC4; + + /** Resource Group */ + byte RESOURCE_GROUP = (byte)0xC6; + + /** Object Environment Group (OEG) */ + byte OBJECT_ENVIRONMENT_GROUP = (byte)0xC7; + + /** Active Environment Group (AEG) */ + byte ACTIVE_ENVIRONMENT_GROUP = (byte)0xC9; + + /** Medium Map */ + byte MEDIUM_MAP = (byte)0xCC; + + /** Form Map */ + byte FORM_MAP = (byte)0xCD; + + /** Name Resource */ + byte NAME_RESOURCE = (byte)0xCE; + + /** Page Overlay */ + byte PAGE_OVERLAY = (byte)0xD8; + + /** Resource Environment Group (REG) */ + byte RESOURCE_ENVIROMENT_GROUP = (byte)0xD9; + + /** Overlay */ + byte OVERLAY = (byte)0xDF; + + /** Data Suppression */ + byte DATA_SUPRESSION = (byte)0xEA; + + /** Bar Code */ + byte BARCODE = (byte)0xEB; + + /** No Operation */ + byte NO_OPERATION = (byte)0xEE; + + /** Image */ + byte IMAGE = (byte)0xFB; + } + +} + diff --git a/src/java/org/apache/fop/afp/modca/AbstractDataObject.java b/src/java/org/apache/fop/afp/modca/AbstractDataObject.java new file mode 100644 index 000000000..c7b987a9e --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractDataObject.java @@ -0,0 +1,108 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceLevel; +import org.apache.fop.afp.Factory; + +/** + * Abstract base class used by the ImageObject and GraphicsObject which both + * have define an ObjectEnvironmentGroup + */ +public abstract class AbstractDataObject extends AbstractNamedAFPObject { + + /** the object environment group */ + protected ObjectEnvironmentGroup objectEnvironmentGroup = null; + + /** the object factory */ + protected final Factory factory; + + /** + * Named constructor + * + * @param factory the object factory + * @param name data object name + */ + public AbstractDataObject(Factory factory, String name) { + super(name); + this.factory = factory; + } + + /** + * Sets the object view port (area position and size). + * + * @param dataObjectInfo + * the object area info + */ + public void setViewport(AFPDataObjectInfo dataObjectInfo) { + AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + + // object area descriptor + int width = objectAreaInfo.getWidth(); + int height = objectAreaInfo.getHeight(); + int widthRes = objectAreaInfo.getWidthRes(); + int heightRes = objectAreaInfo.getHeightRes(); + ObjectAreaDescriptor objectAreaDescriptor + = factory.createObjectAreaDescriptor(width, height, widthRes, heightRes); + getObjectEnvironmentGroup().setObjectAreaDescriptor(objectAreaDescriptor); + + // object area position + AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + AFPResourceLevel resourceLevel = resourceInfo.getLevel(); + ObjectAreaPosition objectAreaPosition = null; + if (resourceLevel.isInline()) { + int x = objectAreaInfo.getX(); + int y = objectAreaInfo.getY(); + int rotation = objectAreaInfo.getRotation(); + objectAreaPosition = factory.createObjectAreaPosition(x, y, rotation); + } else { + // positional values are specified in the oaOffset of the include object + objectAreaPosition = factory.createObjectAreaPosition(0, 0, 0); + } + getObjectEnvironmentGroup().setObjectAreaPosition(objectAreaPosition); + } + + /** + * Gets the ObjectEnvironmentGroup + * + * @return the object environment group + */ + public ObjectEnvironmentGroup getObjectEnvironmentGroup() { + if (objectEnvironmentGroup == null) { + this.objectEnvironmentGroup = factory.createObjectEnvironmentGroup(); + } + return objectEnvironmentGroup; + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); // write triplets + if (objectEnvironmentGroup != null) { + objectEnvironmentGroup.writeToStream(os); + } + } + +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java b/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java new file mode 100644 index 000000000..f3734cfb7 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractDescriptor.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.afp.modca; + +/** + * Base class for AFP descriptor objects + */ +public abstract class AbstractDescriptor extends AbstractStructuredAFPObject { + /** width of this descriptor */ + protected int width = 0; + /** height of this descriptor */ + protected int height = 0; + /** width resolution of this descriptor */ + protected int widthRes = 0; + /** height resolution of this descriptor */ + protected int heightRes = 0; + + /** + * Default constructor + */ + public AbstractDescriptor() { + } + + /** + * Constructor a PresentationTextDescriptor for the specified + * width and height. + * + * @param width The width of the page. + * @param height The height of the page. + * @param widthRes The width resolution of the page. + * @param heightRes The height resolution of the page. + */ + public AbstractDescriptor(int width, int height, int widthRes, int heightRes) { + this.width = width; + this.height = height; + this.widthRes = widthRes; + this.heightRes = heightRes; + } + + /** {@inheritDoc} */ + public String toString() { + return "width=" + width + + ", height=" + height + + ", widthRes=" + widthRes + + ", heightRes=" + heightRes; + } +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java new file mode 100644 index 000000000..a58bba1f0 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractEnvironmentGroup.java @@ -0,0 +1,101 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +/** + * A base class that encapsulates common features of + * ActiveEnvironmentGroup and ResourceEnvironmentGroup + */ +public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject { + + /** + * The collection of MapPageOverlay objects + */ + protected List mapPageOverlays = null; + + /** + * Main constructor + * + * @param name the object name + */ + public AbstractEnvironmentGroup(String name) { + super(name); + } + + private List getMapPageOverlays() { + if (mapPageOverlays == null) { + mapPageOverlays = new java.util.ArrayList(); + } + return mapPageOverlays; + } + + /** + * Actually creates the MPO object. + * Also creates the supporting object (an IPO) + * + * @param name the name of the overlay to be used + */ + public void createOverlay(String name) { + MapPageOverlay mpo = getCurrentMapPageOverlay(); + if (mpo == null) { + mpo = new MapPageOverlay(); + getMapPageOverlays().add(mpo); + } + + try { + mpo.addOverlay(name); + } catch (MaximumSizeExceededException msee) { + mpo = new MapPageOverlay(); + getMapPageOverlays().add(mpo); + try { + mpo.addOverlay(name); + } catch (MaximumSizeExceededException ex) { + // Should never happen (but log just in case) + log.error("createOverlay():: resulted in a MaximumSizeExceededException"); + } + } + } + + /** + * Getter method for the most recent MapPageOverlay added to the + * Active Environment Group (returns null if no MapPageOverlay exist) + * + * @return the most recent Map Coded Font + */ + private MapPageOverlay getCurrentMapPageOverlay() { + if (mapPageOverlays != null && mapPageOverlays.size() > 0) { + return (MapPageOverlay) mapPageOverlays.get(mapPageOverlays.size() - 1); + } else { + return null; + } + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + if (mapPageOverlays != null) { + writeObjects(mapPageOverlays, os); + } + } +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java new file mode 100644 index 000000000..de02f13d3 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java @@ -0,0 +1,113 @@ +/* + * 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.afp.modca; + +import java.io.UnsupportedEncodingException; + +import org.apache.fop.afp.AFPConstants; + +/** + * This is the base class for all named data stream objects. + * A named data stream object has an 8 byte EBCIDIC name. + */ +public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject { + + private static final int DEFAULT_NAME_LENGTH = 8; + + /** + * 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. + * + * @param name the object name + */ + protected AbstractNamedAFPObject(String name) { + this.name = name; + } + + /** + * Returns the name length + * + * @return the name length + */ + protected int getNameLength() { + return DEFAULT_NAME_LENGTH; + } + + /** + * Returns the name as a byte array in EBCIDIC encoding + * + * @return the name as a byte array in EBCIDIC encoding + */ + protected byte[] getNameBytes() { + int afpNameLen = getNameLength(); + int nameLen = name.length(); + if (nameLen < afpNameLen) { + name = (name + " ").substring(0, afpNameLen); + } else if (name.length() > afpNameLen) { + String truncatedName = name.substring(nameLen - afpNameLen, nameLen); + log.warn("Constructor:: name '" + name + "'" + + " truncated to " + afpNameLen + " chars" + + " ('" + truncatedName + "')"); + name = truncatedName; + } + byte[] nameBytes = null; + try { + nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); + } catch (UnsupportedEncodingException usee) { + nameBytes = name.getBytes(); + log.warn( + "Constructor:: UnsupportedEncodingException translating the name " + + name); + } + return nameBytes; + } + + /** {@inheritDoc} */ + protected void copySF(byte[] data, byte type, byte category) { + super.copySF(data, type, category); + byte[] nameData = getNameBytes(); + System.arraycopy(nameData, 0, data, 9, nameData.length); + } + + /** + * Returns the name of this object + * + * @return the name of this object + */ + public String getName() { + return name; + } + + /** {@inheritDoc} */ + public String toString() { + return getName(); + } +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractPageObject.java b/src/java/org/apache/fop/afp/modca/AbstractPageObject.java new file mode 100644 index 000000000..d7252c390 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractPageObject.java @@ -0,0 +1,346 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +import org.apache.fop.afp.AFPLineDataInfo; +import org.apache.fop.afp.AFPTextDataInfo; +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.fonts.AFPFont; + +/** + * Pages contain the data objects that comprise a presentation document. Each + * page has a set of data objects associated with it. Each page within a + * document is independent from any other page, and each must establish its own + * environment parameters. + * + * The page is the level in the document component hierarchy that is used for + * printing or displaying a document's content. The data objects contained in + * the page envelope in the data stream are presented when the page is + * presented. Each data object has layout information associated with it that + * directs the placement and orientation of the data on the page. In addition, + * each page contains layout information that specifies the measurement units, + * page width, and page depth. + * + * A page is initiated by a begin page structured field and terminated by an end + * page structured field. Structured fields that define objects and active + * environment groups or that specify attributes of the page may be encountered + * in page state. + * + */ +public abstract class AbstractPageObject extends AbstractNamedAFPObject { + + /** The active environment group for the page */ + protected ActiveEnvironmentGroup activeEnvironmentGroup = null; + + /** The current presentation text object */ + private PresentationTextObject currentPresentationTextObject = null; + + /** The list of tag logical elements */ + protected List/**/ tagLogicalElements = null; + + /** The list of the include page segments */ + protected List/**/ includePageSegments = null; + + /** The list of objects within this resource container */ + protected List/**/ objects = new java.util.ArrayList(); + + /** The page width */ + private int width; + + /** The page height */ + private int height; + + /** The page rotation */ + protected int rotation = 0; + + /** The page state */ + protected boolean complete = false; + + /** The width resolution */ + private int widthRes; + + /** The height resolution */ + private int heightRes; + + /** the object factory */ + protected final Factory factory; + + /** + * Default constructor + * + * @param factory the object factory + */ + public AbstractPageObject(Factory factory) { + this.factory = factory; + } + + /** + * Main constructor + * + * @param factory the object factory + * @param name the name of this page object + */ + public AbstractPageObject(Factory factory, String name) { + super(name); + this.factory = factory; + } + + /** + * Construct a new page object for the specified name argument, the page + * name should be an 8 character identifier. + * + * @param factory + * the object factory. + * @param name + * the name of the page. + * @param width + * the width of the page. + * @param height + * the height of the page. + * @param rotation + * the rotation of the page. + * @param widthRes + * the width resolution of the page. + * @param heightRes + * the height resolution of the page. + */ + public AbstractPageObject(Factory factory, + String name, int width, int height, int rotation, + int widthRes, int heightRes) { + super(name); + + this.factory = factory; + this.width = width; + this.height = height; + this.rotation = rotation; + this.widthRes = widthRes; + this.heightRes = heightRes; + } + + /** + * Helper method to create a map coded font object on the current page, this + * method delegates the construction of the map coded font object to the + * active environment group on the page. + * + * @param fontReference + * the font number used as the resource identifier + * @param font + * the font + * @param size + * the point size of the font + */ + public void createFont(int fontReference, AFPFont font, int size) { + getActiveEnvironmentGroup().createFont(fontReference, font, size, 0); + } + + /** + * Helper method to create a line on the current page, this method delegates + * to the presentation text object in order to construct the line. + * + * @param lineDataInfo the line data information. + */ + public void createLine(AFPLineDataInfo lineDataInfo) { + getPresentationTextObject().createLineData(lineDataInfo); + } + + /** + * Helper method to create text on the current page, this method delegates + * to the presentation text object in order to construct the text. + * + * @param textDataInfo + * the afp text data + */ + public void createText(AFPTextDataInfo textDataInfo) { + getPresentationTextObject().createTextData(textDataInfo); + } + + /** + * Helper method to mark the end of the page. This should end the control + * sequence on the current presentation text object. + */ + public void endPage() { + if (currentPresentationTextObject != null) { + currentPresentationTextObject.endControlSequence(); + } + complete = true; + } + + /** + * Ends the presentation text object + */ + protected void endPresentationObject() { + if (currentPresentationTextObject != null) { + currentPresentationTextObject.endControlSequence(); + currentPresentationTextObject = null; + } + } + + /** + * Helper method to create a presentation text object + * on the current page and to return the object. + * + * @return the presentation text object + */ + private PresentationTextObject getPresentationTextObject() { + if (currentPresentationTextObject == null) { + PresentationTextObject presentationTextObject + = factory.createPresentationTextObject(); + addObject(presentationTextObject); + this.currentPresentationTextObject = presentationTextObject; + } + return currentPresentationTextObject; + } + + /** + * Creates a TagLogicalElement on the page. + * + * @param name + * the name of the tag + * @param value + * the value of the tag + */ + public void createTagLogicalElement(String name, String value) { + TagLogicalElement tle = new TagLogicalElement(name, value); + if (tagLogicalElements == null) { + tagLogicalElements = new java.util.ArrayList/**/(); + } + tagLogicalElements.add(tle); + } + + /** + * Creates a NoOperation on the page. + * + * @param content the byte data + */ + public void createNoOperation(String content) { + addObject(new NoOperation(content)); + } + + /** + * Creates an IncludePageSegment on the current page. + * + * @param name + * the name of the page segment + * @param x + * the x coordinate of the page segment. + * @param y + * the y coordinate of the page segment. + */ + public void createIncludePageSegment(String name, int x, int y) { + IncludePageSegment ips = factory.createIncludePageSegment(name, x, y); + getIncludePageSegments().add(ips); + } + + /** + * Returns the include page segments list + * + * @return the include page segments list + */ + private List getIncludePageSegments() { + if (this.includePageSegments == null) { + this.includePageSegments = new java.util.ArrayList/**/(); + } + return this.includePageSegments; + } + + /** + * Returns the ActiveEnvironmentGroup associated with this page. + * + * @return the ActiveEnvironmentGroup object + */ + public ActiveEnvironmentGroup getActiveEnvironmentGroup() { + if (activeEnvironmentGroup == null) { + // every page object must have an ActiveEnvironmentGroup + this.activeEnvironmentGroup + = factory.createActiveEnvironmentGroup(width, height, widthRes, heightRes); + + if (rotation != 0) { + switch (rotation) { + case 90: + activeEnvironmentGroup.setObjectAreaPosition(width, 0, rotation); + break; + case 180: + activeEnvironmentGroup.setObjectAreaPosition(width, height, rotation); + break; + case 270: + activeEnvironmentGroup.setObjectAreaPosition(0, height, rotation); + break; + default: + } + } + } + return activeEnvironmentGroup; + } + + /** + * Returns an indication if the page is complete + * + * @return whether this page is complete + */ + public boolean isComplete() { + return complete; + } + + /** + * Returns the height of the page + * + * @return the height of the page + */ + public int getHeight() { + return height; + } + + /** + * Returns the width of the page + * + * @return the width of the page + */ + public int getWidth() { + return width; + } + + /** + * Returns the rotation of the page + * + * @return the rotation of the page + */ + public int getRotation() { + return rotation; + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + writeObjects(this.objects, os); + } + + /** + * Adds an AFP object reference to this page + * + * @param obj an AFP object + */ + public void addObject(Object obj) { + objects.add(obj); + } +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractPreparedAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractPreparedAFPObject.java new file mode 100644 index 000000000..10a516318 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractPreparedAFPObject.java @@ -0,0 +1,96 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * A base class that carries out early preparation of structured field data + * for the AFP object (so the data length can be pre-calculated) + */ +public abstract class AbstractPreparedAFPObject extends AbstractNamedAFPObject +implements PreparedAFPObject { + + /** structured field data to be written */ + protected byte[] data = null; + + /** + * Default constructor + */ + public AbstractPreparedAFPObject() { + } + + /** + * Named constructor + * + * @param name the name of this AFP object + */ + public AbstractPreparedAFPObject(String name) { + super(name); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); // write triplets + if (this.data != null) { + os.write(this.data); + } + } + + /** + * Return the start data length of this structured field + * + * @return the start data length of this structured field + */ + protected int getStartDataLength() { + return 0; + } + + /** + * Return the data length of the structured field data of this AFP object + * + * @return the data length of the structured field data of this AFP object + */ + public int getDataLength() { + if (this.data != null) { + return this.data.length; + } + return 0; + } + + /** + * Return the structured field length + * + * @return the structured field length + */ + protected int getLength() { + return getStartDataLength() + getTripletDataLength() + getDataLength(); + } + + /** + * Sets the data + * + * @param data the data + */ + protected void setData(byte[] data) { + this.data = data; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.java b/src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.java new file mode 100644 index 000000000..9019a6acc --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.List; + +/** + * A base container of prepared structured AFP objects + */ +public abstract class AbstractPreparedObjectContainer extends AbstractNamedAFPObject +implements PreparedAFPObject { + + /** list of objects contained within this container */ + protected List/**/ objects + = new java.util.ArrayList/**/(); + + /** + * Default constructor + */ + protected AbstractPreparedObjectContainer() { + } + + /** + * Named constructor + * + * @param name the name of the container + */ + protected AbstractPreparedObjectContainer(String name) { + super(name); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + writeObjects(objects, os); + } + + /** + * Adds a given prepared object to this container + * + * @param preparedObject the prepared object + */ + public void addObject(PreparedAFPObject preparedObject) { + objects.add(preparedObject); + } + + /** + * Returns the current data length + * + * @return the current data length of this container including + * all enclosed objects (and their containers) + */ + public int getDataLength() { + int dataLen = 0; + Iterator it = objects.iterator(); + while (it.hasNext()) { + Object obj = it.next(); + if (obj instanceof PreparedAFPObject) { + PreparedAFPObject prepObj = (PreparedAFPObject)obj; + dataLen += prepObj.getDataLength(); + } + } + return dataLen; + } +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractResourceEnvironmentGroupContainer.java b/src/java/org/apache/fop/afp/modca/AbstractResourceEnvironmentGroupContainer.java new file mode 100644 index 000000000..baba170f7 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractResourceEnvironmentGroupContainer.java @@ -0,0 +1,99 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.Factory; + + +/** + * An abstract class which encapsulates the common features of + * Document and PageGroup resource containers + */ +public abstract class AbstractResourceEnvironmentGroupContainer + extends AbstractResourceGroupContainer { + + /** + * The resource environment group used to store complex resources + */ + protected ResourceEnvironmentGroup resourceEnvironmentGroup = null; + + /** + * Main constructor + * + * @param factory the object factory + * @param name the name of this resource container + */ + public AbstractResourceEnvironmentGroupContainer( + Factory factory, String name) { + super(factory, name); + } + + /** + * Adds a page to the resource container. + * + * @param page - the Page object + */ + public void addPage(PageObject page) { + addObject(page); + } + + /** + * Adds a PageGroup to the resource container. + * + * @param pageGroup the PageGroup object + */ + public void addPageGroup(PageGroup pageGroup) { + addObject(pageGroup); + } + + /** + * Creates an InvokeMediaMap on the page. + * + * @param name + * the name of the media map + */ + public void createInvokeMediumMap(String name) { + InvokeMediumMap invokeMediumMap = factory.createInvokeMediumMap(name); + addObject(invokeMediumMap); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + if (resourceEnvironmentGroup != null) { + resourceEnvironmentGroup.writeToStream(os); + } + } + + /** + * Returns the resource environment group + * + * @return the resource environment group + */ + protected ResourceEnvironmentGroup getResourceEnvironmentGroup() { + if (resourceEnvironmentGroup == null) { + this.resourceEnvironmentGroup = factory.createResourceEnvironmentGroup(); + } + return this.resourceEnvironmentGroup; + } +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java new file mode 100644 index 000000000..860c6b56a --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java @@ -0,0 +1,167 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Collection; +import java.util.Iterator; + +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.Streamable; + + +/** + * An abstract container of resource objects + */ +public abstract class AbstractResourceGroupContainer extends AbstractPageObject +implements Streamable { + + /** The container started state */ + protected boolean started = false; + + /** the resource group object */ + protected ResourceGroup resourceGroup = null; + + /** + * Default constructor + * + * @param factory the object factory + */ + public AbstractResourceGroupContainer(Factory factory) { + super(factory); + } + + /** + * Named constructor + * + * @param factory the object factory + * @param name the name of this resource container + */ + public AbstractResourceGroupContainer(Factory factory, String name) { + super(factory, name); + } + + /** + * Construct a new page object for the specified name argument, the page + * name should be an 8 character identifier. + * + * @param factory + * the object factory + * @param name + * the name of the page. + * @param width + * the width of the page. + * @param height + * the height of the page. + * @param rotation + * the rotation of the page. + * @param widthRes + * the width resolution of the page. + * @param heightRes + * the height resolution of the page. + */ + public AbstractResourceGroupContainer(Factory factory, + String name, int width, int height, int rotation, int widthRes, int heightRes) { + super(factory, name, width, height, rotation, widthRes, heightRes); + } + + /** + * Return the number of resources in this container + * + * @return the number of resources in this container + */ + protected int getResourceCount() { + if (resourceGroup != null) { + return resourceGroup.getResourceCount(); + } + return 0; + } + + /** + * Returns true if this resource group container contains resources + * + * @return true if this resource group container contains resources + */ + protected boolean hasResources() { + return resourceGroup != null && resourceGroup.getResourceCount() > 0; + } + + /** + * Returns the resource group in this resource group container + * + * @return the resource group in this resource group container + */ + protected ResourceGroup getResourceGroup() { + if (resourceGroup == null) { + resourceGroup = factory.createResourceGroup(); + } + return resourceGroup; + } + +// /** {@inheritDoc} */ +// protected void writeContent(OutputStream os) throws IOException { +// if (resourceGroup != null) { +// resourceGroup.writeToStream(os); +// } +// super.writeContent(os); +// } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + if (!started) { + writeStart(os); + started = true; + } + + writeContent(os); + + if (complete) { + writeEnd(os); + } + } + + /** {@inheritDoc} */ + protected void writeObjects(Collection/**/ objects, OutputStream os) + throws IOException { + if (objects != null && objects.size() > 0) { + Iterator it = objects.iterator(); + while (it.hasNext()) { + AbstractAFPObject ao = (AbstractAFPObject)it.next(); + if (canWrite(ao)) { + ao.writeToStream(os); + it.remove(); + } else { + break; + } + } + } + } + + /** + * Returns true if this object can be written + * + * @param obj an AFP object + * @return true if this object can be written + */ + protected boolean canWrite(AbstractAFPObject obj) { + return obj instanceof AbstractPageObject && ((AbstractPageObject)obj).isComplete(); + } +} diff --git a/src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java new file mode 100644 index 000000000..9bfc11095 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java @@ -0,0 +1,324 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.fop.afp.modca.Registry.ObjectType; +import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; +import org.apache.fop.afp.modca.triplets.ObjectClassificationTriplet; +import org.apache.fop.afp.modca.triplets.Triplet; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * An abstract class encapsulating an MODCA structured object + */ +public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { + /** + * list of object triplets + */ + protected List/**/ triplets = null; + + /** + * triplet data created from triplet list + */ + protected byte[] tripletData = null; + + /** + * Default constructor + */ + protected AbstractStructuredAFPObject() { + } + + /** + * Returns the triplet data length + * + * @return the triplet data length + */ + protected int getTripletDataLength() { + if (tripletData == null) { + try { + getTripletData(); + } catch (IOException e) { + log.error("failed to get triplet data"); + } + } + if (tripletData != null) { + return tripletData.length; + } + return 0; + } + + /** + * Returns the triplet data + * + * @return the triplet data + * @throws IOException throws an I/O exception if one occurred + */ + protected byte[] getTripletData() throws IOException { + if (tripletData == null && triplets != null) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + writeObjects(triplets, baos); + this.tripletData = baos.toByteArray(); + triplets = null; // gc + } + return this.tripletData; + } + + /** + * Writes any triplet data + * + * @param os The stream to write to + * @throws IOException The stream to write to + */ + protected void writeTriplets(OutputStream os) throws IOException { + if (tripletData != null) { + os.write(tripletData); + } else if (triplets != null) { + writeObjects(triplets, os); + triplets = null; // gc + } + } + + /** + * Helper method to write the start of the Object. + * + * @param os The stream to write to + * @throws IOException throws an I/O exception if one occurred + */ + protected void writeStart(OutputStream os) throws IOException { + getTripletData(); + } + + /** + * Helper method to write the end of the Object. + * + * @param os The stream to write to + * @throws IOException an I/O exception if one occurred + */ + protected void writeEnd(OutputStream os) throws IOException { + } + + /** + * Helper method to write the contents of the Object. + * + * @param os The stream to write to + * @throws IOException throws an I/O exception if one occurred + */ + protected void writeContent(OutputStream os) throws IOException { + writeTriplets(os); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + writeStart(os); + writeContent(os); + writeEnd(os); + } + + /** + * Returns the first matching triplet found in the structured field triplet list + * + * @param tripletId the triplet identifier + */ + private Triplet getTriplet(byte tripletId) { + Iterator it = getTriplets().iterator(); + while (it.hasNext()) { + Triplet triplet = (Triplet)it.next(); + if (triplet.getId() == tripletId) { + return triplet; + } + } + return null; + } + + /** + * Returns true of this structured field has the given triplet + * + * @param tripletId the triplet identifier + * @return true if the structured field has the given triplet + */ + public boolean hasTriplet(byte tripletId) { + return getTriplet(tripletId) != null; + } + + /** + * Adds a triplet to this structured object + * + * @param triplet the triplet to add + */ + protected void addTriplet(Triplet triplet) { + getTriplets().add(triplet); + } + + /** + * Adds a list of triplets to the triplets contained within this structured field + * + * @param tripletCollection a collection of triplets + */ + public void addTriplets(Collection/**/ tripletCollection) { + if (tripletCollection != null) { + getTriplets().addAll(tripletCollection); + } + } + + /** @return the triplet list pertaining to this resource */ + protected List/**/ getTriplets() { + if (triplets == null) { + triplets = new java.util.ArrayList(); + } + return triplets; + } + + /** + * Sets the fully qualified name of this resource + * + * @param fqnType the fully qualified name type of this resource + * @param fqnFormat the fully qualified name format of this resource + * @param fqName the fully qualified name of this resource + */ + public void setFullyQualifiedName(byte fqnType, byte fqnFormat, String fqName) { + addTriplet(new FullyQualifiedNameTriplet(fqnType, fqnFormat, fqName)); + } + + /** @return the fully qualified name of this triplet or null if it does not exist */ + public String getFullyQualifiedName() { + FullyQualifiedNameTriplet fqNameTriplet + = (FullyQualifiedNameTriplet)getTriplet(Triplet.FULLY_QUALIFIED_NAME); + if (fqNameTriplet != null) { + return fqNameTriplet.getFullyQualifiedName(); + } + log.warn(this + " has no fully qualified name"); + return null; + } + + /** + * Sets the objects classification + * + * @param objectClass the classification of the object + * @param objectType the MOD:CA registry object type entry for the given + * object/component type of the object + * @param dataInContainer whether the data resides in the container + * @param containerHasOEG whether the container has an object environment group + * @param dataInOCD whether the data resides in a object container data structured field + */ + public void setObjectClassification( + byte objectClass, ObjectType objectType, + boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD) { + addTriplet( + new ObjectClassificationTriplet( + objectClass, objectType, dataInContainer, containerHasOEG, dataInOCD)); + } + + /** + * Sets a comment on this resource + * + * @param comment a comment string + */ + public void setComment(String comment) { + try { + addTriplet(new Triplet(Triplet.COMMENT, comment)); + } catch (UnsupportedEncodingException e) { + log.error(e.getMessage()); + } + } + + /** + * Reads data chunks from an inputstream + * and then formats them with a structured header to a given outputstream + * + * @param dataHeader the header data + * @param lengthOffset offset of length field in data chunk + * @param maxChunkLength the maximum chunk length + * @param inputStream the inputstream to read from + * @param outputStream the outputstream to write to + * @throws IOException thrown if an I/O exception of some sort has occurred. + */ + protected static void copyChunks(byte[] dataHeader, int lengthOffset, + int maxChunkLength, InputStream inputStream, OutputStream outputStream) + throws IOException { + int headerLen = dataHeader.length - lengthOffset; + // length field is just before data so do not include in data length + if (headerLen == 2) { + headerLen = 0; + } + byte[] data = new byte[maxChunkLength]; + int numBytesRead = 0; + while ((numBytesRead = inputStream.read(data, 0, maxChunkLength)) > 0) { + byte[] len = BinaryUtils.convert(headerLen + numBytesRead, 2); + dataHeader[lengthOffset] = len[0]; // Length byte 1 + dataHeader[lengthOffset + 1] = len[1]; // Length byte 2 + outputStream.write(dataHeader); + outputStream.write(data, 0, numBytesRead); + } + } + + /** + * Writes data chunks to a given outputstream + * + * @param data the data byte array + * @param dataHeader the header data + * @param lengthOffset offset of length field in data chunk + * @param maxChunkLength the maximum chunk length + * @param os the outputstream to write to + * @throws IOException thrown if an I/O exception of some sort has occurred. + */ + protected static void writeChunksToStream(byte[] data, byte[] dataHeader, + int lengthOffset, int maxChunkLength, OutputStream os) throws IOException { + int dataLength = data.length; + int numFullChunks = dataLength / maxChunkLength; + int lastChunkLength = dataLength % maxChunkLength; + + int headerLen = dataHeader.length - lengthOffset; + // length field is just before data so do not include in data length + if (headerLen == 2) { + headerLen = 0; + } + + byte[] len; + int off = 0; + if (numFullChunks > 0) { + // write out full data chunks + len = BinaryUtils.convert(headerLen + maxChunkLength, 2); + dataHeader[lengthOffset] = len[0]; // Length byte 1 + dataHeader[lengthOffset + 1] = len[1]; // Length byte 2 + for (int i = 0; i < numFullChunks; i++, off += maxChunkLength) { + os.write(dataHeader); + os.write(data, off, maxChunkLength); + } + } + + if (lastChunkLength > 0) { + // write last data chunk + len = BinaryUtils.convert(headerLen + lastChunkLength, 2); + dataHeader[lengthOffset] = len[0]; // Length byte 1 + dataHeader[lengthOffset + 1] = len[1]; // Length byte 2 + os.write(dataHeader); + os.write(data, off, lastChunkLength); + } + } +} diff --git a/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java new file mode 100644 index 000000000..ddc986be3 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java @@ -0,0 +1,221 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.fonts.AFPFont; + +/** + * An Active Environment Group (AEG) is associated with each page, + * and is contained in the page's begin-end envelope in the data stream. + * The active environment group contains layout and formatting information + * that defines the measurement units and size of the page, and may contain + * resource information. + * + * Any objects that are required for page presentation and that are to be + * treated as resource objects must be mapped with a map structured field + * in the AEG. The scope of an active environment group is the scope of its + * containing page or overlay. + * + */ +public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { + + /** The collection of MapCodedFont objects */ + private final List/**/ mapCodedFonts + = new java.util.ArrayList/**/(); + + /** the collection of MapDataResource objects */ + private final List mapDataResources = null; + + /** the Object Area Descriptor for the active environment group */ + private ObjectAreaDescriptor objectAreaDescriptor = null; + + /** the Object Area Position for the active environment group */ + private ObjectAreaPosition objectAreaPosition = null; + + /** the PresentationTextDescriptor for the active environment group */ + private PresentationTextDescriptor presentationTextDataDescriptor = null; + + /** the PageDescriptor for the active environment group */ + private PageDescriptor pageDescriptor = null; + + /** the resource manager */ + private final Factory factory; + + /** + * Constructor for the ActiveEnvironmentGroup, this takes a + * name parameter which must be 8 characters long. + * + * @param factory the object factory + * @param name the active environment group name + * @param width the page width + * @param height the page height + * @param widthRes the page width resolution + * @param heightRes the page height resolution + */ + public ActiveEnvironmentGroup(Factory factory, + String name, int width, int height, int widthRes, int heightRes) { + super(name); + + this.factory = factory; + + // Create PageDescriptor + this.pageDescriptor + = factory.createPageDescriptor(width, height, widthRes, heightRes); + + // Create ObjectAreaDescriptor + this.objectAreaDescriptor + = factory.createObjectAreaDescriptor(width, height, widthRes, heightRes); + + // Create PresentationTextDataDescriptor + this.presentationTextDataDescriptor + = factory.createPresentationTextDataDescriptor(width, height, + widthRes, heightRes); + } + + /** + * Set the position of the object area + * + * @param x the x offset + * @param y the y offset + * @param rotation the rotation + */ + public void setObjectAreaPosition(int x, int y, int rotation) { + this.objectAreaPosition = factory.createObjectAreaPosition(x, y, rotation); + } + + /** + * Accessor method to obtain the PageDescriptor object of the + * active environment group. + * + * @return the page descriptor object + */ + public PageDescriptor getPageDescriptor() { + return pageDescriptor; + } + + /** + * Accessor method to obtain the PresentationTextDataDescriptor object of + * the active environment group. + * + * @return the presentation text descriptor + */ + public PresentationTextDescriptor getPresentationTextDataDescriptor() { + return presentationTextDataDescriptor; + } + + /** {@inheritDoc} */ + public void writeContent(OutputStream os) throws IOException { + super.writeTriplets(os); + + writeObjects(mapCodedFonts, os); + writeObjects(mapDataResources, os); + writeObjects(mapPageOverlays, os); + + if (pageDescriptor != null) { + pageDescriptor.writeToStream(os); + } + if (objectAreaDescriptor != null && objectAreaPosition != null) { + objectAreaDescriptor.writeToStream(os); + objectAreaPosition.writeToStream(os); + } + if (presentationTextDataDescriptor != null) { + presentationTextDataDescriptor.writeToStream(os); + } + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.ACTIVE_ENVIRONMENT_GROUP); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.ACTIVE_ENVIRONMENT_GROUP); + os.write(data); + } + + /** + * Method to create a map coded font object + * + * @param fontRef the font number used as the resource identifier + * @param font the font + * @param size the point size of the font + * @param orientation the orientation of the font (e.g. 0, 90, 180, 270) + */ + public void createFont(int fontRef, AFPFont font, int size, int orientation) { + MapCodedFont mapCodedFont = getCurrentMapCodedFont(); + if (mapCodedFont == null) { + mapCodedFont = factory.createMapCodedFont(); + mapCodedFonts.add(mapCodedFont); + } + + try { + mapCodedFont.addFont(fontRef, font, size, orientation); + } catch (MaximumSizeExceededException msee) { + mapCodedFont = factory.createMapCodedFont(); + mapCodedFonts.add(mapCodedFont); + + try { + mapCodedFont.addFont(fontRef, font, size, orientation); + } catch (MaximumSizeExceededException ex) { + // Should never happen (but log just in case) + log.error("createFont():: resulted in a MaximumSizeExceededException"); + } + } + } + + /** + * Getter method for the most recent MapCodedFont added to the + * Active Environment Group (returns null if no MapCodedFonts exist) + * + * @return the most recent Map Coded Font. + */ + private MapCodedFont getCurrentMapCodedFont() { + int size = mapCodedFonts.size(); + if (size > 0) { + return (MapCodedFont)mapCodedFonts.get(size - 1); + } else { + return null; + } + } + +// private List getMapDataResources() { +// if (mapDataResources == null) { +// mapDataResources = new java.util.ArrayList(); +// } +// return mapDataResources; +//} + +// /** +// * Method to create a map data resource object +// * @param dataObjectAccessor a data object accessor +// */ +// protected void createMapDataResource(DataObjectAccessor dataObjectAccessor) { +// getMapDataResources().add(new MapDataResource(dataObjectAccessor)); +// } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/ContainerDataDescriptor.java b/src/java/org/apache/fop/afp/modca/ContainerDataDescriptor.java new file mode 100644 index 000000000..0f99d6624 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ContainerDataDescriptor.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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * Container data descriptor (to maintain compatibility with pre-year 2000 applications) + */ +public class ContainerDataDescriptor extends AbstractDescriptor { + + /** + * Main constructor + * + * @param width the container data width + * @param height the container data height + * @param widthRes the container width resolution + * @param heightRes the container height resolution + */ + public ContainerDataDescriptor(int width, int height, int widthRes, + int heightRes) { + super(width, height, widthRes, heightRes); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[21]; + copySF(data, Type.DESCRIPTOR, Category.OBJECT_CONTAINER); + + // SF length + byte[] len = BinaryUtils.convert(data.length - 1, 2); + data[1] = len[0]; + data[2] = len[1]; + + // XocBase = 10 inches + data[9] = 0x00; + + // YocBase = 10 inches + data[10] = 0x00; + + // XocUnits + byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); + data[11] = xdpi[0]; + data[12] = xdpi[1]; + + // YocUnits + byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2); + data[13] = ydpi[0]; + data[14] = ydpi[1]; + + // XocSize + byte[] xsize = BinaryUtils.convert(width, 3); + data[15] = xsize[0]; + data[16] = xsize[1]; + data[17] = xsize[2]; + + // YocSize + byte[] ysize = BinaryUtils.convert(height, 3); + data[18] = ysize[0]; + data[19] = ysize[1]; + data[20] = ysize[2]; + } + +} diff --git a/src/java/org/apache/fop/afp/modca/DataStream.java b/src/java/org/apache/fop/afp/modca/DataStream.java new file mode 100644 index 000000000..c1c5e12a7 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/DataStream.java @@ -0,0 +1,593 @@ +/* + * 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.afp.modca; + +import java.awt.Color; +import java.awt.Point; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.AFPLineDataInfo; +import org.apache.fop.afp.AFPResourceLevel; +import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPTextDataInfo; +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.fonts.AFPFont; +import org.apache.fop.afp.fonts.AFPFontAttributes; +import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; + +/** + * A data stream is a continuous ordered stream of data elements and objects + * conforming to a given format. Application programs can generate data streams + * destined for a presentation service, archive library, presentation device or + * another application program. The strategic presentation data stream + * architectures used is Mixed Object Document Content Architecture (MO:DCA). + * + * The MO:DCA architecture defines the data stream used by applications to + * describe documents and object envelopes for interchange with other + * applications and application services. Documents defined in the MO:DCA format + * may be archived in a database, then later retrieved, viewed, annotated and + * printed in local or distributed systems environments. Presentation fidelity + * is accommodated by including resource objects in the documents that reference + * them. + */ +public class DataStream { + + /** Static logging instance */ + protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp.modca"); + + /** Boolean completion indicator */ + private boolean complete = false; + + /** The AFP document object */ + private Document document = null; + + /** The current page group object */ + private PageGroup currentPageGroup = null; + + /** The current page object */ + private PageObject currentPageObject = null; + + /** The current overlay object */ + private Overlay currentOverlay = null; + + /** The current page */ + private AbstractPageObject currentPage = null; + + /** The MO:DCA interchange set in use (default to MO:DCA-P IS/2 set) */ + private InterchangeSet interchangeSet + = InterchangeSet.valueOf(InterchangeSet.MODCA_PRESENTATION_INTERCHANGE_SET_2); + + private final Factory factory; + + private OutputStream outputStream; + + /** the afp state */ + private final AFPState state; + + /** + * Default constructor for the AFPDocumentStream. + * + * @param factory the resource factory + * @param state the afp state + * @param outputStream the outputstream to write to + */ + public DataStream(Factory factory, AFPState state, OutputStream outputStream) { + this.state = state; + this.factory = factory; + this.outputStream = outputStream; + } + + /** + * Returns the outputstream + * + * @return the outputstream + */ + public OutputStream getOutputStream() { + return this.outputStream; + } + + /** + * Returns the document object + * + * @return the document object + */ + private Document getDocument() { + return this.document; + } + + /** + * Returns the current page + * + * @return the current page + */ + public AbstractPageObject getCurrentPage() { + return this.currentPage; + } + + /** + * The document is started by invoking this method which creates an instance + * of the AFP Document object. + * + * @param name + * the name of this document. + */ + public void setDocumentName(String name) { + if (name != null) { + getDocument().setFullyQualifiedName( + FullyQualifiedNameTriplet.TYPE_BEGIN_DOCUMENT_REF, + FullyQualifiedNameTriplet.FORMAT_CHARSTR, name); + } + } + + /** {@inheritDoc} */ + public void endDocument() throws IOException { + if (complete) { + String msg = "Invalid state - document already ended."; + log.warn("endDocument():: " + msg); + throw new IllegalStateException(msg); + } + + if (currentPageObject != null) { + // End the current page if necessary + endPage(); + } + + if (currentPageGroup != null) { + // End the current page group if necessary + endPageGroup(); + } + + // Write out document + if (document != null) { + document.endDocument(); + document.writeToStream(this.outputStream); + } + + this.outputStream.flush(); + + this.complete = true; + + this.document = null; + + this.outputStream = null; + } + + /** + * Start a new page. When processing has finished on the current page, the + * {@link #endPage()}method must be invoked to mark the page ending. + * + * @param pageWidth + * the width of the page + * @param pageHeight + * the height of the page + * @param pageRotation + * the rotation of the page + * @param pageWidthRes + * the width resolution of the page + * @param pageHeightRes + * the height resolution of the page + */ + public void startPage(int pageWidth, int pageHeight, int pageRotation, + int pageWidthRes, int pageHeightRes) { + currentPageObject = factory.createPage(pageWidth, pageHeight, + pageRotation, pageWidthRes, pageHeightRes); + currentPage = currentPageObject; + currentOverlay = null; + } + + /** + * Start a new overlay. When processing has finished on the current overlay, + * the {@link #endOverlay()}method must be invoked to mark the overlay + * ending. + * + * @param x + * the x position of the overlay on the page + * @param y + * the y position of the overlay on the page + * @param width + * the width of the overlay + * @param height + * the height of the overlay + * @param widthRes + * the width resolution of the overlay + * @param heightRes + * the height resolution of the overlay + * @param overlayRotation + * the rotation of the overlay + */ + public void startOverlay(int x, int y, int width, int height, int widthRes, + int heightRes, int overlayRotation) { + this.currentOverlay = factory.createOverlay( + width, height, widthRes, heightRes, overlayRotation); + + String overlayName = currentOverlay.getName(); + currentPageObject.createIncludePageOverlay(overlayName, x, y, 0); + currentPage = currentOverlay; + } + + /** + * Helper method to mark the end of the current overlay. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void endOverlay() throws IOException { + if (currentOverlay != null) { + currentOverlay.endPage(); + currentOverlay = null; + currentPage = currentPageObject; + } + } + + /** + * Helper method to save the current page. + * + * @return current page object that was saved + */ + public PageObject savePage() { + PageObject pageObject = currentPageObject; + if (currentPageGroup != null) { + currentPageGroup.addPage(currentPageObject); + } else { + document.addPage(currentPageObject); + } + currentPageObject = null; + currentPage = null; + return pageObject; + } + + /** + * Helper method to restore the current page. + * + * @param pageObject + * page object + */ + public void restorePage(PageObject pageObject) { + currentPageObject = pageObject; + currentPage = pageObject; + } + + /** + * Helper method to mark the end of the current page. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void endPage() throws IOException { + if (currentPageObject != null) { + currentPageObject.endPage(); + if (currentPageGroup != null) { + currentPageGroup.addPage(currentPageObject); + currentPageGroup.writeToStream(this.outputStream); + } else { + document.addPage(currentPageObject); + document.writeToStream(this.outputStream); + } + currentPageObject = null; + currentPage = null; + } + } + + /** + * Creates the given page fonts in the current page + * + * @param pageFonts + * a collection of AFP font attributes + */ + public void addFontsToCurrentPage(Map pageFonts) { + Iterator iter = pageFonts.values().iterator(); + while (iter.hasNext()) { + AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter + .next(); + createFont(afpFontAttributes.getFontReference(), afpFontAttributes + .getFont(), afpFontAttributes.getPointSize()); + } + } + + /** + * Helper method to create a map coded font object on the current page, this + * method delegates the construction of the map coded font object to the + * active environment group on the current page. + * + * @param fontReference + * the font number used as the resource identifier + * @param font + * the font + * @param size + * the point size of the font + */ + public void createFont(int fontReference, AFPFont font, int size) { + currentPage.createFont(fontReference, font, size); + } + + /** + * Returns a point on the current page + * + * @param x the X-coordinate + * @param y the Y-coordinate + * @return a point on the current page + */ + private Point getPoint(int x, int y) { + Point p = new Point(); + int rotation = state.getRotation(); + switch (rotation) { + case 90: + p.x = y; + p.y = currentPage.getWidth() - x; + break; + case 180: + p.x = currentPage.getWidth() - x; + p.y = currentPage.getHeight() - y; + break; + case 270: + p.x = currentPage.getHeight() - y; + p.y = x; + break; + default: + p.x = x; + p.y = y; + break; + } + return p; + } + + /** + * Helper method to create text on the current page, this method delegates + * to the current presentation text object in order to construct the text. + * + * @param textDataInfo + * the afp text data + */ + public void createText(AFPTextDataInfo textDataInfo) { + int rotation = state.getRotation(); + if (rotation != 0) { + textDataInfo.setRotation(rotation); + Point p = getPoint(textDataInfo.getX(), textDataInfo.getY()); + textDataInfo.setX(p.x); + textDataInfo.setY(p.y); + } + currentPage.createText(textDataInfo); + } + + /** + * Method to create a line on the current page. + * + * @param lineDataInfo the line data information. + */ + public void createLine(AFPLineDataInfo lineDataInfo) { + currentPage.createLine(lineDataInfo); + } + + /** + * This method will create shading on the page using the specified + * coordinates (the shading contrast is controlled via the red, green, blue + * parameters, by converting this to grey scale). + * + * @param x + * the x coordinate of the shading + * @param y + * the y coordinate of the shading + * @param w + * the width of the shaded area + * @param h + * the height of the shaded area + * @param col + * the shading color + */ + public void createShading(int x, int y, int w, int h, Color col) { + currentPageObject.createShading(x, y, w, h, col.getRed(), col.getGreen(), col.getBlue()); + } + + /** + * Helper method which allows creation of the MPO object, via the AEG. And + * the IPO via the Page. (See actual object for descriptions.) + * + * @param name + * the name of the static overlay + */ + public void createIncludePageOverlay(String name) { + currentPageObject.createIncludePageOverlay(name, 0, 0, state.getRotation()); + currentPageObject.getActiveEnvironmentGroup().createOverlay(name); + } + + /** + * Helper method which allows creation of the IMM object. + * + * @param name + * the name of the medium map + */ + public void createInvokeMediumMap(String name) { + currentPageGroup.createInvokeMediumMap(name); + } + + /** + * Creates an IncludePageSegment on the current page. + * + * @param name + * the name of the include page segment + * @param x + * the x coordinate for the overlay + * @param y + * the y coordinate for the overlay + */ + public void createIncludePageSegment(String name, int x, int y) { + int xOrigin; + int yOrigin; + int orientation = state.getRotation(); + switch (orientation) { + case 90: + xOrigin = currentPage.getWidth() - y; + yOrigin = x; + break; + case 180: + xOrigin = currentPage.getWidth() - x; + yOrigin = currentPage.getHeight() - y; + break; + case 270: + xOrigin = y; + yOrigin = currentPage.getHeight() - x; + break; + default: + xOrigin = x; + yOrigin = y; + break; + } + currentPage.createIncludePageSegment(name, xOrigin, yOrigin); + } + + /** + * Creates a TagLogicalElement on the current page. + * + * @param attributes + * the array of key value pairs. + */ + public void createPageTagLogicalElement(TagLogicalElementBean[] attributes) { + for (int i = 0; i < attributes.length; i++) { + String name = attributes[i].getKey(); + String value = attributes[i].getValue(); + currentPage.createTagLogicalElement(name, value); + } + } + + /** + * Creates a TagLogicalElement on the current page group. + * + * @param attributes + * the array of key value pairs. + */ + public void createPageGroupTagLogicalElement(TagLogicalElementBean[] attributes) { + for (int i = 0; i < attributes.length; i++) { + String name = attributes[i].getKey(); + String value = attributes[i].getValue(); + currentPageGroup.createTagLogicalElement(name, value); + } + } + + /** + * Creates a TagLogicalElement on the current page or page group + * + * @param name + * The tag name + * @param value + * The tag value + */ + public void createTagLogicalElement(String name, String value) { + if (currentPageGroup != null) { + currentPageGroup.createTagLogicalElement(name, value); + } else { + currentPage.createTagLogicalElement(name, value); + } + } + + /** + * Creates a NoOperation item + * + * @param content + * byte data + */ + public void createNoOperation(String content) { + currentPage.createNoOperation(content); + } + + /** + * Returns the current page group + * + * @return the current page group + */ + public PageGroup getCurrentPageGroup() { + return this.currentPageGroup; + } + + /** + * Start a new document. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void startDocument() throws IOException { + this.document = factory.createDocument(); + document.writeToStream(this.outputStream); + } + + /** + * Start a new page group. When processing has finished on the current page + * group the {@link #endPageGroup()}method must be invoked to mark the page + * group ending. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void startPageGroup() throws IOException { + endPageGroup(); + this.currentPageGroup = factory.createPageGroup(); + } + + /** + * Helper method to mark the end of the page group. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void endPageGroup() throws IOException { + if (currentPageGroup != null) { + currentPageGroup.endPageGroup(); + document.addPageGroup(currentPageGroup); + document.writeToStream(outputStream); + currentPageGroup = null; + } + } + + /** + * Sets the MO:DCA interchange set to use + * + * @param interchangeSet the MO:DCA interchange set + */ + public void setInterchangeSet(InterchangeSet interchangeSet) { + this.interchangeSet = interchangeSet; + } + + /** + * Returns the MO:DCA interchange set in use + * + * @return the MO:DCA interchange set in use + */ + public InterchangeSet getInterchangeSet() { + return this.interchangeSet; + } + + /** + * Returns the resource group for a given resource info + * + * @param level a resource level + * @return a resource group for the given resource info + */ + public ResourceGroup getResourceGroup(AFPResourceLevel level) { + ResourceGroup resourceGroup = null; + if (level.isDocument()) { + resourceGroup = document.getResourceGroup(); + } else if (level.isPageGroup()) { + resourceGroup = currentPageGroup.getResourceGroup(); + } else if (level.isPage()) { + resourceGroup = currentPageObject.getResourceGroup(); + } + return resourceGroup; + } + +} diff --git a/src/java/org/apache/fop/afp/modca/Document.java b/src/java/org/apache/fop/afp/modca/Document.java new file mode 100644 index 000000000..bb0dbebe3 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/Document.java @@ -0,0 +1,100 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.Factory; + +/** + * The document is the highest level of the MO:DCA data-stream document + * component hierarchy. Documents can be made up of pages, and the pages, which + * are at the intermediate level, can be made up of objects. Objects are at the + * lowest level, and can be bar codes, graphics, images, and presentation text. + * + * At each level of the hierarchy certain sets of MO:DCA data structures, called + * structured fields, are permissible. The document, pages and objects are + * bounded by structured fields that define their beginnings and their ends. + * These structured fields, called begin-end pairs, provide an envelope for the + * data-stream components. This feature enables a processor of the data stream + * that is not fully compliant with the architecture to bypass those objects + * that are beyond its scope, and to process the data stream to the best of its + * abilities. + * + * A presentation document is one that has been formatted and is intended for + * presentation, usually on a printer or display device. A data stream + * containing a presentation document should produce the same document content + * in the same format on different printers or display devices dependent, + * however, on the capabilities of each of the printers or display devices. A + * presentation document can reference resources that are to be included as part + * of the document to be presented. + * + */ +public final class Document extends AbstractResourceEnvironmentGroupContainer { + + /** + * Constructor for the document object. + * + * @param factory + * the object factory + * @param name + * the name of the document + */ + public Document(Factory factory, String name) { + super(factory, name); + } + + /** + * Method to mark the end of the page group. + */ + public void endDocument() { + complete = true; + } + + /** + * Returns an indication if the page group is complete + * + * @return whether or not this page group is complete + */ + public boolean isComplete() { + return complete; + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.DOCUMENT); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.DOCUMENT); + os.write(data); + } + + /** {@inheritDoc} */ + public String toString() { + return this.name; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/GraphicsDataDescriptor.java b/src/java/org/apache/fop/afp/modca/GraphicsDataDescriptor.java new file mode 100644 index 000000000..5495e2e9c --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/GraphicsDataDescriptor.java @@ -0,0 +1,152 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * GOCA Graphics Data Descriptor + */ +public class GraphicsDataDescriptor extends AbstractDescriptor { + + private final int xlwind; + + private final int xrwind; + + private final int ybwind; + + private final int ytwind; + + /** + * Main constructor + * + * @param xlwind + * the left edge of the graphics window + * @param xrwind + * the right edge of the graphics window + * @param ybwind + * the top edge of the graphics window + * @param ytwind + * the bottom edge of the graphics window + * @param widthRes + * the width resolution of the graphics window + * @param heightRes + * the height resolution of the graphics window + */ + public GraphicsDataDescriptor(int xlwind, int xrwind, int ybwind, + int ytwind, int widthRes, int heightRes) { + this.xlwind = xlwind; + this.xrwind = xrwind; + this.ybwind = ybwind; + this.ytwind = ytwind; + super.widthRes = widthRes; + super.heightRes = heightRes; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] headerData = new byte[9]; + copySF(headerData, Type.DESCRIPTOR, Category.GRAPHICS); + + byte[] drawingOrderSubsetData = getDrawingOrderSubset(); + + byte[] windowSpecificationData = getWindowSpecification(); + + byte[] len = BinaryUtils.convert(headerData.length + + drawingOrderSubsetData.length + + windowSpecificationData.length - 1, 2); + headerData[1] = len[0]; + headerData[2] = len[1]; + + os.write(headerData); + os.write(drawingOrderSubsetData); + os.write(windowSpecificationData); + } + + /** + * Returns the drawing order subset data + * + * @return the drawing order subset data + */ + private byte[] getDrawingOrderSubset() { + final byte[] data = new byte[] { + // Drawing order subset + (byte) 0xF7, + 7, // LENGTH + (byte) 0xB0, // drawing order subset + 0x00, // reserved (must be zero) + 0x00, // reserved (must be zero) + 0x02, // SUBLEV + 0x00, // VERSION 0 + 0x01, // LENGTH (of following field) + 0x00 // GEOM + }; + return data; + } + + private static final int ABS = 2; + private static final int IMGRES = 8; + + /** + * Returns the window specification data + * + * @return the window specification data + */ + private byte[] getWindowSpecification() { + byte[] xlcoord = BinaryUtils.convert(xlwind, 2); + byte[] xrcoord = BinaryUtils.convert(xrwind, 2); + byte[] xbcoord = BinaryUtils.convert(ybwind, 2); + byte[] ytcoord = BinaryUtils.convert(ytwind, 2); + byte[] xResol = BinaryUtils.convert(widthRes * 10, 2); + byte[] yResol = BinaryUtils.convert(heightRes * 10, 2); + byte[] imxyres = xResol; + + // Window specification + final byte[] data = new byte[] { + (byte) 0xF6, + 18, // LENGTH + (ABS + IMGRES), // FLAGS (ABS) + 0x00, // reserved (must be zero) + 0x00, // CFORMAT (coordinate format - 16bit high byte first signed) + 0x00, // UBASE (unit base - ten inches) + + xResol[0], // XRESOL + xResol[1], + yResol[0], // YRESOL + yResol[1], + + imxyres[0], // IMXYRES (Number of image points per ten inches + imxyres[1], // in X and Y directions) + + xlcoord[0], // XLWIND + xlcoord[1], + xrcoord[0], // XRWIND + xrcoord[1], + xbcoord[0], // YBWIND + xbcoord[1], + ytcoord[0], // YTWIND + ytcoord[1] + }; + return data; + } +} diff --git a/src/java/org/apache/fop/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/afp/modca/GraphicsObject.java new file mode 100644 index 000000000..8b76dde15 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/GraphicsObject.java @@ -0,0 +1,303 @@ +/* + * 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.afp.modca; + +import java.awt.Color; +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.goca.GraphicsBox; +import org.apache.fop.afp.goca.GraphicsData; +import org.apache.fop.afp.goca.GraphicsFillet; +import org.apache.fop.afp.goca.GraphicsFullArc; +import org.apache.fop.afp.goca.GraphicsLine; +import org.apache.fop.afp.goca.GraphicsSetArcParameters; +import org.apache.fop.afp.goca.GraphicsSetCharacterSet; +import org.apache.fop.afp.goca.GraphicsSetCurrentPosition; +import org.apache.fop.afp.goca.GraphicsSetLineType; +import org.apache.fop.afp.goca.GraphicsSetLineWidth; +import org.apache.fop.afp.goca.GraphicsSetPatternSymbol; +import org.apache.fop.afp.goca.GraphicsSetProcessColor; +import org.apache.fop.afp.goca.GraphicsString; + +/** + * Top-level GOCA graphics object. + * + * Acts as container and factory of all other graphic objects + */ +public class GraphicsObject extends AbstractDataObject { + + /** The graphics data */ + private GraphicsData currentGraphicsData = null; + + /** list of objects contained within this container */ + protected List/**/ objects + = new java.util.ArrayList/**/(); + + /** + * Default constructor + * + * @param factory the object factory + * @param name the name of graphics object + */ + public GraphicsObject(Factory factory, String name) { + super(factory, name); + } + + /** {@inheritDoc} */ + public void setViewport(AFPDataObjectInfo dataObjectInfo) { + super.setViewport(dataObjectInfo); + + AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + int width = objectAreaInfo.getWidth(); + int height = objectAreaInfo.getHeight(); + int widthRes = objectAreaInfo.getWidthRes(); + int heightRes = objectAreaInfo.getHeightRes(); + final int leftEdge = 0; + final int topEdge = 0; + GraphicsDataDescriptor graphicsDataDescriptor = factory.createGraphicsDataDescriptor( + leftEdge, width, topEdge, height, widthRes, heightRes); + + getObjectEnvironmentGroup().setDataDescriptor(graphicsDataDescriptor); + } + + /** {@inheritDoc} */ + public void addObject(PreparedAFPObject drawingOrder) { + if (currentGraphicsData == null + || (currentGraphicsData.getDataLength() + drawingOrder.getDataLength()) + >= GraphicsData.MAX_DATA_LEN) { + newData(); + } + currentGraphicsData.addObject(drawingOrder); + } + + /** + * Gets the current graphics data, creating a new one if necessary + * + * @return the current graphics data + */ + private GraphicsData getData() { + if (this.currentGraphicsData == null) { + return newData(); + } + return this.currentGraphicsData; + } + + /** + * Creates a new graphics data + * + * @return a newly created graphics data + */ + private GraphicsData newData() { + this.currentGraphicsData = factory.createGraphicsData(); + objects.add(currentGraphicsData); + return currentGraphicsData; + } + + /** + * Sets the current color + * + * @param color the active color to use + */ + public void setColor(Color color) { + addObject(new GraphicsSetProcessColor(color)); + } + + /** + * Sets the current position + * + * @param coords the x and y coordinates of the current position + */ + public void setCurrentPosition(int[] coords) { + addObject(new GraphicsSetCurrentPosition(coords)); + } + + /** + * Sets the line width + * + * @param multiplier the line width multiplier + */ + public void setLineWidth(int multiplier) { + GraphicsSetLineWidth graphicsSetLineWidth = new GraphicsSetLineWidth(multiplier); + addObject(graphicsSetLineWidth); + } + + /** + * Sets the line type + * + * @param type the line type + */ + public void setLineType(byte type) { + GraphicsSetLineType graphicsSetLineType = new GraphicsSetLineType(type); + addObject(graphicsSetLineType); + } + + /** + * Sets whether to fill the next shape + * + * @param fill whether to fill the next shape + */ + public void setFill(boolean fill) { + GraphicsSetPatternSymbol graphicsSetPattern = new GraphicsSetPatternSymbol( + fill ? GraphicsSetPatternSymbol.SOLID_FILL + : GraphicsSetPatternSymbol.NO_FILL + ); + addObject(graphicsSetPattern); + } + + /** + * Sets the character set to use + * + * @param fontReference the character set (font) reference + */ + public void setCharacterSet(int fontReference) { + addObject(new GraphicsSetCharacterSet(fontReference)); + } + + /** + * Adds a line at the given x/y coordinates + * + * @param coords the x/y coordinates (can be a series) + */ + public void addLine(int[] coords) { + addObject(new GraphicsLine(coords)); + } + + /** + * Adds a box at the given coordinates + * + * @param coords the x/y coordinates + */ + public void addBox(int[] coords) { + addObject(new GraphicsBox(coords)); + } + + /** + * Adds a fillet (curve) at the given coordinates + * + * @param coords the x/y coordinates + */ + public void addFillet(int[] coords) { + addObject(new GraphicsFillet(coords)); + } + + /** + * Sets the arc parameters + * + * @param xmaj the maximum value of the x coordinate + * @param ymin the minimum value of the y coordinate + * @param xmin the minimum value of the x coordinate + * @param ymaj the maximum value of the y coordinate + */ + public void setArcParams(int xmaj, int ymin, int xmin, int ymaj) { + addObject(new GraphicsSetArcParameters(xmaj, ymin, xmin, ymaj)); + } + + /** + * Adds an arc + * + * @param x the x coordinate + * @param y the y coordinate + * @param mh the integer portion of the multiplier + * @param mhr the fractional portion of the multiplier + */ + public void addFullArc(int x, int y, int mh, int mhr) { + addObject(new GraphicsFullArc(x, y, mh, mhr)); + } + +// /** +// * Adds an image +// * +// * @param x the x coordinate +// * @param y the y coordinate +// * @param width the image width +// * @param height the image height +// * @param imgData the image data +// */ +// public void addImage(int x, int y, int width, int height, byte[] imgData) { +// addObject(new GraphicsImage(x, y, width, height, imgData)); +// } + + /** + * Adds a string + * + * @param str the string + * @param x the x coordinate + * @param y the y coordinate + */ + public void addString(String str, int x, int y) { + addObject(new GraphicsString(str, x, y)); + } + + /** + * Begins a graphics area (start of fill) + */ + public void beginArea() { + if (currentGraphicsData == null) { + newData(); + } + currentGraphicsData.beginArea(); + } + + /** + * Ends a graphics area (end of fill) + */ + public void endArea() { + if (currentGraphicsData != null) { + currentGraphicsData.endArea(); + } + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsObject: " + getName(); + } + + /** + * Creates a new graphics segment + */ + public void newSegment() { + getData().newSegment(); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.GRAPHICS); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + super.writeObjects(objects, os); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.GRAPHICS); + os.write(data); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/IMImageObject.java b/src/java/org/apache/fop/afp/modca/IMImageObject.java new file mode 100644 index 000000000..a09042441 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/IMImageObject.java @@ -0,0 +1,141 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.ioca.ImageCellPosition; +import org.apache.fop.afp.ioca.ImageInputDescriptor; +import org.apache.fop.afp.ioca.ImageOutputControl; +import org.apache.fop.afp.ioca.ImageRasterData; + +/** + * An IM image data object specifies the contents of a raster image and + * its placement on a page, overlay, or page segment. An IM image can be + * either simple or complex. A simple image is composed of one or more Image + * Raster Data (IRD) structured fields that define the raster pattern for the + * entire image. A complex image is divided into regions called image cells. + * Each image cell is composed of one or more IRD structured fields that define + * the raster pattern for the image cell, and one Image Cell Position (ICP) + * structured field that defines the position of the image cell relative to + * the origin of the entire image. Each ICP also specifies the size of the + * image cell and a fill rectangle into which the cell is replicated. + *

      + */ +public class IMImageObject extends AbstractNamedAFPObject { + + /** + * The image output control + */ + private ImageOutputControl imageOutputControl = null; + + /** + * The image input descriptor + */ + private ImageInputDescriptor imageInputDescriptor = null; + + /** + * The image cell position + */ + private ImageCellPosition imageCellPosition = null; + + /** + * The image rastor data + */ + private ImageRasterData imageRasterData = null; + + /** + * Constructor for the image object with the specified name, + * the name must be a fixed length of eight characters. + * + * @param name The name of the image. + */ + public IMImageObject(String name) { + super(name); + } + + /** + * Sets the ImageOutputControl. + * + * @param imageOutputControl The imageOutputControl to set + */ + public void setImageOutputControl(ImageOutputControl imageOutputControl) { + this.imageOutputControl = imageOutputControl; + } + + /** + * Sets the ImageCellPosition. + * + * @param imageCellPosition The imageCellPosition to set + */ + public void setImageCellPosition(ImageCellPosition imageCellPosition) { + this.imageCellPosition = imageCellPosition; + } + + /** + * Sets the ImageInputDescriptor. + * + * @param imageInputDescriptor The imageInputDescriptor to set + */ + public void setImageInputDescriptor(ImageInputDescriptor imageInputDescriptor) { + this.imageInputDescriptor = imageInputDescriptor; + } + + /** + * Sets the ImageRastorData. + * + * @param imageRasterData The imageRasterData to set + */ + public void setImageRasterData(ImageRasterData imageRasterData) { + this.imageRasterData = imageRasterData; + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + if (imageOutputControl != null) { + imageOutputControl.writeToStream(os); + } + if (imageInputDescriptor != null) { + imageInputDescriptor.writeToStream(os); + } + if (imageCellPosition != null) { + imageCellPosition.writeToStream(os); + } + if (imageRasterData != null) { + imageRasterData.writeToStream(os); + } + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.IM_IMAGE); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.IM_IMAGE); + os.write(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java b/src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java new file mode 100644 index 000000000..07976e18a --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ImageDataDescriptor.java @@ -0,0 +1,78 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * ImageDataDescriptor + */ +public class ImageDataDescriptor extends AbstractDescriptor { + + /** + * Constructor for a ImageDataDescriptor for the specified + * resolution, width and height. + * + * @param width The width of the image. + * @param height The height of the height. + * @param widthRes The horizontal resolution of the image. + * @param heightRes The vertical resolution of the image. + */ + public ImageDataDescriptor(int width, int height, int widthRes, int heightRes) { + super(width, height, widthRes, heightRes); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[22]; + copySF(data, Type.DESCRIPTOR, Category.IMAGE); + + // SF length + byte[] len = BinaryUtils.convert(data.length - 1, 2); + data[1] = len[0]; + data[2] = len[1]; + + byte[] x = BinaryUtils.convert(widthRes, 2); + data[10] = x[0]; + data[11] = x[1]; + + byte[] y = BinaryUtils.convert(heightRes, 2); + data[12] = y[0]; + data[13] = y[1]; + + byte[] w = BinaryUtils.convert(width, 2); + data[14] = w[0]; + data[15] = w[1]; + + byte[] h = BinaryUtils.convert(height, 2); + data[16] = h[0]; + data[17] = h[1]; + + data[18] = (byte)0xF7; // ID = Set IOCA Function Set + data[19] = 0x02; // Length + data[20] = 0x01; // Category = Function set identifier + data[21] = 0x0B; // FCNSET = IOCA FS 11 + + os.write(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/ImageObject.java b/src/java/org/apache/fop/afp/modca/ImageObject.java new file mode 100644 index 000000000..8ab56691f --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ImageObject.java @@ -0,0 +1,154 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPImageObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.ioca.ImageSegment; + +/** + * An IOCA Image Data Object + */ +public class ImageObject extends AbstractDataObject { + + private static final int MAX_DATA_LEN = 32759; + + /** the image segment */ + private ImageSegment imageSegment = null; + + /** + * Constructor for the image object with the specified name, + * the name must be a fixed length of eight characters. + * + * @param name The name of the image. + * @param factory the resource manager + */ + public ImageObject(Factory factory, String name) { + super(factory, name); + } + + private ImageSegment getImageSegment() { + if (imageSegment == null) { + this.imageSegment = factory.createImageSegment(); + } + return imageSegment; + } + + /** {@inheritDoc} */ + public void setViewport(AFPDataObjectInfo dataObjectInfo) { + super.setViewport(dataObjectInfo); + + AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)dataObjectInfo; + int dataWidth = imageObjectInfo.getDataWidth(); + int dataHeight = imageObjectInfo.getDataHeight(); + + AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + int widthRes = objectAreaInfo.getWidthRes(); + int heightRes = objectAreaInfo.getHeightRes(); + + ImageDataDescriptor imageDataDescriptor + = factory.createImageDataDescriptor(dataWidth, dataHeight, widthRes, heightRes); + getObjectEnvironmentGroup().setDataDescriptor(imageDataDescriptor); + + getImageSegment().setImageSize(dataWidth, dataHeight, widthRes, heightRes); + } + + /** + * Sets the image encoding. + * + * @param encoding The image encoding. + */ + public void setEncoding(byte encoding) { + getImageSegment().setEncoding(encoding); + } + + /** + * Sets the image compression. + * + * @param compression The image compression. + */ + public void setCompression(byte compression) { + getImageSegment().setCompression(compression); + } + + /** + * Sets the image IDE size. + * + * @param size The IDE size. + */ + public void setIDESize(byte size) { + getImageSegment().setIDESize(size); + } + + /** + * Sets the image IDE color model. + * + * @param colorModel the IDE color model. + */ + public void setIDEColorModel(byte colorModel) { + getImageSegment().setIDEColorModel(colorModel); + } + + /** + * Set the data of the image. + * + * @param data the image data + */ + public void setData(byte[] data) { + getImageSegment().setData(data); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.IMAGE); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + + if (imageSegment != null) { + final byte[] dataHeader = new byte[9]; + copySF(dataHeader, SF_CLASS, Type.DATA, Category.IMAGE); + final int lengthOffset = 1; + + // TODO save memory! + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + imageSegment.writeToStream(baos); + byte[] data = baos.toByteArray(); + writeChunksToStream(data, dataHeader, lengthOffset, MAX_DATA_LEN, os); + } + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.IMAGE); + os.write(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/IncludeObject.java b/src/java/org/apache/fop/afp/modca/IncludeObject.java new file mode 100644 index 000000000..c0ab5c640 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/IncludeObject.java @@ -0,0 +1,303 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.triplets.MappingOptionTriplet; +import org.apache.fop.afp.modca.triplets.MeasurementUnitsTriplet; +import org.apache.fop.afp.modca.triplets.ObjectAreaSizeTriplet; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * An Include Object structured field references an object on a page or overlay. + * It optionally contains parameters that identify the object and that specify + * presentation parameters such as object position, size, orientation, mapping, + * and default color. + *

      + * Where the presentation parameters conflict with parameters specified in the + * object's environment group (OEG), the parameters in the Include Object + * structured field override. If the referenced object is a page segment, the + * IOB parameters override the corresponding environment group parameters on all + * data objects in the page segment. + *

      + */ +public class IncludeObject extends AbstractNamedAFPObject { + + /** the object referenced is of type page segment */ + public static final byte TYPE_PAGE_SEGMENT = (byte)0x5F; + + /** the object referenced is of type other */ + public static final byte TYPE_OTHER = (byte)0x92; + + /** the object referenced is of type graphic */ + public static final byte TYPE_GRAPHIC = (byte)0xBB; + + /** the object referenced is of type barcode */ + public static final byte TYPE_BARCODE = (byte)0xEB; + + /** the object referenced is of type image */ + public static final byte TYPE_IMAGE = (byte)0xFB; + + + /** the object type referenced (default is other) */ + private byte objectType = TYPE_OTHER; + + /** the X-axis origin of the object area */ + private int xoaOset = 0; + + /** the Y-axis origin of the object area */ + private int yoaOset = 0; + + /** the orientation of the referenced object */ + private int oaOrent = 0; + + /** the X-axis origin defined in the object */ + private int xocaOset = -1; + + /** the Y-axis origin defined in the object */ + private int yocaOset = -1; + + /** + * Constructor for the include object with the specified name, the name must + * be a fixed length of eight characters and is the name of the referenced + * object. + * + * @param name the name of this include object + */ + public IncludeObject(String name) { + super(name); + } + + /** + * Sets the orientation to use for the Include Object. + * + * @param orientation + * The orientation (0,90, 180, 270) + */ + public void setObjectAreaOrientation(int orientation) { + if (orientation == 0 || orientation == 90 || orientation == 180 + || orientation == 270) { + this.oaOrent = orientation; + } else { + throw new IllegalArgumentException( + "The orientation must be one of the values 0, 90, 180, 270"); + } + } + + /** + * Sets the x and y offset to the origin in the object area + * + * @param x the X-axis origin of the object area + * @param y the Y-axis origin of the object area + */ + public void setObjectAreaOffset(int x, int y) { + this.xoaOset = x; + this.yoaOset = y; + } + + /** + * Sets the x and y offset of the content area to the object area + * used in conjunction with the {@link MappingOptionTriplet.POSITION} and + * {@link MappingOptionTriplet.POSITION_AND_TRIM}. + * + * @param x the X-axis origin defined in the object + * @param y the Y-axis origin defined in the object + */ + public void setContentAreaOffset(int x, int y) { + this.xocaOset = x; + this.yocaOset = y; + } + + /** + * Sets the data object type + * + * @param type the data object type + */ + public void setObjectType(byte type) { + this.objectType = type; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[36]; + super.copySF(data, Type.INCLUDE, Category.DATA_RESOURCE); + + // Set the total record length + int tripletDataLength = getTripletDataLength(); + byte[] len = BinaryUtils.convert(35 + tripletDataLength, 2); //Ignore first byte + data[1] = len[0]; + data[2] = len[1]; + + data[17] = 0x00; // reserved + data[18] = objectType; + + //XoaOset (object area) + if (xoaOset > -1) { + byte[] x = BinaryUtils.convert(xoaOset, 3); + data[19] = x[0]; + data[20] = x[1]; + data[21] = x[2]; + } else { + data[19] = (byte)0xFF; + data[20] = (byte)0xFF; + data[21] = (byte)0xFF; + } + + // YoaOset (object area) + if (yoaOset > -1) { + byte[] y = BinaryUtils.convert(yoaOset, 3); + data[22] = y[0]; + data[23] = y[1]; + data[24] = y[2]; + } else { + data[22] = (byte)0xFF; + data[23] = (byte)0xFF; + data[24] = (byte)0xFF; + } + + // XoaOrent/YoaOrent + switch (oaOrent) { + case -1: // use x/y axis orientation defined in object + data[25] = (byte)0xFF; // x axis rotation + data[26] = (byte)0xFF; // + data[27] = (byte)0xFF; // y axis rotation + data[28] = (byte)0xFF; + break; + case 90: + data[25] = 0x2D; + data[26] = 0x00; + data[27] = 0x5A; + data[28] = 0x00; + break; + case 180: + data[25] = 0x5A; + data[25] = 0x00; + data[27] = (byte)0x87; + data[28] = 0x00; + break; + case 270: + data[25] = (byte)0x87; + data[26] = 0x00; + data[27] = 0x00; + data[28] = 0x00; + break; + default: // 0 degrees + data[25] = 0x00; + data[26] = 0x00; + data[27] = 0x2D; + data[28] = 0x00; + break; + } + + // XocaOset (object content) + if (xocaOset > -1) { + byte[] x = BinaryUtils.convert(xocaOset, 3); + data[29] = x[0]; + data[30] = x[1]; + data[31] = x[2]; + } else { + data[29] = (byte)0xFF; + data[30] = (byte)0xFF; + data[31] = (byte)0xFF; + } + + // YocaOset (object content) + if (yocaOset > -1) { + byte[] y = BinaryUtils.convert(yocaOset, 3); + data[32] = y[0]; + data[33] = y[1]; + data[34] = y[2]; + } else { + data[32] = (byte)0xFF; + data[33] = (byte)0xFF; + data[34] = (byte)0xFF; + } + // RefCSys (Reference coordinate system) + data[35] = 0x01; // Page or overlay coordinate system + + // Write structured field data + os.write(data); + + // Write triplet for FQN internal/external object reference + if (tripletData != null) { + os.write(tripletData); + } + } + + private String getObjectTypeName() { + String objectTypeName = null; + if (objectType == TYPE_PAGE_SEGMENT) { + objectTypeName = "page segment"; + } else if (objectType == TYPE_OTHER) { + objectTypeName = "other"; + } else if (objectType == TYPE_GRAPHIC) { + objectTypeName = "graphic"; + } else if (objectType == TYPE_BARCODE) { + objectTypeName = "barcode"; + } else if (objectType == TYPE_IMAGE) { + objectTypeName = "image"; + } + return objectTypeName; + } + + /** {@inheritDoc} */ + public String toString() { + return "IncludeObject{name=" + this.getName() + + ", objectType=" + getObjectTypeName() + + ", xoaOset=" + xoaOset + + ", yoaOset=" + yoaOset + + ", oaOrent" + oaOrent + + ", xocaOset=" + xocaOset + + ", yocaOset=" + yocaOset + + "}"; + } + + /** + * Sets the mapping option + * + * @param optionValue the mapping option value + */ + public void setMappingOption(byte optionValue) { + addTriplet(new MappingOptionTriplet(optionValue)); + } + + /** + * Sets the extent of an object area in the X and Y directions + * + * @param x the x direction extent + * @param y the y direction extent + */ + public void setObjectAreaSize(int x, int y) { + addTriplet(new ObjectAreaSizeTriplet(x, y)); + } + + /** + * Sets the measurement units used to specify the units of measure + * + * @param xRes units per base on the x-axis + * @param yRes units per base on the y-axis + */ + public void setMeasurementUnits(int xRes, int yRes) { + addTriplet(new MeasurementUnitsTriplet(xRes, xRes)); + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java b/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java new file mode 100644 index 000000000..44f0edc5b --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/IncludePageOverlay.java @@ -0,0 +1,129 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * + * The Include Page Overlay structured field references an overlay resource + * definition that is to be positioned on the page. A page overlay can be + * referenced at any time during the page state, but not during an object state. + * The overlay contains its own active environment group definition. + * + * Note: There is no need for the triplets, so I have ignored them. + * + * A real example of where this will be used is for static overlays, such as an + * address on the page. + * + */ +public class IncludePageOverlay extends AbstractNamedAFPObject { + + /** + * The x coordinate + */ + private int x = 0; + + /** + * The y coordinate + */ + private int y = 0; + + /** + * The orientation + */ + private int orientation = 0; + + /** + * Constructor for the Include Page Overlay + * + * @param overlayName Name of the page segment + * @param x The x position + * @param y The y position + * @param orientation The orientation + */ + public IncludePageOverlay(String overlayName, int x, int y, int orientation) { + super(overlayName); + + this.x = x; + this.y = y; + setOrientation(orientation); + } + + /** + * Sets the orientation to use for the overlay. + * + * @param orientation + * The orientation (0,90, 180, 270) + */ + public void setOrientation(int orientation) { + if (orientation == 0 || orientation == 90 || orientation == 180 + || orientation == 270) { + this.orientation = orientation; + } else { + throw new IllegalArgumentException( + "The orientation must be one of the values 0, 90, 180, 270"); + } + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[25]; //(9 +16) + copySF(data, Type.INCLUDE, Category.PAGE_OVERLAY); + + // Set the total record length + byte[] len = BinaryUtils.convert(24, 2); //Ignore first byte + data[1] = len[0]; + data[2] = len[1]; + + byte[] xPos = BinaryUtils.convert(x, 3); + data[17] = xPos[0]; // x coordinate + data[18] = xPos[1]; + data[19] = xPos[2]; + + byte[] yPos = BinaryUtils.convert(y, 3); + data[20] = yPos[0]; // y coordinate + data[21] = yPos[1]; + data[22] = yPos[2]; + + switch (orientation) { + case 90: + data[23] = 0x2D; + data[24] = 0x00; + break; + case 180: + data[23] = 0x5A; + data[24] = 0x00; + break; + case 270: + data[23] = (byte) 0x87; + data[24] = 0x00; + break; + default: + data[23] = 0x00; + data[24] = 0x00; + break; + } + os.write(data); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/IncludePageSegment.java b/src/java/org/apache/fop/afp/modca/IncludePageSegment.java new file mode 100644 index 000000000..7355e3b1a --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/IncludePageSegment.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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Include Page Segment structured field references a page segment resource + * object that is to be presented on the page or overlay presentation space. The IPS + * specifies a reference point on the including page or overlay coordinate system that + * may be used to position objects contained in the page segment. A page segment + * can be referenced at any time during page or overlay state, but not during an + * object state. The page segment inherits the active environment group definition of + * the including page or overlay. + * + * Note : No use for Triplets. + * + * A 'real' example for where this will be used is for + * the dynamic placing of overlay objects, such as signatures + * that may have to be placed at different positions on a document. + * + */ +public class IncludePageSegment extends AbstractNamedAFPObject { + + /** + * The x position where we need to put this object on the page + */ + private int x; + + /** + * The y position where we need to put this object on the page + */ + private int y; + + /** + * Constructor for the Include Page Segment + * + * @param name Name of the page segment + * @param x The x position + * @param y The y position + */ + public IncludePageSegment(String name, int x, int y) { + super(name); + + this.x = x; + this.y = y; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[23]; //(9 +14) + copySF(data, Type.INCLUDE, Category.PAGE_SEGMENT); + + // Set the total record length + byte[] len = BinaryUtils.convert(22, 2); //Ignore first byte + data[1] = len[0]; + data[2] = len[1]; + + byte[] xPos = BinaryUtils.convert(x, 3); + data[17] = xPos[0]; // x coordinate + data[18] = xPos[1]; + data[19] = xPos[2]; + + byte[] yPos = BinaryUtils.convert(y, 3); + data[20] = yPos[0]; // y coordinate + data[21] = yPos[1]; + data[22] = yPos[2]; + + os.write(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/InterchangeSet.java b/src/java/org/apache/fop/afp/modca/InterchangeSet.java new file mode 100644 index 000000000..28a4da42b --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/InterchangeSet.java @@ -0,0 +1,115 @@ +/* + * 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.afp.modca; + +/** + * MO:DCA Interchange Set + */ +public class InterchangeSet { + /** interchange set 1 string value */ + public static final String MODCA_PRESENTATION_INTERCHANGE_SET_1 = "MO:DCA-P IS/1"; + + /** interchange set 2 string value */ + public static final String MODCA_PRESENTATION_INTERCHANGE_SET_2 = "MO:DCA-P IS/2"; + + /** resource interchange set string value */ + public static final String MODCA_RESOURCE_INTERCHANGE_SET = "MO:DCA-L"; + + private static final String[] NAMES = { + MODCA_PRESENTATION_INTERCHANGE_SET_1, + MODCA_PRESENTATION_INTERCHANGE_SET_2, + MODCA_RESOURCE_INTERCHANGE_SET + }; + + private static final int SET_1 = 0; + private static final int SET_2 = 1; + private static final int RESOURCE_SET = 2; + + /** the actual interchange set in use */ + private int value; + + /** + * Returns the interchange set value of a given string + * + * @param str an interchange set value + * @return an interchange set + */ + public static InterchangeSet valueOf(String str) { + if (MODCA_PRESENTATION_INTERCHANGE_SET_1.equals(str)) { + return new InterchangeSet(SET_1); + } else if (MODCA_PRESENTATION_INTERCHANGE_SET_2.equals(str)) { + return new InterchangeSet(SET_2); + } else if (MODCA_RESOURCE_INTERCHANGE_SET.equals(str)) { + return new InterchangeSet(RESOURCE_SET); + } else { + throw new IllegalArgumentException("Invalid MO:DCA interchange set :" + str); + } + } + + /** + * Main constructor + * + * @param value the interchange set value + */ + public InterchangeSet(int value) { + this.value = value; + } + + /** + * Returns true if complies with MOD:CA interchange set 1 + * + * @return true if complies with MOD:CA interchange set 1 + */ + protected boolean is1() { + return value == SET_1; + } + + /** + * Returns true if complies with MOD:CA interchange set 2 + * + * @return true if complies with MOD:CA interchange set 2 + */ + public boolean is2() { + return value == SET_2; + } + + /** + * Returns true if complies with MOD:CA resource set + * + * @return true if complies with MOD:CA resource set + */ + public boolean isResource() { + return value == RESOURCE_SET; + } + + /** {@inheritDoc} */ + public String toString() { + return NAMES[value]; + } + + /** + * Returns true if MOD:CA interchange set 2 (resource groups) is supported + * + * @return true if MOD:CA interchange set 2 (resource groups) is supported + */ + public boolean supportsLevel2() { + return is2() || isResource(); + } +} diff --git a/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java b/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java new file mode 100644 index 000000000..f910a0b9c --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/InvokeMediumMap.java @@ -0,0 +1,57 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Invoke Medium Map structured field identifies the Medium Map that is to + * become active for the document. An Invoke Medium Map structured field affects + * the document's current environment. The Medium Map's effect on current environment + * parameter values lasts until a new Medium Map is invoked. + */ +public class InvokeMediumMap extends AbstractNamedAFPObject { + + /** + * Constructor for the Invoke Medium Map + * + * @param name the name of the medium map + */ + public InvokeMediumMap(String name) { + super(name); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + + byte[] data = new byte[17]; + copySF(data, Type.MAP, Category.MEDIUM_MAP); + + // Set the total record length + byte[] len = BinaryUtils.convert(16, 2); //Ignore first byte + data[1] = len[0]; + data[2] = len[1]; + + os.write(data); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/MapCodedFont.java b/src/java/org/apache/fop/afp/modca/MapCodedFont.java new file mode 100644 index 000000000..fb9637678 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/MapCodedFont.java @@ -0,0 +1,273 @@ +/* + * 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.afp.modca; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.Iterator; +import java.util.List; + +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.fonts.AFPFont; +import org.apache.fop.afp.fonts.CharacterSet; +import org.apache.fop.afp.fonts.FontRuntimeException; +import org.apache.fop.afp.fonts.OutlineFont; +import org.apache.fop.afp.fonts.RasterFont; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Map Coded Font structured field maps a unique coded font resource local + * ID, which may be embedded one or more times within an object's data and + * descriptor, to the identifier of a coded font resource object. Additionally, + * the Map Coded Font structured field specifies a set of resource attributes + * for the coded font. + */ +public class MapCodedFont extends AbstractStructuredAFPObject { + + /** + * The collection of map coded fonts (maximum of 254) + */ + private final List/**/ fontList = new java.util.ArrayList(); + + /** + * Constructor for the MapCodedFont + */ + public MapCodedFont() { + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + byte[] startData = new byte[9]; + copySF(startData, Type.MAP, Category.CODED_FONT); + baos.write(startData); + + Iterator iter = fontList.iterator(); + while (iter.hasNext()) { + FontDefinition fd = (FontDefinition) iter.next(); + + // Start of repeating groups (occurs 1 to 254) + baos.write(0x00); + + if (fd.scale == 0) { + // Raster Font + baos.write(0x22); // Length of 34 + } else { + // Outline Font + baos.write(0x3A); // Length of 58 + } + + // Font Character Set Name Reference + baos.write(0x0C); + baos.write(0x02); + baos.write((byte) 0x86); + baos.write(0x00); + baos.write(fd.characterSet); + + // Font Code Page Name Reference + baos.write(0x0C); + baos.write(0x02); + baos.write((byte) 0x85); + baos.write(0x00); + baos.write(fd.codePage); + + // Character Rotation + baos.write(0x04); + baos.write(0x26); + baos.write(fd.orientation); + baos.write(0x00); + + // Resource Local Identifier + baos.write(0x04); + baos.write(0x24); + baos.write(0x05); + baos.write(fd.fontReferenceKey); + + if (fd.scale != 0) { + // Outline Font (triplet '1F') + baos.write(0x14); + baos.write(0x1F); + baos.write(0x00); + baos.write(0x00); + + baos.write(BinaryUtils.convert(fd.scale, 2)); // Height + baos.write(new byte[] {0x00, 0x00}); // Width + + baos.write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00}); + + baos.write(0x60); + + // Outline Font (triplet '5D') + baos.write(0x04); + baos.write(0x5D); + baos.write(BinaryUtils.convert(fd.scale, 2)); + } + } + + byte[] data = baos.toByteArray(); + + // Set the total record length + byte[] rl1 = BinaryUtils.convert(data.length - 1, 2); + data[1] = rl1[0]; + data[2] = rl1[1]; + + os.write(data); + } + + /** + * Add a font definition on the the map coded font object. + * + * @param fontReference + * the font number used as the resource identifier + * @param font + * the font + * @param size + * the size of the font + * @param orientation + * the orientation of the font + * @throws MaximumSizeExceededException if the maximum number of fonts have been exceeded + */ + public void addFont(int fontReference, AFPFont font, int size, int orientation) + throws MaximumSizeExceededException { + + FontDefinition fd = new FontDefinition(); + + fd.fontReferenceKey = BinaryUtils.convert(fontReference)[0]; + + switch (orientation) { + case 90: + fd.orientation = 0x2D; + break; + case 180: + fd.orientation = 0x5A; + break; + case 270: + fd.orientation = (byte) 0x87; + break; + default: + fd.orientation = 0x00; + break; + } + + try { + if (font instanceof RasterFont) { + RasterFont raster = (RasterFont) font; + CharacterSet cs = raster.getCharacterSet(size); + if (cs == null) { + String msg = "Character set not found for font " + + font.getFontName() + " with point size " + size; + log.error(msg); + throw new FontRuntimeException(msg); + } + + fd.characterSet = cs.getNameBytes(); + + if (fd.characterSet.length != 8) { + throw new IllegalArgumentException("The character set " + + new String(fd.characterSet, + AFPConstants.EBCIDIC_ENCODING) + + " must have a fixed length of 8 characters."); + } + + fd.codePage = cs.getCodePage().getBytes( + AFPConstants.EBCIDIC_ENCODING); + + if (fd.codePage.length != 8) { + throw new IllegalArgumentException("The code page " + + new String(fd.codePage, + AFPConstants.EBCIDIC_ENCODING) + + " must have a fixed length of 8 characters."); + } + + } else if (font instanceof OutlineFont) { + OutlineFont outline = (OutlineFont) font; + CharacterSet cs = outline.getCharacterSet(); + fd.characterSet = cs.getNameBytes(); + + // There are approximately 72 points to 1 inch or 20 1440ths per point. + + fd.scale = ((size / 1000) * 20); + + fd.codePage = cs.getCodePage().getBytes( + AFPConstants.EBCIDIC_ENCODING); + + if (fd.codePage.length != 8) { + throw new IllegalArgumentException("The code page " + + new String(fd.codePage, + AFPConstants.EBCIDIC_ENCODING) + + " must have a fixed length of 8 characters."); + } + } else { + String msg = "Font of type " + font.getClass().getName() + + " not recognized."; + log.error(msg); + throw new FontRuntimeException(msg); + } + + if (fontList.size() > 253) { + // Throw an exception if the size is exceeded + throw new MaximumSizeExceededException(); + } else { + fontList.add(fd); + } + + } catch (UnsupportedEncodingException ex) { + throw new FontRuntimeException("Failed to create font " + + " due to a UnsupportedEncodingException", ex); + } + } + + + /** + * Private utility class used as a container for font attributes + */ + private class FontDefinition { + + /** + * The code page of the font + */ + private byte[] codePage; + + /** + * The character set of the font + */ + private byte[] characterSet; + + /** + * The font reference key + */ + private byte fontReferenceKey; + + /** + * The orientation of the font + */ + private byte orientation; + + /** + * The scale (only specified for outline fonts) + */ + private int scale = 0; + } + +} diff --git a/src/java/org/apache/fop/afp/modca/MapContainerData.java b/src/java/org/apache/fop/afp/modca/MapContainerData.java new file mode 100644 index 000000000..dba7616a8 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/MapContainerData.java @@ -0,0 +1,57 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.triplets.MappingOptionTriplet; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Map Container Data structured field specifies how a presentation data object + * that is carried in an Object Container is mapped into its object area. + */ +public class MapContainerData extends AbstractStructuredAFPObject { + + /** + * Main constructor + * + * @param optionValue the mapping option value + */ + public MapContainerData(byte optionValue) { + super.addTriplet(new MappingOptionTriplet(optionValue)); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[11]; + copySF(data, Type.MAP, Category.OBJECT_CONTAINER); + int tripletLen = getTripletDataLength(); + byte[] len = BinaryUtils.convert(10 + tripletLen, 2); + data[1] = len[0]; + data[2] = len[1]; + len = BinaryUtils.convert(2 + tripletLen, 2); + data[9] = len[0]; + data[10] = len[1]; + os.write(data); + os.write(tripletData); + } +} diff --git a/src/java/org/apache/fop/afp/modca/MapDataResource.java b/src/java/org/apache/fop/afp/modca/MapDataResource.java new file mode 100644 index 000000000..7bebc4c07 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/MapDataResource.java @@ -0,0 +1,58 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Map Data Resource structured field specifies resources that are + * required for presentation. + */ +public class MapDataResource extends AbstractStructuredAFPObject { + + /** + * Main constructor + */ + public MapDataResource() { + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + super.writeStart(os); + byte[] data = new byte[11]; + copySF(data, Type.MAP, Category.DATA_RESOURCE); + + int tripletDataLen = getTripletDataLength(); + + byte[] len = BinaryUtils.convert(10 + tripletDataLen, 2); + data[1] = len[0]; + data[2] = len[1]; + + len = BinaryUtils.convert(2 + tripletDataLen, 2); + data[9] = len[0]; + data[10] = len[1]; + + os.write(data); + os.write(tripletData); + } +} diff --git a/src/java/org/apache/fop/afp/modca/MapPageOverlay.java b/src/java/org/apache/fop/afp/modca/MapPageOverlay.java new file mode 100644 index 000000000..9fd3c7059 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/MapPageOverlay.java @@ -0,0 +1,141 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.List; + +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Map Page Overlay structured field maps a Resource Local ID to the name of + * a Begin Overlay structured field. A Map Page Overlay structured field may + * contain from one to 254 repeating groups. + */ +public class MapPageOverlay extends AbstractAFPObject { + + private static final int MAX_SIZE = 253; + + /** + * The collection of overlays (maximum of 254 stored as byte[]) + */ + private List overLays = null; + + /** + * Constructor for the Map Page Overlay + */ + public MapPageOverlay() { + } + + private List getOverlays() { + if (overLays == null) { + this.overLays = new java.util.ArrayList(); + } + return this.overLays; + } + + /** + * Add an overlay to to the map page overlay object. + * + * @param name + * The name of the overlay. + * @throws MaximumSizeExceededException if the maximum size is reached + */ + public void addOverlay(String name) throws MaximumSizeExceededException { + if (getOverlays().size() > MAX_SIZE) { + throw new MaximumSizeExceededException(); + } + if (name.length() != 8) { + throw new IllegalArgumentException("The name of overlay " + name + + " must be 8 characters"); + } + if (log.isDebugEnabled()) { + log.debug("addOverlay():: adding overlay " + name); + } + try { + byte[] data = name.getBytes(AFPConstants.EBCIDIC_ENCODING); + getOverlays().add(data); + } catch (UnsupportedEncodingException usee) { + log.error("addOverlay():: UnsupportedEncodingException translating the name " + + name); + } + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + int oLayCount = getOverlays().size(); + int recordlength = oLayCount * 18; + + byte[] data = new byte[recordlength + 9]; + + data[0] = 0x5A; + + // Set the total record length + byte[] rl1 = BinaryUtils.convert(recordlength + 8, 2); //Ignore the + // first byte in + // the length + data[1] = rl1[0]; + data[2] = rl1[1]; + + // Structured field ID for a MPO + data[3] = (byte) 0xD3; + data[4] = (byte) Type.MAP; + data[5] = (byte) Category.PAGE_OVERLAY; + + data[6] = 0x00; // Reserved + data[7] = 0x00; // Reserved + data[8] = 0x00; // Reserved + + int pos = 8; + + //For each overlay + byte olayref = 0x00; + + for (int i = 0; i < oLayCount; i++) { + olayref = (byte) (olayref + 1); + + data[++pos] = 0x00; + data[++pos] = 0x12; //the length of repeating group + + data[++pos] = 0x0C; //Fully Qualified Name + data[++pos] = 0x02; + data[++pos] = (byte) 0x84; + data[++pos] = 0x00; + + //now add the name + byte[] name = (byte[]) overLays.get(i); + + for (int j = 0; j < name.length; j++) { + data[++pos] = name[j]; + } + + data[++pos] = 0x04; //Resource Local Identifier (RLI) + data[++pos] = 0x24; + data[++pos] = 0x02; + + //now add the unique id to the RLI + data[++pos] = olayref; + } + os.write(data); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/MaximumSizeExceededException.java b/src/java/org/apache/fop/afp/modca/MaximumSizeExceededException.java new file mode 100644 index 000000000..6d1c74156 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/MaximumSizeExceededException.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.afp.modca; + +/** + * An exception to handle maximum sizes being exceeded. + * + */ +public class MaximumSizeExceededException extends Exception { + + private static final long serialVersionUID = 7823120005542216446L; + + /** + * Default constructor + */ + public MaximumSizeExceededException() { + super(); + } + +} diff --git a/src/java/org/apache/fop/afp/modca/NoOperation.java b/src/java/org/apache/fop/afp/modca/NoOperation.java new file mode 100644 index 000000000..cb5841346 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/NoOperation.java @@ -0,0 +1,100 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The No Operation structured field may be used to carry comments + * or any other type of unarchitected data. Although not recommended, + * it may also be used to carry semantic data in private or exchange data + * streams. However, because receivers of interchange data streams should + * ignore the content of No Operation structured fields and because + * receiver-generator products are not required to propagate + * No Operation structured fields, no semantics should be attached to + * 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 + */ + 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 writeToStream(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]; + + // Structured field ID for a TLE + data[3] = (byte) 0xD3; + data[4] = (byte) 0xEE; + data[5] = (byte) 0xEE; + + data[6] = 0x00; // Reserved + data[7] = 0x00; // Reserved + data[8] = 0x00; // Reserved + + int pos = 9; + for (int i = 0; i < contentLen; i++) { + data[pos++] = contentData[i]; + } + os.write(data); + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/ObjectAreaDescriptor.java b/src/java/org/apache/fop/afp/modca/ObjectAreaDescriptor.java new file mode 100644 index 000000000..21c21e39f --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ObjectAreaDescriptor.java @@ -0,0 +1,87 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.fop.afp.modca.triplets.MeasurementUnitsTriplet; +import org.apache.fop.afp.modca.triplets.ObjectAreaSizeTriplet; +import org.apache.fop.afp.modca.triplets.PresentationSpaceResetMixingTriplet; +import org.apache.fop.afp.modca.triplets.Triplet; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Object Area Descriptor structured field specifies the size and attributes + * of an object area presentation space. + */ +public class ObjectAreaDescriptor extends AbstractDescriptor { + + /** + * Construct an object area descriptor for the specified object width + * and object height. + * + * @param width the object width. + * @param height the object height. + * @param widthRes the object width resolution. + * @param heightRes the object height resolution. + */ + public ObjectAreaDescriptor(int width, int height, int widthRes, int heightRes) { + super(width, height, widthRes, heightRes); + } + + /** {@inheritDoc} */ + protected byte[] getTripletData() throws IOException { + if (tripletData == null) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + // Specifies the associated ObjectAreaPosition structured field + final byte oapId = 0x01; + Triplet triplet = new Triplet(Triplet.DESCRIPTOR_POSITION, oapId); + triplet.writeToStream(baos); + + triplet = new MeasurementUnitsTriplet(widthRes, heightRes); + triplet.writeToStream(baos); + + triplet = new ObjectAreaSizeTriplet(width, height); + triplet.writeToStream(baos); + + triplet = new PresentationSpaceResetMixingTriplet( + PresentationSpaceResetMixingTriplet.NOT_RESET); + triplet.writeToStream(baos); + + this.tripletData = baos.toByteArray(); + } + return this.tripletData; + } + + /** {@inheritDoc} */ + public void writeStart(OutputStream os) throws IOException { + super.writeStart(os); + byte[] data = new byte[9]; + copySF(data, Type.DESCRIPTOR, Category.OBJECT_AREA); + byte[] len = BinaryUtils.convert(data.length + tripletData.length - 1, 2); + data[1] = len[0]; // Length + data[2] = len[1]; + os.write(data); + } + +} diff --git a/src/java/org/apache/fop/afp/modca/ObjectAreaPosition.java b/src/java/org/apache/fop/afp/modca/ObjectAreaPosition.java new file mode 100644 index 000000000..3929c1196 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ObjectAreaPosition.java @@ -0,0 +1,112 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Object Area Position structured field specifies the origin and + * orientation of the object area, and the origin and orientation of the + * object content within the object area. + */ +public class ObjectAreaPosition extends AbstractAFPObject { + + private final int x; + private final int y; + private final int rotation; + private int xOffset; + private int yOffset; + + /** + * Construct an object area position for the specified object y, y position. + * + * @param x The x coordinate. + * @param y The y coordinate. + * @param rotation The coordinate system rotation (must be 0, 90, 180, 270). + */ + public ObjectAreaPosition(int x, int y, int rotation) { + this.x = x; + this.y = y; + this.rotation = rotation; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[33]; + copySF(data, Type.POSITION, Category.OBJECT_AREA); + + byte[] len = BinaryUtils.convert(32, 2); + data[1] = len[0]; // Length + data[2] = len[1]; + + data[9] = 0x01; // OAPosID = 1 + data[10] = 0x17; // RGLength = 23 + + byte[] xcoord = BinaryUtils.convert(x, 3); + data[11] = xcoord[0]; // XoaOSet + data[12] = xcoord[1]; + data[13] = xcoord[2]; + + byte[] ycoord = BinaryUtils.convert(y, 3); + data[14] = ycoord[0]; // YoaOSet + data[15] = ycoord[1]; + data[16] = ycoord[2]; + + byte xorient = (byte)(rotation / 2); + data[17] = xorient; // XoaOrent + + byte yorient = (byte)(rotation / 2 + 45); + data[19] = yorient; // YoaOrent + + byte[] xoffset = BinaryUtils.convert(xOffset, 3); + data[22] = xoffset[0]; // XocaOSet + data[23] = xoffset[1]; + data[24] = xoffset[2]; + + byte[] yoffset = BinaryUtils.convert(yOffset, 3); + data[25] = yoffset[0]; // YocaOSet + data[26] = yoffset[1]; + data[27] = yoffset[2]; + + data[28] = 0x00; // XocaOrent + data[29] = 0x00; + + data[30] = 0x2D; // YocaOrent + data[31] = 0x00; + + data[32] = 0x01; // RefCSys + + os.write(data); + } + + /** {@inheritDoc} */ + public String toString() { + return "ObjectAreaPosition{" + + "x=" + x + + ", y=" + y + + ", rotation=" + rotation + + ", rotation=" + rotation + + ", xOffset=" + xOffset + + ", yOffset=" + yOffset; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/ObjectContainer.java b/src/java/org/apache/fop/afp/modca/ObjectContainer.java new file mode 100644 index 000000000..791f4da1b --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ObjectContainer.java @@ -0,0 +1,124 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.commons.io.IOUtils; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceLevel; +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.modca.triplets.MappingOptionTriplet; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * Object containers are MO:DCA objects that envelop and carry object data. + */ +public class ObjectContainer extends AbstractDataObject { + + /** the object container data maximum length */ + private static final int MAX_DATA_LEN = 32759; + + private InputStream inputStream; + + /** + * Main constructor + * + * @param factory the object factory + * @param name the name of this object container + */ + public ObjectContainer(Factory factory, String name) { + super(factory, name); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] headerData = new byte[17]; + copySF(headerData, Type.BEGIN, Category.OBJECT_CONTAINER); + + // Set the total record length + int containerLen = headerData.length + getTripletDataLength() - 1; + byte[] len = BinaryUtils.convert(containerLen, 2); + headerData[1] = len[0]; // Length byte 1 + headerData[2] = len[1]; // Length byte 2 + + os.write(headerData); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); // write triplets and OEG + + // write OCDs + byte[] dataHeader = new byte[9]; + copySF(dataHeader, SF_CLASS, Type.DATA, Category.OBJECT_CONTAINER); + final int lengthOffset = 1; + + copyChunks(dataHeader, lengthOffset, MAX_DATA_LEN, inputStream, os); + IOUtils.closeQuietly(inputStream); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.OBJECT_CONTAINER); + os.write(data); + } + + /** {@inheritDoc} */ + public void setViewport(AFPDataObjectInfo dataObjectInfo) { + AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); + AFPResourceLevel resourceLevel = resourceInfo.getLevel(); + + // only need to set MCD and CDD when OC when is inlined (pre-2000 apps) + if (resourceLevel.isInline()) { + super.setViewport(dataObjectInfo); + + MapContainerData mapContainerData + = factory.createMapContainerData(MappingOptionTriplet.SCALE_TO_FIT); + getObjectEnvironmentGroup().setMapContainerData(mapContainerData); + + int dataWidth = dataObjectInfo.getDataWidth(); + int dataHeight = dataObjectInfo.getDataHeight(); + + AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + int widthRes = objectAreaInfo.getWidthRes(); + int heightRes = objectAreaInfo.getHeightRes(); + + ContainerDataDescriptor containerDataDescriptor + = factory.createContainerDataDescriptor( + dataWidth, dataHeight, widthRes, heightRes); + getObjectEnvironmentGroup().setDataDescriptor(containerDataDescriptor); + } + } + + /** + * Sets the inputstream for the the object container data + * + * @param inputStream the inputstream for the object container data + */ + public void setInputStream(InputStream inputStream) { + this.inputStream = inputStream; + } +} diff --git a/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java new file mode 100644 index 000000000..8cb610d9e --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java @@ -0,0 +1,173 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * An Object Environment Group (OEG) may be associated with an object and is contained + * within the object's begin-end envelope. + * The object environment group defines the object's origin and orientation on the page, + * and can contain font and color attribute table information. The scope of an object + * environment group is the scope of its containing object. + * + * An application that creates a data-stream document may omit some of the parameters + * normally contained in the object environment group, or it may specify that one or + * more default values are to be used. + */ +public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { + + /** the PresentationEnvironmentControl for the object environment group */ + private PresentationEnvironmentControl presentationEnvironmentControl = null; + + /** the ObjectAreaDescriptor for the object environment group */ + private ObjectAreaDescriptor objectAreaDescriptor = null; + + /** the ObjectAreaPosition for the object environment group */ + private ObjectAreaPosition objectAreaPosition = null; + + /** the DataDescriptor for the object environment group */ + private AbstractDescriptor dataDescriptor; + + /** the MapDataResource for the object environment group */ + private MapDataResource mapDataResource; + + /** the MapContainerData for the object environment group */ + private MapContainerData mapContainerData; + + /** + * Constructor for the ObjectEnvironmentGroup, this takes a + * name parameter which must be 8 characters long. + * + * @param name the object environment group name + */ + public ObjectEnvironmentGroup(String name) { + super(name); + } + + /** + * Sets the Object Area Descriptor + * + * @param objectAreaDescriptor the object area descriptor + */ + public void setObjectAreaDescriptor(ObjectAreaDescriptor objectAreaDescriptor) { + this.objectAreaDescriptor = objectAreaDescriptor; + } + + /** + * Sets the Object Area Position + * + * @param objectAreaPosition the object area position + */ + public void setObjectAreaPosition(ObjectAreaPosition objectAreaPosition) { + this.objectAreaPosition = objectAreaPosition; + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.OBJECT_ENVIRONMENT_GROUP); + + int tripletDataLength = getTripletDataLength(); + int sfLen = data.length + tripletDataLength - 1; + byte[] len = BinaryUtils.convert(sfLen, 2); + data[1] = len[0]; + data[2] = len[1]; + + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + + if (presentationEnvironmentControl != null) { + presentationEnvironmentControl.writeToStream(os); + } + + if (objectAreaDescriptor != null) { + objectAreaDescriptor.writeToStream(os); + } + + if (objectAreaPosition != null) { + objectAreaPosition.writeToStream(os); + } + + if (mapContainerData != null) { + mapContainerData.writeToStream(os); + } + + if (mapDataResource != null) { + mapDataResource.writeToStream(os); + } + + if (dataDescriptor != null) { + dataDescriptor.writeToStream(os); + } + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.OBJECT_ENVIRONMENT_GROUP); + os.write(data); + } + + /** + * Sets the presentation environment control + * + * @param presentationEnvironmentControl the presentation environment control + */ + public void setPresentationEnvironmentControl( + PresentationEnvironmentControl presentationEnvironmentControl) { + this.presentationEnvironmentControl = presentationEnvironmentControl; + } + + /** + * Sets the data descriptor + * + * @param dataDescriptor the data descriptor + */ + public void setDataDescriptor(AbstractDescriptor dataDescriptor) { + this.dataDescriptor = dataDescriptor; + } + + /** + * Sets the map data resource + * + * @param mapDataResource the map data resource + */ + public void setMapDataResource(MapDataResource mapDataResource) { + this.mapDataResource = mapDataResource; + } + + /** + * Sets the map container data + * + * @param mapContainerData the map container data + */ + public void setMapContainerData(MapContainerData mapContainerData) { + this.mapContainerData = mapContainerData; + } + +} diff --git a/src/java/org/apache/fop/afp/modca/Overlay.java b/src/java/org/apache/fop/afp/modca/Overlay.java new file mode 100644 index 000000000..ea9619b20 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/Overlay.java @@ -0,0 +1,87 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.Factory; + + +/** + * 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. + */ +public class Overlay extends PageObject { + + /** + * Construct a new overlay object for the specified name argument, the overlay + * name should be an 8 character identifier. + * + * @param factory + * the resource manager of the page. + * @param name + * the name of the page. + * @param width + * the width of the page. + * @param height + * the height of the page. + * @param rotation + * the rotation of the page. + * @param widthResolution + * the width resolution of the page. + * @param heightResolution + * the height resolution of the page. + */ + public Overlay(Factory factory, + String name, int width, int height, int rotation, + int widthResolution, int heightResolution) { + super(factory, name, width, height, rotation, widthResolution, heightResolution); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.OVERLAY); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + + getActiveEnvironmentGroup().writeToStream(os); + + writeObjects(includePageSegments, os); + writeObjects(tagLogicalElements, os); + writeObjects(objects, os); + } + + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.OVERLAY); + os.write(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/PageDescriptor.java b/src/java/org/apache/fop/afp/modca/PageDescriptor.java new file mode 100644 index 000000000..502123def --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PageDescriptor.java @@ -0,0 +1,88 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Page Descriptor structured field specifies the size and attributes of + * a page or overlay presentation space. + * + */ +public class PageDescriptor extends AbstractDescriptor { + + /** + * Construct a page descriptor for the specified page width + * and page height. + * + * @param width The page width. + * @param height The page height. + * @param widthRes The page width resolution + * @param heightRes The page height resolution + */ + public PageDescriptor(int width, int height, int widthRes, int heightRes) { + super(width, height, widthRes, heightRes); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[24]; + copySF(data, Type.DESCRIPTOR, Category.PAGE); + data[2] = 0x17; + + // XpgBase + data[9] = 0x00; // XpgBase = 10 inches + + // YpgBase + data[10] = 0x00; // YpgBase = 10 inches + + // XpgUnits + byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); + data[11] = xdpi[0]; + data[12] = xdpi[1]; + + // YpgUnits + 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]; + data[16] = x[1]; + data[17] = x[2]; + + // YpgSize + byte[] y = BinaryUtils.convert(height, 3); + data[18] = y[0]; + data[19] = y[1]; + data[20] = y[2]; + + data[21] = 0x00; // Reserved + data[22] = 0x00; // Reserved + data[23] = 0x00; // Reserved + + os.write(data); + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/PageGroup.java b/src/java/org/apache/fop/afp/modca/PageGroup.java new file mode 100644 index 000000000..47e378d72 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PageGroup.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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +import org.apache.fop.afp.Factory; + +/** + * A page group is used in the data stream to define a named, logical grouping + * of sequential pages. Page groups are delimited by begin-end structured fields + * that carry the name of the page group. Page groups are defined so that the + * pages that comprise the group can be referenced or processed as a single + * entity. Page groups are often processed in stand-alone fashion; that is, they + * are indexed, retrieved, and presented outside the context of the containing + * document. + */ +public class PageGroup extends AbstractResourceEnvironmentGroupContainer { + + /** The tag logical elements contained within this group */ + private List tagLogicalElements = null; + + /** + * Constructor for the PageGroup. + * + * @param factory the resource manager + * @param name the name of the page group + */ + public PageGroup(Factory factory, String name) { + super(factory, name); + } + + private List getTagLogicalElements() { + if (tagLogicalElements == null) { + this.tagLogicalElements = new java.util.ArrayList(); + } + return this.tagLogicalElements; + } + + /** + * Creates a TagLogicalElement on the page. + * + * @param name + * the name of the tag + * @param value + * the value of the tag + */ + public void createTagLogicalElement(String name, String value) { + TagLogicalElement tle = factory.createTagLogicalElement(name, value); + if (!getTagLogicalElements().contains(tle)) { + getTagLogicalElements().add(tle); + } + } + + /** + * Method to mark the end of the page group. + */ + protected void endPageGroup() { + complete = true; + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + writeObjects(tagLogicalElements, os); + super.writeContent(os); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.PAGE_GROUP); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.PAGE_GROUP); + os.write(data); + } + + /** {@inheritDoc} */ + public String toString() { + return this.getName(); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/PageObject.java b/src/java/org/apache/fop/afp/modca/PageObject.java new file mode 100644 index 000000000..33852d90b --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PageObject.java @@ -0,0 +1,219 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.Factory; +import org.apache.fop.afp.ioca.ImageCellPosition; +import org.apache.fop.afp.ioca.ImageInputDescriptor; +import org.apache.fop.afp.ioca.ImageOutputControl; +import org.apache.fop.afp.ioca.ImageRasterData; +import org.apache.fop.afp.ioca.ImageRasterPattern; + +/** + * Pages contain the data objects that comprise a presentation document. Each + * page has a set of data objects associated with it. Each page within a + * document is independent from any other page, and each must establish its own + * environment parameters. + * + * The page is the level in the document component hierarchy that is used for + * printing or displaying a document's content. The data objects contained in + * the page envelope in the data stream are presented when the page is + * presented. Each data object has layout information associated with it that + * directs the placement and orientation of the data on the page. In addition, + * each page contains layout information that specifies the measurement units, + * page width, and page depth. + * + * A page is initiated by a begin page structured field and terminated by an end + * page structured field. Structured fields that define objects and active + * environment groups or that specify attributes of the page may be encountered + * in page state. + * + */ +public class PageObject extends AbstractResourceGroupContainer { + + /** + * Construct a new page object for the specified name argument, the page + * name should be an 8 character identifier. + * + * @param factory the resource manager + * + * @param name + * the name of the page. + * @param width + * the width of the page. + * @param height + * the height of the page. + * @param rotation + * the rotation of the page. + * @param widthRes + * the width resolution of the page. + * @param heightRes + * the height resolution of the page. + */ + public PageObject(Factory factory, + String name, int width, int height, int rotation, + int widthRes, int heightRes) { + super(factory, name, width, height, rotation, widthRes, heightRes); + } + + /** + * Creates an IncludePageOverlay on the page. + * + * @param name + * the name of the overlay + * @param x + * the x position of the overlay + * @param y + * the y position of the overlay + * @param orientation + * the orientation required for the overlay + */ + public void createIncludePageOverlay(String name, int x, int y, int orientation) { + getActiveEnvironmentGroup().createOverlay(name); + IncludePageOverlay ipo = new IncludePageOverlay(name, x, y, orientation); + addObject(ipo); + } + + /** + * This method will create shading on the page using the specified + * coordinates (the shading contrast is controlled via the red, green blue + * parameters, by converting this to grayscale). + * + * @param x + * the x coordinate of the shading + * @param y + * the y coordinate of the shading + * @param w + * the width of the shaded area + * @param h + * the height of the shaded area + * @param red + * the red value + * @param green + * the green value + * @param blue + * the blue value + */ + public void createShading(int x, int y, int w, int h, int red, int green, int blue) { + int xCoord = 0; + int yCoord = 0; + int areaWidth = 0; + int areaHeight = 0; + switch (rotation) { + case 90: + xCoord = areaWidth - y - h; + yCoord = x; + areaWidth = h; + areaHeight = w; + break; + case 180: + xCoord = areaWidth - x - w; + yCoord = areaHeight - y - h; + areaWidth = w; + areaHeight = h; + break; + case 270: + xCoord = y; + yCoord = areaHeight - x - w; + areaWidth = h; + areaHeight = w; + break; + default: + xCoord = x; + yCoord = y; + areaWidth = w; + areaHeight = h; + break; + } + + // Convert the color to grey scale + float shade = (float) ((red * 0.3) + (green * 0.59) + (blue * 0.11)); + + int grayscale = Math.round((shade / 255) * 16); + + IMImageObject imImageObject = factory.createIMImageObject(); + + ImageOutputControl imageOutputControl = new ImageOutputControl(0, 0); + ImageInputDescriptor imageInputDescriptor = new ImageInputDescriptor(); + ImageCellPosition imageCellPosition = new ImageCellPosition(xCoord, yCoord); + imageCellPosition.setXFillSize(areaWidth); + imageCellPosition.setYFillSize(areaHeight); + imageCellPosition.setXSize(64); + imageCellPosition.setYSize(8); + + //defining this as a resource + byte[] rasterData = ImageRasterPattern.getRasterData(grayscale); + ImageRasterData imageRasterData = factory.createImageRasterData(rasterData); + + imImageObject.setImageOutputControl(imageOutputControl); + imImageObject.setImageInputDescriptor(imageInputDescriptor); + imImageObject.setImageCellPosition(imageCellPosition); + imImageObject.setImageRasterData(imageRasterData); + addObject(imImageObject); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.PAGE); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + writeTriplets(os); + + getActiveEnvironmentGroup().writeToStream(os); + + writeObjects(includePageSegments, os); + writeObjects(tagLogicalElements, os); + writeObjects(objects, os); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.PAGE); + os.write(data); + } + + /** + * Adds an AFP object reference to this page + * + * @param obj an AFP object + */ + public void addObject(Object obj) { + endPresentationObject(); + super.addObject(obj); + } + + /** {@inheritDoc} */ + public String toString() { + return this.getName(); + } + + /** {@inheritDoc} */ + protected boolean canWrite(AbstractAFPObject ao) { + return true; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/PageSegment.java b/src/java/org/apache/fop/afp/modca/PageSegment.java new file mode 100644 index 000000000..ab1388efb --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PageSegment.java @@ -0,0 +1,90 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +/** + * A page segment 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. + * Page segments contain any combination of IOCA image objects and + * GOCA graphics objects. + */ +public class PageSegment extends AbstractNamedAFPObject { + + private List/**/ objects = null; + + /** + * Main constructor + * + * @param name the name of this object + */ + public PageSegment(String name) { + super(name); + } + + /** + * Returns a list of objects contained withing this page segment + * + * @return a list of objects contained within this page segment + */ + public List/**/ getObjects() { + if (objects == null) { + objects = new java.util.ArrayList(); + } + return objects; + } + + /** + * Adds a resource object (image/graphic) to this page segment + * + * @param object the resource objec to add to this page segment + */ + public void addObject(AbstractAFPObject object) { + getObjects().add(object); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.PAGE_SEGMENT); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); + writeObjects(objects, os); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.PAGE_SEGMENT); + os.write(data); + } + + /** {@inheritDoc} */ + public String toString() { + return this.name; + } +} diff --git a/src/java/org/apache/fop/afp/modca/PreparedAFPObject.java b/src/java/org/apache/fop/afp/modca/PreparedAFPObject.java new file mode 100644 index 000000000..2771515bf --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PreparedAFPObject.java @@ -0,0 +1,34 @@ +/* + * 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.afp.modca; + +/** + * An AFP object which is able to know its own data length before write() + */ +public interface PreparedAFPObject { + + /** + * Returns the current data length of this container + * + * @return the current data length of this container including + * all enclosed GOCA drawing objects + */ + int getDataLength(); +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java b/src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java new file mode 100644 index 000000000..b1f95e236 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java @@ -0,0 +1,145 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Preprocess Presentation Object structured field specifies presentation + * parameters for a data object that has been mapped as a resource. + */ +public class PreprocessPresentationObject extends AbstractStructuredAFPObject { + private static final byte TYPE_OTHER = (byte)0x92; + private static final byte TYPE_OVERLAY = (byte)0xDF; + private static final byte TYPE_IMAGE = (byte)0xFB; + + private byte objType = TYPE_OTHER; + private byte objOrent = 0; // object always processed at 0 degree orientation + private int objXOffset = -1; + private int objYOffset = -1; + + /** + * Main constructor + * + * @param prePresObj the presentation object to be preprocessed + */ + public PreprocessPresentationObject(AbstractStructuredAFPObject prePresObj) { + if (prePresObj instanceof ImageObject || prePresObj instanceof Overlay) { + if (prePresObj instanceof ImageObject) { + this.objType = TYPE_IMAGE; + } else { + this.objType = TYPE_OVERLAY; + } + setFullyQualifiedName( + FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF, + FullyQualifiedNameTriplet.FORMAT_CHARSTR, + prePresObj.getFullyQualifiedName()); + } else { + this.objType = TYPE_OTHER; + } + } + + public static final byte ORIENTATION_ZERO_DEGREES = 1; + public static final byte ORIENTATION_90_DEGREES = 2; + public static final byte ORIENTATION_180_DEGREES = 4; + public static final byte ORIENTATION_270_DEGREES = 8; + + /** + * Sets the object orientations relative to media leading edge + * + * @param orientation the object orientations relative to media leading edge + */ + public void setOrientation(byte orientation) { + objOrent = (byte)orientation; + } + + /** + * Sets the X axis origin for object content + * + * @param xOffset the X axis origin for object content + */ + public void setXOffset(int xOffset) { + this.objXOffset = xOffset; + } + + /** + * Sets the Y axis origin for object content + * + * @param yOffset the Y axis origin for object content + */ + public void setYOffset(int yOffset) { + this.objYOffset = yOffset; + } + + /** {@inheritDoc} */ + public void writeStart(OutputStream os) throws IOException { + super.writeStart(os); + + byte[] data = new byte[9]; + copySF(data, Type.PROCESS, Category.DATA_RESOURCE); + + byte[] l = BinaryUtils.convert(19 + getTripletDataLength(), 2); + data[1] = l[0]; // Length byte 1 + data[2] = l[1]; // Length byte 1 + + os.write(data); + } + + /** {@inheritDoc} */ + public void writeContent(OutputStream os) throws IOException { + byte[] data = new byte[12]; + byte[] l = BinaryUtils.convert(12 + getTripletDataLength(), 2); + data[0] = l[0]; // RGLength + data[1] = l[1]; // RGLength + data[2] = objType; // ObjType + data[3] = 0x00; // Reserved + data[4] = 0x00; // Reserved + data[5] = objOrent; // ObjOrent + if (objXOffset > 0) { + byte[] xOff = BinaryUtils.convert(objYOffset, 3); + data[6] = xOff[0]; // XocaOset (not specified) + data[7] = xOff[1]; // XocaOset + data[8] = xOff[2]; // XocaOset + } else { + data[6] = (byte)0xFF; // XocaOset (not specified) + data[7] = (byte)0xFF; // XocaOset + data[8] = (byte)0xFF; // XocaOset + } + if (objYOffset > 0) { + byte[] yOff = BinaryUtils.convert(objYOffset, 3); + data[9] = yOff[0]; // YocaOset (not specified) + data[10] = yOff[1]; // YocaOset + data[11] = yOff[2]; // YocaOset + } else { + data[9] = (byte)0xFF; // YocaOset (not specified) + data[10] = (byte)0xFF; // YocaOset + data[11] = (byte)0xFF; // YocaOset + } + os.write(data); + + // Triplets + super.writeContent(os); + } + +} diff --git a/src/java/org/apache/fop/afp/modca/PresentationEnvironmentControl.java b/src/java/org/apache/fop/afp/modca/PresentationEnvironmentControl.java new file mode 100644 index 000000000..49b33c0ef --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PresentationEnvironmentControl.java @@ -0,0 +1,97 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.triplets.Triplet; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Presentation Environment Control structured field specifies parameters that + * affect the rendering of presentation data and the appearance that is to be assumed + * by the presentation device. + */ +public class PresentationEnvironmentControl extends AbstractStructuredAFPObject { + + /** + * Main constructor + */ + public PresentationEnvironmentControl() { + } + + /** + * Sets the object offset + */ + public void setObjectOffset() { + addTriplet(new ObjectOffsetTriplet()); + } + + /** + * Sets the rendering intent + */ + public void setRenderingIntent() { + addTriplet(new RenderingIntentTriplet()); + } + + /** + * Sets the device appearance + */ + public void setDeviceAppearance() { + addTriplet(new DeviceAppearanceTriplet()); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[11]; + copySF(data, Type.CONTROL, Category.DOCUMENT); + int tripletDataLen = getTripletDataLength(); + byte[] len = BinaryUtils.convert(10 + tripletDataLen); + data[1] = len[0]; + data[2] = len[1]; + data[9] = 0x00; // Reserved; must be zero + data[10] = 0x00; // Reserved; must be zero + + os.write(data); + os.write(tripletData); + } + + // TODO + private class DeviceAppearanceTriplet extends Triplet { + public DeviceAppearanceTriplet() { + super(Triplet.DEVICE_APPEARANCE); + } + } + + // TODO + private class RenderingIntentTriplet extends Triplet { + public RenderingIntentTriplet() { + super(Triplet.RENDERING_INTENT); + } + } + + // TODO + private class ObjectOffsetTriplet extends Triplet { + public ObjectOffsetTriplet() { + super(Triplet.OBJECT_OFFSET); + } + } +} diff --git a/src/java/org/apache/fop/afp/modca/PresentationTextData.java b/src/java/org/apache/fop/afp/modca/PresentationTextData.java new file mode 100644 index 000000000..4bc2b914e --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PresentationTextData.java @@ -0,0 +1,569 @@ +/* + * 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.afp.modca; + +import java.awt.Color; +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.fop.afp.AFPLineDataInfo; +import org.apache.fop.afp.AFPTextDataInfo; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * Presentation text data contains the graphic characters and the control + * sequences necessary to position the characters within the object space. The + * data consists of: - graphic characters to be presented - control sequences + * that position them - modal control sequences that adjust the positions by + * small amounts - other functions causing text to be presented with differences + * in appearance. + * + * The graphic characters are expected to conform to a coded font representation + * so that they can be translated from the code point in the object data to the + * character in the coded font. The units of measure for linear displacements + * are derived from the PresentationTextDescriptor or from the hierarchical + * defaults. + * + * In addition to graphic character code points, Presentation Text data can + * contain embedded control sequences. These are strings of two or more bytes + * which signal an alternate mode of processing for the content of the current + * Presentation Text data. + * + */ +public class PresentationTextData extends AbstractAFPObject { + + /** + * The maximum size of the presentation text data. + */ + private static final int MAX_SIZE = 8192; + + /** + * The afp data relating to this presentation text data. + */ + private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + /** + * The current x coordinate. + */ + private int currentX = -1; + + /** + * The current y cooridnate + */ + private int currentY = -1; + + /** + * The current font + */ + private String currentFont = ""; + + /** + * The current orientation + */ + private int currentOrientation = 0; + + /** + * The current color + */ + private Color currentColor = new Color(0, 0, 0); + + /** + * The current variable space increment + */ + private int currentVariableSpaceCharacterIncrement = 0; + + /** + * The current inter character adjustment + */ + private int currentInterCharacterAdjustment = 0; + + /** + * Default constructor for the PresentationTextData. + */ + public PresentationTextData() { + this(false); + } + + /** + * Constructor for the PresentationTextData, the boolean flag indicate + * whether the control sequence prefix should be set to indicate the start + * of a new control sequence. + * + * @param controlInd + * The control sequence indicator. + */ + public PresentationTextData(boolean controlInd) { + final byte[] data = { + 0x5A, // Structured field identifier + 0x00, // Record length byte 1 + 0x00, // Record length byte 2 + (byte) 0xD3, // PresentationTextData identifier byte 1 + (byte) 0xEE, // PresentationTextData identifier byte 2 + (byte) 0x9B, // PresentationTextData identifier byte 3 + 0x00, // Flag + 0x00, // Reserved + 0x00, // Reserved + }; + baos.write(data, 0, 9); + + if (controlInd) { + baos.write(new byte[] {0x2B, (byte) 0xD3}, 0, 2); + } + } + + /** + * The Set Coded Font Local control sequence activates a coded font and + * specifies the character attributes to be used. This is a modal control + * sequence. + * + * @param font + * The font local identifier. + * @param afpdata + * The output stream to which data should be written. + */ + private void setCodedFont(byte font, ByteArrayOutputStream afpdata) { + // Avoid unnecessary specification of the font + if (String.valueOf(font).equals(currentFont)) { + return; + } else { + currentFont = String.valueOf(font); + } + + afpdata.write(new byte[] {0x03, (byte) 0xF1, font}, 0, 3); + } + + /** + * Establishes the current presentation position on the baseline at a new + * I-axis coordinate, which is a specified number of measurement units from + * the B-axis. There is no change to the current B-axis coordinate. + * + * @param coordinate + * The coordinate for the inline move. + * @param afpdata + * The output stream to which data should be written. + */ + private void absoluteMoveInline(int coordinate, + ByteArrayOutputStream afpdata) { + byte[] b = BinaryUtils.convert(coordinate, 2); + afpdata.write(new byte[] {0x04, (byte) 0xC7, b[0], b[1]}, 0, 4); + currentX = coordinate; + } + + /** + * Establishes the baseline and the current presentation position at a new + * B-axis coordinate, which is a specified number of measurement units from + * the I-axis. There is no change to the current I-axis coordinate. + * + * @param coordinate + * The coordinate for the baseline move. + * @param afpdata + * The output stream to which data should be written. + */ + private void absoluteMoveBaseline(int coordinate, + ByteArrayOutputStream afpdata) { + byte[] b = BinaryUtils.convert(coordinate, 2); + afpdata.write(new byte[] {0x04, (byte) 0xD3, b[0], b[1]}, 0, 4); + currentY = coordinate; + } + + private static final int TRANSPARENT_MAX_SIZE = 253; + + /** + * The Transparent Data control sequence contains a sequence of code points + * that are presented without a scan for embedded control sequences. + * + * @param data + * The text data to add. + * @param afpdata + * The output stream to which data should be written. + */ + private void addTransparentData(byte[] data, ByteArrayOutputStream afpdata) { + // Calculate the length + int l = data.length + 2; + if (l > 255) { + // Check that we are not exceeding the maximum length + throw new IllegalArgumentException( + "Transparent data is longer than " + TRANSPARENT_MAX_SIZE + " bytes: " + data); + } + afpdata.write(new byte[] {BinaryUtils.convert(l)[0], (byte) 0xDB}, + 0, 2); + afpdata.write(data, 0, data.length); + } + + /** + * Draws a line of specified length and specified width in the B-direction + * from the current presentation position. The location of the current + * presentation position is unchanged. + * + * @param length + * The length of the rule. + * @param width + * The width of the rule. + * @param afpdata + * The output stream to which data should be written. + */ + private void drawBaxisRule(int length, int width, + ByteArrayOutputStream afpdata) { + afpdata.write(new byte[] { + 0x07, // Length + (byte) 0xE7, // Type + }, 0, 2); + // Rule length + byte[] data1 = BinaryUtils.shortToByteArray((short) length); + afpdata.write(data1, 0, data1.length); + // Rule width + byte[] data2 = BinaryUtils.shortToByteArray((short) width); + afpdata.write(data2, 0, data2.length); + // Rule width fraction + afpdata.write(0x00); + } + + /** + * Draws a line of specified length and specified width in the I-direction + * from the current presentation position. The location of the current + * presentation position is unchanged. + * + * @param length + * The length of the rule. + * @param width + * The width of the rule. + * @param afpdata + * The output stream to which data should be written. + */ + private void drawIaxisRule(int length, int width, + ByteArrayOutputStream afpdata) { + afpdata.write(new byte[] { + 0x07, // Length + (byte) 0xE5, // Type + }, 0, 2); + // Rule length + byte[] data1 = BinaryUtils.shortToByteArray((short) length); + afpdata.write(data1, 0, data1.length); + // Rule width + byte[] data2 = BinaryUtils.shortToByteArray((short) width); + afpdata.write(data2, 0, data2.length); + // Rule width fraction + afpdata.write(0x00); + } + + /** + * Create the presentation text data for the byte array of data. + * + * @param textDataInfo + * the afp text data + * @throws MaximumSizeExceededException + * thrown if the maximum number of text data is exceeded + */ + public void createTextData(AFPTextDataInfo textDataInfo) + throws MaximumSizeExceededException { + + ByteArrayOutputStream afpdata = new ByteArrayOutputStream(); + + int rotation = textDataInfo.getRotation(); + if (currentOrientation != rotation) { + setTextOrientation(rotation, afpdata); + currentOrientation = rotation; + currentX = -1; + currentY = -1; + } + + // Avoid unnecessary specification of the Y coordinate + int y = textDataInfo.getY(); + if (currentY != y) { + absoluteMoveBaseline(y, afpdata); + currentX = -1; + } + + // Avoid unnecessary specification of the X coordinate + int x = textDataInfo.getX(); + if (currentX != x) { + absoluteMoveInline(x, afpdata); + } + + // Avoid unnecessary specification of the variable space increment + if (textDataInfo.getVariableSpaceCharacterIncrement() + != currentVariableSpaceCharacterIncrement) { + setVariableSpaceCharacterIncrement(textDataInfo + .getVariableSpaceCharacterIncrement(), afpdata); + currentVariableSpaceCharacterIncrement = textDataInfo + .getVariableSpaceCharacterIncrement(); + } + + // Avoid unnecessary specification of the inter character adjustment + if (textDataInfo.getInterCharacterAdjustment() != currentInterCharacterAdjustment) { + setInterCharacterAdjustment(textDataInfo.getInterCharacterAdjustment(), + afpdata); + currentInterCharacterAdjustment = textDataInfo + .getInterCharacterAdjustment(); + } + + // Avoid unnecessary specification of the text color + if (!textDataInfo.getColor().equals(currentColor)) { + setExtendedTextColor(textDataInfo.getColor(), afpdata); + currentColor = textDataInfo.getColor(); + } + + setCodedFont(BinaryUtils.convert(textDataInfo.getFontReference())[0], + afpdata); + + // Add transparent data + byte[] data = textDataInfo.getData(); + if (data.length <= TRANSPARENT_MAX_SIZE) { + addTransparentData(data, afpdata); + } else { + // data size greater than TRANSPARENT_MAX_SIZE so slice + int numTransData = data.length / TRANSPARENT_MAX_SIZE; + byte[] buff = new byte[TRANSPARENT_MAX_SIZE]; + int currIndex = 0; + for (int transDataCnt = 0; transDataCnt < numTransData; transDataCnt++) { + currIndex = transDataCnt * TRANSPARENT_MAX_SIZE; + System.arraycopy(data, currIndex, buff, 0, TRANSPARENT_MAX_SIZE); + addTransparentData(buff, afpdata); + } + int remainingTransData = data.length / TRANSPARENT_MAX_SIZE; + buff = new byte[remainingTransData]; + System.arraycopy(data, currIndex, buff, 0, remainingTransData); + addTransparentData(buff, afpdata); + } + currentX = -1; + + int dataSize = afpdata.size(); + + if (baos.size() + dataSize > MAX_SIZE) { + currentX = -1; + currentY = -1; + throw new MaximumSizeExceededException(); + } + + byte[] outputdata = afpdata.toByteArray(); + baos.write(outputdata, 0, outputdata.length); + } + + private int ensurePositive(int value) { + if (value < 0) { + return 0; + } + return value; + } + + /** + * Drawing of lines using the starting and ending coordinates, thickness and + * colour arguments. + * + * @param lineDataInfo the line data information. + * @throws MaximumSizeExceededException + * thrown if the maximum number of line data has been exceeded + */ + public void createLineData(AFPLineDataInfo lineDataInfo) throws MaximumSizeExceededException { + + ByteArrayOutputStream afpdata = new ByteArrayOutputStream(); + + int orientation = lineDataInfo.getRotation(); + if (currentOrientation != orientation) { + setTextOrientation(orientation, afpdata); + currentOrientation = orientation; + } + + // Avoid unnecessary specification of the Y coordinate + int y1 = ensurePositive(lineDataInfo.getY1()); + if (y1 != currentY) { + absoluteMoveBaseline(y1, afpdata); + } + + // Avoid unnecessary specification of the X coordinate + int x1 = ensurePositive(lineDataInfo.getX1()); + if (x1 != currentX) { + absoluteMoveInline(x1, afpdata); + } + + Color color = lineDataInfo.getColor(); + if (!color.equals(currentColor)) { + setExtendedTextColor(color, afpdata); + currentColor = color; + } + + int x2 = ensurePositive(lineDataInfo.getX2()); + int y2 = ensurePositive(lineDataInfo.getY2()); + int thickness = lineDataInfo.getThickness(); + if (y1 == y2) { + drawIaxisRule(x2 - x1, thickness, afpdata); + } else if (x1 == x2) { + drawBaxisRule(y2 - y1, thickness, afpdata); + } else { + log.error("Invalid axis rule unable to draw line"); + return; + } + + int dataSize = afpdata.size(); + + if (baos.size() + dataSize > MAX_SIZE) { + currentX = -1; + currentY = -1; + throw new MaximumSizeExceededException(); + } + + byte[] outputdata = afpdata.toByteArray(); + baos.write(outputdata, 0, outputdata.length); + } + + /** + * The Set Text Orientation control sequence establishes the I-direction and + * B-direction for the subsequent text. This is a modal control sequence. + * + * Semantics: This control sequence specifies the I-axis and B-axis + * orientations with respect to the Xp-axis for the current Presentation + * Text object. The orientations are rotational values expressed in degrees + * and minutes. + * + * @param orientation + * The text orientation (0, 90, 180, 270). + * @param os + * The output stream to which data should be written. + */ + private void setTextOrientation(int orientation, + ByteArrayOutputStream os) { + os.write(new byte[] {0x06, (byte) 0xF7, }, 0, 2); + switch (orientation) { + case 90: + os.write(0x2D); + os.write(0x00); + os.write(0x5A); + os.write(0x00); + break; + case 180: + os.write(0x5A); + os.write(0x00); + os.write(0x87); + os.write(0x00); + break; + case 270: + os.write(0x87); + os.write(0x00); + os.write(0x00); + os.write(0x00); + break; + default: + os.write(0x00); + os.write(0x00); + os.write(0x2D); + os.write(0x00); + break; + } + } + + /** + * The Set Extended Text Color control sequence specifies a color value and + * defines the color space and encoding for that value. The specified color + * value is applied to foreground areas of the text presentation space. This + * is a modal control sequence. + * + * @param col + * The color to be set. + * @param os + * The output stream to which data should be written. + */ + private void setExtendedTextColor(Color col, ByteArrayOutputStream os) { + byte[] colorData = new byte[] { + 15, // Control sequence length + (byte) 0x81, // Control sequence function type + 0x00, // Reserved; must be zero + 0x01, // Color space - 0x01 = RGB + 0x00, // Reserved; must be zero + 0x00, // Reserved; must be zero + 0x00, // Reserved; must be zero + 0x00, // Reserved; must be zero + 8, // Number of bits in component 1 + 8, // Number of bits in component 2 + 8, // Number of bits in component 3 + 0, // Number of bits in component 4 + (byte) (col.getRed()), // Red intensity + (byte) (col.getGreen()), // Green intensity + (byte) (col.getBlue()), // Blue intensity + }; + + os.write(colorData, 0, colorData.length); + } + + /** + * //TODO This is a modal control sequence. + * + * @param incr + * The increment to be set. + * @param os + * The output stream to which data should be written. + */ + private void setVariableSpaceCharacterIncrement(int incr, + ByteArrayOutputStream os) { + byte[] b = BinaryUtils.convert(incr, 2); + + os.write(new byte[] { + 4, // Control sequence length + (byte) 0xC5, // Control sequence function type + b[0], b[1] }, + 0, 4); + } + + /** + * //TODO This is a modal control sequence. + * + * @param incr + * The increment to be set. + * @param os + * The output stream to which data should be written. + */ + private void setInterCharacterAdjustment(int incr, ByteArrayOutputStream os) { + byte[] b = BinaryUtils.convert(Math.abs(incr), 2); + os.write(new byte[] { + 5, // Control sequence length + (byte) 0xC3, // Control sequence function type + b[0], b[1], (byte) (incr >= 0 ? 0 : 1) // Direction + }, 0, 5); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = baos.toByteArray(); + byte[] size = BinaryUtils.convert(data.length - 1, 2); + data[1] = size[0]; + data[2] = size[1]; + os.write(data); + } + + /** + * A control sequence is a sequence of bytes that specifies a control + * function. A control sequence consists of a control sequence introducer + * and zero or more parameters. The control sequence can extend multiple + * presentation text data objects, but must eventually be terminated. This + * method terminates the control sequence. + * + * @throws MaximumSizeExceededException + * thrown in the event that maximum size has been exceeded + */ + public void endControlSequence() throws MaximumSizeExceededException { + byte[] data = new byte[2]; + data[0] = 0x02; + data[1] = (byte) 0xF8; + if (data.length + baos.size() > MAX_SIZE) { + throw new MaximumSizeExceededException(); + } + baos.write(data, 0, data.length); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/PresentationTextDescriptor.java b/src/java/org/apache/fop/afp/modca/PresentationTextDescriptor.java new file mode 100644 index 000000000..ef2696da8 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PresentationTextDescriptor.java @@ -0,0 +1,101 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Presentation Text Descriptor specifies the units of measure for the + * Presentation Text object space, the size of the Presentation Text object + * space, and the initial values for modal parameters, called initial text + * conditions. Initial values not provided are defaulted by the controlling + * environment or the receiving device. + * + * The Presentation Text Descriptor provides the following initial values: + * - Unit base + * - Xp-units per unit base + * - Yp-units per unit base + * - Xp-extent of the presentation space + * - Yp-extent of the presentation space + * - Initial text conditions. + * + * The initial text conditions are values provided by the Presentation Text + * Descriptor to initialize the modal parameters of the control sequences. + * Modal control sequences typically are characterized by the word set in + * the name of the control sequence. Modal parameters are identified as such + * in their semantic descriptions. + * + */ +public class PresentationTextDescriptor extends AbstractDescriptor { + + /** + * Constructor a PresentationTextDescriptor for the specified + * width and height. + * + * @param width The width of the page. + * @param height The height of the page. + * @param widthRes The width resolution of the page. + * @param heightRes The height resolution of the page. + */ + public PresentationTextDescriptor(int width, int height, + int widthRes, int heightRes) { + super(width, height, widthRes, heightRes); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[23]; + + copySF(data, Type.MIGRATION, Category.PRESENTATION_TEXT); + + data[1] = 0x00; // length + data[2] = 0x16; + + data[9] = 0x00; + data[10] = 0x00; + + byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); + data[11] = xdpi[0]; // xdpi + data[12] = xdpi[1]; + + byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2); + data[13] = ydpi[0]; // ydpi + data[14] = ydpi[1]; + + byte[] x = BinaryUtils.convert(width, 3); + data[15] = x[0]; + data[16] = x[1]; + data[17] = x[2]; + + byte[] y = BinaryUtils.convert(height, 3); + data[18] = y[0]; + data[19] = y[1]; + data[20] = y[2]; + + data[21] = 0x00; + data[22] = 0x00; + + os.write(data); + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/PresentationTextObject.java b/src/java/org/apache/fop/afp/modca/PresentationTextObject.java new file mode 100644 index 000000000..070a33a84 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/PresentationTextObject.java @@ -0,0 +1,169 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +import org.apache.fop.afp.AFPLineDataInfo; +import org.apache.fop.afp.AFPTextDataInfo; + +/** + * The Presentation Text object is the data object used in document processing + * environments for representing text which has been prepared for presentation. + * Text, as used here, means an ordered string of characters, such as graphic + * symbols, numbers, and letters, that are suitable for the specific purpose of + * representing coherent information. Text which has been prepared for + * presentation has been reduced to a primitive form through explicit + * specification of the characters and their placement in the presentation + * space. Control sequences which designate specific control functions may be + * embedded within the text. These functions extend the primitive form by + * applying specific characteristics to the text when it is presented. The + * collection of the graphic characters and control codes is called Presentation + * Text, and the object that contains the Presentation Text is called the + * PresentationText object. + */ +public class PresentationTextObject extends AbstractNamedAFPObject { + + /** + * The current presentation text data + */ + private PresentationTextData currentPresentationTextData = null; + + /** + * The presentation text data list + */ + private List/**/ presentationTextDataList = null; + + /** + * Construct a new PresentationTextObject for the specified name argument, + * the name should be an 8 character identifier. + * + * @param name the name of this presentation object + */ + public PresentationTextObject(String name) { + super(name); + } + + /** + * Create the presentation text data for the byte array of data. + * + * @param textDataInfo + * The afp text data + */ + public void createTextData(AFPTextDataInfo textDataInfo) { + if (currentPresentationTextData == null) { + startPresentationTextData(); + } + try { + currentPresentationTextData.createTextData(textDataInfo); + } catch (MaximumSizeExceededException msee) { + endPresentationTextData(); + createTextData(textDataInfo); + } + } + + /** + * Drawing of lines using the starting and ending coordinates, thickness and + * orientation arguments. + * + * @param lineDataInfo the line data information. + */ + public void createLineData(AFPLineDataInfo lineDataInfo) { + if (currentPresentationTextData == null) { + startPresentationTextData(); + } + try { + currentPresentationTextData.createLineData(lineDataInfo); + } catch (MaximumSizeExceededException msee) { + endPresentationTextData(); + createLineData(lineDataInfo); + } + } + + /** + * Helper method to mark the start of the presentation text data + */ + private void startPresentationTextData() { + if (presentationTextDataList == null) { + presentationTextDataList = new java.util.ArrayList/**/(); + } + if (presentationTextDataList.size() == 0) { + currentPresentationTextData = new PresentationTextData(true); + } else { + currentPresentationTextData = new PresentationTextData(); + } + presentationTextDataList.add(currentPresentationTextData); + } + + /** + * Helper method to mark the end of the presentation text data + */ + private void endPresentationTextData() { + this.currentPresentationTextData = null; + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.PRESENTATION_TEXT); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + writeObjects(this.presentationTextDataList, os); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.PRESENTATION_TEXT); + os.write(data); + } + + /** + * A control sequence is a sequence of bytes that specifies a control + * function. A control sequence consists of a control sequence introducer + * and zero or more parameters. The control sequence can extend multiple + * presentation text data objects, but must eventually be terminated. This + * method terminates the control sequence. + */ + public void endControlSequence() { + if (currentPresentationTextData == null) { + startPresentationTextData(); + } + try { + currentPresentationTextData.endControlSequence(); + } catch (MaximumSizeExceededException msee) { + endPresentationTextData(); + endControlSequence(); + } + } + + /** {@inheritDoc} */ + public String toString() { + if (presentationTextDataList != null) { + return presentationTextDataList.toString(); + } + return null; + } +} diff --git a/src/java/org/apache/fop/afp/modca/Registry.java b/src/java/org/apache/fop/afp/modca/Registry.java new file mode 100644 index 000000000..23c72cd39 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/Registry.java @@ -0,0 +1,254 @@ +/* + * 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.afp.modca; + +import java.util.Collections; + +import org.apache.xmlgraphics.util.MimeConstants; + +/** + * MOD:CA Registry of object types + */ +public final class Registry { + /** IOB supported object types */ + private static final byte COMPID_IOCA_FS10 = 5; + private static final byte COMPID_IOCA_FS11 = 11; + private static final byte COMPID_IOCA_FS45 = 12; + private static final byte COMPID_EPS = 13; + private static final byte COMPID_TIFF = 14; + private static final byte COMPID_GIF = 22; + private static final byte COMPID_JFIF = 23; // jpeg file interchange format + private static final byte COMPID_PDF_SINGLE_PAGE = 25; + private static final byte COMPID_PCL_PAGE_OBJECT = 34; + + /** mime type entry mapping */ + private final java.util.Map/**/ mimeObjectTypeMap + = Collections.synchronizedMap( + new java.util.HashMap/**/()); + + /** singleton instance */ + private static Registry instance = null; + + /** + * Returns a single instance of a MO:DCA Registry + * + * @return a single instance of an MO:DCA Registry + */ + public static Registry getInstance() { + synchronized (Registry.class) { + if (instance == null) { + instance = new Registry(); + } + } + return instance; + } + + /** + * private constructor + */ + private Registry() { + init(); + } + + /** + * Initializes the mimetype map + */ + private void init() { + mimeObjectTypeMap.put( + MimeConstants.MIME_AFP_IOCA_FS10, + new ObjectType( + COMPID_IOCA_FS10, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x05}, + "IOCA FS10", + true, + MimeConstants.MIME_AFP_IOCA_FS10 + ) + ); + mimeObjectTypeMap.put( + MimeConstants.MIME_AFP_IOCA_FS11, + new ObjectType( + COMPID_IOCA_FS11, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x11}, + "IOCA FS11", + true, + MimeConstants.MIME_AFP_IOCA_FS11 + ) + ); + mimeObjectTypeMap.put( + MimeConstants.MIME_AFP_IOCA_FS45, + new ObjectType( + COMPID_IOCA_FS45, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x12}, + "IOCA FS45", + true, + MimeConstants.MIME_AFP_IOCA_FS45 + ) + ); + mimeObjectTypeMap.put( + MimeConstants.MIME_EPS, + new ObjectType( + COMPID_EPS, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0D}, + "Encapsulated Postscript", + true, + MimeConstants.MIME_EPS + ) + ); + mimeObjectTypeMap.put( + MimeConstants.MIME_TIFF, + new ObjectType( + COMPID_TIFF, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0E}, + "TIFF", + true, + MimeConstants.MIME_TIFF + ) + ); + mimeObjectTypeMap.put( + MimeConstants.MIME_GIF, + new ObjectType( + COMPID_GIF, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x16}, + "GIF", + true, + MimeConstants.MIME_GIF + ) + ); + mimeObjectTypeMap.put( + MimeConstants.MIME_JPEG, + new ObjectType( + COMPID_JFIF, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x17}, + "JFIF", + true, + MimeConstants.MIME_JPEG + ) + ); + mimeObjectTypeMap.put(MimeConstants.MIME_PDF, + new ObjectType( + COMPID_PDF_SINGLE_PAGE, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x19}, + "PDF Single-page Object", + true, + MimeConstants.MIME_PDF + ) + ); + mimeObjectTypeMap.put( + MimeConstants.MIME_PCL, + new ObjectType( + COMPID_PCL_PAGE_OBJECT, + new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x22}, + "PCL Page Object", + true, + MimeConstants.MIME_PCL + ) + ); + } + + /** + * Returns the MOD:CA object type given a mimetype + * + * @param mimeType the object mimetype + * @return the MOD:CA object type + */ + public ObjectType getObjectType(String mimeType) { + return (ObjectType)mimeObjectTypeMap.get(mimeType); + } + + /** + * Encapsulates a MOD:CA Registry Object Type entry + */ + public class ObjectType { + private final byte componentId; + private final byte[] oid; + private final String name; + private final boolean includable; + private final String mimeType; + + /** + * Main constructor + * + * @param componentId the component id of this object type + * @param oid the object id of this object type + * @param name the object type name + * @param includable true if this object can be included with an IOB structured field + * @param mimeType the mime type associated with this object type + */ + public ObjectType(byte componentId, byte[] oid, String name, + boolean includable, String mimeType) { + this.name = name; + this.includable = includable; + this.mimeType = mimeType; + this.componentId = componentId; + this.oid = oid; + } + + /** + * Returns a MOD:CA object type OID from a given a componentId + * + * @return the corresponding object type id for a given component id + * or null if the component id is unknown and the object type OID was not found. + */ + public byte[] getOID() { + return this.oid; + } + + /** + * Returns the object type name for the given componentId + * + * @return the object type name for the given componentId + */ + public String getName() { + return this.name; + } + + /** + * Returns the compontentId for this entry + * + * @return the compontentId for this entry + */ + public byte getComponentId() { + return this.componentId; + } + + /** + * Returns true if this component can be included with an IOB structured field + * + * @return true if this component can be included with an IOB structured field + */ + public boolean isIncludable() { + return this.includable; + } + + /** + * Returns the mime type associated with this object type + * + * @return the mime type associated with this object type + */ + public String getMimeType() { + return this.mimeType; + } + + /** {@inheritDoc} */ + public String toString() { + return this.getName(); + } + } +} diff --git a/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java new file mode 100644 index 000000000..cb0653ddd --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java @@ -0,0 +1,134 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +/** + * A Resource Environment Group contains a set of resources for a document + * or for a group of pages in a document. + */ +public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup { + /** + * Default name for the resource group + */ + private static final String DEFAULT_NAME = "REG00001"; + + /** + * The maps data resources contained in this resource environment group + */ + private List/**/ mapDataResources = null; + + /** + * The maps page overlays contained in this resource environment group + */ + private List mapPageOverlays = null; + + /** + * The pre-process presentation objects contained in this resource environment group + */ + private List/**/ preProcessPresentationObjects = null; + + /** + * The resource environment group state + */ + private boolean complete = false; + + /** + * Default constructor + */ + public ResourceEnvironmentGroup() { + this(DEFAULT_NAME); + } + + private List/**/ getMapDataResources() { + if (mapDataResources == null) { + this.mapDataResources = new java.util.ArrayList/**/(); + } + return this.mapDataResources; + } + + private List getMapPageOverlays() { + if (mapPageOverlays == null) { + this.mapPageOverlays = new java.util.ArrayList(); + } + return this.mapPageOverlays; + } + + private List/**/ getPreprocessPresentationObjects() { + if (preProcessPresentationObjects == null) { + this.preProcessPresentationObjects + = new java.util.ArrayList/**/(); + } + return this.preProcessPresentationObjects; + } + + /** + * Constructor for the ResourceEnvironmentGroup, this takes a + * name parameter which must be 8 characters long. + * @param name the resource environment group name + */ + public ResourceEnvironmentGroup(String name) { + super(name); + } + +// /** +// * Adds an AFP object mapping reference to this resource environment group +// * @param obj the object to add +// */ +// public void addObject(AbstractStructuredAFPObject obj) { +// getMapDataResources().add(new MapDataResource(obj)); +// createOverlay(obj.get); +// getPreprocessPresentationObjects().add(new PreprocessPresentationObject(obj)); +// } + + /** + * Returns an indication if the resource environment group is complete + * + * @return whether or not this resource environment group is complete or not + */ + public boolean isComplete() { + return complete; + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.RESOURCE_ENVIROMENT_GROUP); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.RESOURCE_ENVIROMENT_GROUP); + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + writeObjects(mapDataResources, os); + writeObjects(mapPageOverlays, os); + writeObjects(preProcessPresentationObjects, os); + } + +} diff --git a/src/java/org/apache/fop/afp/modca/ResourceGroup.java b/src/java/org/apache/fop/afp/modca/ResourceGroup.java new file mode 100644 index 000000000..2218998a0 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ResourceGroup.java @@ -0,0 +1,107 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.Set; + +import org.apache.fop.afp.Streamable; + +/** + * A Resource Group contains a set of overlays. + */ +public class ResourceGroup extends AbstractNamedAFPObject { + + /** Set of resource uri */ + private final Set/**/ resourceSet = new java.util.HashSet/**/(); + + /** + * Constructor for the ResourceGroup, this takes a + * name parameter which must be 8 characters long. + * + * @param name the resource group name + */ + public ResourceGroup(String name) { + super(name); + } + + /** + * Add this named object to this resource group + * + * @param namedObject a named object + * @throws IOException thrown if an I/O exception of some sort has occurred. + */ + public void addObject(AbstractNamedAFPObject namedObject) throws IOException { + resourceSet.add(namedObject); + } + + /** + * Returns the number of resources contained in this resource group + * + * @return the number of resources contained in this resource group + */ + public int getResourceCount() { + return resourceSet.size(); + } + + /** + * Returns true if the resource exists within this resource group, + * false otherwise. + * + * @param uri the uri of the resource + * @return true if the resource exists within this resource group + */ + public boolean resourceExists(String uri) { + return resourceSet.contains(uri); + } + + /** {@inheritDoc} */ + public void writeStart(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.RESOURCE_GROUP); + os.write(data); + } + + /** {@inheritDoc} */ + public void writeContent(OutputStream os) throws IOException { + Iterator it = resourceSet.iterator(); + while (it.hasNext()) { + Object object = it.next(); + if (object instanceof Streamable) { + Streamable streamableObject = (Streamable)object; + streamableObject.writeToStream(os); + } + } + } + + /** {@inheritDoc} */ + public void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.RESOURCE_GROUP); + os.write(data); + } + + /** {@inheritDoc} */ + public String toString() { + return this.name + " " + resourceSet/*getResourceMap()*/; + } +} diff --git a/src/java/org/apache/fop/afp/modca/ResourceObject.java b/src/java/org/apache/fop/afp/modca/ResourceObject.java new file mode 100644 index 000000000..a5b551e07 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/ResourceObject.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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.fop.afp.modca.triplets.Triplet; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * This resource structured field begins an envelope that is used to carry + * resource objects in print-file-level (external) resource groups. + */ +public class ResourceObject extends AbstractPreparedAFPObject { + + private AbstractNamedAFPObject namedObject; + + /** + * Default constructor + * + * @param name the name of this resource (reference id) + */ + public ResourceObject(String name) { + super(name); + } + + /** + * Sets the data object referenced by this resource object + * + * @param obj the named data object + */ + public void setDataObject(AbstractNamedAFPObject obj) { + this.namedObject = obj; + } + + /** + * Returns the data object referenced by this resource object + * + * @return the data object referenced by this resource object + */ + public AbstractNamedAFPObject getDataObject() { + return namedObject; + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + super.writeStart(os); + + byte[] data = new byte[19]; + copySF(data, Type.BEGIN, Category.NAME_RESOURCE); + + // Set the total record length + int tripletDataLength = getTripletDataLength(); + byte[] len = BinaryUtils.convert(18 + tripletDataLength, 2); + data[1] = len[0]; // Length byte 1 + data[2] = len[1]; // Length byte 2 + + // Set reserved bits + data[17] = 0x00; // Reserved + data[18] = 0x00; // Reserved + + os.write(data); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + super.writeContent(os); // write triplets + if (namedObject != null) { + namedObject.writeToStream(os); + } + } + + /** {@inheritDoc} */ + protected void writeEnd(OutputStream os) throws IOException { + byte[] data = new byte[17]; + copySF(data, Type.END, Category.NAME_RESOURCE); + os.write(data); + } + + /** {@inheritDoc} */ + public String toString() { + return this.getName(); + } + + /** + * Sets Resource Object Type triplet + * + * @param type the resource object type + */ + public void setType(byte type) { + getTriplets().add(new ResourceObjectTypeTriplet(type)); + } + + /** graphics object type */ + public static final byte TYPE_GRAPHIC = 0x03; + + /** barcode object type */ + public static final byte TYPE_BARCODE = 0x05; + + /** image object type */ + public static final byte TYPE_IMAGE = 0x06; + + /** font character set type */ + public static final byte TYPE_FONT_CHARACTER_SET = 0x40; + + /** code page type */ + public static final byte TYPE_CODE_PAGE = 0x41; + + /** coded font type */ + public static final byte TYPE_CODED_FONT = 0x42; + + /** object container type */ + public static final byte TYPE_OBJECT_CONTAINER = (byte) 0x92; + + /** document object type */ + public static final byte TYPE_DOCUMENT = (byte) 0xA8; + + /** page segment object type */ + public static final byte TYPE_PAGE_SEGMENT = (byte) 0xFB; + + /** overlay object type */ + public static final byte TYPE_OVERLAY_OBJECT = (byte) 0xFC; + + /** page def type */ + public static final byte TYPE_PAGEDEF = (byte) 0xFD; + + /** form def type */ + public static final byte TYPE_FORMDEF = (byte) 0xFE; + + + /** resource object type triplet */ + private class ResourceObjectTypeTriplet extends Triplet { + + private static final byte RESOURCE_OBJECT = 0x21; + + /** + * Main constructor + * + * @param objectType the resource object type + */ + public ResourceObjectTypeTriplet(byte objectType) { + super(RESOURCE_OBJECT, + new byte[] { + objectType, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Constant Data + } + ); + } + } +} diff --git a/src/java/org/apache/fop/afp/modca/StreamedResourceGroup.java b/src/java/org/apache/fop/afp/modca/StreamedResourceGroup.java new file mode 100644 index 000000000..d6ab741b6 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/StreamedResourceGroup.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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * A print-file resource group + */ +public class StreamedResourceGroup extends ResourceGroup { + /** the outputstream to write to */ + private final OutputStream os; + + private boolean started = false; + + private boolean complete = false; + + /** + * Main constructor + * + * @param name the resource group name + * @param os the outputstream + */ + public StreamedResourceGroup(String name, OutputStream os) { + super(name); + this.os = os; + } + + /** + * Adds a resource to the external resource group + * + * @param namedObject a named object + * @throws IOException thrown if an I/O exception of some sort has occurred. + */ + public void addObject(AbstractNamedAFPObject namedObject) throws IOException { + if (!started) { + writeStart(os); + started = true; + } + try { + namedObject.writeToStream(os); + } finally { + os.flush(); + } + } + + /** + * Closes this external resource group file + * + * @throws IOException thrown if an I/O exception of some sort has occurred. + */ + public void close() throws IOException { + writeEnd(os); + complete = true; + } + + /** + * Returns true if this resource group is complete + * + * @return true if this resource group is complete + */ + public boolean isComplete() { + return this.complete; + } + + /** + * Returns the outputstream + * + * @return the outputstream + */ + public OutputStream getOutputStream() { + return this.os; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/TagLogicalElement.java b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java new file mode 100644 index 000000000..2e1fa5e07 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/TagLogicalElement.java @@ -0,0 +1,130 @@ +/* + * 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.afp.modca; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; + +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.util.BinaryUtils; + +/** + * A Tag Logical Element structured field assigns an attribute name and an + * attribute value to a page or page group. The Tag Logical Element structured + * field may be embedded directly in the page or page group, or it may reference + * the page or page group from a document index. When a Tag Logical Element + * structured field references a page or is embedded in a page following the + * active environment group, it is associated with the page. When a Tag Logical + * Element structured field references a page group or is embedded in a page + * group following the Begin Named Page Group structured field, it is associated + * with the page group. When a Tag Logical Element structured field is associated + * with a page group, the parameters of the Tag Logical Element structured field + * are inherited by all pages in the page group and by all other page groups + * that are nested in the page group. The scope of a Tag Logical Element is + * determined by its position with respect to other TLEs that reference, or are + * embedded in, the same page or page group. The Tag Logical Element structured + * field does not provide any presentation specifications and therefore has no + * effect on the appearance of a document when it is presented. + *

      + */ +public class TagLogicalElement extends AbstractAFPObject { + + /** + * Name of the key, used within the TLE + */ + private String name = null; + + /** + * Value returned by the key + */ + private String value = null; + + /** + * Construct a tag logical element with the name and value specified. + * + * @param name the name of the tag logical element + * @param value the value of the tag logical element + */ + public TagLogicalElement(String name, String value) { + this.name = name; + this.value = value; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + + byte[] data = new byte[17 + name.length() + value.length()]; + + data[0] = 0x5A; + // Set the total record length + byte[] rl1 + = BinaryUtils.convert(16 + name.length() + value.length(), 2); + //Ignore first byte + data[1] = rl1[0]; + data[2] = rl1[1]; + + // Structured field ID for a TLE + data[3] = (byte) 0xD3; + data[4] = (byte) Type.ATTRIBUTE; + data[5] = (byte) Category.PROCESS_ELEMENT; + + data[6] = 0x00; // Reserved + data[7] = 0x00; // Reserved + data[8] = 0x00; // Reserved + + //Use 2 triplets, attrubute name and value (the key for indexing) + + byte[] rl2 = BinaryUtils.convert(name.length() + 4, 1); + data[9] = rl2[0]; // length of the triplet, including this field + data[10] = 0x02; //Identifies it as a FQN triplet + data[11] = 0x0B; // GID format + data[12] = 0x00; + + byte[] tleByteName = null; + byte[] tleByteValue = null; + try { + tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING); + tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING); + } catch (UnsupportedEncodingException usee) { + tleByteName = name.getBytes(); + tleByteValue = value.getBytes(); + log.warn( + "Constructor:: UnsupportedEncodingException translating the name " + + name); + } + + int pos = 13; + for (int i = 0; i < tleByteName.length; i++) { + data[pos++] = tleByteName[i]; + } + + byte[] rl3 = BinaryUtils.convert(tleByteValue.length + 4, 1); + data[pos++] = rl3[0]; // length of the triplet, including this field + data[pos++] = 0x36; //Identifies the triplet, attribute value + data[pos++] = 0x00; // Reserved + data[pos++] = 0x00; // Reserved + + for (int i = 0; i < tleByteValue.length; i++) { + data[pos++] = tleByteValue[i]; + } + os.write(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java b/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.java new file mode 100644 index 000000000..5d4523777 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/TagLogicalElementBean.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.afp.modca; + +/** + * The TagLogicalElementBean provides a bean for holding the attributes of + * a tag logical element as key value pairs. + *

      + */ +public class TagLogicalElementBean { + + /** The key attribute */ + private String key; + + /** The value attribute */ + private String value; + + /** + * Constructor for the TagLogicalElementBean. + * + * @param key the key attribute + * @param value the value attribute + */ + public TagLogicalElementBean(String key, String value) { + this.key = key; + this.value = value; + } + + /** + * Getter for the key attribute. + * + * @return the key + */ + public String getKey() { + return key; + } + + /** + * Getter for the value attribute. + * + * @return the value + */ + public String getValue() { + return value; + } + +} diff --git a/src/java/org/apache/fop/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java new file mode 100644 index 000000000..a6059d3ec --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java @@ -0,0 +1,55 @@ +/* + * 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.afp.modca.triplets; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Extended Resource Local Identifier triplet specifies a resource type and a + * four byte local identifier or LID. The LID usually is associated with a specific + * resource name by a map structured field, such as a Map Data Resource structured + * field, or a Map Media Type structured field. + */ +public class ExtendedResourceLocalIdentifierTriplet extends Triplet { + + /** the image resource type */ + public static final byte TYPE_IMAGE_RESOURCE = 0x10; + + /** the retired value type */ + public static final byte TYPE_RETIRED_VALUE = 0x30; + + /** the retired value type */ + public static final byte TYPE_MEDIA_RESOURCE = 0x40; + + /** + * Main constructor + * + * @param type the resource type + * @param localId the resource local id + */ + public ExtendedResourceLocalIdentifierTriplet(byte type, int localId) { + super(Triplet.EXTENDED_RESOURCE_LOCAL_IDENTIFIER); + byte[] data = new byte[5]; + data[0] = type; + byte[] resLID = BinaryUtils.convert(localId, 4); + System.arraycopy(resLID, 0, data, 1, resLID.length); + super.setData(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/triplets/FullyQualifiedNameTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/FullyQualifiedNameTriplet.java new file mode 100644 index 000000000..a949124c8 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/FullyQualifiedNameTriplet.java @@ -0,0 +1,191 @@ +/* + * 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.afp.modca.triplets; + +import java.io.UnsupportedEncodingException; + +import org.apache.fop.afp.AFPConstants; + +/** + * A Fully Qualified Name triplet enable the identification and referencing of + * objects using Gloabl Identifiers (GIDs). + */ +public class FullyQualifiedNameTriplet extends Triplet { + + // Specifies how the GID will be used + + /** This GID replaces the first parameter in the structured field that contains a GID name. */ + public static final byte TYPE_REPLACE_FIRST_GID_NAME = 0x01; + + /** This triplet contains the name of a font family. */ + public static final byte TYPE_FONT_FAMILY_NAME = 0x07; + + /** This triplet contains the name of a font typeface. */ + public static final byte TYPE_FONT_TYPEFACE_NAME = 0x08; + + /** This triplet specifies a reference to the MO:DCA resource hierarchy. */ + public static final byte TYPE_MODCA_RESOURCE_HIERARCHY_REF = 0x09; + + /** The triplet contains a GID reference to a begin resource group structured field. */ + public static final byte TYPE_BEGIN_RESOURCE_GROUP_REF = 0x0A; + + /** The triplet contains a GID reference to a document attribute. */ + public static final byte TYPE_ATTRIBUTE_GID = 0x0B; + + /** The triplet contains the GID of a process element. */ + public static final byte TYPE_PROCESS_ELEMENT_GID = 0x0C; + + /** The triplet contains a reference to a begin page group structured field. */ + public static final byte TYPE_BEGIN_PAGE_GROUP_REF = 0x0D; + + /** The triplet contains a reference to a media type. */ + public static final byte TYPE_MEDIA_TYPE_REF = 0x11; + + /** The triplet contains a reference to a color management resource. */ + public static final byte TYPE_COLOR_MANAGEMENT_RESOURCE_REF = 0x41; + + /** The triplet contains a reference to a data-object font file that defines a base font. */ + public static final byte TYPE_DATA_OBJECT_FONT_BASE_FONT_ID = 0x6E; + + /** The triplet contains a reference to a data-object font file that defines a linked font. */ + public static final byte TYPE_DATA_OBJECT_FONT_LINKED_FONT_ID = 0x7E; + + /** The triplet contains a reference to a begin document structured field. */ + public static final byte TYPE_BEGIN_DOCUMENT_REF = (byte)0x83; + + /** + * The triplet contains a reference to a begin structured field associated with a resource; + * or contains a GID reference to a coded font. + */ + public static final byte TYPE_BEGIN_RESOURCE_OBJECT_REF = (byte)0x84; + + /** + * The triplet contains a GID reference to a code page that specifies the code points and + * graphic character names for a coded font. + */ + public static final byte TYPE_CODE_PAGE_NAME_REF = (byte)0x85; + + /** + * The triplet contains a GID name reference to a font character set that specifies + * a set of graphics characters. + */ + public static final byte TYPE_FONT_CHARSET_NAME_REF = (byte)0x86; + + /** The triplet contains a GID reference to a begin page structured field. */ + public static final byte TYPE_BEGIN_PAGE_REF = (byte)0x87; + + /** The triplet contains a GID reference to a begin medium map structured field. */ + public static final byte TYPE_BEGIN_MEDIUM_MAP_REF = (byte)0x8D; + + /** + * The triplet contains a GID reference to a coded font, which identifies a specific + * code page and a specific font character set. + */ + public static final byte TYPE_CODED_FONT_NAME_REF = (byte)0x8E; + + /** The triplet contains a GID reference to a begin document index structured field. */ + public static final byte TYPE_BEGIN_DOCUMENT_INDEX_REF = (byte)0x98; + + /** The triplet contains a GID reference to a begin overlay structured field. */ + public static final byte TYPE_BEGIN_OVERLAY_REF = (byte)0xB0; + + /** The triplet contains a GID reference to a resource used by a data object. */ + public static final byte TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF = (byte)0xBE; + + /** The triplet contains a GID reference to an index element structured field. */ + public static final byte TYPE_INDEX_ELEMENT_GID = (byte)0xCA; + + /** + * The triplet contains a reference to other object data which may or may + * not be defined by an IBM presentation architecture. + */ + public static final byte TYPE_OTHER_OBJECT_DATA_REF = (byte)0xCE; + + /** + * The triplet contains a reference to a resource used by a data object. + * The GID may be a filename or any other identifier associated with the + * resource and is used to located the resource object in the resource hierarchy. + * The data object that uses the resource may or may not be defined by an + * IBM presentation architecture. + */ + public static final byte TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF = (byte)0xDE; + + + // GID Format + + /** The GID is a character encoded name. */ + public static final byte FORMAT_CHARSTR = (byte)0x00; + + /** the GID is a ASN.1 object identifier (OID). */ + public static final byte FORMAT_OID = (byte)0x10; + + /** the GID is a uniform resource locator (URL). */ + public static final byte FORMAT_URL = (byte)0x20; + + + private String fqName; + + /** + * @return the actual fully qualified name of this triplet + */ + public String getFullyQualifiedName() { + return fqName; + } + + /** + * Main constructor + * + * @param type the fully qualified name type + * @param format the fully qualified name format + * @param fqName the fully qualified name + */ + public FullyQualifiedNameTriplet(byte type, byte format, String fqName) { + super(FULLY_QUALIFIED_NAME); + + this.fqName = fqName; + + byte[] fqNameBytes; + String encoding = AFPConstants.EBCIDIC_ENCODING; + if (format == FORMAT_URL) { + encoding = AFPConstants.US_ASCII_ENCODING; + } + try { + fqNameBytes = fqName.getBytes(encoding); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException( + encoding + " encoding failed"); + } + + byte[] data = new byte[2 + fqNameBytes.length]; + data[0] = type; + data[1] = format; + // FQName + System.arraycopy(fqNameBytes, 0, data, 2, fqNameBytes.length); + + super.setData(data); + } + + /** + * {@inheritDoc} + */ + public String toString() { + return this.fqName; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/triplets/MappingOptionTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/MappingOptionTriplet.java new file mode 100644 index 000000000..9fe6dad79 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/MappingOptionTriplet.java @@ -0,0 +1,68 @@ +/* + * 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.afp.modca.triplets; + +/** + * Specifies the mapping of data object presentation space to object area + */ +public class MappingOptionTriplet extends Triplet { + /** + * the data object is placed in the upper left corner, all data must be presented + * within the object area extents + */ + public static final byte POSITION = 0x00; + + /** + * the data object is placed in the upper left corner, all data that falls within + * the object area extents will be presented but data that falls outside will not be presented + */ + public static final byte POSITION_AND_TRIM = 0x10; + + /** + * the data object is centred and symmetrically scaled up or down + * while preserving aspect ratio + */ + public static final byte SCALE_TO_FIT = 0x20; + + /** + * the data object is centred, all data that falls within the object area extents + * will be presented but data that falls outside will not be presented + */ + public static final byte CENTER_AND_TRIM = 0x30; + +// public static final byte MIGRATION_MAPPING_1 = 0x41; +// public static final byte MIGRATION_MAPPING_2 = 0x42; +// public static final byte MIGRATION_MAPPING_3 = 0x50; + + /** the data object is centred, aspect ratio is not always preserved */ + public static final byte SCALE_TO_FILL = 0x60; + + /** used to map ip3i print data objects */ + public static final byte UP3I_PRINT_DATA = 0x70; + + /** + * Main constructor + * + * @param mapValue the mapping option to use + */ + public MappingOptionTriplet(byte mapValue) { + super(Triplet.MAPPING_OPTION, mapValue); + } +} diff --git a/src/java/org/apache/fop/afp/modca/triplets/MeasurementUnitsTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/MeasurementUnitsTriplet.java new file mode 100644 index 000000000..d39dc5f96 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/MeasurementUnitsTriplet.java @@ -0,0 +1,54 @@ +/* + * 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.afp.modca.triplets; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Measurement Units triplet is used to specify the units of measure + * for a presentation space + */ +public class MeasurementUnitsTriplet extends Triplet { + + private static final byte TEN_INCHES = 0x00; + private static final byte TEN_CM = 0x01; + + /** + * Main constructor + * + * @param xRes units per base on the x-axis + * @param yRes units per base on the y-axis + */ + public MeasurementUnitsTriplet(int xRes, int yRes) { + super(MEASUREMENT_UNITS); + //TODO: units correct? + byte[] xUnits = BinaryUtils.convert(xRes * 10, 2); + byte[] yUnits = BinaryUtils.convert(yRes * 10, 2); + byte[] data = new byte[] { + TEN_INCHES, // XoaBase + TEN_INCHES, // YoaBase + xUnits[0], // XoaUnits (x units per unit base) + xUnits[1], + yUnits[0], // YoaUnits (y units per unit base) + yUnits[1] + }; + super.setData(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/triplets/ObjectAreaSizeTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/ObjectAreaSizeTriplet.java new file mode 100644 index 000000000..64fba23c9 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/ObjectAreaSizeTriplet.java @@ -0,0 +1,62 @@ +/* + * 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.afp.modca.triplets; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Object Area Size triplet is used to specify the extent of an object area + * in the X and Y directions + */ +public class ObjectAreaSizeTriplet extends Triplet { + + /** + * Main constructor + * + * @param x the object area extent for the X axis + * @param y the object area extent for the Y axis + * @param type the object area size type + */ + public ObjectAreaSizeTriplet(int x, int y, byte type) { + super(Triplet.OBJECT_AREA_SIZE); + byte[] xOASize = BinaryUtils.convert(x, 3); + byte[] yOASize = BinaryUtils.convert(y, 3); + byte[] data = new byte[] { + type, // SizeType + xOASize[0], // XoaSize - Object area extent for X axis + xOASize[1], + xOASize[2], + yOASize[0], // YoaSize - Object area extent for Y axis + yOASize[1], + yOASize[2] + }; + super.setData(data); + } + + /** + * Main constructor + * + * @param x the object area extent for the X axis + * @param y the object area extent for the Y axis + */ + public ObjectAreaSizeTriplet(int x, int y) { + this(x, y, (byte)0x02); + } +} diff --git a/src/java/org/apache/fop/afp/modca/triplets/ObjectByteExtentTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/ObjectByteExtentTriplet.java new file mode 100644 index 000000000..355fe8288 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/ObjectByteExtentTriplet.java @@ -0,0 +1,39 @@ +/* + * 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.afp.modca.triplets; + +import org.apache.fop.afp.util.BinaryUtils; + +/** + * The Object Byte Extent triplet is used to specify the number of bytes contained in an object + */ +public class ObjectByteExtentTriplet extends Triplet { + + /** + * Main constructor + * + * @param byteExt the number of bytes contained in the object + */ + public ObjectByteExtentTriplet(int byteExt) { + super(OBJECT_BYTE_EXTENT); + byte[] data = BinaryUtils.convert(byteExt, 4); + super.setData(data); + } +} diff --git a/src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java new file mode 100644 index 000000000..1692339ac --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java @@ -0,0 +1,188 @@ +/* + * 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.afp.modca.triplets; + +import java.io.UnsupportedEncodingException; + +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.modca.Registry.ObjectType; +import org.apache.fop.afp.util.StringUtils; + +/** + * The Object Classification is used to classify and identify object data. + * The object data may or may not be defined by an IBM presentation architecture + */ +public class ObjectClassificationTriplet extends Triplet { + + /** + * The scope of this object is the including page or overlay + */ + public static final byte CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT = 0x01; + + /** + * The scope of this object is not defined + */ + public static final byte CLASS_TIME_VARIANT_PRESENTATION_OBJECT = 0x10; + + /** + * This is not a presentation object, the scope of this object is not defined + */ + public static final byte CLASS_EXECUTABLE_PROGRAM = 0x20; + + /** + * Setup information file, document level. This is not a presentation object, + */ + public static final byte CLASS_SETUP_FILE = 0x30; + + /** + * This is a resource used by a presentation object that may itself be a resource. + * The scope of the resource is the object that uses the resource. + */ + public static final byte CLASS_SECONDARY_RESOURCE = 0x40; + + /** + * Data object font. This is a non-FOCA font resource used to present + * text in a data object. The scope of the resource is the object that + * uses the resource. + */ + public static final byte CLASS_DATA_OBJECT_FONT = 0x41; + + /** + * Main constructor + * + * @param objectClass the object class type + * @param objectType the object type registry entry + * @param dataInContainer whether the data resides in the container + * @param containerHasOEG whether the container has an object environment group + * @param dataInOCD whether the data resides in a object container data structured field + */ + public ObjectClassificationTriplet(byte objectClass, ObjectType objectType, + boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD) { + // no object level or company name specified + this(objectClass, objectType, dataInContainer, containerHasOEG, dataInOCD, null, null); + } + + + private static final int OBJECT_LEVEL_LEN = 8; + private static final int OBJECT_TYPE_NAME_LEN = 32; + private static final int COMPANY_NAME_LEN = 32; + + /** + * Fully parameterized constructor + * + * @param objectClass the object class type + * @param objectType the object type registry entry + * @param dataInContainer whether the data resides in the container + * @param containerHasOEG whether the container has an object environment group + * @param dataInOCD whether the data resides in a object container data structured field + * @param objLev the release level or version number of the object type + * @param compName the name of the company or organization that owns the object definition + */ + public ObjectClassificationTriplet(byte objectClass, ObjectType objectType, + boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD, + String objLev, String compName) { + super(OBJECT_CLASSIFICATION); + + if (objectType == null) { + throw new IllegalArgumentException("MO:DCA Registry object type is null"); + } + + byte[] data = new byte[94]; + data[0] = 0x00; // reserved (must be zero) + data[1] = objectClass; // ObjClass + data[2] = 0x00; // reserved (must be zero) + data[3] = 0x00; // reserved (must be zero) + + // StrucFlgs - Information on the structure of the object container + byte[] strucFlgs = getStrucFlgs(dataInContainer, containerHasOEG, dataInOCD); + data[4] = strucFlgs[0]; + data[5] = strucFlgs[1]; + + byte[] oid = objectType.getOID(); + // RegObjId - MOD:CA-registered ASN.1 OID for object type (8-23) + System.arraycopy(oid, 0, data, 6, oid.length); + + // ObjTpName - name of object type (24-55) + byte[] objTpName; + try { + objTpName = StringUtils.rpad(objectType.getName(), ' ', OBJECT_TYPE_NAME_LEN).getBytes( + AFPConstants.EBCIDIC_ENCODING); + System.arraycopy(objTpName, 0, data, 22, objTpName.length); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException("an encoding exception occurred"); + } + + // ObjLev - release level or version number of object type (56-63) + byte[] objectLevel; + try { + objectLevel = StringUtils.rpad(objLev, ' ', OBJECT_LEVEL_LEN).getBytes( + AFPConstants.EBCIDIC_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException("an encoding exception occurred"); + } + System.arraycopy(objectLevel, 0, data, 54, objectLevel.length); + + // CompName - name of company or organization that owns object definition (64-95) + byte[] companyName; + try { + companyName = StringUtils.rpad(compName, ' ', COMPANY_NAME_LEN).getBytes( + AFPConstants.EBCIDIC_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new IllegalArgumentException("an encoding exception occurred"); + } + System.arraycopy(companyName, 0, data, 62, companyName.length); + + super.setData(data); + } + + /** + * Returns the structured field flags + * + * @param dataInContainer true if the object data in carried in the object container + * @param containerHasOEG true if the object container has an object environment group + * @param dataInOCD true if the object container data carries the object data + * + * @return the byte value of this structure + */ + public byte[] getStrucFlgs(boolean dataInContainer, boolean containerHasOEG, + boolean dataInOCD) { + byte[] strucFlgs = new byte[2]; + // Object Container (BOC/EOC) + if (dataInContainer) { + strucFlgs[0] |= 3 << 6; + } else { + strucFlgs[0] |= 1 << 6; + } + // Object Environment Group (OEG) + if (containerHasOEG) { + strucFlgs[0] |= 3 << 4; + } else { + strucFlgs[0] |= 1 << 4; + } + // Object Container Data (OCD) structured fields + if (dataInOCD) { + strucFlgs[0] |= 3 << 2; + } else { + strucFlgs[0] |= 1 << 2; + } + strucFlgs[1] = 0x00; + return strucFlgs; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java new file mode 100644 index 000000000..0f087e4fd --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java @@ -0,0 +1,62 @@ +/* + * 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.afp.modca.triplets; + +/** + * This triplet is used to specify the resulting appearance when data in a new + * presentation space is merged with data in an existing presentation space. + */ +public class PresentationSpaceMixingRulesTriplet extends Triplet { + + /** background on background mixing rule */ + public static final byte RULE_BACK_ON_BACK = 0x70; + + /** background on foreground mixing rule */ + public static final byte RULE_BACK_ON_FORE = 0x71; + + /** foreground on background mixing rule */ + public static final byte RULE_FORE_ON_BACK = 0x72; + + /** foreground on foreground mixing rule */ + public static final byte RULE_FORE_ON_FORE = 0x73; + + + /** overpaint */ + public static final byte OVERPAINT = (byte)0x01; + + /** underpaint */ + public static final byte UNDERPAINT = (byte)0x02; + + /** blend */ + public static final byte BLEND = (byte)0x03; + + /** MO:DCA default mixing */ + public static final byte DEFAULT = (byte)0xFF; + + + /** + * Main constructor + * + * @param rules the mixing rules + */ + public PresentationSpaceMixingRulesTriplet(byte[] rules) { + super(PRESENTATION_SPACE_MIXING_RULE, rules); + } +} diff --git a/src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceResetMixingTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceResetMixingTriplet.java new file mode 100644 index 000000000..38041f140 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceResetMixingTriplet.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.afp.modca.triplets; + +/** + * This triplet is used to specify the resulting appearance when data in a new + * presentation space is merged with data in an existing presentation space. + */ +public class PresentationSpaceResetMixingTriplet extends Triplet { + + /** + * Do not reset to the color of the medium prior to + * placing data into this MO:DCA presentation space. + */ + public static final byte NOT_RESET = 0x00; + + /** + * Reset to the color of the medium prior to placing + * data into this MO:DCA presentation space. + */ + public static final byte RESET = 0x01; + + /** + * Main constructor + * + * @param backgroundMixFlag the background mixing flag + */ + public PresentationSpaceResetMixingTriplet(byte backgroundMixFlag) { + super(PRESENTATION_SPACE_RESET_MIXING, backgroundMixFlag); + } +} diff --git a/src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java new file mode 100644 index 000000000..784975c43 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java @@ -0,0 +1,21 @@ +/* + * 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.afp.modca.triplets; + diff --git a/src/java/org/apache/fop/afp/modca/triplets/Triplet.java b/src/java/org/apache/fop/afp/modca/triplets/Triplet.java new file mode 100644 index 000000000..b7f51466b --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/Triplet.java @@ -0,0 +1,162 @@ +/* + * 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.afp.modca.triplets; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; + +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.Streamable; + +/** + * A simple implementation of a MOD:CA triplet + */ +public class Triplet implements Streamable { + public static final byte CODED_GRAPHIC_CHARACTER_SET_GLOBAL_IDENTIFIER = 0x01; + + /** Triplet identifiers */ + public static final byte FULLY_QUALIFIED_NAME = 0x02; + public static final byte MAPPING_OPTION = 0x04; + public static final byte OBJECT_CLASSIFICATION = 0x10; + public static final byte MODCA_INTERCHANGE_SET = 0x18; + public static final byte FONT_DESCRIPTOR_SPECIFICATION = 0x1F; + public static final byte OBJECT_FUNCTION_SET_SPECIFICATION = 0x21; + public static final byte EXTENDED_RESOURCE_LOCAL_IDENTIFIER = 0x22; + public static final byte RESOURCE_LOCAL_IDENTIFIER = 0x24; + public static final byte RESOURCE_SECTION_NUMBER = 0x25; + public static final byte CHARACTER_ROTATION = 0x26; + public static final byte OBJECT_BYTE_OFFSET = 0x2D; + public static final byte ATTRIBUTE_VALUE = 0x36; + public static final byte DESCRIPTOR_POSITION = 0x43; + public static final byte MEDIA_EJECT_CONTROL = 0x45; + public static final byte PAGE_OVERLAY_CONDITIONAL_PROCESSING = 0x46; + public static final byte RESOURCE_USAGE_ATTRIBUTE = 0x47; + public static final byte MEASUREMENT_UNITS = 0x4B; + public static final byte OBJECT_AREA_SIZE = 0x4C; + public static final byte AREA_DEFINITION = 0x4D; + public static final byte COLOR_SPECIFICATION = 0x4E; + public static final byte ENCODING_SCHEME_ID = 0x50; + public static final byte MEDIUM_MAP_PAGE_NUMBER = 0x56; + public static final byte OBJECT_BYTE_EXTENT = 0x57; + public static final byte OBJECT_STRUCTURED_FIELD_OFFSET = 0x58; + public static final byte OBJECT_STRUCTURED_FIELD_EXTENT = 0x59; + public static final byte OBJECT_OFFSET = 0x5A; + public static final byte FONT_HORIZONTAL_SCALE_FACTOR = 0x5D; + public static final byte OBJECT_COUNT = 0x5E; + public static final byte OBJECT_DATE_AND_TIMESTAMP = 0x62; + public static final byte COMMENT = 0x65; + public static final byte MEDIUM_ORIENTATION = 0x68; + public static final byte RESOURCE_OBJECT_INCLUDE = 0x6C; + public static final byte PRESENTATION_SPACE_RESET_MIXING = 0x70; + public static final byte PRESENTATION_SPACE_MIXING_RULE = 0x71; + public static final byte UNIVERSAL_DATE_AND_TIMESTAMP = 0x72; + public static final byte TONER_SAVER = 0x74; + public static final byte COLOR_FIDELITY = 0x75; + public static final byte FONT_FIDELITY = 0x78; + public static final byte ATTRIBUTE_QUALIFIER = (byte)0x80; + public static final byte PAGE_POSITION_INFORMATION = (byte)0x81; + public static final byte PARAMETER_VALUE = (byte)0x82; + public static final byte PRESENTATION_CONTROL = (byte)0x83; + public static final byte FONT_RESOLUTION_AND_METRIC_TECHNOLOGY = (byte)0x84; + public static final byte FINISHING_OPERATION = (byte)0x85; + public static final byte TEXT_FIDELITY = (byte)0x86; + public static final byte MEDIA_FIDELITY = (byte)0x87; + public static final byte FINISHING_FIDELITY = (byte)0x88; + public static final byte DATA_OBJECT_FONT_DESCRIPTOR = (byte)0x8B; + public static final byte LOCALE_SELECTOR = (byte)0x8C; + public static final byte UP3I_FINISHING_OPERATION = (byte)0x8E; + public static final byte COLOR_MANAGEMENT_RESOURCE_DESCRIPTOR = (byte)0x91; + public static final byte RENDERING_INTENT = (byte)0x95; + public static final byte CMR_TAG_FIDELITY = (byte)0x96; + public static final byte DEVICE_APPEARANCE = (byte)0x97; + + /** the triplet identifier */ + private final byte id; + + /** the triplet's data contents */ + private byte[] data; + + /** + * Main constructor + * + * @param id the triplet identifier (see static definitions above) + * @param data the data item contained in this triplet + */ + public Triplet(byte id, byte[] data) { + this(id); + setData(data); + } + + /** + * Constructor + * + * @param id the triplet identifier (see static definitions above) + */ + public Triplet(byte id) { + this.id = id; + } + + /** + * Constructor + * + * @param id the triplet identifier (see static definitions above) + * @param content the content byte data + */ + public Triplet(byte id, byte content) { + this(id, new byte[] {content}); + } + + /** + * Constructor + * + * @param id the triplet identifier (see static definitions above) + * @param data the data item (in String form) contained in this triplet + * @throws UnsupportedEncodingException EBCIDIC encoding is not supported + */ + public Triplet(byte id, String data) throws UnsupportedEncodingException { + this(id, data.getBytes(AFPConstants.EBCIDIC_ENCODING)); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + os.write((byte)data.length + 2); + os.write(id); + os.write(data); + } + + /** + * Returns the triplet identifier + * + * @return the triplet identifier + */ + public byte getId() { + return this.id; + } + + /** + * Sets the data contents of this triplet + * + * @param data the data contents + */ + protected void setData(byte[] data) { + this.data = data; + } +} diff --git a/src/java/org/apache/fop/afp/util/BinaryUtils.java b/src/java/org/apache/fop/afp/util/BinaryUtils.java new file mode 100644 index 000000000..2b2649415 --- /dev/null +++ b/src/java/org/apache/fop/afp/util/BinaryUtils.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.afp.util; + +import java.io.ByteArrayOutputStream; + +/** + * Library of utility useful conversion methods. + * + */ +public final class BinaryUtils { + + /** + * Convert an int into the corresponding byte array by encoding each + * two hexadecimal digits as a char. This will return a byte array + * to the length specified by bufsize. + * @param integer The int representation. + * @param bufsize The required byte array size. + * @return the hexadecimal digits as a byte array + */ + public static byte[] convert(int integer, int bufsize) { + StringBuffer buf = new StringBuffer(Integer.toHexString(integer)); + //Convert to an even number of digits + if (buf.length() % 2 != 0) { + buf.insert(0, "0"); + } + int size = buf.length() / 2; + if (size > bufsize) { + buf.delete(0, buf.length() - (bufsize * 2)); + } else { + while (size < bufsize) { + buf.insert(0, "00"); + size++; + } + } + return convert(buf.toString()); + } + + /** + * Convert an int into the corresponding byte array by encoding each + * two hexadecimal digits as a char. + * @param integer The int representation + * @return the hexadecimal digits as a byte array + */ + public static byte[] convert(int integer) { + return convert(Integer.toHexString(integer)); + } + + /** + * Convert a String of hexadecimal digits into the corresponding + * byte array by encoding each two hexadecimal digits as a byte. + * @param digits The hexadecimal digits representation. + * @return the hexadecimal digits as a byte array + */ + public static byte[] convert(String digits) { + + if (digits.length() % 2 == 0) { + // Even number of digits, so ignore + } else { + // Convert to an even number of digits + digits = "0" + digits; + } + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + for (int i = 0; i < digits.length(); i += 2) { + char c1 = digits.charAt(i); + char c2 = digits.charAt(i + 1); + byte b = 0; + if ((c1 >= '0') && (c1 <= '9')) { + b += ((c1 - '0') * 16); + } else if ((c1 >= 'a') && (c1 <= 'f')) { + b += ((c1 - 'a' + 10) * 16); + } else if ((c1 >= 'A') && (c1 <= 'F')) { + b += ((c1 - 'A' + 10) * 16); + } else { + throw new IllegalArgumentException("Bad hexadecimal digit"); + } + + if ((c2 >= '0') && (c2 <= '9')) { + b += (c2 - '0'); + } else if ((c2 >= 'a') && (c2 <= 'f')) { + b += (c2 - 'a' + 10); + } else if ((c2 >= 'A') && (c2 <= 'F')) { + b += (c2 - 'A' + 10); + } else { + throw new IllegalArgumentException("Bad hexadecimal digit"); + } + baos.write(b); + } + return (baos.toByteArray()); + } + + /** + * Convert the specified short into a byte array. + * @param value The value to be converted. + * @param array The array to receive the data. + * @param offset The offset into the byte array for the start of the value. + */ + public static void shortToByteArray( + short value, + byte[] array, + int offset) { + array[offset] = (byte) (value >>> 8); + array[offset + 1] = (byte) value; + } + + /** + * Convert the specified short into a byte array. + * @param value The value to be converted. + * @return The byte array + */ + public static byte[] shortToByteArray(short value) { + byte[] serverValue = new byte[2]; + shortToByteArray(value, serverValue, 0); + return serverValue; + } + +} diff --git a/src/java/org/apache/fop/afp/util/DTDEntityResolver.java b/src/java/org/apache/fop/afp/util/DTDEntityResolver.java new file mode 100644 index 000000000..dcf5ad7d9 --- /dev/null +++ b/src/java/org/apache/fop/afp/util/DTDEntityResolver.java @@ -0,0 +1,120 @@ +/* + * 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.afp.util; + +import java.io.IOException; +import java.net.URL; + +import org.apache.fop.afp.fonts.FontRuntimeException; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; + +/** + * An entity resolver for both DOM and SAX models of the SAX document. + *

      + * The entity resolver only handles queries for the DTD. It will find any URI + * with a recognised public id and return an {@link org.xml.sax.InputSource}. + *

      + * @author Joe Schmetzer + */ +public class DTDEntityResolver implements EntityResolver { + + /** Public ID for the AFP fonts 1.0 DTD. */ + public static final String AFP_DTD_1_0_ID + = "-//APACHE/DTD AFP Installed Font Definition DTD 1.0//EN"; + + /** Resource location for the AFP fonts 1.0 DTD. */ + public static final String AFP_DTD_1_0_RESOURCE + = "afp-fonts-1.0.dtd"; + + /** Public ID for the AFP fonts 1.1 DTD. */ + public static final String AFP_DTD_1_1_ID + = "-//APACHE/DTD AFP Installed Font Definition DTD 1.1//EN"; + + /** Resource location for the AFP fonts 1.1 DTD. */ + public static final String AFP_DTD_1_1_RESOURCE + = "afp-fonts-1.1.dtd"; + + /** Public ID for the AFP fonts 1.2 DTD. */ + public static final String AFP_DTD_1_2_ID + = "-//APACHE/DTD AFP Installed Font Definition DTD 1.2//EN"; + + /** Resource location for the AFP fonts 1.2 DTD. */ + public static final String AFP_DTD_1_2_RESOURCE + = "afp-fonts-1.2.dtd"; + + /** + * Resolve the combination of system and public identifiers. + * If this resolver recognises the publicId, it will handle the resolution + * from the classpath, otherwise it will return null and allow the default + * resolution to occur. + * + * @param publicId the public identifier to use + * @param systemId the system identifier to resolve + * @return An input source to the entity or null if not handled + * @throws IOException an error reading the stream + */ + public InputSource resolveEntity(String publicId, String systemId) + throws IOException { + + URL resource = null; + if ( AFP_DTD_1_2_ID.equals(publicId) ) { + resource = getResource( AFP_DTD_1_2_RESOURCE ); + } else if ( AFP_DTD_1_1_ID.equals(publicId) ) { + resource = getResource( AFP_DTD_1_1_RESOURCE ); + } else if ( AFP_DTD_1_0_ID.equals(publicId) ) { + throw new FontRuntimeException( + "The AFP Installed Font Definition 1.0 DTD is not longer supported" ); + } else if (systemId != null && systemId.indexOf("afp-fonts.dtd") >= 0 ) { + throw new FontRuntimeException( + "The AFP Installed Font Definition DTD must be specified using the public id" ); + } else { + return null; + } + + InputSource inputSource = new InputSource( resource.openStream() ); + inputSource.setPublicId( publicId ); + inputSource.setSystemId( systemId ); + + return inputSource; + } + + /** + * Returns the URL of a resource on the classpath + * @param resourceName the path to the resource relative to the root of the + * classpath. + * @return the URL of the required resource + * @throws FontRuntimeException if the resource could not be found. + */ + private URL getResource(String resourcePath) { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + cl = ClassLoader.getSystemClassLoader(); + } + + URL resource = cl.getResource( resourcePath ); + if (resource == null) { + throw new FontRuntimeException( "Resource " + resourcePath + + "could not be found on the classpath" ); + } + + return resource; + } +} diff --git a/src/java/org/apache/fop/afp/util/StringUtils.java b/src/java/org/apache/fop/afp/util/StringUtils.java new file mode 100644 index 000000000..ce68d27be --- /dev/null +++ b/src/java/org/apache/fop/afp/util/StringUtils.java @@ -0,0 +1,81 @@ +/* + * 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.afp.util; + +/** + * Library of utility methods useful in dealing with strings. + * + */ +public class StringUtils { + + /** + * Padds the string to the left with the given character for + * the specified length. + * @param input The input string. + * @param padding The char used for padding. + * @param length The length of the new string. + * @return The padded string. + */ + public static String lpad(String input, char padding, int length) { + + if (input == null) { + input = new String(); + } + + if (input.length() >= length) { + return input; + } else { + StringBuffer result = new StringBuffer(); + int numChars = length - input.length(); + for (int i = 0; i < numChars; i++) { + result.append(padding); + } + result.append(input); + return result.toString(); + } + } + + /** + * Padds the string to the right with the given character for + * the specified length. + * @param input The input string. + * @param padding The char used for padding. + * @param length The length of the new string. + * @return The padded string. + */ + public static String rpad(String input, char padding, int length) { + + if (input == null) { + input = new String(); + } + + if (input.length() >= length) { + return input; + } else { + StringBuffer result = new StringBuffer(input); + int numChars = length - input.length(); + for (int i = 0; i < numChars; i++) { + result.append(padding); + } + return result.toString(); + } + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/util/StructuredFieldReader.java b/src/java/org/apache/fop/afp/util/StructuredFieldReader.java new file mode 100644 index 000000000..34add3bbe --- /dev/null +++ b/src/java/org/apache/fop/afp/util/StructuredFieldReader.java @@ -0,0 +1,133 @@ +/* + * 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.afp.util; + +import java.io.IOException; +import java.io.InputStream; + +/** + * A helper class to read structured fields from a MO:DCA document. Each + * component of a mixed object document is explicitly defined and delimited + * in the data. This is accomplished through the use of MO:DCA data structures, + * called structured fields. Structured fields are used to envelop document + * components and to provide commands and information to applications using + * the data. Structured fields may contain one or more parameters. Each + * parameter provides one value from a set of values defined by the architecture. + *

      + * MO:DCA structured fields consist of two parts: an introducer that identifies + * the length and type of the structured field, and data that provides the + * structured field's effect. The data is contained in a set of parameters, + * which can consist of other data structures and data elements. The maximum + * length of a structured field is 32767 bytes. + *

      + */ +public class StructuredFieldReader { + + /** + * The input stream to read + */ + private InputStream inputStream = null; + + /** + * The constructor for the StructuredFieldReader + * @param inputStream the input stream to process + */ + public StructuredFieldReader(InputStream inputStream) { + this.inputStream = inputStream; + } + + /** + * Get the next structured field as identified by the identifer + * parameter (this must be a valid MO:DCA structured field. + * @param identifier the three byte identifier + * @throws IOException if an I/O exception occurred + * @return the next structured field or null when there are no more + */ + public byte[] getNext(byte[] identifier) throws IOException { + + int bufferPointer = 0; + byte[] bufferData = new byte[identifier.length + 2]; + for (int x = 0; x < identifier.length; x++) { + bufferData[x] = 0x00; + } + + int c; + while ((c = inputStream.read()) > -1) { + + bufferData[bufferPointer] = (byte) c; + + // Check the last characters in the buffer + int index = 0; + boolean found = true; + + for (int i = identifier.length - 1; i > -1; i--) { + + int p = bufferPointer - index; + if (p < 0) { + p = bufferData.length + p; + } + + index++; + + if (identifier[i] != bufferData[p]) { + found = false; + break; + } + + } + + if (found) { + + byte[] length = new byte[2]; + + int a = bufferPointer - identifier.length; + if (a < 0) { + a = bufferData.length + a; + } + + int b = bufferPointer - identifier.length - 1; + if (b < 0) { + b = bufferData.length + b; + } + + length[0] = bufferData[b]; + length[1] = bufferData[a]; + + int reclength = ((length[0] & 0xFF) << 8) + + (length[1] & 0xFF) - identifier.length - 2; + + byte[] retval = new byte[reclength]; + + inputStream.read(retval, 0, reclength); + + return retval; + + } + + bufferPointer++; + if (bufferPointer >= bufferData.length) { + bufferPointer = 0; + } + + } + + return null; + } +} diff --git a/src/java/org/apache/fop/fonts/Base14Font.java b/src/java/org/apache/fop/fonts/Base14Font.java index 04349a148..9b2e95bc7 100644 --- a/src/java/org/apache/fop/fonts/Base14Font.java +++ b/src/java/org/apache/fop/fonts/Base14Font.java @@ -19,6 +19,7 @@ package org.apache.fop.fonts; + /** * Base class for all Base 14 fonts. */ diff --git a/src/java/org/apache/fop/fonts/CustomFont.java b/src/java/org/apache/fop/fonts/CustomFont.java index 0b40dfecc..4cf24ae16 100644 --- a/src/java/org/apache/fop/fonts/CustomFont.java +++ b/src/java/org/apache/fop/fonts/CustomFont.java @@ -26,6 +26,7 @@ import java.util.Set; import javax.xml.transform.Source; + /** * Abstract base class for custom fonts loaded from files, for example. */ diff --git a/src/java/org/apache/fop/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java index ebd45457d..e9740c00c 100644 --- a/src/java/org/apache/fop/fonts/Font.java +++ b/src/java/org/apache/fop/fonts/Font.java @@ -23,6 +23,7 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.fonts.CodePointMapping; /** * This class holds font state information and provides access to the font diff --git a/src/java/org/apache/fop/fonts/FontCollection.java b/src/java/org/apache/fop/fonts/FontCollection.java index 3c9bba7f4..d481ae2f9 100644 --- a/src/java/org/apache/fop/fonts/FontCollection.java +++ b/src/java/org/apache/fop/fonts/FontCollection.java @@ -24,6 +24,7 @@ package org.apache.fop.fonts; * Sets up a set of fonts */ public interface FontCollection { + /** * Sets up fonts in a font info object. * diff --git a/src/java/org/apache/fop/fonts/FontDescriptor.java b/src/java/org/apache/fop/fonts/FontDescriptor.java index fadc73834..e7c81c9f3 100644 --- a/src/java/org/apache/fop/fonts/FontDescriptor.java +++ b/src/java/org/apache/fop/fonts/FontDescriptor.java @@ -19,6 +19,7 @@ package org.apache.fop.fonts; + /** * This interface enhances the font metrics interface with access methods to * value needed to register fonts in various target formats like PDF or diff --git a/src/java/org/apache/fop/fonts/FontEventListener.java b/src/java/org/apache/fop/fonts/FontEventListener.java index b508d7053..740a05fdc 100644 --- a/src/java/org/apache/fop/fonts/FontEventListener.java +++ b/src/java/org/apache/fop/fonts/FontEventListener.java @@ -19,7 +19,6 @@ package org.apache.fop.fonts; - /** * Event listener interface for font-related events. */ diff --git a/src/java/org/apache/fop/fonts/FontMetrics.java b/src/java/org/apache/fop/fonts/FontMetrics.java index 7d5588690..29ade1ef3 100644 --- a/src/java/org/apache/fop/fonts/FontMetrics.java +++ b/src/java/org/apache/fop/fonts/FontMetrics.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Set; + /** * Main interface for access to font metrics. */ diff --git a/src/java/org/apache/fop/fonts/FontTriplet.java b/src/java/org/apache/fop/fonts/FontTriplet.java index 8e0acd8f2..f5cfe442a 100644 --- a/src/java/org/apache/fop/fonts/FontTriplet.java +++ b/src/java/org/apache/fop/fonts/FontTriplet.java @@ -21,6 +21,7 @@ package org.apache.fop.fonts; import java.io.Serializable; + /** * FontTriplet contains information on name, style and weight of one font */ diff --git a/src/java/org/apache/fop/fonts/FontType.java b/src/java/org/apache/fop/fonts/FontType.java index 0abe06a10..95b594ca4 100644 --- a/src/java/org/apache/fop/fonts/FontType.java +++ b/src/java/org/apache/fop/fonts/FontType.java @@ -19,12 +19,10 @@ package org.apache.fop.fonts; -import org.apache.avalon.framework.ValuedEnum; - /** * This class enumerates all supported font types. */ -public class FontType extends ValuedEnum { +public class FontType { /** * Collective identifier for "other" font types @@ -51,12 +49,16 @@ public class FontType extends ValuedEnum { */ public static final FontType TRUETYPE = new FontType("TrueType", 5); + private final String name; + private final int value; + /** * @see org.apache.avalon.framework.Enum#Enum(String) */ protected FontType(String name, int value) { - super(name, value); + this.name = name; + this.value = value; } @@ -107,4 +109,22 @@ public class FontType extends ValuedEnum { } } + /** + * Returns the name + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Returns the value + * + * @return the value + */ + public int getValue() { + return value; + } + } diff --git a/src/java/org/apache/fop/fonts/FontUtil.java b/src/java/org/apache/fop/fonts/FontUtil.java index 6ec89631f..49f23c12f 100644 --- a/src/java/org/apache/fop/fonts/FontUtil.java +++ b/src/java/org/apache/fop/fonts/FontUtil.java @@ -19,6 +19,7 @@ package org.apache.fop.fonts; + /** * Font utilities. */ diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java index f25ca4e7e..b22b92e2f 100644 --- a/src/java/org/apache/fop/fonts/MultiByteFont.java +++ b/src/java/org/apache/fop/fonts/MultiByteFont.java @@ -23,6 +23,7 @@ package org.apache.fop.fonts; import java.text.DecimalFormat; import java.util.Map; + /** * Generic MultiByte (CID) font */ diff --git a/src/java/org/apache/fop/fonts/MutableFont.java b/src/java/org/apache/fop/fonts/MutableFont.java index 5939bfed4..a5acf51b3 100644 --- a/src/java/org/apache/fop/fonts/MutableFont.java +++ b/src/java/org/apache/fop/fonts/MutableFont.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Set; + /** * This interface is used to set the values of a font during configuration time. */ diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java index 6b0e88cbb..dc8a020ae 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java @@ -20,12 +20,12 @@ package org.apache.fop.layoutmgr.inline; import org.apache.fop.fo.flow.PageNumber; -import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.area.inline.TextArea; -import org.apache.fop.area.Trait; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; +import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.area.inline.TextArea; +import org.apache.fop.area.Trait; import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.traits.MinOptMax; diff --git a/src/java/org/apache/fop/pdf/PDFState.java b/src/java/org/apache/fop/pdf/PDFState.java index 0f3e06070..138458552 100644 --- a/src/java/org/apache/fop/pdf/PDFState.java +++ b/src/java/org/apache/fop/pdf/PDFState.java @@ -25,7 +25,7 @@ import java.awt.Shape; import java.awt.geom.Area; import java.awt.geom.GeneralPath; -import org.apache.fop.render.AbstractState; +import org.apache.fop.AbstractState; /** * This keeps information about the current state when writing to pdf. @@ -44,7 +44,7 @@ import org.apache.fop.render.AbstractState; * It is impossible to optimise the result without analysing the all * the possible combinations after completing. */ -public class PDFState extends org.apache.fop.render.AbstractState { +public class PDFState extends org.apache.fop.AbstractState { private static final long serialVersionUID = 5384726143906371279L; @@ -165,7 +165,7 @@ public class PDFState extends org.apache.fop.render.AbstractState { return new PDFState(); } - private class PDFData extends org.apache.fop.render.AbstractState.AbstractData { + private class PDFData extends org.apache.fop.AbstractState.AbstractData { private static final long serialVersionUID = 3527950647293177764L; diff --git a/src/java/org/apache/fop/render/AbstractState.java b/src/java/org/apache/fop/render/AbstractState.java deleted file mode 100644 index 04409390f..000000000 --- a/src/java/org/apache/fop/render/AbstractState.java +++ /dev/null @@ -1,433 +0,0 @@ -/* - * 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.awt.Color; -import java.awt.geom.AffineTransform; -import java.io.Serializable; -import java.util.Arrays; -import java.util.Iterator; -import java.util.Stack; - -/** - * A base class which holds information about the current rendering state. - */ -public abstract class AbstractState implements Cloneable, Serializable { - - /** current state data */ - private AbstractData currentData = null; - - /** the state stack */ - private StateStack stateStack = null; - - /** - * Instantiates a new state data object - * - * @return a new state data object - */ - protected abstract AbstractData instantiateData(); - - /** - * Instantiates a new state object - * - * @return a new state object - */ - protected abstract AbstractState instantiateState(); - - /** - * Returns the currently valid state - * - * @return the currently valid state - */ - public AbstractData getData() { - if (currentData == null) { - currentData = instantiateData(); - } - return currentData; - } - - /** - * Set the current color. - * Check if the new color is a change and then set the current color. - * - * @param col the color to set - * @return true if the color has changed - */ - public boolean setColor(Color col) { - if (!col.equals(getData().color)) { - getData().color = col; - return true; - } - return false; - } - - /** - * Get the color. - * - * @return the color - */ - public Color getColor() { - if (getData().color == null) { - getData().color = Color.black; - } - return getData().color; - } - - /** - * Get the background color. - * - * @return the background color - */ - public Color getBackColor() { - if (getData().backColor == null) { - getData().backColor = Color.white; - } - return getData().backColor; - } - - /** - * Set the current background color. - * Check if the new background color is a change and then set the current background color. - * - * @param col the background color to set - * @return true if the color has changed - */ - public boolean setBackColor(Color col) { - if (!col.equals(getData().backColor)) { - getData().backColor = col; - return true; - } - return false; - } - - /** - * Set the current font name - * - * @param internalFontName the internal font name - * @return true if the font name has changed - */ - public boolean setFontName(String internalFontName) { - if (!internalFontName.equals(getData().fontName)) { - getData().fontName = internalFontName; - return true; - } - return false; - } - - /** - * Gets the current font name - * - * @return the current font name - */ - public String getFontName() { - return getData().fontName; - } - - /** - * Gets the current font size - * - * @return the current font size - */ - public int getFontSize() { - return getData().fontSize; - } - - /** - * Set the current font size. - * Check if the font size is a change and then set the current font size. - * - * @param size the font size to set - * @return true if the font size has changed - */ - public boolean setFontSize(int size) { - if (size != getData().fontSize) { - getData().fontSize = size; - return true; - } - return false; - } - - /** - * Set the current line width. - * - * @param width the line width in points - * @return true if the line width has changed - */ - public boolean setLineWidth(float width) { - if (getData().lineWidth != width) { - getData().lineWidth = width; - return true; - } - return false; - } - - /** - * Returns the current line width - * - * @return the current line width - */ - public float getLineWidth() { - return getData().lineWidth; - } - - /** - * Sets the dash array (line type) for the current basic stroke - * - * @param dash the line dash array - * @return true if the dash array has changed - */ - public boolean setDashArray(float[] dash) { - if (!Arrays.equals(dash, getData().dashArray)) { - getData().dashArray = dash; - return true; - } - return false; - } - - /** - * Get the current transform. - * This gets the combination of all transforms in the - * current state. - * - * @return the calculate combined transform for the current state - */ - public AffineTransform getTransform() { - AffineTransform at = new AffineTransform(); - for (Iterator iter = getStateStack().iterator(); iter.hasNext();) { - AbstractData data = (AbstractData)iter.next(); - AffineTransform stackTrans = data.getTransform(); - at.concatenate(stackTrans); - } - AffineTransform currentTrans = getData().getTransform(); - at.concatenate(currentTrans); - return at; - } - - /** - * Check the current transform. - * The transform for the current state is the combination of all - * transforms in the current state. The parameter is compared - * against this current transform. - * - * @param tf the transform the check against - * @return true if the new transform is different then the current transform - */ - public boolean checkTransform(AffineTransform tf) { - return !tf.equals(getData().getTransform()); - } - - /** - * Get a copy of the base transform for the page. Used to translate - * IPP/BPP values into X,Y positions when positioning is "fixed". - * - * @return the base transform, or null if the state stack is empty - */ - public AffineTransform getBaseTransform() { - if (getStateStack().isEmpty()) { - return null; - } else { - AbstractData baseData = (AbstractData)getStateStack().get(0); - return (AffineTransform) baseData.getTransform().clone(); - } - } - - /** - * Concatenates the given AffineTransform to the current one. - * - * @param at the transform to concatenate to the current level transform - */ - public void concatenate(AffineTransform at) { - getData().concatenate(at); - } - - /** - * Resets the current AffineTransform. - */ - public void resetTransform() { - getData().resetTransform(); - } - - /** - * Push the current state onto the stack. - * This call should be used when the Q operator is used - * so that the state is known when popped. - */ - public void push() { - AbstractData copy = (AbstractData)getData().clone(); - getStateStack().push(copy); - } - - /** - * Pop the state from the stack and set current values to popped state. - * This should be called when a Q operator is used so - * the state is restored to the correct values. - * - * @return the restored state, null if the stack is empty - */ - public AbstractData pop() { - if (!getStateStack().isEmpty()) { - this.currentData = (AbstractData)getStateStack().pop(); - return this.currentData; - } else { - return null; - } - } - - /** - * Clears the state stack - */ - public void clear() { - getStateStack().clear(); - currentData = null; - } - - /** - * Return the state stack - * - * @return the state stack - */ - protected Stack/**/ getStateStack() { - if (stateStack == null) { - stateStack = new StateStack(); - } - return stateStack; - } - - /** {@inheritDoc} */ - public Object clone() { - AbstractState state = instantiateState(); - state.stateStack = new StateStack(this.stateStack); - state.currentData = (AbstractData)this.currentData.clone(); - return state; - } - - /** {@inheritDoc} */ - public String toString() { - return ", stateStack=" + stateStack - + ", currentData=" + currentData; - } - - /** - * A base state data holding object - */ - public abstract class AbstractData implements Cloneable, Serializable { - - /** The current color */ - private Color color = null; - - /** The current background color */ - private Color backColor = null; - - /** The current font name */ - private String fontName = null; - - /** The current font size */ - private int fontSize = 0; - - /** The current line width */ - private float lineWidth = 0; - - /** The dash array for the current basic stroke (line type) */ - private float[] dashArray = null; - - /** The current transform */ - private AffineTransform transform = null; - - /** - * Concatenate the given AffineTransform with the current thus creating - * a new viewport. Note that all concatenation operations are logged - * so they can be replayed if necessary (ex. for block-containers with - * "fixed" positioning. - * - * @param at Transformation to perform - */ - public void concatenate(AffineTransform at) { - getTransform().concatenate(at); - } - - /** - * Get the current AffineTransform. - * - * @return the current transform - */ - public AffineTransform getTransform() { - if (transform == null) { - transform = new AffineTransform(); - } - return transform; - } - - /** - * Resets the current AffineTransform. - */ - public void resetTransform() { - transform = getBaseTransform(); -// transform = new AffineTransform(); - } - - /** - * Returns the derived rotation from the current transform - * - * @return the derived rotation from the current transform - */ - public int getDerivedRotation() { - AffineTransform at = getTransform(); - double sx = at.getScaleX(); - double sy = at.getScaleY(); - double shx = at.getShearX(); - double shy = at.getShearY(); - int rotation = 0; - if (sx == 0 && sy == 0 && shx > 0 && shy < 0) { - rotation = 270; - } else if (sx < 0 && sy < 0 && shx == 0 && shy == 0) { - rotation = 180; - } else if (sx == 0 && sy == 0 && shx < 0 && shy > 0) { - rotation = 90; - } else { - rotation = 0; - } - return rotation; - } - - /** {@inheritDoc} */ - public Object clone() { - AbstractData data = instantiateData(); - data.color = this.color; - data.backColor = this.backColor; - data.fontName = this.fontName; - data.fontSize = this.fontSize; - data.lineWidth = this.lineWidth; - data.dashArray = this.dashArray; - data.transform = new AffineTransform(this.transform); - return data; - } - - /** {@inheritDoc} */ - public String toString() { - return "color=" + color - + ", backColor=" + backColor - + ", fontName=" + fontName - + ", fontSize=" + fontSize - + ", lineWidth=" + lineWidth - + ", dashArray=" + dashArray - + ", transform=" + transform; - } - } -} diff --git a/src/java/org/apache/fop/render/StateStack.java b/src/java/org/apache/fop/render/StateStack.java deleted file mode 100644 index ab68a3968..000000000 --- a/src/java/org/apache/fop/render/StateStack.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.util.Collection; - -/** - * No copy constructor for java.util.Stack so extended and implemented one. - */ -public class StateStack extends java.util.Stack { - - private static final long serialVersionUID = 4897178211223823041L; - - /** - * Default constructor - */ - public StateStack() { - super(); - } - - /** - * Copy constructor - * - * @param c initial contents of stack - */ - public StateStack(Collection c) { - elementCount = c.size(); - // 10% for growth - elementData = new Object[ - (int)Math.min((elementCount * 110L) / 100, Integer.MAX_VALUE)]; - c.toArray(elementData); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPAbstractGraphicsObjectPainter.java b/src/java/org/apache/fop/render/afp/AFPAbstractGraphicsObjectPainter.java deleted file mode 100644 index 101d28b61..000000000 --- a/src/java/org/apache/fop/render/afp/AFPAbstractGraphicsObjectPainter.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.modca.GraphicsObject; -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; - -/** - * A simple AFP Graphics 2D painter - */ -public abstract class AFPAbstractGraphicsObjectPainter implements Graphics2DImagePainter { - /** Static logging instance */ - protected static Log log = LogFactory.getLog(AFPAbstractGraphicsObjectPainter.class); - - private final AFPGraphics2D graphics2D; - - /** - * Default constructor - */ - public AFPAbstractGraphicsObjectPainter() { - final boolean textAsShapes = false; - this.graphics2D = new AFPGraphics2D(textAsShapes); - } - - /** - * Constructor - * - * @param graphics the afp graphics 2d implementation - */ - public AFPAbstractGraphicsObjectPainter(AFPGraphics2D graphics) { - this.graphics2D = graphics; - } - - /** - * Sets the GOCA Graphics Object - * - * @param graphicsObject the GOCA Graphics Object - */ - public void setGraphicsObject(GraphicsObject graphicsObject) { - this.graphics2D.setGraphicsObject(graphicsObject); - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java b/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java index 565732b06..0c32204e2 100644 --- a/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java @@ -21,6 +21,14 @@ package org.apache.fop.render.afp; import java.io.IOException; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPForeignAttributeReader; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPUnitConverter; + + /** * Abstract image configurator */ @@ -51,7 +59,7 @@ public abstract class AFPAbstractImageFactory { * @return the data object info * @throws IOException thrown if an I/O exception of some sort has occurred. */ - public AFPDataObjectInfo create(AFPImageInfo afpImageInfo) throws IOException { + public AFPDataObjectInfo create(AFPRendererImageInfo afpImageInfo) throws IOException { AFPDataObjectInfo dataObjectInfo = createDataObjectInfo(); // set resource information diff --git a/src/java/org/apache/fop/render/afp/AFPBatikGraphicsObjectPainter.java b/src/java/org/apache/fop/render/afp/AFPBatikGraphicsObjectPainter.java index 94da16d71..0aa77d61b 100644 --- a/src/java/org/apache/fop/render/afp/AFPBatikGraphicsObjectPainter.java +++ b/src/java/org/apache/fop/render/afp/AFPBatikGraphicsObjectPainter.java @@ -24,6 +24,8 @@ import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.apache.batik.gvt.GraphicsNode; +import org.apache.fop.afp.AFPAbstractGraphicsObjectPainter; +import org.apache.fop.afp.AFPGraphics2D; /** * Paints SVG as a GOCA Graphics Object using Batik diff --git a/src/java/org/apache/fop/render/afp/AFPBorderPainter.java b/src/java/org/apache/fop/render/afp/AFPBorderPainter.java deleted file mode 100644 index 5fbb91abc..000000000 --- a/src/java/org/apache/fop/render/afp/AFPBorderPainter.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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 java.awt.geom.AffineTransform; - -import org.apache.fop.fo.Constants; -import org.apache.fop.render.afp.modca.DataStream; -import org.apache.fop.util.ColorUtil; - -/** - * Handles the drawing of borders/lines in AFP - */ -public class AFPBorderPainter extends AbstractAFPPainter { - - /** - * Main constructor - * - * @param state the unit converter - * @param dataStream the afp datastream - */ - public AFPBorderPainter(AFPState state, DataStream dataStream) { - super(state, dataStream); - } - - /** {@inheritDoc} */ - public void paint(PaintInfo paintInfo) { - BorderPaintInfo borderPaintInfo = (BorderPaintInfo)paintInfo; - float w = borderPaintInfo.getX2() - borderPaintInfo.getX1(); - float h = borderPaintInfo.getY2() - borderPaintInfo.getY1(); - if ((w < 0) || (h < 0)) { - log.error("Negative extent received. Border won't be painted."); - return; - } - - int pageWidth = dataStream.getCurrentPage().getWidth(); - int pageHeight = dataStream.getCurrentPage().getHeight(); - AFPUnitConverter unitConv = state.getUnitConverter(); - AffineTransform at = state.getData().getTransform(); - - float x1 = unitConv.pt2units(borderPaintInfo.getX1()); - float y1 = unitConv.pt2units(borderPaintInfo.getY1()); - float x2 = unitConv.pt2units(borderPaintInfo.getX2()); - float y2 = unitConv.pt2units(borderPaintInfo.getY2()); - - switch (state.getRotation()) { - case 0: - x1 += at.getTranslateX(); - y1 += at.getTranslateY(); - x2 += at.getTranslateX(); - y2 += at.getTranslateY(); - break; - case 90: - x1 += at.getTranslateY(); - y1 += (float) (pageWidth - at.getTranslateX()); - x2 += at.getTranslateY(); - y2 += (float) (pageWidth - at.getTranslateX()); - break; - case 180: - x1 += (float) (pageWidth - at.getTranslateX()); - y1 += (float) (pageHeight - at.getTranslateY()); - x2 += (float) (pageWidth - at.getTranslateX()); - y2 += (float) (pageHeight - at.getTranslateY()); - break; - case 270: - x1 = (float) (pageHeight - at.getTranslateY()); - y1 += (float) at.getTranslateX(); - x2 += x1; - y2 += (float) at.getTranslateX(); - break; - } - - AFPLineDataInfo lineDataInfo = new AFPLineDataInfo(); - lineDataInfo.setColor(borderPaintInfo.getColor()); - lineDataInfo.setRotation(state.getRotation()); - lineDataInfo.x1 = Math.round(x1); - lineDataInfo.y1 = Math.round(y1); - if (borderPaintInfo.isHorizontal()) { - lineDataInfo.setThickness(Math.round(y2 - y1)); - } else { - lineDataInfo.setThickness(Math.round(x2 - x1)); - } - - // handle border-*-style - switch (borderPaintInfo.getStyle()) { - case Constants.EN_DOUBLE: - if (borderPaintInfo.isHorizontal()) { - lineDataInfo.x2 = Math.round(x2); - lineDataInfo.y2 = lineDataInfo.y1; - dataStream.createLine(lineDataInfo); - lineDataInfo.y1 += Math.round((lineDataInfo.thickness / 3) * 2); - dataStream.createLine(lineDataInfo); - } else { - lineDataInfo.x2 = lineDataInfo.x1; - lineDataInfo.y2 = Math.round(y2); - dataStream.createLine(lineDataInfo); - lineDataInfo.x1 += Math.round((lineDataInfo.thickness / 3) * 2); - dataStream.createLine(lineDataInfo); - } - break; - case Constants.EN_DASHED: - int thick = lineDataInfo.thickness * 3; - if (borderPaintInfo.isHorizontal()) { - lineDataInfo.x2 = lineDataInfo.x1 + thick; - lineDataInfo.y2 = lineDataInfo.y1; - int ex2 = Math.round(x2); - while (lineDataInfo.x1 + thick < ex2) { - dataStream.createLine(lineDataInfo); - lineDataInfo.x1 += 2 * thick; - lineDataInfo.x2 = lineDataInfo.x1 + thick; - } - } else { - lineDataInfo.x2 = lineDataInfo.x1; - lineDataInfo.y2 = lineDataInfo.y1 + thick; - int ey2 = Math.round(y2); - while (lineDataInfo.y1 + thick < ey2) { - dataStream.createLine(lineDataInfo); - lineDataInfo.y1 += 2 * thick; - lineDataInfo.y2 = lineDataInfo.y1 + thick; - } - } - break; - case Constants.EN_DOTTED: - if (borderPaintInfo.isHorizontal()) { - lineDataInfo.x2 = lineDataInfo.x1 + lineDataInfo.thickness; - lineDataInfo.y2 = lineDataInfo.y1; - int ex2 = Math.round(x2); - while (lineDataInfo.x1 + lineDataInfo.thickness < ex2) { - dataStream.createLine(lineDataInfo); - lineDataInfo.x1 += 3 * lineDataInfo.thickness; - lineDataInfo.x2 = lineDataInfo.x1 + lineDataInfo.thickness; - } - } else { - lineDataInfo.x2 = lineDataInfo.x1; - lineDataInfo.y2 = lineDataInfo.y1 + lineDataInfo.thickness; - int ey2 = Math.round(y2); - while (lineDataInfo.y1 + lineDataInfo.thickness < ey2) { - dataStream.createLine(lineDataInfo); - lineDataInfo.y1 += 3 * lineDataInfo.thickness; - lineDataInfo.y2 = lineDataInfo.y1 + lineDataInfo.thickness; - } - } - break; - case Constants.EN_GROOVE: - case Constants.EN_RIDGE: - //TODO - lineDataInfo.x2 = Math.round(x2); - float colFactor = (borderPaintInfo.getStyle() == Constants.EN_GROOVE ? 0.4f : -0.4f); - float h3 = (y2 - y1) / 3; - lineDataInfo.color = ColorUtil.lightenColor(borderPaintInfo.getColor(), -colFactor); - lineDataInfo.thickness = Math.round(h3); - lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1); - dataStream.createLine(lineDataInfo); - lineDataInfo.color = borderPaintInfo.getColor(); - lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1 + h3); - dataStream.createLine(lineDataInfo); - lineDataInfo.color = ColorUtil.lightenColor(borderPaintInfo.getColor(), colFactor); - lineDataInfo.y1 = lineDataInfo.y2 = Math.round(y1 + h3 + h3); - dataStream.createLine(lineDataInfo); - break; - case Constants.EN_HIDDEN: - break; - case Constants.EN_INSET: - case Constants.EN_OUTSET: - case Constants.EN_SOLID: - default: - if (borderPaintInfo.isHorizontal()) { - lineDataInfo.x2 = Math.round(x2); - lineDataInfo.y2 = lineDataInfo.y1; - } else { - lineDataInfo.x2 = lineDataInfo.x1; - lineDataInfo.y2 = Math.round(y2); - } - dataStream.createLine(lineDataInfo); - } - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPConstants.java b/src/java/org/apache/fop/render/afp/AFPConstants.java deleted file mode 100644 index b9ab2de78..000000000 --- a/src/java/org/apache/fop/render/afp/AFPConstants.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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; - -/** - * Constants used by the AFP renderer. - * - */ -public interface AFPConstants { - - /** - * The encoding to use to convert to EBCIDIC - */ - String EBCIDIC_ENCODING = "Cp1146"; - - /** - * The encoding to use to convert to ASCII - */ - String ASCII_ENCODING = "Cp1252"; - - /** - * The encoding to use to convert to US ASCII (7 bit) - */ - String US_ASCII_ENCODING = "US-ASCII"; - - /** - * The scaling of the default transform is set to - * approximately 72 user space coordinates per square inch - */ - int DPI_72 = 72; - - /** - * 72dpi in millipoints - */ - int DPI_72_MPTS = DPI_72 * 1000; -} diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectFactory.java b/src/java/org/apache/fop/render/afp/AFPDataObjectFactory.java deleted file mode 100644 index f8e3c1518..000000000 --- a/src/java/org/apache/fop/render/afp/AFPDataObjectFactory.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * 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 java.awt.geom.Rectangle2D; - -import org.apache.fop.render.afp.ioca.ImageContent; -import org.apache.fop.render.afp.modca.AbstractDataObject; -import org.apache.fop.render.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.render.afp.modca.Document; -import org.apache.fop.render.afp.modca.Factory; -import org.apache.fop.render.afp.modca.GraphicsObject; -import org.apache.fop.render.afp.modca.ImageObject; -import org.apache.fop.render.afp.modca.IncludeObject; -import org.apache.fop.render.afp.modca.ObjectContainer; -import org.apache.fop.render.afp.modca.Overlay; -import org.apache.fop.render.afp.modca.PageSegment; -import org.apache.fop.render.afp.modca.Registry; -import org.apache.fop.render.afp.modca.ResourceObject; -import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet; -import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet; -import org.apache.xmlgraphics.image.codec.tiff.TIFFImage; -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; - -/** - * Factory for high level data objects (Image/Graphics etc) - */ -public class AFPDataObjectFactory { - - private final Factory factory; - - /** - * Main constructor - * - * @param factory an object factory - */ - public AFPDataObjectFactory(Factory factory) { - this.factory = factory; - } - - /** - * Creates and configures an ObjectContainer. - * - * @param dataObjectInfo the object container info - * @return a newly created Object Container - */ - public ObjectContainer createObjectContainer(AFPDataObjectInfo dataObjectInfo) { - ObjectContainer objectContainer = factory.createObjectContainer(); - - // set object classification - Registry.ObjectType objectType = dataObjectInfo.getObjectType(); - AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); - AFPResourceLevel resourceLevel = resourceInfo.getLevel(); - final boolean dataInContainer = true; - final boolean containerHasOEG = resourceLevel.isInline(); - final boolean dataInOCD = true; - objectContainer.setObjectClassification( - ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, - objectType, dataInContainer, containerHasOEG, dataInOCD); - - objectContainer.setInputStream(dataObjectInfo.getInputStream()); - return objectContainer; - } - - /** - * Creates and configures an IOCA Image Object. - * - * @param imageObjectInfo the image object info - * @return a newly created IOCA Image Object - */ - public ImageObject createImage(AFPImageObjectInfo imageObjectInfo) { - // IOCA bitmap image - ImageObject imageObj = factory.createImageObject(); - if (imageObjectInfo.hasCompression()) { - int compression = imageObjectInfo.getCompression(); - switch (compression) { - case TIFFImage.COMP_FAX_G3_1D: - imageObj.setEncoding(ImageContent.COMPID_G3_MH); - break; - case TIFFImage.COMP_FAX_G3_2D: - imageObj.setEncoding(ImageContent.COMPID_G3_MR); - break; - case TIFFImage.COMP_FAX_G4_2D: - imageObj.setEncoding(ImageContent.COMPID_G3_MMR); - break; - default: - throw new IllegalStateException( - "Invalid compression scheme: " + compression); - } - } - - if (imageObjectInfo.isColor()) { - imageObj.setIDESize((byte) 24); - } else { - imageObj.setIDESize((byte) imageObjectInfo.getBitsPerPixel()); - } - imageObj.setData(imageObjectInfo.getData()); - - return imageObj; - } - - /** - * Creates and returns a new graphics object. - * - * @param graphicsObjectInfo the graphics object info - * @return a new graphics object - */ - public GraphicsObject createGraphic(AFPGraphicsObjectInfo graphicsObjectInfo) { - // set newly created graphics object in g2d - GraphicsObject graphicsObj = factory.createGraphicsObject(); - AFPGraphics2D g2d = graphicsObjectInfo.getGraphics2D(); - g2d.setGraphicsObject(graphicsObj); - - // paint to graphics object - Graphics2DImagePainter painter = graphicsObjectInfo.getPainter(); - Rectangle2D area = graphicsObjectInfo.getArea(); - painter.paint(g2d, area); - - // return painted graphics object - return graphicsObj; - } - - /** - * Creates and returns a new include object. - * - * @param includeName the include name - * @param dataObjectInfo a data object info - * - * @return a new include object - */ - public IncludeObject createInclude(String includeName, AFPDataObjectInfo dataObjectInfo) { - IncludeObject includeObj = factory.createInclude(includeName); - - if (dataObjectInfo instanceof AFPImageObjectInfo) { - // IOCA image object - includeObj.setObjectType(IncludeObject.TYPE_IMAGE); - } else if (dataObjectInfo instanceof AFPGraphicsObjectInfo) { - // graphics object - includeObj.setObjectType(IncludeObject.TYPE_GRAPHIC); - } else { - // object container - includeObj.setObjectType(IncludeObject.TYPE_OTHER); - - // set mandatory object classification (type other) - Registry.ObjectType objectType = dataObjectInfo.getObjectType(); - if (objectType != null) { - // set object classification - final boolean dataInContainer = true; - final boolean containerHasOEG = false; // environment parameters set in include - final boolean dataInOCD = true; - includeObj.setObjectClassification( - // object scope not defined - ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT, - objectType, dataInContainer, containerHasOEG, dataInOCD); - } else { - throw new IllegalStateException( - "Failed to set Object Classification Triplet on Object Container."); - } - } - - AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - - int xOffset = objectAreaInfo.getX(); - int yOffset = objectAreaInfo.getY(); - includeObj.setObjectAreaOffset(xOffset, yOffset); - - int width = objectAreaInfo.getWidth(); - int height = objectAreaInfo.getHeight(); - includeObj.setObjectAreaSize(width, height); - - int rotation = objectAreaInfo.getRotation(); - includeObj.setObjectAreaOrientation(rotation); - - int widthRes = objectAreaInfo.getWidthRes(); - int heightRes = objectAreaInfo.getHeightRes(); - includeObj.setMeasurementUnits(widthRes, heightRes); - - includeObj.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT); - - return includeObj; - } - - /** - * Creates a resource object wrapper for named includable data objects - * - * @param namedObj an named object - * @param resourceInfo resource information - * @param objectType the object type - * @return a new resource object wrapper - */ - public ResourceObject createResource(AbstractNamedAFPObject namedObj, - AFPResourceInfo resourceInfo, Registry.ObjectType objectType) { - ResourceObject resourceObj = null; - String resourceName = resourceInfo.getName(); - if (resourceName != null) { - resourceObj = factory.createResource(resourceName); - } else { - resourceObj = factory.createResource(); - } - - if (namedObj instanceof Document) { - resourceObj.setType(ResourceObject.TYPE_DOCUMENT); - } else if (namedObj instanceof PageSegment) { - resourceObj.setType(ResourceObject.TYPE_PAGE_SEGMENT); - } else if (namedObj instanceof Overlay) { - resourceObj.setType(ResourceObject.TYPE_OVERLAY_OBJECT); - } else if (namedObj instanceof AbstractDataObject) { - AbstractDataObject dataObj = (AbstractDataObject)namedObj; - if (namedObj instanceof ObjectContainer) { - resourceObj.setType(ResourceObject.TYPE_OBJECT_CONTAINER); - - // set object classification - final boolean dataInContainer = true; - final boolean containerHasOEG = false; // must be included - final boolean dataInOCD = true; - // mandatory triplet for object container - resourceObj.setObjectClassification( - ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, - objectType, dataInContainer, containerHasOEG, dataInOCD); - } else if (namedObj instanceof ImageObject) { - // ioca image type - resourceObj.setType(ResourceObject.TYPE_IMAGE); - } else if (namedObj instanceof GraphicsObject) { - resourceObj.setType(ResourceObject.TYPE_GRAPHIC); - } else { - throw new UnsupportedOperationException( - "Unsupported resource object for data object type " + dataObj); - } - } else { - throw new UnsupportedOperationException( - "Unsupported resource object type " + namedObj); - } - - // set the resource information/classification on the data object - resourceObj.setDataObject(namedObj); - return resourceObj; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectInfo.java b/src/java/org/apache/fop/render/afp/AFPDataObjectInfo.java deleted file mode 100644 index cdd4b4d37..000000000 --- a/src/java/org/apache/fop/render/afp/AFPDataObjectInfo.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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 java.io.InputStream; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.modca.Registry; - -/** - * A list of parameters associated with an AFP data objects - */ -public class AFPDataObjectInfo { - private static final Log log = LogFactory.getLog("org.apache.fop.afp"); - - /** the object area info */ - private AFPObjectAreaInfo objectAreaInfo; - - /** resource info */ - private AFPResourceInfo resourceInfo; - - /** the data object width */ - private int dataWidth; - - /** the data object height */ - private int dataHeight; - - /** the object data in an inputstream */ - private InputStream inputStream; - - /** the object registry mimetype */ - private String mimeType; - - /** - * Default constructor - */ - public AFPDataObjectInfo() { - } - - /** - * Sets the image mime type - * - * @param mimeType the image mime type - */ - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } - - /** - * Returns the mime type of this data object - * - * @return the mime type of this data object - */ - public String getMimeType() { - return mimeType; - } - - /** - * Convenience method to return the object type - * - * @return the object type - */ - public Registry.ObjectType getObjectType() { - return Registry.getInstance().getObjectType(getMimeType()); - } - - /** - * Returns the resource level at which this data object should reside - * - * @return the resource level at which this data object should reside - */ - public AFPResourceInfo getResourceInfo() { - if (resourceInfo == null) { - this.resourceInfo = new AFPResourceInfo(); - } - return resourceInfo; - } - - /** - * Sets the resource level at which this object should reside - * - * @param resourceInfo the resource level at which this data object should reside - */ - public void setResourceInfo(AFPResourceInfo resourceInfo) { - this.resourceInfo = resourceInfo; - } - - /** - * Sets the object area info - * - * @param objectAreaInfo the object area info - */ - public void setObjectAreaInfo(AFPObjectAreaInfo objectAreaInfo) { - this.objectAreaInfo = objectAreaInfo; - } - - /** - * Returns the object area info - * - * @return the object area info - */ - public AFPObjectAreaInfo getObjectAreaInfo() { - return this.objectAreaInfo; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPDataObjectInfo{" - + "mimeType=" + mimeType - + ", dataWidth=" + dataWidth - + ", dataHeight=" + dataHeight - + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "") - + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : ""); - } - - /** - * Returns the uri of this data object - * - * @return the uri of this data object - */ - public String getUri() { - return getResourceInfo().getUri(); - } - - /** - * Sets the data object uri - * - * @param uri the data object uri - */ - public void setUri(String uri) { - getResourceInfo().setUri(uri); - } - - /** - * Returns the image data width - * - * @return the image data width - */ - public int getDataWidth() { - return dataWidth; - } - - /** - * Sets the image data width - * - * @param imageDataWidth the image data width - */ - public void setDataWidth(int imageDataWidth) { - this.dataWidth = imageDataWidth; - } - - /** - * Returns the image data height - * - * @return the image data height - */ - public int getDataHeight() { - return dataHeight; - } - - /** - * Sets the image data height - * - * @param imageDataHeight the image data height - */ - public void setDataHeight(int imageDataHeight) { - this.dataHeight = imageDataHeight; - } - - /** - * Sets the object data inputstream - * - * @param inputStream the object data inputstream - */ - public void setInputStream(InputStream inputStream) { - this.inputStream = inputStream; - } - - /** - * Returns the object data inputstream - * - * @return the object data inputstream - */ - public InputStream getInputStream() { - return this.inputStream; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java index a4979eb89..dcf074262 100644 --- a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java @@ -19,8 +19,18 @@ package org.apache.fop.render.afp; +import java.awt.Point; +import java.awt.geom.Rectangle2D; import java.io.IOException; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPForeignAttributeReader; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPUnitConverter; + + /** * Abstract image configurator */ @@ -47,33 +57,35 @@ public abstract class AFPDataObjectInfoFactory { /** * Configures the data object info * - * @param afpImageInfo the afp image info + * @param rendererImageInfo the afp image info * @return the data object info * @throws IOException thrown if an I/O exception of some sort has occurred. */ - public AFPDataObjectInfo create(AFPImageInfo afpImageInfo) throws IOException { + public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { AFPDataObjectInfo dataObjectInfo = createDataObjectInfo(); // set resource information AFPResourceInfo resourceInfo - = foreignAttributeReader.getResourceInfo(afpImageInfo.foreignAttributes); - resourceInfo.setUri(afpImageInfo.uri); + = foreignAttributeReader.getResourceInfo(rendererImageInfo.getForeignAttributes()); + resourceInfo.setUri(rendererImageInfo.getURI()); dataObjectInfo.setResourceInfo(resourceInfo); // set object area AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); - float srcX = afpImageInfo.origin.x + (float)afpImageInfo.pos.getX(); - float srcY = afpImageInfo.origin.y + (float)afpImageInfo.pos.getY(); + Point origin = rendererImageInfo.getOrigin(); + Rectangle2D position = rendererImageInfo.getPosition(); + float srcX = origin.x + (float)position.getX(); + float srcY = origin.y + (float)position.getY(); AFPUnitConverter unitConv = state.getUnitConverter(); int[] coords = unitConv.mpts2units(new float[] {srcX, srcY}); objectAreaInfo.setX(coords[X]); objectAreaInfo.setY(coords[Y]); - int width = Math.round(unitConv.mpt2units((float)afpImageInfo.pos.getWidth())); + int width = Math.round(unitConv.mpt2units((float)position.getWidth())); objectAreaInfo.setWidth(width); - int height = Math.round(unitConv.mpt2units((float)afpImageInfo.pos.getHeight())); + int height = Math.round(unitConv.mpt2units((float)position.getHeight())); objectAreaInfo.setHeight(height); int resolution = state.getResolution(); diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java index b54479e53..4211fe360 100644 --- a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java +++ b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java @@ -22,6 +22,7 @@ package org.apache.fop.render.afp; import java.util.Iterator; import java.util.Map; +import org.apache.fop.afp.AFPState; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; diff --git a/src/java/org/apache/fop/render/afp/AFPFontAttributes.java b/src/java/org/apache/fop/render/afp/AFPFontAttributes.java deleted file mode 100644 index ffbc85046..000000000 --- a/src/java/org/apache/fop/render/afp/AFPFontAttributes.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.render.afp.fonts.AFPFont; - -/** - * This class encapsulates the font attributes that need to be included - * in the AFP data stream. This class does not assist in converting the - * font attributes to AFP code pages and character set values. - * - */ -public class AFPFontAttributes { - - /** - * The font reference - */ - private int fontReference; - - /** - * The font key - */ - private String fontKey; - - /** - * The font - */ - private AFPFont font; - - /** - * The point size - */ - private int pointSize; - - /** - * Constructor for the AFPFontAttributes - * @param fontKey the font key - * @param font the font - * @param pointSize the point size - */ - public AFPFontAttributes(String fontKey, AFPFont font, int pointSize) { - this.fontKey = fontKey; - this.font = font; - this.pointSize = pointSize; - } - - /** - * @return the font - */ - public AFPFont getFont() { - return font; - } - - /** - * @return the FontKey attribute - */ - public String getFontKey() { - return fontKey + pointSize; - } - - /** - * @return the point size attribute - */ - public int getPointSize() { - return pointSize; - } - - /** - * @return the FontReference attribute - */ - public int getFontReference() { - return fontReference; - } - - /** - * Sets the FontReference attribute - * @param fontReference the FontReference to set - */ - public void setFontReference(int fontReference) { - this.fontReference = fontReference; - } - - /** {@inheritDoc} */ - public String toString() { - return "fontReference=" + fontReference - + ", fontKey=" + fontKey - + ", font=" + font - + ", pointSize=" + pointSize; - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java b/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java deleted file mode 100644 index 4d5d4c1db..000000000 --- a/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 java.io.File; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.extensions.AFPElementMapping; -import org.apache.xmlgraphics.util.QName; - -/** - * Parses any AFP foreign attributes - */ -public class AFPForeignAttributeReader { - private static final Log log = LogFactory.getLog("org.apache.fop.afp"); - - /** the resource-name attribute */ - public static final String RESOURCE_NAME = "afp:resource-name"; - - /** the resource-level attribute */ - public static final String RESOURCE_LEVEL = "afp:resource-level"; - - /** the resource-group-file attribute */ - public static final String RESOURCE_GROUP_FILE = "afp:resource-group-file"; - - /** - * Main constructor - */ - public AFPForeignAttributeReader() { - } - - /** - * Returns the resource information - * - * @param foreignAttributes the foreign attributes - * @return the resource information - */ - public AFPResourceInfo getResourceInfo(Map/**/ foreignAttributes) { - AFPResourceInfo resourceInfo = new AFPResourceInfo(); - if (foreignAttributes != null && !foreignAttributes.isEmpty()) { - QName resourceNameKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_NAME); - String resourceName = (String)foreignAttributes.get(resourceNameKey); - if (resourceName != null) { - resourceInfo.setName(resourceName); - } - AFPResourceLevel level = getResourceLevel(foreignAttributes); - if (level != null) { - resourceInfo.setLevel(level); - } - } - return resourceInfo; - } - - /** - * Returns the resource level - * - * @param foreignAttributes the foreign attributes - * @return the resource level - */ - public AFPResourceLevel getResourceLevel(Map/**/ foreignAttributes) { - AFPResourceLevel resourceLevel = null; - if (foreignAttributes != null && !foreignAttributes.isEmpty()) { - QName resourceLevelKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_LEVEL); - if (foreignAttributes.containsKey(resourceLevelKey)) { - String levelString = (String)foreignAttributes.get(resourceLevelKey); - resourceLevel = AFPResourceLevel.valueOf(levelString); - // if external get resource group file attributes - if (resourceLevel != null && resourceLevel.isExternal()) { - QName resourceGroupFileKey = new QName(AFPElementMapping.NAMESPACE, - RESOURCE_GROUP_FILE); - String resourceGroupFile - = (String)foreignAttributes.get(resourceGroupFileKey); - if (resourceGroupFile == null) { - String msg = RESOURCE_GROUP_FILE + " not specified"; - log.error(msg); - throw new UnsupportedOperationException(msg); - } - File resourceExternalGroupFile = new File(resourceGroupFile); - SecurityManager security = System.getSecurityManager(); - try { - if (security != null) { - security.checkWrite(resourceExternalGroupFile.getPath()); - } - } catch (SecurityException ex) { - String msg = "unable to gain write access to external resource file: " - + resourceGroupFile; - log.error(msg); - } - - try { - boolean exists = resourceExternalGroupFile.exists(); - if (exists) { - log.warn("overwriting external resource file: " - + resourceGroupFile); - } - resourceLevel.setExternalFilePath(resourceGroupFile); - } catch (SecurityException ex) { - String msg = "unable to gain read access to external resource file: " - + resourceGroupFile; - log.error(msg); - } - } - } - } - return resourceLevel; - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPGraphics2D.java deleted file mode 100644 index 9acf76873..000000000 --- a/src/java/org/apache/fop/render/afp/AFPGraphics2D.java +++ /dev/null @@ -1,582 +0,0 @@ -/* - * 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 java.awt.AlphaComposite; -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.GraphicsConfiguration; -import java.awt.Image; -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.AffineTransform; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Line2D; -import java.awt.geom.PathIterator; -import java.awt.geom.Rectangle2D; -import java.awt.image.BufferedImage; -import java.awt.image.ImageObserver; -import java.awt.image.RenderedImage; -import java.awt.image.renderable.RenderableImage; -import java.io.IOException; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.ImageSize; -import org.apache.xmlgraphics.image.loader.impl.ImageRendered; -import org.apache.xmlgraphics.java2d.AbstractGraphics2D; -import org.apache.xmlgraphics.java2d.GraphicContext; -import org.apache.xmlgraphics.java2d.StrokingTextHandler; -import org.apache.xmlgraphics.java2d.TextHandler; -import org.apache.xmlgraphics.ps.ImageEncodingHelper; - -import org.apache.fop.apps.MimeConstants; -import org.apache.fop.render.afp.goca.GraphicsSetLineType; -import org.apache.fop.render.afp.modca.GraphicsObject; - -/** - * This is a concrete implementation of AbstractGraphics2D (and - * therefore of Graphics2D) which is able to generate GOCA byte - * codes. - * - * @see org.apache.xmlgraphics.java2d.AbstractGraphics2D - */ -public class AFPGraphics2D extends AbstractGraphics2D { - - private static final Log log = LogFactory.getLog(AFPGraphics2D.class); - - private static final int X = 0; - - private static final int Y = 1; - - private static final int X1 = 0; - - private static final int Y1 = 1; - - private static final int X2 = 2; - - private static final int Y2 = 3; - - - /** graphics object */ - private GraphicsObject graphicsObj = null; - - /** Fallback text handler */ - protected TextHandler fallbackTextHandler = new StrokingTextHandler(this); - - /** Custom text handler */ - protected TextHandler customTextHandler = null; - - /** AFP info */ - private AFPInfo info = null; - - /** Current AFP state */ - private AFPState state = null; - - /** - * Main constructor - * - * @param textAsShapes - * if true, all text is turned into shapes in the convertion. No - * text is output. - * - */ - public AFPGraphics2D(boolean textAsShapes) { - super(textAsShapes); - } - - /** - * Copy Constructor - * - * @param g2d - * a AFPGraphics2D whose properties should be copied - */ - public AFPGraphics2D(AFPGraphics2D g2d) { - super(g2d); - this.graphicsObj = g2d.graphicsObj; - this.fallbackTextHandler = g2d.fallbackTextHandler; - this.customTextHandler = g2d.customTextHandler; - this.info = g2d.info; - this.state = g2d.state; - } - - /** - * Sets the AFPInfo - * - * @param afpInfo the AFP Info to use - */ - public void setAFPInfo(AFPInfo afpInfo) { - this.info = afpInfo; - this.state = info.getState(); - } - - /** - * Gets the AFPInfo - * - * @return the AFPInfo - */ - public AFPInfo getAFPInfo() { - return this.info; - } - - /** - * Sets the GraphicContext - * - * @param gc - * GraphicContext to use - */ - public void setGraphicContext(GraphicContext gc) { - this.gc = gc; - } - - /** - * Apply the stroke to the AFP graphics object. - * This takes the java stroke and outputs the appropriate settings - * to the AFP graphics object so that the stroke attributes are handled. - * - * @param stroke the java stroke - */ - protected void applyStroke(Stroke stroke) { - if (stroke instanceof BasicStroke) { - BasicStroke basicStroke = (BasicStroke) stroke; - float lineWidth = basicStroke.getLineWidth(); - if (state.setLineWidth(lineWidth)) { - getGraphicsObject().setLineWidth(Math.round(lineWidth * 2)); - } - // note: this is an approximation at best! - float[] dashArray = basicStroke.getDashArray(); - if (state.setDashArray(dashArray)) { - byte type = GraphicsSetLineType.DEFAULT; // normally SOLID - if (dashArray != null) { - type = GraphicsSetLineType.DOTTED; // default to plain DOTTED if dashed line - // float offset = basicStroke.getDashPhase(); - if (dashArray.length == 2) { - if (dashArray[0] < dashArray[1]) { - type = GraphicsSetLineType.SHORT_DASHED; - } else if (dashArray[0] > dashArray[1]) { - type = GraphicsSetLineType.LONG_DASHED; - } - } else if (dashArray.length == 4) { - if (dashArray[0] > dashArray[1] - && dashArray[2] < dashArray[3]) { - type = GraphicsSetLineType.DASH_DOT; - } else if (dashArray[0] < dashArray[1] - && dashArray[2] < dashArray[3]) { - type = GraphicsSetLineType.DOUBLE_DOTTED; - } - } else if (dashArray.length == 6) { - if (dashArray[0] > dashArray[1] - && dashArray[2] < dashArray[3] - && dashArray[4] < dashArray[5]) { - type = GraphicsSetLineType.DASH_DOUBLE_DOTTED; - } - } - } - getGraphicsObject().setLineType(type); - } - } else { - log.warn("Unsupported Stroke: " + stroke.getClass().getName()); - } - } - - /** - * Handle the Batik drawing event - * - * @param shape - * the shape to draw - * @param fill - * true if the shape is to be drawn filled - */ - private void doDrawing(Shape shape, boolean fill) { - getGraphicsObject(); - if (!fill) { - graphicsObj.newSegment(); - } - - Color color = getColor(); - if (state.setColor(color)) { - graphicsObj.setColor(color); - } - - Stroke stroke = getStroke(); - applyStroke(stroke); - - if (fill) { - graphicsObj.beginArea(); - } - AffineTransform trans = super.getTransform(); - - PathIterator iter = shape.getPathIterator(trans); - double[] dstPts = new double[6]; - int[] coords = null; - if (shape instanceof Line2D) { - iter.currentSegment(dstPts); - coords = new int[4]; - coords[X1] = (int) Math.round(dstPts[X]); - coords[Y1] = (int) Math.round(dstPts[Y]); - iter.next(); - iter.currentSegment(dstPts); - coords[X2] = (int) Math.round(dstPts[X]); - coords[Y2] = (int) Math.round(dstPts[Y]); - graphicsObj.addLine(coords); - } else if (shape instanceof Rectangle2D) { - iter.currentSegment(dstPts); - coords = new int[4]; - coords[X2] = (int) Math.round(dstPts[X]); - coords[Y2] = (int) Math.round(dstPts[Y]); - iter.next(); - iter.next(); - iter.currentSegment(dstPts); - coords[X1] = (int) Math.round(dstPts[X]); - coords[Y1] = (int) Math.round(dstPts[Y]); - graphicsObj.addBox(coords); - } else if (shape instanceof Ellipse2D) { - Ellipse2D elip = (Ellipse2D) shape; - double scale = trans.getScaleX(); - double radiusWidth = elip.getWidth() / 2; - double radiusHeight = elip.getHeight() / 2; - graphicsObj.setArcParams( - (int)Math.round(radiusWidth * scale), - (int)Math.round(radiusHeight * scale), - 0, - 0 - ); - double[] srcPts = new double[] {elip.getCenterX(), elip.getCenterY()}; - trans.transform(srcPts, 0, dstPts, 0, 1); - final int mh = 1; - final int mhr = 0; - graphicsObj.addFullArc( - (int)Math.round(dstPts[X]), - (int)Math.round(dstPts[Y]), - mh, - mhr - ); - } else { - // graphics segment opening coordinates (x,y) - // current position coordinates (x,y) - for (int[] openingCoords = new int[2], currCoords = new int[2]; - !iter.isDone(); iter.next()) { - // round the coordinate values and combine with current position - // coordinates - int type = iter.currentSegment(dstPts); - if (type == PathIterator.SEG_MOVETO) { - openingCoords[X] = currCoords[X] = (int)Math.round(dstPts[X]); - openingCoords[Y] = currCoords[Y] = (int)Math.round(dstPts[Y]); - } else { - int numCoords; - if (type == PathIterator.SEG_LINETO) { - numCoords = 2; - } else if (type == PathIterator.SEG_QUADTO) { - numCoords = 4; - } else if (type == PathIterator.SEG_CUBICTO) { - numCoords = 6; - } else { - // close of the graphics segment - if (type == PathIterator.SEG_CLOSE) { - coords = new int[] { - coords[coords.length - 2], //prev X - coords[coords.length - 1], //prev Y - openingCoords[X], - openingCoords[Y] - }; - graphicsObj.addLine(coords); - } else { - log.debug("Unrecognised path iterator type: " - + type); - } - continue; - } - // combine current position coordinates with new graphics - // segment coordinates - coords = new int[numCoords + 2]; - coords[X] = currCoords[X]; - coords[Y] = currCoords[Y]; - for (int i = 0; i < numCoords; i++) { - coords[i + 2] = (int) Math.round(dstPts[i]); - } - if (type == PathIterator.SEG_LINETO) { - graphicsObj.addLine(coords); - } else if (type == PathIterator.SEG_QUADTO - || type == PathIterator.SEG_CUBICTO) { - graphicsObj.addFillet(coords); - } - // update current position coordinates - currCoords[X] = coords[coords.length - 2]; - currCoords[Y] = coords[coords.length - 1]; - } - } - } - if (fill) { - graphicsObj.endArea(); - } - } - - /** {@inheritDoc} */ - public void draw(Shape shape) { -// log.debug("draw() shape=" + shape); - doDrawing(shape, false); - } - - /** {@inheritDoc} */ - public void fill(Shape shape) { -// log.debug("fill() shape=" + shape); - doDrawing(shape, true); - } - - /** - * Central handler for IOExceptions for this class. - * - * @param ioe - * IOException to handle - */ - public void handleIOException(IOException ioe) { - // TODO Surely, there's a better way to do this. - log.error(ioe.getMessage()); - ioe.printStackTrace(); - } - - /** {@inheritDoc} */ - public void drawString(String str, float x, float y) { - try { - if (customTextHandler != null && !textAsShapes) { - customTextHandler.drawString(str, x, y); - } else { - fallbackTextHandler.drawString(str, x, y); - } - } catch (IOException ioe) { - handleIOException(ioe); - } - } - - /** {@inheritDoc} */ - public GraphicsConfiguration getDeviceConfiguration() { - return new AFPGraphicsConfiguration(); - } - - /** {@inheritDoc} */ - public void copyArea(int x, int y, int width, int height, int dx, int dy) { - log.debug("copyArea() NYI: "); - } - - /** {@inheritDoc} */ - public Graphics create() { - return new AFPGraphics2D(this); - } - - /** {@inheritDoc} */ - public void dispose() { - this.graphicsObj = null; - } - - /** {@inheritDoc} */ - public boolean drawImage(Image img, int x, int y, ImageObserver observer) { - return drawImage(img, x, y, img.getWidth(observer), img.getHeight(observer), observer); - } - - private BufferedImage buildBufferedImage(Dimension size) { - return new BufferedImage(size.width, size.height, - BufferedImage.TYPE_INT_ARGB); - } - - private AFPImageObjectInfo getImageObjectInfo( - RenderedImage img, int x, int y, int width, int height) throws IOException { - ImageInfo imageInfo = new ImageInfo(null, "image/unknown"); - ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), 72); - imageInfo.setSize(size); - - ImageRendered imageRendered = new ImageRendered(imageInfo, img, null); - RenderedImage renderedImage = imageRendered.getRenderedImage(); - - // create image object info - AFPImageObjectInfo imageObjectInfo = new AFPImageObjectInfo(); - - imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); - - imageObjectInfo.setBitsPerPixel(state.getBitsPerPixel()); - - imageObjectInfo.setResourceInfo(info.getResourceInfo()); - - int dataHeight = renderedImage.getHeight(); - imageObjectInfo.setDataHeight(dataHeight); - - int dataWidth = renderedImage.getWidth(); - imageObjectInfo.setDataWidth(dataWidth); - - boolean colorImages = state.isColorImages(); - imageObjectInfo.setColor(colorImages); - - ByteArrayOutputStream boas = new ByteArrayOutputStream(); - ImageEncodingHelper.encodeRenderedImageAsRGB(renderedImage, boas); - byte[] imageData = boas.toByteArray(); - - // convert to grayscale - if (!colorImages) { - boas.reset(); - int bitsPerPixel = state.getBitsPerPixel(); - imageObjectInfo.setBitsPerPixel(bitsPerPixel); - ImageEncodingHelper.encodeRGBAsGrayScale( - imageData, dataWidth, dataHeight, bitsPerPixel, boas); - imageData = boas.toByteArray(); - } - imageObjectInfo.setData(imageData); - - if (imageInfo != null) { - imageObjectInfo.setUri(imageInfo.getOriginalURI()); - } - - // create object area info - AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); - - AffineTransform at = gc.getTransform(); - float[] srcPts = new float[] {x, y}; - float[] dstPts = new float[srcPts.length]; - at.transform(srcPts, 0, dstPts, 0, 1); - objectAreaInfo.setX(Math.round(dstPts[X])); - objectAreaInfo.setY(Math.round(dstPts[Y])); - - AFPUnitConverter unitConv = state.getUnitConverter(); - - int w = Math.round(unitConv.pt2units(width)); - objectAreaInfo.setWidth(w); - - int h = Math.round(unitConv.pt2units(height)); - objectAreaInfo.setHeight(h); - - int resolution = state.getResolution(); - objectAreaInfo.setWidthRes(resolution); - objectAreaInfo.setHeightRes(resolution); - - imageObjectInfo.setObjectAreaInfo(objectAreaInfo); - - return imageObjectInfo; - } - - /** {@inheritDoc} */ - public boolean drawImage(Image img, int x, int y, int width, int height, - ImageObserver observer) { - - // draw with AWT Graphics2D - Dimension size = new Dimension(width, height); - BufferedImage bufferedImage = buildBufferedImage(size); - - java.awt.Graphics2D g2d = bufferedImage.createGraphics(); - g2d.setComposite(AlphaComposite.SrcOver); - - Color color = new Color(1, 1, 1, 0); - g2d.setBackground(color); - g2d.setPaint(color); - - g2d.fillRect(0, 0, width, height); - - int bufferedWidth = bufferedImage.getWidth(); - int bufferedHeight = bufferedImage.getHeight(); - Rectangle clipRect = new Rectangle(0, 0, bufferedWidth, bufferedHeight); - g2d.clip(clipRect); - - g2d.setComposite(gc.getComposite()); - - boolean drawn = g2d.drawImage(img, 0, 0, bufferedWidth, bufferedHeight, observer); - g2d.dispose(); - - if (drawn) { - try { - // get image object info - AFPImageObjectInfo imageObjectInfo = getImageObjectInfo(bufferedImage, x, y, width, height); - - // create image resource - AFPResourceManager resourceManager = info.getResourceManager(); - resourceManager.createObject(imageObjectInfo); - return true; - } catch (IOException ioe) { - handleIOException(ioe); - } - } - return false; - } - - /** {@inheritDoc} */ - public void drawRenderableImage(RenderableImage img, AffineTransform xform) { - log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform); - } - - /** {@inheritDoc} */ - public void drawRenderedImage(RenderedImage img, AffineTransform xform) { - log.debug("drawRenderedImage() NYI: img=" + img + ", xform=" + xform); - } - - /** {@inheritDoc} */ - public FontMetrics getFontMetrics(Font f) { - log.debug("getFontMetrics() NYI: f=" + f); - return null; - } - - /** {@inheritDoc} */ - public void setXORMode(Color col) { - log.debug("setXORMode() NYI: col=" + col); - } - - /** - * Sets a custom TextHandler implementation that is responsible for painting - * text. The default TextHandler paints all text as shapes. A custom - * implementation can implement text painting using text painting operators. - * - * @param handler - * the custom TextHandler implementation - */ - public void setCustomTextHandler(TextHandler handler) { - this.customTextHandler = handler; - } - - /** - * Returns the GOCA graphics object - * - * @return the GOCA graphics object - */ - protected GraphicsObject getGraphicsObject() { - return this.graphicsObj; - } - - /** - * Sets the GOCA graphics object - * - * @param obj the GOCA graphics object - */ - public void setGraphicsObject(GraphicsObject obj) { - this.graphicsObj = obj; - } - - /** - * Sets the AFP state - * - * @param state the AFP state - */ - protected void setState(AFPState state) { - this.state = state; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java index 6561902d9..453e16429 100644 --- a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java @@ -25,6 +25,10 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.IOException; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.afp.AFPGraphicsObjectInfo; +import org.apache.fop.afp.AFPResourceManager; +import org.apache.fop.afp.AFPState; import org.apache.fop.render.AbstractGraphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContext.RendererContextWrapper; @@ -56,7 +60,7 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { * * @return the AFP graphics 2D implementation */ - protected AFPGraphics2D getGraphics2D() { + public AFPGraphics2D getGraphics2D() { return g2d; } @@ -70,11 +74,12 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(context); - g2d.setAFPInfo(afpInfo); + g2d.setResourceManager(afpInfo.getResourceManager()); + g2d.setResourceInfo(afpInfo.getResourceInfo()); + g2d.setState(afpInfo.getState()); g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); // // scale/convert to afp units - AFPState state = afpInfo.getState(); // AFPUnitConverter unitConv = state.getUnitConverter(); // float scale = unitConv.mpt2units(1); @@ -96,6 +101,7 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { RendererContextWrapper ctx = RendererContext.wrapRendererContext(context); BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false); + AFPState state = afpInfo.getState(); AffineTransform trans = state.getData().getTransform(); float scale = AFPRenderer.NORMAL_AFP_RESOLUTION / context.getUserAgent().getTargetResolution(); diff --git a/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java b/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java deleted file mode 100644 index 1f40b7cfd..000000000 --- a/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 java.awt.GraphicsDevice; -import java.awt.Rectangle; -import java.awt.Transparency; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.awt.image.ColorModel; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.svg.GraphicsConfiguration; - -/** - * Our implementation of the class that returns information about - * roughly what we can handle and want to see (alpha for example). - */ -public class AFPGraphicsConfiguration extends GraphicsConfiguration { - // We use this to get a good colormodel.. - private static final BufferedImage BI_WITH_ALPHA - = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); - // We use this to get a good colormodel.. - private static final BufferedImage BI_WITHOUT_ALPHA - = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); - - /** - * Construct a buffered image with an alpha channel, unless - * transparencty is OPAQUE (no alpha at all). - * - * @param width the width of the image - * @param height the height of the image - * @param transparency the alpha value of the image - * @return the new buffered image - */ - public BufferedImage createCompatibleImage(int width, int height, - int transparency) { - if (transparency == Transparency.OPAQUE) { - return new BufferedImage(width, height, - BufferedImage.TYPE_INT_RGB); - } else { - return new BufferedImage(width, height, - BufferedImage.TYPE_INT_ARGB); - } - } - - /** - * Construct a buffered image with an alpha channel. - * - * @param width the width of the image - * @param height the height of the image - * @return the new buffered image - */ - public BufferedImage createCompatibleImage(int width, int height) { - return new BufferedImage(width, height, - BufferedImage.TYPE_INT_ARGB); - } - - /** - * TODO: This should return the page bounds in Pts, - * I couldn't figure out how to get this for the current - * page from the PDFDocument (this still works for now, - * but it should be fixed...). - * - * @return the bounds of the PDF document page - */ - public Rectangle getBounds() { - return null; - } - - /** - * Return a good default color model for this 'device'. - * @return the colour model for the configuration - */ - public ColorModel getColorModel() { - return BI_WITH_ALPHA.getColorModel(); - } - - /** - * Return a good color model given transparency - * - * @param transparency the alpha value for the colour model - * @return the colour model for the configuration - */ - public ColorModel getColorModel(int transparency) { - if (transparency == Transparency.OPAQUE) { - return BI_WITHOUT_ALPHA.getColorModel(); - } else { - return BI_WITH_ALPHA.getColorModel(); - } - } - - private static final Log log = LogFactory.getLog(AFPGraphicsConfiguration.class); - - private AffineTransform defaultTransform = null; - private AffineTransform normalizingTransform = null; - private GraphicsDevice graphicsDevice = null; - - /** - * The default transform (1:1). - * - * @return the default transform for the configuration - */ - public AffineTransform getDefaultTransform() { - log.debug("getDefaultTransform()"); - if (defaultTransform == null) { - defaultTransform = new AffineTransform(); - } - return defaultTransform; - } - - /** - * The normalizing transform (1:1) (since we currently - * render images at 72dpi, which we might want to change - * in the future). - * - * @return the normalizing transform for the configuration - */ - public AffineTransform getNormalizingTransform() { - log.debug("getNormalizingTransform()"); - if (normalizingTransform == null) { - normalizingTransform = new AffineTransform(2, 0, 0, 2, 0, 0); - } - return normalizingTransform; - } - - /** - * {@inheritDoc} - */ - public GraphicsDevice getDevice() { - log.debug("getDevice()"); - if (graphicsDevice == null) { - graphicsDevice = new AFPGraphicsDevice(this); - } - return graphicsDevice; - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java b/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java deleted file mode 100644 index d4c756a5a..000000000 --- a/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; - -/** - * This implements the GraphicsDevice interface as appropriate for - * an AFPGraphics2D. - */ -public class AFPGraphicsDevice extends GraphicsDevice { - - /** - * The Graphics Config that created us... - */ - protected GraphicsConfiguration gc; - - /** - * Create a new AF{ graphics device. - * - * @param gc The graphics configuration we should reference - */ - public AFPGraphicsDevice(AFPGraphicsConfiguration gc) { - this.gc = gc; - } - - /** - * Return an array of our one GraphicsConfig - * - * @return an array containing the one graphics configuration - */ - public GraphicsConfiguration[] getConfigurations() { - return new GraphicsConfiguration[] {gc}; - } - - /** - * Return out sole GraphicsConfig. - * - * @return the graphics configuration that created this object - */ - public GraphicsConfiguration getDefaultConfiguration() { - return this.gc; - } - - /** - * Generate an IdString.. - * - * @return the ID string for this device, uses toString - */ - public String getIDstring() { - return toString(); - } - - /** - * Let the caller know that we are "a printer" - * - * @return the type which is always printer - */ - public int getType() { - return GraphicsDevice.TYPE_PRINTER; - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPGraphicsObjectInfo.java b/src/java/org/apache/fop/render/afp/AFPGraphicsObjectInfo.java deleted file mode 100644 index b4c651574..000000000 --- a/src/java/org/apache/fop/render/afp/AFPGraphicsObjectInfo.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 java.awt.geom.Rectangle2D; - -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; -import org.apache.xmlgraphics.util.MimeConstants; - -/** - * A graphics object info which contains necessary painting objects - */ -public class AFPGraphicsObjectInfo extends AFPDataObjectInfo { - - /** the graphics object painter implementation */ - private Graphics2DImagePainter painter; - - /** the graphics object area */ - private Rectangle2D area; - - /** the AFP graphics 2d implementation */ - private AFPGraphics2D g2d; - - /** - * Returns the graphics painter - * - * @return the graphics painter - */ - public Graphics2DImagePainter getPainter() { - return this.painter; - } - - /** - * Sets the graphics painter - * - * @param graphicsPainter the graphics painter - */ - public void setPainter(Graphics2DImagePainter graphicsPainter) { - this.painter = graphicsPainter; - } - - /** - * Returns the graphics area - * - * @return the graphics area - */ - public Rectangle2D getArea() { - return this.area; - } - - /** - * Sets the graphics area area - * - * @param area the graphics object area - */ - public void setArea(Rectangle2D area) { - this.area = area; - } - - /** - * Sets the AFP graphics 2D implementation - * - * @param g2d the AFP graphics 2D implementation - */ - public void setGraphics2D(AFPGraphics2D g2d) { - this.g2d = g2d; - } - - /** - * Returns the AFP graphics 2D implementation - * - * @return the AFP graphics 2D implementation - */ - public AFPGraphics2D getGraphics2D() { - return this.g2d; - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsObjectInfo{" + super.toString() + "}"; - } - - /** {@inheritDoc} */ - public String getMimeType() { - return MimeConstants.MIME_SVG; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java b/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java index ab9cf7ef7..d76e26d57 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java @@ -26,7 +26,16 @@ import java.awt.geom.Rectangle2D; import java.io.IOException; import org.apache.batik.bridge.BridgeContext; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.afp.AFPGraphicsObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceLevel; +import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPTextHandler; import org.apache.fop.image.loader.batik.GenericGraphics2DImagePainter; +import org.apache.fop.render.RendererContext; import org.apache.fop.svg.SVGUserAgent; import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; import org.apache.xmlgraphics.util.MimeConstants; @@ -54,9 +63,9 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { private static final AFPResourceLevel inlineResourceLevel = new AFPResourceLevel(AFPResourceLevel.INLINE); /** {@inheritDoc} */ - public AFPDataObjectInfo create(AFPImageInfo afpImageInfo) throws IOException { + public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { AFPGraphicsObjectInfo graphicsObjectInfo - = (AFPGraphicsObjectInfo)super.create(afpImageInfo); + = (AFPGraphicsObjectInfo)super.create(rendererImageInfo); AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo(); // level not explicitly set/changed so default to inline for GOCA graphic objects @@ -69,13 +78,17 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { graphicsObjectInfo.setMimeType(MimeConstants.MIME_AFP_GOCA); // set graphics 2d - AFPGraphics2DAdapter g2dAdapter = afpImageInfo.g2dAdapter; + AFPGraphics2DAdapter g2dAdapter = rendererImageInfo.getGraphics2DAdapter(); AFPGraphics2D g2d = g2dAdapter.getGraphics2D(); graphicsObjectInfo.setGraphics2D(g2d); - // set afp info - AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(afpImageInfo.rendererContext); - g2d.setAFPInfo(afpInfo); + // set resource, state and font info + RendererContext rendererContext = rendererImageInfo.getRendererContext(); + AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(rendererContext); + g2d.setResourceManager(afpInfo.getResourceManager()); + g2d.setResourceInfo(afpInfo.getResourceInfo()); + g2d.setState(afpInfo.getState()); + g2d.setFontInfo(afpInfo.getFontInfo()); // set to default graphic context g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); @@ -89,7 +102,7 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { // controls whether text painted by Batik is generated using text or path operations SVGUserAgent svgUserAgent - = new SVGUserAgent(afpImageInfo.rendererContext.getUserAgent(), new AffineTransform()); + = new SVGUserAgent(rendererContext.getUserAgent(), new AffineTransform()); BridgeContext ctx = new BridgeContext(svgUserAgent); if (!afpInfo.strokeText()) { AFPTextHandler textHandler = new AFPTextHandler(g2d); @@ -101,7 +114,7 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { } // set painter - ImageGraphics2D imageG2D = (ImageGraphics2D)afpImageInfo.img; + ImageGraphics2D imageG2D = (ImageGraphics2D)rendererImageInfo.getImage(); GenericGraphics2DImagePainter painter = (GenericGraphics2DImagePainter)imageG2D.getGraphics2DImagePainter(); painter = new AFPGraphics2DImagePainter(painter); diff --git a/src/java/org/apache/fop/render/afp/AFPImageInfo.java b/src/java/org/apache/fop/render/afp/AFPImageInfo.java deleted file mode 100644 index 9acc87b3f..000000000 --- a/src/java/org/apache/fop/render/afp/AFPImageInfo.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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 java.awt.Point; -import java.awt.geom.Rectangle2D; -import java.util.Map; - -import org.apache.fop.render.RendererContext; -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageInfo; - -/** - * The AFP image information - */ -public class AFPImageInfo { - - /** the image uri */ - protected final String uri; - - /** the current pos */ - protected final Rectangle2D pos; - - /** the origin */ - protected final Point origin; - - /** the foreign attributes */ - protected final Map foreignAttributes; - - /** the image info */ - protected final ImageInfo info; - - /** the image */ - protected final Image img; - - /** the AFP graphics 2d adapter */ - protected AFPGraphics2DAdapter g2dAdapter; - - /** the renderer context */ - protected RendererContext rendererContext; - - /** - * Main constructor - * - * @param uri the image uri - * @param pos the image content area - * @param origin the current position - * @param info the image info - * @param img the image - * @param foreignAttributes the foreign attributes - */ - public AFPImageInfo(String uri, Rectangle2D pos, Point origin, - ImageInfo info, Image img, Map foreignAttributes) { - this.uri = uri; - this.pos = pos; - this.origin = origin; - this.info = info; - this.img = img; - this.foreignAttributes = foreignAttributes; - } - - /** - * Sets the renderer context - * - * @param rendererContext the renderer context - */ - public void setRendererContext(RendererContext rendererContext) { - this.rendererContext = rendererContext; - } - - /** - * Sets the graphics 2d adapter - * - * @param adapter the graphics 2d adapter - */ - public void setGraphics2DAdapter(AFPGraphics2DAdapter adapter) { - this.g2dAdapter = adapter; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPImageObjectInfo.java b/src/java/org/apache/fop/render/afp/AFPImageObjectInfo.java deleted file mode 100644 index 711e135d0..000000000 --- a/src/java/org/apache/fop/render/afp/AFPImageObjectInfo.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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; - - - -/** - * A list of parameters associated with an image - */ -public class AFPImageObjectInfo extends AFPDataObjectInfo { - /** number of bits per pixel used */ - private int bitsPerPixel; - - /** is this a color image? */ - private boolean color; - - /** compression type if any */ - private int compression = -1; - - /** the object data in a byte array */ - private byte[] data; - - /** - * Default constructor - */ - public AFPImageObjectInfo() { - super(); - } - - /** - * Sets the number of bits per pixel - * - * @param bitsPerPixel the number of bits per pixel - */ - public void setBitsPerPixel(int bitsPerPixel) { - this.bitsPerPixel = bitsPerPixel; - } - - /** - * Sets if this image is color - * - * @param color true if this is a color image - */ - public void setColor(boolean color) { - this.color = color; - } - - /** - * Returns the number of bits used per pixel - * - * @return the number of bits used per pixel - */ - public int getBitsPerPixel() { - return bitsPerPixel; - } - - /** - * Returns true if this is a color image - * - * @return true if this is a color image - */ - public boolean isColor() { - return color; - } - - /** - * Returns true if this image uses compression - * - * @return true if this image uses compression - */ - public boolean hasCompression() { - return compression > -1; - } - - /** - * Returns the compression type - * - * @return the compression type - */ - public int getCompression() { - return compression; - } - - /** - * Sets the compression used with this image - * - * @param compression the type of compression used with this image - */ - public void setCompression(int compression) { - this.compression = compression; - } - - /** - * Sets the object data - * - * @param data the object data - */ - public void setData(byte[] data) { - this.data = data; - } - - /** - * Returns the object data - * - * @return the object data - */ - public byte[] getData() { - return this.data; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPImageObjectInfo{" + super.toString() - + ", compression=" + compression - + ", color=" + color - + ", bitsPerPixel=" + bitsPerPixel - + "}"; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java b/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java index 172b67038..19504f6c9 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java @@ -22,6 +22,10 @@ package org.apache.fop.render.afp; import java.io.IOException; import java.io.InputStream; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPState; +import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; /** @@ -39,13 +43,14 @@ public class AFPImageRawStreamFactory extends AFPDataObjectInfoFactory { } /** {@inheritDoc} */ - public AFPDataObjectInfo create(AFPImageInfo afpImageInfo) throws IOException { - AFPDataObjectInfo dataObjectInfo = super.create(afpImageInfo); - String mimeType = afpImageInfo.info.getMimeType(); + public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { + AFPDataObjectInfo dataObjectInfo = super.create(rendererImageInfo); + ImageInfo imageInfo = rendererImageInfo.getImageInfo(); + String mimeType = imageInfo.getMimeType(); if (mimeType != null) { dataObjectInfo.setMimeType(mimeType); } - ImageRawStream rawStream = (ImageRawStream) afpImageInfo.img; + ImageRawStream rawStream = (ImageRawStream) rendererImageInfo.getImage(); int resolution = state.getResolution(); AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); diff --git a/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java b/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java index b3ffe31db..9c59e8b83 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java @@ -23,9 +23,13 @@ import java.awt.image.RenderedImage; import java.io.IOException; import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.fop.apps.MimeConstants; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPImageObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPState; import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.ps.ImageEncodingHelper; +import org.apache.xmlgraphics.util.MimeConstants; /** * A buffered image data object info factory @@ -42,9 +46,9 @@ public class AFPImageRenderedFactory extends AFPDataObjectInfoFactory { } /** {@inheritDoc} */ - public AFPDataObjectInfo create(AFPImageInfo afpImageInfo) throws IOException { + public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { AFPImageObjectInfo imageObjectInfo - = (AFPImageObjectInfo)super.create(afpImageInfo); + = (AFPImageObjectInfo)super.create(rendererImageInfo); imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); @@ -53,7 +57,7 @@ public class AFPImageRenderedFactory extends AFPDataObjectInfoFactory { objectAreaInfo.setWidthRes(resolution); objectAreaInfo.setHeightRes(resolution); - ImageRendered imageRendered = (ImageRendered) afpImageInfo.img; + ImageRendered imageRendered = (ImageRendered) rendererImageInfo.img; RenderedImage renderedImage = imageRendered.getRenderedImage(); int dataHeight = renderedImage.getHeight(); diff --git a/src/java/org/apache/fop/render/afp/AFPInfo.java b/src/java/org/apache/fop/render/afp/AFPInfo.java index 73bbb24a3..5fd59c2aa 100644 --- a/src/java/org/apache/fop/render/afp/AFPInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPInfo.java @@ -20,6 +20,9 @@ package org.apache.fop.render.afp; import org.apache.avalon.framework.configuration.Configuration; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceManager; +import org.apache.fop.afp.AFPState; import org.apache.fop.fonts.FontInfo; /** diff --git a/src/java/org/apache/fop/render/afp/AFPLineDataInfo.java b/src/java/org/apache/fop/render/afp/AFPLineDataInfo.java deleted file mode 100644 index 618cf21ae..000000000 --- a/src/java/org/apache/fop/render/afp/AFPLineDataInfo.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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 java.awt.Color; - -/** Line data information */ -public class AFPLineDataInfo { - - /** the x1 coordinate */ - int x1; - - /** the y1 coordinate */ - int y1; - - /** the x2 coordinate */ - int x2; - - /** the y2 coordinate */ - int y2; - - /** the thickness */ - int thickness; - - /** the painting color */ - Color color; - - /** the rotation */ - int rotation = 0; - - /** - * Default constructor - */ - public AFPLineDataInfo() { - } - - /** - * Returns the X1 coordinate - * - * @return the X1 coordinate - */ - public int getX1() { - return x1; - } - - /** - * Sets the X1 coordinate - * - * @param x1 the X1 coordinate - */ - public void setX1(int x1) { - this.x1 = x1; - } - - /** - * Returns the Y1 coordinate - * - * @return the Y1 coordinate - */ - public int getY1() { - return y1; - } - - /** - * Sets the Y1 coordinate - * - * @param y1 the Y1 coordinate - */ - public void setY1(int y1) { - this.y1 = y1; - } - - /** - * Returns the X2 coordinate - * - * @return the X2 coordinate - */ - public int getX2() { - return x2; - } - - /** - * Sets the X2 coordinate - * - * @param x2 the X2 coordinate - */ - public void setX2(int x2) { - this.x2 = x2; - } - - /** - * Returns the Y2 coordinate - * - * @return the Y2 coordinate - */ - public int getY2() { - return y2; - } - - /** - * Sets the Y2 coordinate - * - * @param y2 the Y2 coordinate - */ - public void setY2(int y2) { - this.y2 = y2; - } - - /** - * Returns the line thickness - * - * @return the line thickness - */ - public int getThickness() { - return thickness; - } - - /** - * Sets the line thickness - * - * @param thickness the line thickness - */ - public void setThickness(int thickness) { - this.thickness = thickness; - } - - /** - * Returns line color - * - * @return the line color - */ - public Color getColor() { - return color; - } - - /** - * Sets the line color - * - * @param color the line color - */ - public void setColor(Color color) { - this.color = color; - } - - /** - * Returns line rotation - * - * @return the line rotation - */ - public int getRotation() { - return rotation; - } - - /** - * Sets the line rotation - * - * @param rotation the line rotation - */ - public void setRotation(int rotation) { - this.rotation = rotation; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPLineDataInfo{x1=" + x1 - + ", y1=" + y1 - + ", x2=" + x2 - + ", y2=" + y2 - + ", thickness=" + thickness - + ", color=" + color - + ", rotation=" + rotation - + "}"; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPObjectAreaInfo.java b/src/java/org/apache/fop/render/afp/AFPObjectAreaInfo.java deleted file mode 100644 index 0a3cdef87..000000000 --- a/src/java/org/apache/fop/render/afp/AFPObjectAreaInfo.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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; - -/** - * A common class used to convey locations, - * dimensions and resolutions of data objects. - */ -public class AFPObjectAreaInfo { - private int x; - private int y; - private int width; - private int height; - private int widthRes; - private int heightRes; - private int rotation = 0; - - /** - * Sets the x position of the data object - * - * @param x the x position of the data object - */ - public void setX(int x) { - this.x = x; - } - - /** - * Sets the y position of the data object - * - * @param y the y position of the data object - */ - public void setY(int y) { - this.y = y; - } - - /** - * Sets the data object width - * - * @param width the width of the data object - */ - public void setWidth(int width) { - this.width = width; - } - - /** - * Sets the data object height - * - * @param height the height of the data object - */ - public void setHeight(int height) { - this.height = height; - } - - /** - * Sets the width resolution - * - * @param widthRes the width resolution - */ - public void setWidthRes(int widthRes) { - this.widthRes = widthRes; - } - - /** - * Sets the height resolution - * - * @param heightRes the height resolution - */ - public void setHeightRes(int heightRes) { - this.heightRes = heightRes; - } - - /** - * Returns the x coordinate of this data object - * - * @return the x coordinate of this data object - */ - public int getX() { - return x; - } - - /** - * Returns the y coordinate of this data object - * - * @return the y coordinate of this data object - */ - public int getY() { - return y; - } - - /** - * Returns the width of this data object - * - * @return the width of this data object - */ - public int getWidth() { - return width; - } - - /** - * Returns the height of this data object - * - * @return the height of this data object - */ - public int getHeight() { - return height; - } - - /** - * Returns the width resolution of this data object - * - * @return the width resolution of this data object - */ - public int getWidthRes() { - return widthRes; - } - - /** - * Returns the height resolution of this data object - * - * @return the height resolution of this data object - */ - public int getHeightRes() { - return heightRes; - } - - /** - * Returns the rotation of this data object - * - * @return the rotation of this data object - */ - public int getRotation() { - return rotation; - } - - /** - * Sets the data object rotation - * - * @param rotation the data object rotation - */ - public void setRotation(int rotation) { - this.rotation = rotation; - } - - /** {@inheritDoc} */ - public String toString() { - return "x=" + x - + ", y=" + y - + ", width=" + width - + ", height=" + height - + ", widthRes=" + widthRes - + ", heightRes=" + heightRes - + ", rotation=" + rotation; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPPageFonts.java b/src/java/org/apache/fop/render/afp/AFPPageFonts.java deleted file mode 100644 index 1bcbbb51d..000000000 --- a/src/java/org/apache/fop/render/afp/AFPPageFonts.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.render.afp.fonts.AFPFont; - -/** - * Holds the current page fonts - */ -public class AFPPageFonts extends java.util.HashMap { - private static final long serialVersionUID = -4991896259427109041L; - - /** - * Default constructor - */ - public AFPPageFonts() { - super(); - } - - /** - * Parameterized constructor - * - * @param fonts an existing set of afp page fonts - */ - public AFPPageFonts(AFPPageFonts fonts) { - super(fonts); - } - - /** - * Registers a font on the current page and returns font attributes - * - * @param fontName the internal font name - * @param font the AFPFont - * @param fontSize the font point size - * @return newly registered AFPFontAttributes - */ - public AFPFontAttributes registerFont(String fontName, AFPFont font, int fontSize) { - String pageFontKey = fontName + "_" + fontSize; - AFPFontAttributes afpFontAttributes = (AFPFontAttributes)super.get(pageFontKey); - // Add to page font mapping if not already present - if (afpFontAttributes == null) { - afpFontAttributes = new AFPFontAttributes(fontName, font, fontSize); - super.put(pageFontKey, afpFontAttributes); - afpFontAttributes.setFontReference(super.size()); - } - return afpFontAttributes; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java b/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java index 2f090b0ba..17aff9fc0 100644 --- a/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java @@ -21,6 +21,10 @@ package org.apache.fop.render.afp; import java.io.IOException; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPImageObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPState; import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; /** @@ -38,10 +42,10 @@ public class AFPRawCCITTFaxFactory extends AFPDataObjectInfoFactory { } /** {@inheritDoc} */ - public AFPDataObjectInfo create(AFPImageInfo afpImageInfo) throws IOException { - AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)super.create(afpImageInfo); + public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { + AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)super.create(rendererImageInfo); - ImageRawCCITTFax ccitt = (ImageRawCCITTFax) afpImageInfo.img; + ImageRawCCITTFax ccitt = (ImageRawCCITTFax) rendererImageInfo.img; imageObjectInfo.setCompression(ccitt.getCompression()); AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); diff --git a/src/java/org/apache/fop/render/afp/AFPRectanglePainter.java b/src/java/org/apache/fop/render/afp/AFPRectanglePainter.java deleted file mode 100644 index 18f275459..000000000 --- a/src/java/org/apache/fop/render/afp/AFPRectanglePainter.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 java.awt.geom.AffineTransform; - -import org.apache.fop.render.afp.modca.DataStream; - -public class AFPRectanglePainter extends AbstractAFPPainter { - - /** - * Main constructor - * - * @param state the afp state - * @param dataStream the afp datastream - */ - public AFPRectanglePainter(AFPState state, DataStream dataStream) { - super(state, dataStream); - } - - /** {@inheritDoc} */ - public void paint(PaintInfo paintInfo) { - RectanglePaintInfo rectanglePaintInfo = (RectanglePaintInfo)paintInfo; - int pageWidth = dataStream.getCurrentPage().getWidth(); - int pageHeight = dataStream.getCurrentPage().getHeight(); - - AFPUnitConverter unitConv = state.getUnitConverter(); - float width = unitConv.pt2units(rectanglePaintInfo.getWidth()); - float height = unitConv.pt2units(rectanglePaintInfo.getHeight()); - float x = unitConv.pt2units(rectanglePaintInfo.getX()); - float y = unitConv.pt2units(rectanglePaintInfo.getY()); - - AffineTransform at = state.getData().getTransform(); - - AFPLineDataInfo lineDataInfo = new AFPLineDataInfo(); - lineDataInfo.color = state.getColor(); - lineDataInfo.rotation = state.getRotation(); - lineDataInfo.thickness = Math.round(height); - - switch (lineDataInfo.rotation) { - case 0: - lineDataInfo.x1 = Math.round((float)at.getTranslateX() + x); - lineDataInfo.y1 = lineDataInfo.y2 = Math.round((float)at.getTranslateY() + y); - lineDataInfo.x2 = Math.round((float)at.getTranslateX() + x + width); - break; - case 90: - lineDataInfo.x1 = Math.round((float)at.getTranslateY() + x); - lineDataInfo.y1 = lineDataInfo.y2 - = pageWidth - Math.round((float)at.getTranslateX()) + Math.round(y); - lineDataInfo.x2 = Math.round(width + (float)at.getTranslateY() + x); - break; - case 180: - lineDataInfo.x1 = pageWidth - Math.round((float)at.getTranslateX() - x); - lineDataInfo.y1 = lineDataInfo.y2 = pageHeight - Math.round((float)at.getTranslateY() - y); - lineDataInfo.x2 = pageWidth - Math.round((float)at.getTranslateX() - x - width); - break; - case 270: - lineDataInfo.x1 = pageHeight - Math.round((float)at.getTranslateY() - x); - lineDataInfo.y1 = lineDataInfo.y2 = Math.round((float)at.getTranslateX() + y); - lineDataInfo.x2 = lineDataInfo.x1 + Math.round(width - x); - break; - } - dataStream.createLine(lineDataInfo); - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 89ec9ad63..d0737ed70 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -33,6 +33,23 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.apache.fop.AbstractState; +import org.apache.fop.afp.AFPBorderPainter; +import org.apache.fop.afp.AFPConstants; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPPageFonts; +import org.apache.fop.afp.AFPRectanglePainter; +import org.apache.fop.afp.AFPResourceManager; +import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPTextDataInfo; +import org.apache.fop.afp.AFPUnitConverter; +import org.apache.fop.afp.BorderPaintInfo; +import org.apache.fop.afp.RectanglePaintInfo; +import org.apache.fop.afp.fonts.AFPFont; +import org.apache.fop.afp.fonts.AFPFontAttributes; +import org.apache.fop.afp.fonts.AFPFontCollection; +import org.apache.fop.afp.modca.DataStream; +import org.apache.fop.afp.modca.PageObject; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; @@ -51,15 +68,10 @@ import org.apache.fop.fonts.FontCollection; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontManager; import org.apache.fop.render.AbstractPathOrientedRenderer; -import org.apache.fop.render.AbstractState; import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.render.afp.extensions.AFPElementMapping; import org.apache.fop.render.afp.extensions.AFPPageSetup; -import org.apache.fop.render.afp.fonts.AFPFont; -import org.apache.fop.render.afp.fonts.AFPFontCollection; -import org.apache.fop.render.afp.modca.DataStream; -import org.apache.fop.render.afp.modca.PageObject; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageInfo; @@ -423,8 +435,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { Point origin = new Point(currentIPPosition, currentBPPosition); AFPDataObjectInfoFactory factory = dataObjectInfoProvider.getFactory(img); if (factory != null) { - AFPImageInfo afpImageInfo - = new AFPImageInfo(uri, pos, origin, info, img, foreignAttributes); + AFPRendererImageInfo afpImageInfo + = new AFPRendererImageInfo(uri, pos, origin, info, img, foreignAttributes); if (factory instanceof AFPImageGraphics2DFactory) { RendererContext rendererContext = createRendererContext( x, y, posInt.width, posInt.height, foreignAttributes); diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index aba38af2f..6a59d27e3 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java @@ -24,6 +24,11 @@ import java.util.List; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.fop.afp.fonts.AFPFontInfo; +import org.apache.fop.afp.fonts.CharacterSet; +import org.apache.fop.afp.fonts.FopCharacterSet; +import org.apache.fop.afp.fonts.OutlineFont; +import org.apache.fop.afp.fonts.RasterFont; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontTriplet; @@ -31,11 +36,6 @@ import org.apache.fop.fonts.FontUtil; import org.apache.fop.fonts.Typeface; import org.apache.fop.render.PrintRendererConfigurator; import org.apache.fop.render.Renderer; -import org.apache.fop.render.afp.fonts.AFPFontInfo; -import org.apache.fop.render.afp.fonts.CharacterSet; -import org.apache.fop.render.afp.fonts.FopCharacterSet; -import org.apache.fop.render.afp.fonts.OutlineFont; -import org.apache.fop.render.afp.fonts.RasterFont; import org.apache.fop.util.LogUtil; /** diff --git a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java new file mode 100644 index 000000000..d4a14d3c2 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.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.render.afp; + +import java.awt.Point; +import java.awt.geom.Rectangle2D; +import java.util.Map; + +import org.apache.fop.render.RendererContext; +import org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.image.loader.ImageInfo; + +/** + * The AFP image information + */ +public class AFPRendererImageInfo { + + /** the image uri */ + protected final String uri; + + /** the current pos */ + protected final Rectangle2D pos; + + /** the origin */ + protected final Point origin; + + /** the foreign attributes */ + protected final Map foreignAttributes; + + /** the image info */ + protected final ImageInfo info; + + /** the image */ + protected final Image img; + + /** the AFP graphics 2d adapter */ + protected AFPGraphics2DAdapter g2dAdapter; + + /** the renderer context */ + protected RendererContext rendererContext; + + /** + * Main constructor + * + * @param uri the image uri + * @param pos the image content area + * @param origin the current position + * @param info the image info + * @param img the image + * @param foreignAttributes the foreign attributes + */ + public AFPRendererImageInfo(String uri, Rectangle2D pos, Point origin, + ImageInfo info, Image img, Map foreignAttributes) { + this.uri = uri; + this.pos = pos; + this.origin = origin; + this.info = info; + this.img = img; + this.foreignAttributes = foreignAttributes; + } + + /** + * Sets the renderer context + * + * @param rendererContext the renderer context + */ + public void setRendererContext(RendererContext rendererContext) { + this.rendererContext = rendererContext; + } + + /** + * Sets the graphics 2d adapter + * + * @param adapter the graphics 2d adapter + */ + public void setGraphics2DAdapter(AFPGraphics2DAdapter adapter) { + this.g2dAdapter = adapter; + } + + /** + * Returns the image info + * + * @return the image info + */ + public ImageInfo getImageInfo() { + return this.info; + } + + /** + * Returns the image + * + * @return the image + */ + public Image getImage() { + return this.img; + } + + /** + * Returns the graphics 2D adapter + * + * @return the graphics 2D adapter + */ + public AFPGraphics2DAdapter getGraphics2DAdapter() { + return this.g2dAdapter; + } + + /** + * Returns the renderer context + * + * @return the renderer context + */ + public RendererContext getRendererContext() { + return this.rendererContext; + } + + /** + * Return the foreign attributes + * @return the foreign attributes + */ + public Map getForeignAttributes() { + return this.foreignAttributes; + } + + /** + * Return the uri + * + * @return the uri + */ + public String getURI() { + return this.uri; + } + + /** + * Return the origin + * + * @return the origin + */ + public Point getOrigin() { + return this.origin; + } + + /** + * Return the position + * + * @return the position + */ + public Rectangle2D getPosition() { + return this.pos; + } + +} diff --git a/src/java/org/apache/fop/render/afp/AFPResourceInfo.java b/src/java/org/apache/fop/render/afp/AFPResourceInfo.java deleted file mode 100644 index f52a3cd0b..000000000 --- a/src/java/org/apache/fop/render/afp/AFPResourceInfo.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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; - -/** - * The level at which a resource is to reside in the AFP output - */ -public class AFPResourceInfo { - private static final AFPResourceLevel DEFAULT_LEVEL - = new AFPResourceLevel(AFPResourceLevel.PRINT_FILE); - - /** the uri of this resource */ - private String uri = null; - - /** the reference name of this resource */ - private String name = null; - - /** the resource level of this resource */ - private AFPResourceLevel level = DEFAULT_LEVEL; - - /** true when the resource level was changed */ - private boolean levelChanged = false; - - /** - * Sets the data object uri - * - * @param uri the data object uri - */ - public void setUri(String uri) { - this.uri = uri; - } - - /** - * Returns the uri of this data object - * - * @return the uri of this data object - */ - public String getUri() { - return uri; - } - - /** - * Sets the resource reference name - * - * @param resourceName the resource reference name - */ - public void setName(String resourceName) { - this.name = resourceName; - } - - /** - * Returns the resource reference name - * - * @return the resource reference name - */ - public String getName() { - return this.name; - } - - /** - * Returns the resource level - * - * @return the resource level - */ - public AFPResourceLevel getLevel() { - if (level == null) { - return DEFAULT_LEVEL; - } - return this.level; - } - - /** - * Sets the resource level - * - * @param resourceLevel the resource level - */ - public void setLevel(AFPResourceLevel resourceLevel) { - this.level = resourceLevel; - levelChanged = true; - } - - /** - * Returns true when the resource level was set - * - * @return true when the resource level was set - */ - public boolean levelChanged() { - return levelChanged; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPResourceInfo{uri=" + uri - + (name != null ? ", name=" + name : "") - + (level != null ? ", level=" + level : "") - + "}"; - - } - - /** {@inheritDoc} */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if ((obj == null) || !(obj instanceof AFPResourceInfo)) { - return false; - } - - AFPResourceInfo ri = (AFPResourceInfo)obj; - return (uri == ri.uri || uri != null && uri.equals(ri.uri)) - && (name == ri.name || name != null && name.equals(ri.name)) - && (level == ri.level || level != null && level.equals(ri.level)); - } - - /** {@inheritDoc} */ - public int hashCode() { - int hash = 7; - hash = 31 * hash + (null == uri ? 0 : uri.hashCode()); - hash = 31 * hash + (null == name ? 0 : name.hashCode()); - hash = 31 * hash + (null == level ? 0 : level.hashCode()); - return hash; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPResourceLevel.java b/src/java/org/apache/fop/render/afp/AFPResourceLevel.java deleted file mode 100644 index 8dc1c2077..000000000 --- a/src/java/org/apache/fop/render/afp/AFPResourceLevel.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * 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; - -/** - * A resource level - */ -public class AFPResourceLevel { - - /** directly in page **/ - public static final int INLINE = 0; - - /** page level **/ - public static final int PAGE = 1; - - /** page group level **/ - public static final int PAGE_GROUP = 2; - - /** document level **/ - public static final int DOCUMENT = 3; - - /** print file level **/ - public static final int PRINT_FILE = 4; - - /** external level **/ - public static final int EXTERNAL = 5; - - private static final String NAME_INLINE = "inline"; - private static final String NAME_PAGE = "page"; - private static final String NAME_PAGE_GROUP = "page-group"; - private static final String NAME_DOCUMENT = "document"; - private static final String NAME_PRINT_FILE = "print-file"; - private static final String NAME_EXTERNAL = "external"; - - private static final String[] NAMES = new String[] { - NAME_INLINE, NAME_PAGE, NAME_PAGE_GROUP, NAME_DOCUMENT, NAME_PRINT_FILE, NAME_EXTERNAL - }; - - - /** where the resource will reside in the AFP output */ - private int level = PRINT_FILE; // default is print-file level - - /** the external resource group file path */ - private String extFilePath = null; - - /** - * Sets the resource placement level within the AFP output - * - * @param levelString the resource level (page, page-group, document, print-file or external) - * @return true if the resource level was successfully set - */ - public static AFPResourceLevel valueOf(String levelString) { - if (levelString != null) { - levelString = levelString.toLowerCase(); - AFPResourceLevel resourceLevel = null; - for (int i = 0; i < NAMES.length; i++) { - if (NAMES[i].equals(levelString)) { - resourceLevel = new AFPResourceLevel(i); - break; - } - } - return resourceLevel; - } - return null; - } - - /** - * Main constructor - * - * @param level the resource level - */ - public AFPResourceLevel(int level) { - setLevel(level); - } - - /** - * Sets the resource level - * - * @param level the resource level - */ - public void setLevel(int level) { - this.level = level; - } - - /** - * Returns true if this is at page level - * - * @return true if this is at page level - */ - public boolean isPage() { - return level == PAGE; - } - - /** - * Returns true if this is at page group level - * - * @return true if this is at page group level - */ - public boolean isPageGroup() { - return level == PAGE_GROUP; - } - - /** - * Returns true if this is at document level - * - * @return true if this is at document level - */ - public boolean isDocument() { - return level == DOCUMENT; - } - - /** - * Returns true if this is at external level - * - * @return true if this is at external level - */ - public boolean isExternal() { - return level == EXTERNAL; - } - - /** - * Returns true if this is at print-file level - * - * @return true if this is at print-file level - */ - public boolean isPrintFile() { - return level == PRINT_FILE; - } - - /** - * Returns true if this resource level is inline - * - * @return true if this resource level is inline - */ - public boolean isInline() { - return level == INLINE; - } - - /** - * Returns the destination file path of the external resource group file - * - * @return the destination file path of the external resource group file - */ - public String getExternalFilePath() { - return this.extFilePath; - } - - /** - * Sets the external destination of the resource - * - * @param filePath the external resource group file - */ - public void setExternalFilePath(String filePath) { - this.extFilePath = filePath; - } - - /** {@inheritDoc} */ - public String toString() { - return NAMES[level] + (isExternal() ? ", file=" + extFilePath : ""); - } - - /** {@inheritDoc} */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if ((obj == null) || !(obj instanceof AFPResourceLevel)) { - return false; - } - - AFPResourceLevel rl = (AFPResourceLevel)obj; - return (level == level) - && (extFilePath == rl.extFilePath - || extFilePath != null && extFilePath.equals(rl.extFilePath)); - } - - /** {@inheritDoc} */ - public int hashCode() { - int hash = 7; - hash = 31 * hash + level; - hash = 31 * hash + (null == extFilePath ? 0 : extFilePath.hashCode()); - return hash; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPResourceManager.java b/src/java/org/apache/fop/render/afp/AFPResourceManager.java deleted file mode 100644 index 6acc2419c..000000000 --- a/src/java/org/apache/fop/render/afp/AFPResourceManager.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * 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 java.io.IOException; -import java.io.OutputStream; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.modca.AbstractDataObject; -import org.apache.fop.render.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.render.afp.modca.DataStream; -import org.apache.fop.render.afp.modca.Factory; -import org.apache.fop.render.afp.modca.IncludeObject; -import org.apache.fop.render.afp.modca.Registry; -import org.apache.fop.render.afp.modca.ResourceGroup; - -/** - * Manages the creation and storage of document resources - */ -public class AFPResourceManager { - /** Static logging instance */ - private static final Log log = LogFactory.getLog(AFPResourceManager.class); - - /** The AFP datastream (document tree) */ - private DataStream dataStream; - - /** Resource creation factory */ - private final Factory factory; - - private final AFPStreamer streamer; - - private final AFPDataObjectFactory dataObjectFactory; - - /** Maintain a reference count of instream objects for referencing purposes */ - private int instreamObjectCount = 0; - - /** a mapping of resourceInfo --> include name */ - private final Map/**/ includeNameMap - = new java.util.HashMap()/**/; - - /** - * Main constructor - */ - public AFPResourceManager() { - this.factory = new Factory(); - this.streamer = new AFPStreamer(factory); - this.dataObjectFactory = new AFPDataObjectFactory(factory); - } - - /** - * Sets the outputstream - * - * @param state the afp state - * @param outputStream the outputstream - */ - public void createDataStream(AFPState state, OutputStream outputStream) { - this.dataStream = streamer.createDataStream(state); - streamer.setOutputStream(outputStream); - } - - /** - * Returns the AFP DataStream - * - * @return the AFP DataStream - */ - public DataStream getDataStream() { - return this.dataStream; - } - - /** - * Tells the streamer to write - * - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public void writeToStream() throws IOException { - streamer.close(); - } - - /** - * Sets the default resource group file path - * - * @param filePath the default resource group file path - */ - - public void setDefaultResourceGroupFilePath(String filePath) { - streamer.setDefaultResourceGroupFilePath(filePath); - } - - /** - * Creates a new data object in the AFP datastream - * - * @param dataObjectInfo the data object info - * - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public void createObject(AFPDataObjectInfo dataObjectInfo) throws IOException { - AbstractNamedAFPObject namedObj = null; - - AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); - String uri = resourceInfo.getUri(); - if (uri == null) { - uri = "/"; - } - // if this is an instream data object adjust the uri to ensure that its unique - if (uri.endsWith("/")) { - uri += "#" + (++instreamObjectCount); - resourceInfo.setUri(uri); - } - - String objectName = (String)includeNameMap.get(resourceInfo); - if (objectName == null) { - boolean useInclude = true; - Registry.ObjectType objectType = null; - - // new resource so create - if (dataObjectInfo instanceof AFPImageObjectInfo) { - AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)dataObjectInfo; - namedObj = dataObjectFactory.createImage(imageObjectInfo); - } else if (dataObjectInfo instanceof AFPGraphicsObjectInfo) { - AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)dataObjectInfo; - namedObj = dataObjectFactory.createGraphic(graphicsObjectInfo); - } else { - // natively embedded object - namedObj = dataObjectFactory.createObjectContainer(dataObjectInfo); - objectType = dataObjectInfo.getObjectType(); - useInclude = objectType != null && objectType.isIncludable(); - } - - // set data object viewport (i.e. position, rotation, dimension, resolution) - if (namedObj instanceof AbstractDataObject) { - AbstractDataObject dataObj = (AbstractDataObject)namedObj; - dataObj.setViewport(dataObjectInfo); - } - - AFPResourceLevel resourceLevel = resourceInfo.getLevel(); - ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel); - useInclude &= resourceGroup != null; - if (useInclude) { - // if it is to reside within a resource group at print-file or external level - if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) { - // wrap newly created data object in a resource object - namedObj = dataObjectFactory.createResource(namedObj, resourceInfo, objectType); - } - - // add data object into its resource group destination - resourceGroup.addObject(namedObj); - - // create the include object - objectName = namedObj.getName(); - IncludeObject includeObject - = dataObjectFactory.createInclude(objectName, dataObjectInfo); - - // add an include to the current page - dataStream.getCurrentPage().addObject(includeObject); - - // record mapping of resource info to data object resource name - includeNameMap.put(resourceInfo, objectName); - } else { - // not to be included so inline data object directly into the current page - dataStream.getCurrentPage().addObject(namedObj); - } - } else { - // an existing data resource so reference it by adding an include to the current page - IncludeObject includeObject - = dataObjectFactory.createInclude(objectName, dataObjectInfo); - dataStream.getCurrentPage().addObject(includeObject); - } - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index b3632b70f..57837fb4f 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -32,6 +32,15 @@ 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.fop.afp.AFPForeignAttributeReader; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.afp.AFPGraphicsObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceManager; +import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPTextHandler; +import org.apache.fop.afp.AFPUnitConverter; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; @@ -109,7 +118,6 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { protected void renderSVGDocument(final RendererContext context, final Document doc) throws IOException { - AFPRenderer renderer = (AFPRenderer)context.getRenderer(); AFPInfo afpInfo = getAFPInfo(context); // fallback paint as bitmap @@ -125,7 +133,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { } String uri = ((AbstractDocument)doc).getDocumentURI(); - AFPState state = (AFPState)renderer.getState(); + AFPState state = afpInfo.getState(); state.setImageUri(uri); // set the data object parameters @@ -160,8 +168,12 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { // Configure Graphics2D implementation final boolean textAsShapes = false; AFPGraphics2D g2d = new AFPGraphics2D(textAsShapes); + + g2d.setResourceManager(afpInfo.getResourceManager()); + g2d.setResourceInfo(afpInfo.getResourceInfo()); + g2d.setState(afpInfo.getState()); g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - g2d.setAFPInfo(afpInfo); + g2d.setFontInfo(afpInfo.getFontInfo()); // Configure GraphicsObjectPainter with the Graphics2D implementation AFPBatikGraphicsObjectPainter painter = new AFPBatikGraphicsObjectPainter(g2d); @@ -172,9 +184,9 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { = new SVGUserAgent(context.getUserAgent(), new AffineTransform()); BridgeContext ctx = new BridgeContext(svgUserAgent); if (!afpInfo.strokeText()) { - AFPTextHandler afpTextHandler = new AFPTextHandler(g2d); - g2d.setCustomTextHandler(afpTextHandler); - AFPTextPainter textPainter = new AFPTextPainter(afpTextHandler); + AFPTextHandler textHandler = new AFPTextHandler(g2d); + g2d.setCustomTextHandler(textHandler); + AFPTextPainter textPainter = new AFPTextPainter(textHandler); ctx.setTextPainter(textPainter); AFPTextElementBridge tBridge = new AFPTextElementBridge(textPainter); ctx.putBridge(tBridge); diff --git a/src/java/org/apache/fop/render/afp/AFPState.java b/src/java/org/apache/fop/render/afp/AFPState.java deleted file mode 100644 index 8209f3153..000000000 --- a/src/java/org/apache/fop/render/afp/AFPState.java +++ /dev/null @@ -1,511 +0,0 @@ -/* - * 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.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.AbstractState; - -/** - * This keeps information about the current state when writing to an AFP datastream. - */ -public class AFPState extends org.apache.fop.render.AbstractState implements Cloneable { - - private static final long serialVersionUID = 8206711712452344473L; - - private static Log log = LogFactory.getLog("org.apache.fop.render.afp.AFPState"); - - /** the portrait rotation */ - private int portraitRotation = 0; - - /** the landscape rotation */ - private int landscapeRotation = 270; - - /** color image support */ - private boolean colorImages = false; - - /** images are supported in this AFP environment */ - private boolean nativeImages = false; - - /** default value for image depth */ - private int bitsPerPixel = 8; - - /** the output resolution */ - private int resolution = 240; // 240 dpi - - /** the current page */ - private AFPPageState pageState = new AFPPageState(); - -// /** reference orientation */ -// private int orientation = 0; - - /** a unit converter */ - private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this); - - /** - * Sets the rotation to be used for portrait pages, valid values are 0 - * (default), 90, 180, 270. - * - * @param rotation - * The rotation in degrees. - */ - protected void setPortraitRotation(int rotation) { - if (rotation == 0 || rotation == 90 || rotation == 180 - || rotation == 270) { - portraitRotation = rotation; - } else { - throw new IllegalArgumentException( - "The portrait rotation must be one" - + " of the values 0, 90, 180, 270"); - - } - } - - /** - * Returns the rotation to be used for portrait pages - * - * @return the rotation to be used for portrait pages - */ - protected int getPortraitRotation() { - return this.portraitRotation; - } - - /** - * Sets the rotation to be used for landscape pages, valid values are 0, 90, - * 180, 270 (default). - * - * @param rotation - * The rotation in degrees. - */ - protected void setLandscapeRotation(int rotation) { - if (rotation == 0 || rotation == 90 || rotation == 180 - || rotation == 270) { - landscapeRotation = rotation; - } else { - throw new IllegalArgumentException( - "The landscape rotation must be one" - + " of the values 0, 90, 180, 270"); - } - } - - /** - * Returns the landscape rotation - * - * @return the landscape rotation - */ - protected int getLandscapeRotation() { - return this.landscapeRotation; - } - - /** - * Sets the number of bits used per pixel - * - * @param bitsPerPixel - * number of bits per pixel - */ - public void setBitsPerPixel(int bitsPerPixel) { - switch (bitsPerPixel) { - case 1: - case 4: - case 8: - this.bitsPerPixel = bitsPerPixel; - break; - default: - log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8."); - this.bitsPerPixel = 8; - break; - } - } - - /** - * Returns the number of bits per pixel - * - * @return the number of bits per pixel - */ - public int getBitsPerPixel() { - return this.bitsPerPixel; - } - - /** - * Sets whether images are color or not - * - * @param colorImages - * color image output - */ - public void setColorImages(boolean colorImages) { - this.colorImages = colorImages; - } - - /** - * Returns true if color images are to be used - * - * @return true if color images are to be used - */ - protected boolean isColorImages() { - return this.colorImages; - } - - /** - * Sets whether images are natively supported or not in the AFP environment - * - * @param nativeImages true if images are natively supported in this AFP environment - */ - public void setNativeImages(boolean nativeImages) { - this.nativeImages = nativeImages; - } - - /** - * Returns true if images are supported natively in this AFP environment - * - * @return true if images are supported natively in this AFP environment - */ - protected boolean isNativeImages() { - return this.nativeImages; - } - - /** - * Sets the output/device resolution - * - * @param resolution - * the output resolution (dpi) - */ - public void setResolution(int resolution) { - if (log.isDebugEnabled()) { - log.debug("renderer-resolution set to: " + resolution + "dpi"); - } - this.resolution = resolution; - } - - /** - * Returns the output/device resolution. - * - * @return the resolution in dpi - */ - protected int getResolution() { - return this.resolution; - } - - /** {@inheritDoc} */ - protected AbstractData instantiateData() { - return new AFPData(); - } - - /** {@inheritDoc} */ - protected AbstractState instantiateState() { - return new AFPState(); - } - - /** - * Returns the state of the current page - * - * @return the state of the current page - */ - protected AFPPageState getPageState() { - return this.pageState; - } - - /** - * Sets if the current painted shape is to be filled - * - * @param fill true if the current painted shape is to be filled - * @return true if the fill value has changed - */ - protected boolean setFill(boolean fill) { - if (fill != ((AFPData)getData()).filled) { - ((AFPData)getData()).filled = fill; - return true; - } - return false; - } - - /** - * Gets the current page fonts - * - * @return the current page fonts - */ - protected AFPPageFonts getPageFonts() { - return pageState.getFonts(); - } - - /** - * Increments and returns the page font count - * - * @return the page font count - */ - public int incrementPageFontCount() { - return pageState.incrementFontCount(); - } - - /** - * Sets the page width - * - * @param pageWidth the page width - */ - public void setPageWidth(int pageWidth) { - pageState.setWidth(pageWidth); - } - - /** - * Returns the page width - * - * @return the page width - */ - public int getPageWidth() { - return pageState.getWidth(); - } - - /** - * Sets the page height - * - * @param pageHeight the page height - */ - public void setPageHeight(int pageHeight) { - pageState.setHeight(pageHeight); - } - - /** - * Returns the page height - * - * @return the page height - */ - public int getPageHeight() { - return pageState.getHeight(); - } - - /** - * Returns the page rotation - * - * @return the page rotation - */ - public int getPageRotation() { - return pageState.getOrientation(); - } - - /** - * Sets the uri of the current image - * - * @param uri the uri of the current image - */ - protected void setImageUri(String uri) { - ((AFPData)getData()).imageUri = uri; - } - - /** - * Gets the uri of the current image - * - * @return the uri of the current image - */ - public String getImageUri() { - return ((AFPData)getData()).imageUri; - } - - /** - * Returns the currently derived rotation - * - * @return the currently derived rotation - */ - public int getRotation() { - return getData().getDerivedRotation(); - } - - /** - * Returns the unit converter - * - * @return the unit converter - */ - public AFPUnitConverter getUnitConverter() { - return this.unitConv; - } - - /** {@inheritDoc} */ - public Object clone() { - AFPState state = (AFPState)super.clone(); - state.pageState = (AFPPageState)this.pageState.clone(); - state.portraitRotation = this.portraitRotation; - state.landscapeRotation = this.landscapeRotation; - state.bitsPerPixel = this.bitsPerPixel; - state.colorImages = this.colorImages; - state.resolution = this.resolution; - return state; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPState{" + "portraitRotation=" + portraitRotation - + ", landscapeRotation=" + landscapeRotation - + ", colorImages=" + colorImages - + ", bitsPerPixel=" + bitsPerPixel - + ", resolution=" + resolution - + ", pageState=" + pageState - + super.toString() - + "}"; - } - - /** - * Page level state data - */ - private class AFPPageState implements Cloneable { - /** page width */ - private int width = 0; - - /** page height */ - private int height = 0; - - /** page fonts */ - private AFPPageFonts fonts = new AFPPageFonts(); - - /** page font count */ - private int fontCount = 0; - - /** page orientation */ - private int orientation = 0; - - /** - * Returns the page width - * - * @return the page width - */ - protected int getWidth() { - return width; - } - - /** - * Sets the page width - * - * @param width the page width - */ - protected void setWidth(int width) { - this.width = width; - } - - /** - * Returns the page height - * - * @return the page height - */ - protected int getHeight() { - return height; - } - - /** - * Sets the page height - * - * @param height the page height - */ - protected void setHeight(int height) { - this.height = height; - } - - /** - * Returns the page fonts - * - * @return the page fonts - */ - protected AFPPageFonts getFonts() { - return fonts; - } - - /** - * Sets the current page fonts - * - * @param fonts the current page fonts - */ - protected void setFonts(AFPPageFonts fonts) { - this.fonts = fonts; - } - - /** - * Increments and returns the current page font count - * - * @return increment and return the current page font count - */ - protected int incrementFontCount() { - return ++fontCount; - } - - /** - * Returns the current page orientation - * - * @return the current page orientation - */ - protected int getOrientation() { - return orientation; - } - - /** - * Sets the current page orientation - * - * @param orientation the current page orientation - */ - protected void setOrientation(int orientation) { - this.orientation = orientation; - } - - /** {@inheritDoc} */ - public Object clone() { - AFPPageState state = new AFPPageState(); - state.width = this.width; - state.height = this.height; - state.orientation = this.orientation; - state.fonts = new AFPPageFonts(this.fonts); - state.fontCount = this.fontCount; - return state; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPPageState{width=" + width - + ", height=" + height - + ", orientation=" + orientation - + ", fonts=" + fonts - + ", fontCount=" + fontCount - + "}"; - } - } - - /** - * Block level state data - */ - private class AFPData extends org.apache.fop.render.AbstractState.AbstractData { - private static final long serialVersionUID = -1789481244175275686L; - - /** The current fill status */ - private boolean filled = false; - - private String imageUri = null; - - /** {@inheritDoc} */ - public Object clone() { - AFPData obj = (AFPData)super.clone(); - obj.filled = this.filled; - obj.imageUri = this.imageUri; - return obj; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPData{" + super.toString() - + ", filled=" + filled - + ", imageUri=" + imageUri - + "}"; - } - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPStreamer.java b/src/java/org/apache/fop/render/afp/AFPStreamer.java deleted file mode 100644 index be68caab2..000000000 --- a/src/java/org/apache/fop/render/afp/AFPStreamer.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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 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.io.RandomAccessFile; -import java.util.Iterator; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.modca.DataStream; -import org.apache.fop.render.afp.modca.Factory; -import org.apache.fop.render.afp.modca.ResourceGroup; -import org.apache.fop.render.afp.modca.StreamedResourceGroup; - -/** - * Manages the streaming of the AFP output - */ -public class AFPStreamer implements Streamable { - /** Static logging instance */ - private static final Log log = LogFactory.getLog(AFPStreamer.class); - - private static final String AFPDATASTREAM_TEMP_FILE_PREFIX = "AFPDataStream_"; - - private static final int BUFFER_SIZE = 4096; - - private static final String DEFAULT_EXTERNAL_RESOURCE_FILENAME = "resources.afp"; - - - private final Factory factory; - - /** A mapping of external resource destinations to resource groups */ - private final Map/**/pathResourceGroupMap - = new java.util.HashMap/**/(); - - private StreamedResourceGroup printFileResourceGroup; - - /** Sets the default resource group file path */ - private String defaultResourceGroupFilePath = DEFAULT_EXTERNAL_RESOURCE_FILENAME; - - private File tempFile; - - /** temporary document outputstream */ - private OutputStream documentOutputStream; - - /** the final outputstream */ - private OutputStream outputStream; - - private RandomAccessFile documentFile; - - private DataStream dataStream; - - /** - * Main constructor - * - * @param factory a factory - */ - public AFPStreamer(Factory factory) { - this.factory = factory; - } - - /** - * Creates a new DataStream - * @param state the afp state - * - * @return a new {@link DataStream} - */ - public DataStream createDataStream(AFPState state) { - try { - this.tempFile = File.createTempFile(AFPDATASTREAM_TEMP_FILE_PREFIX, null); - this.documentFile = new RandomAccessFile(tempFile, "rw"); - this.documentOutputStream = new BufferedOutputStream( - new FileOutputStream(documentFile.getFD())); - this.dataStream = factory.createDataStream(state, documentOutputStream); - } catch (IOException e) { - log.error(e.getMessage()); - } - return dataStream; - } - - /** - * Sets the default resource group file path - * - * @param filePath the default resource group file path - */ - public void setDefaultResourceGroupFilePath(String filePath) { - this.defaultResourceGroupFilePath = filePath; - } - - /** - * Returns the resource group for a given resource info - * - * @param level a resource level - * @return a resource group for the given resource info - */ - public ResourceGroup getResourceGroup(AFPResourceLevel level) { - ResourceGroup resourceGroup = null; - if (level.isInline()) { // no resource group for inline level - return null; - } - if (level.isExternal()) { - String filePath = level.getExternalFilePath(); - if (filePath == null) { - log.warn("No file path provided for external resource, using default."); - filePath = defaultResourceGroupFilePath; - } - resourceGroup = (ResourceGroup)pathResourceGroupMap.get(filePath); - if (resourceGroup == null) { - OutputStream os = null; - try { - os = new BufferedOutputStream(new FileOutputStream(filePath)); - } catch (FileNotFoundException fnfe) { - log.error("Failed to create/open external resource group file '" - + filePath + "'"); - } finally { - if (os != null) { - resourceGroup = factory.createStreamedResourceGroup(os); - pathResourceGroupMap.put(filePath, resourceGroup); - } - } - } - } else if (level.isPrintFile()) { - if (printFileResourceGroup == null) { - // use final outputstream for print-file resource group - printFileResourceGroup = factory.createStreamedResourceGroup(outputStream); - } - resourceGroup = printFileResourceGroup; - } else { - // resource group in afp document datastream - resourceGroup = dataStream.getResourceGroup(level); - } - return resourceGroup; - } - - /** - * Closes off the AFP stream writing the document stream - * - * @throws IOException if an an I/O exception of some sort has occurred - */ - public void close() throws IOException { - // write out any external resource groups - Iterator it = pathResourceGroupMap.entrySet().iterator(); - while (it.hasNext()) { - StreamedResourceGroup resourceGroup = (StreamedResourceGroup)it.next(); - resourceGroup.close(); - } - - // close any open print-file resource group - if (printFileResourceGroup != null) { - printFileResourceGroup.close(); - } - - // write out document - writeToStream(outputStream); - - outputStream.close(); - - // delete temporary file - tempFile.delete(); - } - - /** - * Sets the final outputstream - * - * @param outputStream an outputstream - */ - public void setOutputStream(OutputStream outputStream) { - this.outputStream = outputStream; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - int len = (int)documentFile.length(); - int numChunks = len / BUFFER_SIZE; - int remainingChunkSize = len % BUFFER_SIZE; - byte[] buffer; - - documentFile.seek(0); - if (numChunks > 0) { - buffer = new byte[BUFFER_SIZE]; - for (int i = 0; i < numChunks; i++) { - documentFile.read(buffer, 0, BUFFER_SIZE); - os.write(buffer, 0, BUFFER_SIZE); - } - } else { - buffer = new byte[remainingChunkSize]; - } - if (remainingChunkSize > 0) { - documentFile.read(buffer, 0, remainingChunkSize); - os.write(buffer, 0, remainingChunkSize); - } - os.flush(); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPTextDataInfo.java b/src/java/org/apache/fop/render/afp/AFPTextDataInfo.java deleted file mode 100644 index 7cc90c589..000000000 --- a/src/java/org/apache/fop/render/afp/AFPTextDataInfo.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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 java.awt.Color; - -/** - * Text data information - */ -public class AFPTextDataInfo { - - private int fontReference; - - private int x; - - private int y; - - private Color color; - - private int variableSpaceCharacterIncrement; - - private int interCharacterAdjustment; - - private byte[] data; - - private int rotation; - - /** - * Returns the font reference - * - * @return the font reference - */ - public int getFontReference() { - return fontReference; - } - - /** - * Sets the font reference - * - * @param fontReference the font reference - */ - protected void setFontReference(int fontReference) { - this.fontReference = fontReference; - } - - /** - * Returns the x coordinate - * - * @return the x coordinate - */ - public int getX() { - return x; - } - - /** - * Sets the X coordinate - * - * @param x the X coordinate - */ - public void setX(int x) { - this.x = x; - } - - /** - * Returns the y coordinate - * - * @return the y coordinate - */ - public int getY() { - return y; - } - - /** - * Sets the Y coordinate - * - * @param y the Y coordinate - */ - public void setY(int y) { - this.y = y; - } - - /** - * Returns the color - * - * @return the color - */ - public Color getColor() { - return color; - } - - /** - * Sets the color - * - * @param color the color - */ - protected void setColor(Color color) { - this.color = color; - } - - /** - * Return the variable space character increment - * - * @return the variable space character increment - */ - public int getVariableSpaceCharacterIncrement() { - return variableSpaceCharacterIncrement; - } - - /** - * Sets the variable space character increment - * - * @param variableSpaceCharacterIncrement the variable space character increment - */ - protected void setVariableSpaceCharacterIncrement( - int variableSpaceCharacterIncrement) { - this.variableSpaceCharacterIncrement = variableSpaceCharacterIncrement; - } - - /** - * Return the inter character adjustment - * - * @return the inter character adjustment - */ - public int getInterCharacterAdjustment() { - return interCharacterAdjustment; - } - - /** - * Sets the inter character adjustment - * - * @param interCharacterAdjustment the inter character adjustment - */ - protected void setInterCharacterAdjustment(int interCharacterAdjustment) { - this.interCharacterAdjustment = interCharacterAdjustment; - } - - /** - * Return the text data - * - * @return the text data - */ - public byte[] getData() { - return data; - } - - /** - * Sets the text data - * - * @param data the text orientation - */ - protected void setData(byte[] data) { - this.data = data; - } - - /** - * Sets the text orientation - * - * @param rotation the text rotation - */ - public void setRotation(int rotation) { - this.rotation = rotation; - } - - /** - * Returns the text rotation - * - * @return the text rotation - */ - public int getRotation() { - return this.rotation; - } - - /** {@inheritDoc} */ - public String toString() { - return "TextDataInfo{fontReference=" + fontReference - + ", x=" + x - + ", y=" + y - + ", color=" + color - + ", vsci=" + variableSpaceCharacterIncrement - + ", ica=" + interCharacterAdjustment - + ", orientation=" + rotation - + ", data=" + data - + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPTextHandler.java b/src/java/org/apache/fop/render/afp/AFPTextHandler.java deleted file mode 100644 index 0bd36b3e6..000000000 --- a/src/java/org/apache/fop/render/afp/AFPTextHandler.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 java.awt.Color; -import java.io.IOException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.render.afp.fonts.AFPFont; -import org.apache.fop.render.afp.modca.GraphicsObject; -import org.apache.xmlgraphics.java2d.TextHandler; - -/** - * Specialized TextHandler implementation that the AFPGraphics2D class delegates to to paint text - * using AFP GOCA text operations. - */ -public class AFPTextHandler implements TextHandler { - - /** logging instance */ - private static Log log = LogFactory.getLog(AFPTextHandler.class); - - private AFPGraphics2D g2d = null; - - /** Overriding FontState */ - protected Font overrideFont = null; - - /** current state */ - private AFPState state = null; - - /** - * Main constructor. - * @param g2d the PSGraphics2D instance this instances is used by - */ - public AFPTextHandler(AFPGraphics2D g2d) { - this.g2d = g2d; - this.state = g2d.getAFPInfo().getState(); - } - - /** - * Return the font information associated with this object - * @return the FontInfo object - */ - public FontInfo getFontInfo() { - return g2d.getAFPInfo().getFontInfo(); - } - - /** - * Add a text string to the current data object of the AFP datastream. - * The text is painted using text operations. - * {@inheritDoc} - */ - public void drawString(String str, float x, float y) throws IOException { - log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y); - GraphicsObject graphicsObj = g2d.getGraphicsObject(); - Color col = g2d.getColor(); - if (state.setColor(col)) { - graphicsObj.setColor(col); - } - if (overrideFont != null) { - FontInfo fontInfo = getFontInfo(); - AFPPageFonts pageFonts = state.getPageFonts(); - String internalFontName = overrideFont.getFontName(); - int fontSize = overrideFont.getFontSize(); - if (state.setFontName(internalFontName) || state.setFontSize(fontSize)) { - AFPFont font = (AFPFont)fontInfo.getFonts().get(internalFontName); - AFPFontAttributes afpFontAttributes = pageFonts.registerFont( - internalFontName, - font, - fontSize - ); - int fontReference = afpFontAttributes.getFontReference(); - graphicsObj.setCharacterSet(fontReference); - } - } - graphicsObj.addString(str, Math.round(x), Math.round(y)); - } - - /** - * Sets the overriding font. - * @param overrideFont Overriding Font to set - */ - public void setOverrideFont(Font overrideFont) { - this.overrideFont = overrideFont; - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPTextPainter.java b/src/java/org/apache/fop/render/afp/AFPTextPainter.java index 3e908792d..7cc96d0cc 100644 --- a/src/java/org/apache/fop/render/afp/AFPTextPainter.java +++ b/src/java/org/apache/fop/render/afp/AFPTextPainter.java @@ -34,6 +34,11 @@ import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.afp.AFPTextHandler; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontTriplet; import org.apache.batik.dom.svg.SVGOMTextElement; import org.apache.batik.gvt.text.Mark; @@ -44,9 +49,6 @@ import org.apache.batik.gvt.text.TextPaintInfo; import org.apache.batik.gvt.font.GVTFontFamily; import org.apache.batik.gvt.renderer.StrokingTextPainter; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontTriplet; /** * Renders the attributed character iterator of a TextNode. diff --git a/src/java/org/apache/fop/render/afp/AFPUnitConverter.java b/src/java/org/apache/fop/render/afp/AFPUnitConverter.java deleted file mode 100644 index 8a25bb604..000000000 --- a/src/java/org/apache/fop/render/afp/AFPUnitConverter.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 java.awt.geom.AffineTransform; - - -/** - * AFP Unit converter - */ -public class AFPUnitConverter { - - /** the AFP state */ - private final AFPState state; - - /** - * Unit converter - * - * @param state the AFP state - */ - public AFPUnitConverter(AFPState state) { - this.state = state; - } - - /** - * Converts millipoints to units - * - * @param srcPts source points - * @param dstPts destination points - * @return transformed points - */ - public int[] mpts2units(float[] srcPts, float[] dstPts) { - return transformPoints(srcPts, dstPts, true); - } - - /** - * Converts points to units - * - * @param srcPts source points - * @param dstPts destination points - * @return transformed points - */ - public int[] pts2units(float[] srcPts, float[] dstPts) { - return transformPoints(srcPts, dstPts, false); - } - - /** - * Converts millipoints to units - * - * @param srcPts source points - * @return transformed points - */ - public int[] mpts2units(float[] srcPts) { - return transformPoints(srcPts, null, true); - } - - /** - * Converts points to units - * - * @param srcPts source points - * @return transformed points - */ - public int[] pts2units(float[] srcPts) { - return transformPoints(srcPts, null, false); - } - - /** - * Converts point to unit - * - * @param pt point - * @return transformed point - */ - public float pt2units(float pt) { - return pt / ((float)AFPConstants.DPI_72 / state.getResolution()); - } - - /** - * Converts millipoint to unit - * - * @param mpt millipoint - * @return transformed point - */ - public float mpt2units(float mpt) { - return mpt / ((float)AFPConstants.DPI_72_MPTS / state.getResolution()); - } - - private int[] transformPoints(float[] srcPts, float[] dstPts, boolean milli) { - if (dstPts == null) { - dstPts = new float[srcPts.length]; - } - AffineTransform at = state.getData().getTransform(); - at.transform(srcPts, 0, dstPts, 0, srcPts.length / 2); - int[] coords = new int[srcPts.length]; - for (int i = 0; i < srcPts.length; i++) { - if (!milli) { - dstPts[i] *= 1000; - } - coords[i] = Math.round(dstPts[i]); - } - return coords; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AbstractAFPPainter.java b/src/java/org/apache/fop/render/afp/AbstractAFPPainter.java deleted file mode 100644 index ec148e5a4..000000000 --- a/src/java/org/apache/fop/render/afp/AbstractAFPPainter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.modca.DataStream; - -public abstract class AbstractAFPPainter { - - /** Static logging instance */ - protected static Log log = LogFactory.getLog("org.apache.fop.render.afp"); - - protected final DataStream dataStream; - protected final AFPState state; - - /** - * Main constructor - * - * @param state the afp state - * @param dataStream the afp datastream - */ - public AbstractAFPPainter(AFPState state, DataStream dataStream) { - this.state = state; - this.dataStream = dataStream; - } - - /** - * Paints the painting item - * - * @param paintInfo the painting information - */ - public abstract void paint(PaintInfo paintInfo); -} diff --git a/src/java/org/apache/fop/render/afp/BorderPaintInfo.java b/src/java/org/apache/fop/render/afp/BorderPaintInfo.java deleted file mode 100644 index 9ba7f29cf..000000000 --- a/src/java/org/apache/fop/render/afp/BorderPaintInfo.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 java.awt.Color; - -/** - * Border painting information - */ -public class BorderPaintInfo implements PaintInfo { - private final float x1; - private final float y1; - private final float x2; - private final float y2; - private final boolean isHorizontal; - private final int style; - private final Color color; - - /** - * Main constructor - * - * @param x1 the x1 coordinate - * @param y1 the y1 coordinate - * @param x2 the x2 coordinate - * @param y2 the y2 coordinate - * @param isHorizontal true when the border line is horizontal - * @param style the border style - * @param color the border color - */ - public BorderPaintInfo(float x1, float y1, float x2, float y2, - boolean isHorizontal, int style, Color color) { - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - this.isHorizontal = isHorizontal; - this.style = style; - this.color = color; - } - - /** - * Returns the x1 coordinate - * - * @return the x1 coordinate - */ - public float getX1() { - return x1; - } - - /** - * Returns the y1 coordinate - * - * @return the y1 coordinate - */ - public float getY1() { - return y1; - } - - /** - * Returns the x2 coordinate - * - * @return the x2 coordinate - */ - public float getX2() { - return x2; - } - - /** - * Returns the y2 coordinate - * - * @return the y2 coordinate - */ - public float getY2() { - return y2; - } - - /** - * Returns true when this is a horizontal line - * - * @return true when this is a horizontal line - */ - public boolean isHorizontal() { - return isHorizontal; - } - - /** - * Returns the style - * - * @return the style - */ - public int getStyle() { - return style; - } - - /** - * Returns the color - * - * @return the color - */ - public Color getColor() { - return color; - } -} diff --git a/src/java/org/apache/fop/render/afp/PaintInfo.java b/src/java/org/apache/fop/render/afp/PaintInfo.java deleted file mode 100644 index 3225ef61d..000000000 --- a/src/java/org/apache/fop/render/afp/PaintInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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; - -/** - * Generic painting information interface - */ -public interface PaintInfo { - -} diff --git a/src/java/org/apache/fop/render/afp/RectanglePaintInfo.java b/src/java/org/apache/fop/render/afp/RectanglePaintInfo.java deleted file mode 100644 index 9e4b3f2e7..000000000 --- a/src/java/org/apache/fop/render/afp/RectanglePaintInfo.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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; - -/** - * Filled rectangle painting information - */ -public class RectanglePaintInfo implements PaintInfo { - - private final float x; - private final float y; - private final float width; - private final float height; - - /** - * Main constructor - * - * @param x the x coordinate - * @param y the y coordinate - * @param width the width - * @param height the height - */ - public RectanglePaintInfo(float x, float y, float width, float height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - /** - * Returns the x coordinate - * - * @return the x coordinate - */ - protected float getX() { - return x; - } - - /** - * Returns the y coordinate - * - * @return the y coordinate - */ - protected float getY() { - return y; - } - - /** - * Returns the width - * - * @return the width - */ - protected float getWidth() { - return width; - } - - /** - * Returns the height - * - * @return the height - */ - protected float getHeight() { - return height; - } - -} diff --git a/src/java/org/apache/fop/render/afp/Streamable.java b/src/java/org/apache/fop/render/afp/Streamable.java deleted file mode 100644 index cb2cd1bda..000000000 --- a/src/java/org/apache/fop/render/afp/Streamable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 java.io.IOException; -import java.io.OutputStream; - -/** - * Implementing object is able to write to an OutputStream - */ -public interface Streamable { - - /** - * DataStream objects must implement the writeToStream() - * method to write its data to the given OutputStream - * - * @param os the outputsteam stream - * @throws java.io.IOException an I/O exception of some sort has occurred. - */ - void writeToStream(OutputStream os) throws IOException; -} diff --git a/src/java/org/apache/fop/render/afp/exceptions/FontRuntimeException.java b/src/java/org/apache/fop/render/afp/exceptions/FontRuntimeException.java deleted file mode 100644 index a54e4ad67..000000000 --- a/src/java/org/apache/fop/render/afp/exceptions/FontRuntimeException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.exceptions; - -/** - * A runtime exception for handling fatal errors in processing fonts. - *

      - */ -public class FontRuntimeException extends NestedRuntimeException { - - /** - * Constructs a FontRuntimeException with the specified message. - * @param msg the exception mesaage - */ - public FontRuntimeException(String msg) { - super(msg); - } - - /** - * Constructs a FontRuntimeException with the specified message - * wrapping the underlying exception. - * @param msg the exception mesaage - * @param t the underlying exception - */ - public FontRuntimeException(String msg, Throwable t) { - super(msg, t); - } - -} diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPBase12FontCollection.java b/src/java/org/apache/fop/render/afp/fonts/AFPBase12FontCollection.java deleted file mode 100644 index 9157b9083..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/AFPBase12FontCollection.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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.fonts; - -import org.apache.fop.fonts.Base14Font; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontCollection; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.base14.Courier; -import org.apache.fop.fonts.base14.CourierBold; -import org.apache.fop.fonts.base14.CourierBoldOblique; -import org.apache.fop.fonts.base14.CourierOblique; -import org.apache.fop.fonts.base14.Helvetica; -import org.apache.fop.fonts.base14.HelveticaBold; -import org.apache.fop.fonts.base14.HelveticaOblique; -import org.apache.fop.fonts.base14.TimesBold; -import org.apache.fop.fonts.base14.TimesBoldItalic; -import org.apache.fop.fonts.base14.TimesItalic; -import org.apache.fop.fonts.base14.TimesRoman; - -/** - * Sets up a typical Base 12 font configuration for AFP - */ -public class AFPBase12FontCollection implements FontCollection { - - /** standard raster font sizes */ - private static final int[] RASTER_SIZES = {6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 30, 36}; - - /** standard raster font charset references */ - private static final String[] CHARSET_REF = { - "60", "70", "80", "90", "00", "A0", "B0", "D0", "F0", "H0", "J0", "N0", "T0", "Z0"}; - - private void addCharacterSet(RasterFont font, String charsetName, Base14Font base14) { - for (int i = 0; i < RASTER_SIZES.length; i++) { - int size = RASTER_SIZES[i]; - FopCharacterSet characterSet = new FopCharacterSet( - CharacterSet.DEFAULT_CODEPAGE, CharacterSet.DEFAULT_ENCODING, - charsetName + CHARSET_REF[i], size, base14); - font.addCharacterSet(size, characterSet); - } - } - - private int addFontProperties(FontInfo fontInfo, AFPFont font, - String[] names, String style, int weight, int num) { - String internalFontKey = "F" + num; - fontInfo.addMetrics(internalFontKey, font); - fontInfo.addFontProperties(internalFontKey, names, style, weight); - num++; - return num; - } - - /** {@inheritDoc} */ - public int setup(int start, FontInfo fontInfo) { - - /** - * Add the base 12 fonts (Helvetica, Times and Courier) - * - * Note: this default font configuration may not be available - * on your AFP environment. - */ - int num = start; - RasterFont font = null; - - /** standard font family reference names for Helvetica font */ - final String[] helveticaNames = {"Helvetica", "Arial", "sans-serif"}; - font = new RasterFont("Helvetica"); - addCharacterSet(font, "C0H200", new Helvetica()); - num = addFontProperties(fontInfo, font, helveticaNames, - Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, num); - - font = new RasterFont("Helvetica Italic"); - addCharacterSet(font, "C0H300", new HelveticaOblique()); - num = addFontProperties(fontInfo, font, helveticaNames, - Font.STYLE_ITALIC, Font.WEIGHT_NORMAL, num); - - font = new RasterFont("Helvetica (Semi) Bold"); - addCharacterSet(font, "C0H400", new HelveticaBold()); - num = addFontProperties(fontInfo, font, helveticaNames, - Font.STYLE_NORMAL, Font.WEIGHT_BOLD, num); - - font = new RasterFont("Helvetica Italic (Semi) Bold"); - addCharacterSet(font, "C0H500", new HelveticaOblique()); - num = addFontProperties(fontInfo, font, helveticaNames, - Font.STYLE_ITALIC, Font.WEIGHT_BOLD, num); - - - /** standard font family reference names for Times font */ - - /** any is treated as serif */ - final String[] timesNames = {"Times", "TimesRoman", "Times Roman", "Times-Roman", - "Times New Roman", "TimesNewRoman", "serif", "any"}; - - font = new RasterFont("Times Roman"); - addCharacterSet(font, "CON200", new TimesRoman()); - num = addFontProperties(fontInfo, font, timesNames, - Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, num); - - font = new RasterFont("Times Roman Italic"); - addCharacterSet(font, "CON300", new TimesItalic()); - num = addFontProperties(fontInfo, font, timesNames, - Font.STYLE_ITALIC, Font.WEIGHT_NORMAL, num); - - font = new RasterFont("Times Roman Bold"); - addCharacterSet(font, "CON400", new TimesBold()); - num = addFontProperties(fontInfo, font, timesNames, - Font.STYLE_NORMAL, Font.WEIGHT_BOLD, num); - - font = new RasterFont("Times Roman Italic Bold"); - addCharacterSet(font, "CON500", new TimesBoldItalic()); - num = addFontProperties(fontInfo, font, timesNames, - Font.STYLE_ITALIC, Font.WEIGHT_BOLD, num); - - - /** standard font family reference names for Courier font */ - final String[] courierNames = {"Courier", "monospace"}; - - font = new RasterFont("Courier"); - addCharacterSet(font, "C04200", new Courier()); - num = addFontProperties(fontInfo, font, courierNames, - Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, num); - - font = new RasterFont("Courier Italic"); - addCharacterSet(font, "C04300", new CourierOblique()); - num = addFontProperties(fontInfo, font, courierNames, - Font.STYLE_ITALIC, Font.WEIGHT_NORMAL, num); - - font = new RasterFont("Courier Bold"); - addCharacterSet(font, "C04400", new CourierBold()); - num = addFontProperties(fontInfo, font, courierNames, - Font.STYLE_NORMAL, Font.WEIGHT_BOLD, num); - - font = new RasterFont("Courier Italic Bold"); - addCharacterSet(font, "C04500", new CourierBoldOblique()); - num = addFontProperties(fontInfo, font, courierNames, - Font.STYLE_ITALIC, Font.WEIGHT_BOLD, num); - - return num; - } - -} diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFont.java b/src/java/org/apache/fop/render/afp/fonts/AFPFont.java deleted file mode 100644 index e87675e63..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/AFPFont.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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.fonts; -import java.util.Map; -import java.util.Set; - -import org.apache.fop.fonts.FontType; -import org.apache.fop.fonts.Typeface; - - -/** - * All implementations of AFP fonts should extend this base class, - * the object implements the FontMetrics information. - *

      - */ -public abstract class AFPFont extends Typeface { - - /** The font name */ - protected String name; - - /** - * Constructor for the base font requires the name. - * @param name the name of the font - */ - public AFPFont(String name) { - this.name = name; - } - - /** {@inheritDoc} */ - public String getFontName() { - return this.name; - } - - /** {@inheritDoc} */ - public String getEmbedFontName() { - return this.name; - } - - /** {@inheritDoc} */ - public String getFullName() { - return getFontName(); - } - - /** {@inheritDoc} */ - public Set getFamilyNames() { - Set s = new java.util.HashSet(); - s.add(this.name); - return s; - } - - /** - * Returns the type of the font. - * @return the font type - */ - public FontType getFontType() { - return FontType.OTHER; - } - - /** - * Indicates if the font has kerning information. - * @return True, if kerning is available. - */ - public boolean hasKerningInfo() { - return false; - } - - /** - * Returns the kerning map for the font. - * @return the kerning map - */ - public Map getKerningInfo() { - return null; - } - - /** - * Returns the character set for a given size - * @param size the font size - * @return the character set object - */ - public abstract CharacterSet getCharacterSet(int size); - - /** - * Determines whether this font contains a particular character/glyph. - * @param c character to check - * @return True if the character is supported, False otherwise - */ - public boolean hasChar(char c) { - return true; - } - - /** {@inheritDoc} */ - public String toString() { - return "name=" + name; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java deleted file mode 100644 index 540ee3b49..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.fonts; - -import java.util.Iterator; -import java.util.List; - -import org.apache.fop.events.EventBroadcaster; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontCollection; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontTriplet; -import org.apache.fop.render.afp.AFPEventProducer; - -/** - * A base collection of AFP fonts - */ -public class AFPFontCollection implements FontCollection { - - private final EventBroadcaster eventBroadcaster; - - private final List/**/ fontInfoList; - - /** - * Main constructor - * - * @param eventBroadcaster the event broadcaster - * @param fontInfoList the font info list - */ - public AFPFontCollection(EventBroadcaster eventBroadcaster, - List/**/ fontInfoList) { - this.eventBroadcaster = eventBroadcaster; - this.fontInfoList = fontInfoList; - } - - /** {@inheritDoc} */ - public int setup(int start, FontInfo fontInfo) { - int num = 1; - AFPEventProducer eventProducer = AFPEventProducer.Provider.get(eventBroadcaster); - if (fontInfoList != null && fontInfoList.size() > 0) { - for (Iterator it = fontInfoList.iterator(); it.hasNext();) { - AFPFontInfo afpFontInfo = (AFPFontInfo)it.next(); - AFPFont afpFont = afpFontInfo.getAFPFont(); - List/**/ tripletList = afpFontInfo.getFontTriplets(); - for (Iterator it2 = tripletList.iterator(); it2.hasNext();) { - FontTriplet triplet = (FontTriplet)it2.next(); - fontInfo.addFontProperties("F" + num, - triplet.getName(), triplet.getStyle(), triplet.getWeight()); - fontInfo.addMetrics("F" + num, afpFont); - num++; - } - } - if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL) == null) { - eventProducer.warnMissingDefaultFont(this, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL); - } - if (fontInfo.fontLookup("any", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL) == null) { - eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_NORMAL); - } - if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_BOLD) == null) { - eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_BOLD); - } - if (fontInfo.fontLookup("any", Font.STYLE_ITALIC, Font.WEIGHT_BOLD) == null) { - eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_BOLD); - } - } else { - eventProducer.warnDefaultFontSetup(this); - - // Go with a default base 12 configuration for AFP environments - FontCollection base12FontCollection = new AFPBase12FontCollection(); - num = base12FontCollection.setup(num, fontInfo); - } - return num; - } - -} diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontInfo.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontInfo.java deleted file mode 100644 index a70dce4b9..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/AFPFontInfo.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.fonts; - -import java.util.List; - -/** - * FontInfo contains meta information on fonts - */ -public class AFPFontInfo { - - private AFPFont font; - private List/**/ tripletList; - - /** - * Main constructor - * - * @param afpFont The AFP Font - * @param tripletList List of font triplets to associate with this font - */ - public AFPFontInfo(AFPFont afpFont, List/**/ tripletList) { - this.font = afpFont; - this.tripletList = tripletList; - } - - /** - * Returns the afp font - * - * @return the afp font - */ - public AFPFont getAFPFont() { - return font; - } - - /** - * Returns the list of font triplets associated with this font. - * - * @return List of font triplets - */ - public List/**/ getFontTriplets() { - return tripletList; - } - -} - diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java deleted file mode 100644 index f72d23d47..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * 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.fonts; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.tools.StructuredFieldReader; - -/** - * The AFPFontReader is responsible for reading the font attributes from binary - * code page files and the character set metric files. In IBM font structure, a - * code page maps each character of text to the characters in a character set. - * Each character is translated into a code point. When the character is - * printed, each code point is matched to a character ID on the code page - * specified. The character ID is then matched to the image (raster pattern or - * outline pattern) of the character in the character set specified. The image - * in the character set is the image that is printed in the document. To be a - * valid code page for a particular character set, all character IDs in the code - * page must be included in that character set.

      This class will read the - * font information from the binary code page files and character set metric - * files in order to determine the correct metrics to use when rendering the - * formatted object.

      - * - * @author Pete Townsend - */ -public final class AFPFontReader { - - /** - * Static logging instance - */ - protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.fonts"); - - /** - * Template used to convert lists to arrays. - */ - private static final CharacterSetOrientation[] EMPTY_CSO_ARRAY = new CharacterSetOrientation[0]; - - /** Codepage MO:DCA structured field. */ - private static final byte[] CODEPAGE_SF = new byte[] { - (byte) 0xD3, (byte) 0xA8, (byte) 0x87}; - - /** Character table MO:DCA structured field. */ - private static final byte[] CHARACTER_TABLE_SF = new byte[] { - (byte) 0xD3, (byte) 0x8C, (byte) 0x87}; - - /** Font control MO:DCA structured field. */ - private static final byte[] FONT_CONTROL_SF = new byte[] { - (byte) 0xD3, (byte) 0xA7, (byte) 0x89 }; - - /** Font orientation MO:DCA structured field. */ - private static final byte[] FONT_ORIENTATION_SF = new byte[] { - (byte) 0xD3, (byte) 0xAE, (byte) 0x89 }; - - /** Font position MO:DCA structured field. */ - private static final byte[] FONT_POSITION_SF = new byte[] { - (byte) 0xD3, (byte) 0xAC, (byte) 0x89 }; - - /** Font index MO:DCA structured field. */ - private static final byte[] FONT_INDEX_SF = new byte[] { - (byte) 0xD3, (byte) 0x8C, (byte) 0x89 }; - - /** - * The conversion factor to millipoints for 240 dpi - */ - private static final int FOP_100_DPI_FACTOR = 1; - - /** - * The conversion factor to millipoints for 240 dpi - */ - private static final int FOP_240_DPI_FACTOR = 300000; - - /** - * The conversion factor to millipoints for 300 dpi - */ - private static final int FOP_300_DPI_FACTOR = 240000; - - /** - * The encoding to use to convert from EBCIDIC to ASCII - */ - private static final String ASCII_ENCODING = "UTF8"; - - /** - * The collection of code pages - */ - private final Map/*>*/ codePages - = new java.util.HashMap/*>*/(); - - /** - * Returns an InputStream to a given file path and filename - * - * @param path the file path - * @param filename the file name - * @return an inputStream - * - * @throws IOException in the event that an I/O exception of some sort has occurred - */ - private InputStream openInputStream(String path, String filename) throws IOException { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - if (classLoader == null) { - classLoader = AFPFontReader.class.getClassLoader(); - } - - URL url = classLoader.getResource(path); - - if (url == null) { - try { - File file = new File(path); - url = file.toURI().toURL(); - if (url == null) { - String msg = "file not found " + filename + " in classpath: " + path; - log.error(msg); - throw new FileNotFoundException(msg); - } - } catch (MalformedURLException ex) { - String msg = "file not found " + filename + " in classpath: " + path; - log.error(msg); - throw new FileNotFoundException(msg); - } - } - - File directory = new File(url.getPath()); - if (!directory.canRead()) { - String msg = "Failed to read directory " + url.getPath(); - log.error(msg); - throw new FileNotFoundException(msg); - } - - final String filterpattern = filename.trim(); - FilenameFilter filter = new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.startsWith(filterpattern); - } - }; - - File[] files = directory.listFiles(filter); - - if (files.length < 1) { - String msg = "file search for " + filename + " located " - + files.length + " files"; - log.error(msg); - throw new FileNotFoundException(msg); - } else if (files.length > 1) { - String msg = "file search for " + filename + " located " - + files.length + " files"; - log.warn(msg); - } - - InputStream inputStream = files[0].toURI().toURL().openStream(); - - if (inputStream == null) { - String msg = "AFPFontReader:: getInputStream():: file not found for " + filename; - log.error(msg); - throw new FileNotFoundException(msg); - } - - return inputStream; - } - - /** - * Closes the inputstream - * - * @param inputStream the inputstream to close - */ - private void closeInputStream(InputStream inputStream) { - try { - if (inputStream != null) { - inputStream.close(); - } - } catch (Exception ex) { - // Lets log at least! - log.error(ex.getMessage()); - } - } - - /** - * Load the font details and metrics into the CharacterSetMetric object, - * this will use the actual afp code page and character set files to load - * the object with the necessary metrics. - * - * @param characterSet the CharacterSetMetric object to populate - * @throws IOException if an I/O exception of some sort has occurred. - */ - public void loadCharacterSetMetric(CharacterSet characterSet) throws IOException { - - InputStream inputStream = null; - - try { - - /** - * Get the code page which contains the character mapping - * information to map the unicode character id to the graphic - * chracter global identifier. - */ - String codePageId = new String(characterSet.getCodePage()); - String path = characterSet.getPath(); - - Map/**/ codePage = (Map/**/)codePages.get(codePageId); - - if (codePage == null) { - codePage = loadCodePage(codePageId, characterSet.getEncoding(), path); - codePages.put(codePageId, codePage); - } - - /** - * Load the character set metric information, no need to cache this - * information as it should be cached by the objects that wish to - * load character set metric information. - */ - final String characterSetName = characterSet.getName(); - - inputStream = openInputStream(path, characterSetName); - - StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream); - - // Process D3A789 Font Control - FontControl fontControl = processFontControl(structuredFieldReader); - - if (fontControl != null) { - //process D3AE89 Font Orientation - CharacterSetOrientation[] characterSetOrientations - = processFontOrientation(structuredFieldReader); - - int dpi = fontControl.getDpi(); - - //process D3AC89 Font Position - processFontPosition(structuredFieldReader, characterSetOrientations, dpi); - - //process D38C89 Font Index (per orientation) - for (int i = 0; i < characterSetOrientations.length; i++) { - processFontIndex(structuredFieldReader, - characterSetOrientations[i], codePage, dpi); - characterSet.addCharacterSetOrientation(characterSetOrientations[i]); - } - } else { - throw new IOException( - "Failed to read font control structured field in character set " - + characterSetName); - } - - } finally { - closeInputStream(inputStream); - } - - } - - /** - * Load the code page information from the appropriate file. The file name - * to load is determined by the code page name and the file extension 'CDP'. - * - * @param codePage - * the code page identifier - * @param encoding - * the encoding to use for the character decoding - * @returns a code page mapping - */ - private Map/**/ loadCodePage(String codePage, String encoding, - String path) throws IOException { - - // Create the HashMap to store code page information - Map/**/ codePages = new java.util.HashMap/**/(); - - InputStream inputStream = null; - try { - inputStream = openInputStream(path, codePage.trim()); - - StructuredFieldReader structuredFieldReader = new StructuredFieldReader(inputStream); - byte[] data = structuredFieldReader.getNext(CHARACTER_TABLE_SF); - - int position = 0; - byte[] gcgiBytes = new byte[8]; - byte[] charBytes = new byte[1]; - - // Read data, ignoring bytes 0 - 2 - for (int index = 3; index < data.length; index++) { - if (position < 8) { - // Build the graphic character global identifier key - gcgiBytes[position] = data[index]; - position++; - } else if (position == 9) { - position = 0; - // Set the character - charBytes[0] = data[index]; - String gcgiString = new String(gcgiBytes, - AFPConstants.EBCIDIC_ENCODING); - String charString = new String(charBytes, encoding); -// int value = charString.charAt(0); - codePages.put(gcgiString, charString); - } else { - position++; - } - } - } finally { - closeInputStream(inputStream); - } - - return codePages; - } - - /** - * Process the font control details using the structured field reader. - * - * @param structuredFieldReader - * the structured field reader - */ - private FontControl processFontControl(StructuredFieldReader structuredFieldReader) - throws IOException { - - byte[] fncData = structuredFieldReader.getNext(FONT_CONTROL_SF); - -// int position = 0; - FontControl fontControl = null; - if (fncData != null) { - fontControl = new FontControl(); - - if (fncData[7] == (byte) 0x02) { - fontControl.setRelative(true); - } - - int dpi = (((fncData[9] & 0xFF) << 8) + (fncData[10] & 0xFF)) / 10; - - fontControl.setDpi(dpi); - } - return fontControl; - } - - /** - * Process the font orientation details from using the structured field - * reader. - * - * @param structuredFieldReader - * the structured field reader - */ - private CharacterSetOrientation[] processFontOrientation( - StructuredFieldReader structuredFieldReader) throws IOException { - - byte[] data = structuredFieldReader.getNext(FONT_ORIENTATION_SF); - - int position = 0; - byte[] fnoData = new byte[26]; - - List orientations = new java.util.ArrayList(); - - // Read data, ignoring bytes 0 - 2 - for (int index = 3; index < data.length; index++) { - // Build the font orientation record - fnoData[position] = data[index]; - position++; - - if (position == 26) { - - position = 0; - - int orientation = 0; - - switch (fnoData[2]) { - case 0x00: - orientation = 0; - break; - case 0x2D: - orientation = 90; - break; - case 0x5A: - orientation = 180; - break; - case (byte) 0x87: - orientation = 270; - break; - default: - System.out.println("ERROR: Oriantation"); - } - - CharacterSetOrientation cso = new CharacterSetOrientation( - orientation); - orientations.add(cso); - - } - } - - return (CharacterSetOrientation[]) orientations - .toArray(EMPTY_CSO_ARRAY); - } - - /** - * Populate the CharacterSetOrientation object in the suplied array with the - * font position details using the supplied structured field reader. - * - * @param structuredFieldReader - * the structured field reader - * @param characterSetOrientations - * the array of CharacterSetOrientation objects - */ - private void processFontPosition(StructuredFieldReader structuredFieldReader, - CharacterSetOrientation[] characterSetOrientations, int dpi) throws IOException { - - byte[] data = structuredFieldReader.getNext(FONT_POSITION_SF); - - int position = 0; - byte[] fpData = new byte[26]; - - int characterSetOrientationIndex = 0; - int fopFactor = 0; - - switch (dpi) { - case 100: - fopFactor = FOP_100_DPI_FACTOR; - break; - case 240: - fopFactor = FOP_240_DPI_FACTOR; - break; - case 300: - fopFactor = FOP_300_DPI_FACTOR; - break; - default: - String msg = "Unsupported font resolution of " + dpi + " dpi."; - log.error(msg); - throw new IOException(msg); - } - - // Read data, ignoring bytes 0 - 2 - for (int index = 3; index < data.length; index++) { - if (position < 22) { - // Build the font orientation record - fpData[position] = data[index]; - } else if (position == 22) { - - position = 0; - - CharacterSetOrientation characterSetOrientation - = characterSetOrientations[characterSetOrientationIndex]; - - int xHeight = ((fpData[2] & 0xFF) << 8) + (fpData[3] & 0xFF); - int capHeight = ((fpData[4] & 0xFF) << 8) + (fpData[5] & 0xFF); - int ascHeight = ((fpData[6] & 0xFF) << 8) + (fpData[7] & 0xFF); - int dscHeight = ((fpData[8] & 0xFF) << 8) + (fpData[9] & 0xFF); - - dscHeight = dscHeight * -1; - - characterSetOrientation.setXHeight(xHeight * fopFactor); - characterSetOrientation.setCapHeight(capHeight * fopFactor); - characterSetOrientation.setAscender(ascHeight * fopFactor); - characterSetOrientation.setDescender(dscHeight * fopFactor); - - characterSetOrientationIndex++; - - fpData[position] = data[index]; - - } - - position++; - } - - } - - /** - * Process the font index details for the character set orientation. - * - * @param structuredFieldReader - * the structured field reader - * @param cso - * the CharacterSetOrientation object to populate - * @param codepage - * the map of code pages - */ - private void processFontIndex(StructuredFieldReader structuredFieldReader, - CharacterSetOrientation cso, Map/**/ codepage, int dpi) - throws IOException { - - byte[] data = structuredFieldReader.getNext(FONT_INDEX_SF); - - int fopFactor = 0; - - switch (dpi) { - case 100: - fopFactor = FOP_100_DPI_FACTOR; - break; - case 240: - fopFactor = FOP_240_DPI_FACTOR; - break; - case 300: - fopFactor = FOP_300_DPI_FACTOR; - break; - default: - String msg = "Unsupported font resolution of " + dpi + " dpi."; - log.error(msg); - throw new IOException(msg); - } - - int position = 0; - - byte[] gcgid = new byte[8]; - byte[] fiData = new byte[20]; - - int lowest = 255; - int highest = 0; - - // Read data, ignoring bytes 0 - 2 - for (int index = 3; index < data.length; index++) { - if (position < 8) { - gcgid[position] = data[index]; - position++; - } else if (position < 27) { - fiData[position - 8] = data[index]; - position++; - } else if (position == 27) { - - fiData[position - 8] = data[index]; - - position = 0; - - String gcgiString = new String(gcgid, AFPConstants.EBCIDIC_ENCODING); - - String idx = (String) codepage.get(gcgiString); - - if (idx != null) { - - int cidx = idx.charAt(0); - int width = ((fiData[0] & 0xFF) << 8) + (fiData[1] & 0xFF); - - if (cidx < lowest) { - lowest = cidx; - } - - if (cidx > highest) { - highest = cidx; - } - - int a = (width * fopFactor); - - cso.setWidth(cidx, a); - - } - - } - } - - cso.setFirstChar(lowest); - cso.setLastChar(highest); - - } - - private class FontControl { - - private int dpi; - - private boolean isRelative = false; - - public int getDpi() { - return dpi; - } - - public void setDpi(int i) { - dpi = i; - } - - public boolean isRelative() { - return isRelative; - } - - public void setRelative(boolean b) { - isRelative = b; - } - } - -} diff --git a/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java b/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java deleted file mode 100644 index fc0ab8b16..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/CharacterSet.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * 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.fonts; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.AFPConstants; -import org.apache.fop.render.afp.tools.StringUtils; - -/** - * The IBM Font Object Content Architecture (FOCA) supports presentation - * of character shapes by defining their characteristics, which include - * font description information for identifying the characters, font metric - * information for positioning the characters, and character shape information - * for presenting the character images. - *

      - * Presenting a graphic character on a presentation surface requires - * information on the rotation and position of character on the physical - * or logical page. - *

      - * This class proivdes font metric information for a particular font - * as identified by the character set name. This information is obtained - * directly from the AFP font files which must be installed in the path - * specified in the afp-fonts xml definition file. - *

      - */ -public class CharacterSet { - - /** Static logging instance */ - protected static final Log log = LogFactory.getLog(CharacterSet.class.getName()); - - /** default codepage */ - protected static final String DEFAULT_CODEPAGE = "T1V10500"; - - /** default encoding */ - protected static final String DEFAULT_ENCODING = "Cp500"; - - private static final int MAX_NAME_LEN = 8; - - - /** The code page to which the character set relates */ - protected String codePage; - - /** The encoding used for the code page */ - protected String encoding; - - /** The character set relating to the font */ - protected String name; - - /** The path to the installed fonts */ - protected String path; - - /** Indicator as to whether to metrics have been loaded */ - private boolean isMetricsLoaded = false; - - /** The current orientation (currently only 0 is supported by FOP) */ - private final String currentOrientation = "0"; - - /** The collection of objects for each orientation */ - private Map characterSetOrientations = null; - - /** - * 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 - * @param path the path to the installed afp fonts - */ - public CharacterSet(String codePage, String encoding, String name, String path) { - if (name.length() > MAX_NAME_LEN) { - String msg = "Character set name '" + name + "' must be a maximum of " - + MAX_NAME_LEN + " characters"; - log.error("Constructor:: " + msg); - throw new IllegalArgumentException(msg); - } - - if (name.length() < MAX_NAME_LEN) { - this.name = StringUtils.rpad(name, ' ', MAX_NAME_LEN); - } else { - this.name = name; - } - this.codePage = codePage; - this.encoding = encoding; - this.path = path; - - this.characterSetOrientations = new java.util.HashMap(4); - } - - /** - * Add character set metric information for the different orientations - * - * @param cso the metrics for the orientation - */ - public void addCharacterSetOrientation(CharacterSetOrientation cso) { - characterSetOrientations.put( - String.valueOf(cso.getOrientation()), - cso); - } - - /** - * Ascender height is the distance from the character baseline to the - * top of the character box. A negative ascender height signifies that - * all of the graphic character is below the character baseline. For - * a character rotation other than 0, ascender height loses its - * meaning when the character is lying on its side or is upside down - * with respect to normal viewing orientation. For the general case, - * 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() { - load(); - return getCharacterSetOrientation().getAscender(); - } - - /** - * 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() { - load(); - return getCharacterSetOrientation().getCapHeight(); - } - - /** - * 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() { - load(); - return getCharacterSetOrientation().getDescender(); - } - - /** - * Returns the first character in the character set - * - * @return the first character in the character set - */ - public int getFirstChar() { - load(); - return getCharacterSetOrientation().getFirstChar(); - } - - /** - * Returns the last character in the character set - * - * @return the last character in the character set - */ - public int getLastChar() { - load(); - return getCharacterSetOrientation().getLastChar(); - } - - /** - * Returns the path where the font resources are installed - * - * @return the path where the font resources are installed - */ - public String getPath() { - return path; - } - - /** - * Get the width (in 1/1000ths of a point size) of all characters - * - * @return the widths of all characters - */ - public int[] getWidths() { - load(); - return getCharacterSetOrientation().getWidths(); - } - - /** - * XHeight refers to the height of the lower case letters above the baseline. - * - * @return the typical height of characters - */ - public int getXHeight() { - load(); - return getCharacterSetOrientation().getXHeight(); - } - - /** - * 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 - */ - public int getWidth(int character) { - load(); - return getCharacterSetOrientation().getWidth(character); - } - - /** - * Lazy creation of the character metrics, the afp font file will only - * be processed on a method call requiring the metric information. - */ - private void load() { - if (!isMetricsLoaded) { - AFPFontReader afpFontReader = new AFPFontReader(); - try { - afpFontReader.loadCharacterSetMetric(this); - isMetricsLoaded = true; - } catch (IOException e) { - String msg = "Failed to load the character set metrics for code page " + codePage; - log.error(msg); - throw new RuntimeException(e.getMessage()); - } - } - } - - /** - * Returns the AFP character set identifier - * - * @return the AFP character set identifier - */ - public String getName() { - return name; - } - - /** - * Returns the AFP character set identifier as a byte array - * - * @return the AFP character set identifier as a byte array - */ - public byte[] getNameBytes() { - byte[] nameBytes = null; - try { - nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); - } catch (UnsupportedEncodingException usee) { - nameBytes = name.getBytes(); - log.warn( - "UnsupportedEncodingException translating the name " + name); - } - return nameBytes; - } - - /** - * Returns the AFP code page identifier - * - * @return the AFP code page identifier - */ - public String getCodePage() { - return codePage; - } - - /** - * Returns the AFP code page encoding - * - * @return the AFP code page encoding - */ - public String getEncoding() { - return encoding; - } - - /** - * Helper method to return the current CharacterSetOrientation, note - * that FOP does not yet implement the "reference-orientation" - * attribute therefore we always use the orientation zero degrees, - * Other orientation information is captured for use by a future - * implementation (whenever FOP implement the mechanism). This is also - * 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() { - CharacterSetOrientation c - = (CharacterSetOrientation) characterSetOrientations.get(currentOrientation); - return c; - } - - /** - * 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 - */ - public char mapChar(char c) { - return c; - } - -} diff --git a/src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java b/src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java deleted file mode 100644 index e13029717..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/CharacterSetOrientation.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * 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.fonts; - -/** - * The IBM Font Object Content Architecture (FOCA) supports presentation - * of character shapes by defining their characteristics, which include - * Font-Description information for identifying the characters, Font-Metric - * information for positioning the characters, and Character-Shape - * information for presenting the character images. - * - * Presenting a graphic character on a presentation surface requires - * that you communicate this information clearly to rotate and position - * characters correctly on the physical or logical page. - * - * This class provides font metric information for a particular font - * as by the orientation. - * - * This information is obtained directly from the AFP font files which must - * be installed in the classpath under in the location specified by the path - * attribute in the afp-font.xml file. - *

      - */ -public class CharacterSetOrientation { - - /** - * The code page to which the character set relates - */ - private String codePage; - - /** - * The encoding used for the code page - */ - private String encoding; - - /** - * The ascender height for the character set - */ - private int ascender; - - /** - * The descender depth for the character set - */ - private int descender; - - /** - * The height of capital letters - */ - private int capHeight; - - /** - * The characters in the charcater set - */ - private int[] chars = new int[256]; - - /** - * The height of lowercase letters - */ - private int xHeight; - - /** - * The first character - */ - private int firstChar; - - /** - * The last character - */ - private int lastChar; - - - /** - * The character set orientation - */ - private int orientation = 0; - - /** - * Constructor for the CharacterSetOrientation, the orientation is - * expressed as the degrees rotation (i.e 0, 90, 180, 270) - * @param orientation the character set orientation - */ - public CharacterSetOrientation(int orientation) { - this.orientation = orientation; - } - - /** - * Ascender height is the distance from the character baseline to the - * top of the character box. A negative ascender height signifies that - * all of the graphic character is below the character baseline. For - * a character rotation other than 0, ascender height loses its - * meaning when the character is lying on its side or is upside down - * with respect to normal viewing orientation. For the general case, - * Ascender Height is the character�s 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() { - return ascender; - } - - /** - * 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() { - return capHeight; - } - - /** - * 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() { - return descender; - } - - /** - * The first character in the character set - * @return the first character - */ - public int getFirstChar() { - return firstChar; - } - - /** - * The last character in the character set - * @return the last character - */ - public int getLastChar() { - return lastChar; - } - - /** - * The orientation for these metrics in the character set - * @return the orientation - */ - public int getOrientation() { - return orientation; - } - - /** - * Get the width (in 1/1000ths of a point size) of all characters - * in this character set. - * @return the widths of all characters - */ - public int[] getWidths() { - int arr[] = new int[(getLastChar() - getFirstChar()) + 1]; - System.arraycopy(chars, getFirstChar(), arr, 0, (getLastChar() - getFirstChar()) + 1); - return arr; - } - - /** - * XHeight refers to the height of the lower case letters above - * the baseline. - * @return heightX the typical height of characters - */ - public int getXHeight() { - return xHeight; - } - - /** - * Get the width (in 1/1000ths of a point size) of the character - * identified by the parameter passed. - * @param characterIndex the character to evaluate - * @return the widths of the character - */ - public int getWidth(int characterIndex) { - if (characterIndex >= chars.length) { - throw new IllegalArgumentException("Invalid character index: " - + characterIndex + ", maximum is " + (chars.length - 1)); - } - return chars[characterIndex]; - } - - /** - * Ascender height is the distance from the character baseline to the - * top of the character box. A negative ascender height signifies that - * all of the graphic character is below the character baseline. For - * a character rotation other than 0, ascender height loses its - * meaning when the character is lying on its side or is upside down - * with respect to normal viewing orientation. For the general case, - * Ascender Height is the character�s most positive y-axis value. - * For bounded character boxes, for a given character having an - * ascender, ascender height and baseline offset are equal. - * @param ascender the ascender to set - */ - public void setAscender(int ascender) { - this.ascender = ascender; - } - - /** - * 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. - * @param capHeight the cap height to set - */ - public void setCapHeight(int capHeight) { - this.capHeight = capHeight; - } - - /** - * 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. - * @param descender the descender value in millipoints - */ - public void setDescender(int descender) { - this.descender = descender; - } - - /** - * The first character in the character set - * @param firstChar the first character - */ - public void setFirstChar(int firstChar) { - this.firstChar = firstChar; - } - - /** - * The last character in the character set - * @param lastChar the last character - */ - public void setLastChar(int lastChar) { - this.lastChar = lastChar; - } - - /** - * Set the width (in 1/1000ths of a point size) of the character - * identified by the parameter passed. - * @param character the character for which the width is being set - * @param width the widths of the character - */ - public void setWidth(int character, int width) { - - if (character >= chars.length) { - // Increase the size of the array if necessary - int arr[] = new int[(character - firstChar) + 1]; - System.arraycopy(chars, 0, arr, 0, chars.length); - chars = arr; - } - chars[character] = width; - - } - - /** - * XHeight refers to the height of the lower case letters above - * the baseline. - * @param xHeight the typical height of characters - */ - public void setXHeight(int xHeight) { - this.xHeight = xHeight; - } -} diff --git a/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java b/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java deleted file mode 100644 index d5beb5a33..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/FopCharacterSet.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.fonts; - -import org.apache.fop.fonts.Typeface; - -/** - * A Character set for a normal FOP font

      - */ -public class FopCharacterSet extends CharacterSet { - - /** The character set for this font */ - private Typeface charSet = null; - private int size = 0; - - /** - * 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 - * @param size the font size - * @param charSet the fop character set - */ - public FopCharacterSet( - String codePage, - String encoding, - String name, - int size, - Typeface charSet) { - - super(codePage, encoding, name, null); - this.charSet = charSet; - this.size = size * 1000; - } - - /** - * Ascender height is the distance from the character baseline to the - * top of the character box. A negative ascender height signifies that - * all of the graphic character is below the character baseline. For - * a character rotation other than 0, ascender height loses its - * meaning when the character is lying on its side or is upside down - * with respect to normal viewing orientation. For the general case, - * Ascender Height is the character�s 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() { - return charSet.getAscender(size); - } - - /** - * 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() { - return charSet.getCapHeight(size); - } - - /** - * 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() { - return charSet.getDescender(size); - } - - /** - * The first character in the character set - * @return the first character - */ - public int getFirstChar() { - return 0; - } - - /** - * The last character in the character set - * @return the last character - */ - public int getLastChar() { - return 0; - } - - /** - * Get the width (in 1/1000ths of a point size) of all characters - * @return the widths of all characters - */ - public int[] getWidths() { - return charSet.getWidths(); - } - - /** - * XHeight refers to the height of the lower case letters above the baseline. - * @return the typical height of characters - */ - public int getXHeight() { - return charSet.getXHeight(size); - } - - /** - * 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 - */ - public int getWidth(int character) { - return charSet.getWidth(character, size); - } - - /** - * Map a Unicode character to a code point in the font. - * @param c character to map - * @return the mapped character - */ - public char mapChar(char c) { - return charSet.mapChar(c); - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java b/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java deleted file mode 100644 index 71c5dfb6f..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/OutlineFont.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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.fonts; - -/** - * A font defined as a set of lines and curves as opposed to a bitmap font. An - * outline font can be scaled to any size and otherwise transformed more easily - * than a bitmap font, and with more attractive results.

      - * - */ -public class OutlineFont extends AFPFont { - - /** The character set for this font */ - private CharacterSet charSet = null; - - /** - * Constructor for an outline font. - * - * @param name - * the name of the font - * @param charSet - * the chracter set - */ - public OutlineFont(String name, CharacterSet charSet) { - super(name); - this.charSet = charSet; - } - - /** - * Get the character set metrics. - * - * @return the character set - */ - public CharacterSet getCharacterSet() { - - return charSet; - - } - - /** - * Get the character set metrics. - * @param size ignored - * @return the character set - */ - public CharacterSet getCharacterSet(int size) { - - return charSet; - - } - - /** - * Get the first character in this font. - * @return the first character in this font - */ - public int getFirstChar() { - return charSet.getFirstChar(); - } - - /** - * Get the last character in this font. - * @return the last character in this font - */ - public int getLastChar() { - return charSet.getLastChar(); - } - - /** - * The ascender is the part of a lowercase letter that extends above the - * "x-height" (the height of the letter "x"), such as "d", "t", or "h". Also - * used to denote the part of the letter extending above the x-height. - * - * @param size - * the point size - * @return the ascender for the given size - */ - public int getAscender(int size) { - return charSet.getAscender() / 1000 * size; - } - - /** - * Obtains the height of capital letters for the specified point size. - * - * @param size - * the point size - * @return the cap height for the given size - */ - public int getCapHeight(int size) { - return charSet.getCapHeight() / 1000 * size; - } - - /** - * The descender is the part of a lowercase letter that extends below the - * base line, such as "g", "j", or "p". Also used to denote the part of the - * letter extending below the base line. - * - * @param size - * the point size - * @return the descender for the given size - */ - public int getDescender(int size) { - return charSet.getDescender() / 1000 * size; - } - - /** - * The "x-height" (the height of the letter "x"). - * - * @param size - * the point size - * @return the x height for the given size - */ - public int getXHeight(int size) { - return charSet.getXHeight() / 1000 * size; - } - - /** - * Obtain the width of the character for the specified point size. - * @param character the character - * @param size point size - * @return the width of the character for the specified point size - */ - public int getWidth(int character, int size) { - return charSet.getWidth(character) / 1000 * size; - } - - /** - * Get the getWidth (in 1/1000ths of a point size) of all characters in this - * character set. - * - * @param size - * the point size - * @return the widths of all characters - */ - public int[] getWidths(int size) { - int[] widths = charSet.getWidths(); - for (int i = 0; i < widths.length; i++) { - widths[i] = widths[i] / 1000 * size; - } - return widths; - } - - /** - * Get the getWidth (in 1/1000ths of a point size) of all characters in this - * character set. - * - * @return the widths of all characters - */ - public int[] getWidths() { - return getWidths(1000); - } - - /** - * Map a Unicode character to a code point in the font. - * @param c character to map - * @return the mapped character - */ - public char mapChar(char c) { - return charSet.mapChar(c); - } - - /** {@inheritDoc} */ - public String getEncodingName() { - return charSet.getEncoding(); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/fonts/RasterFont.java b/src/java/org/apache/fop/render/afp/fonts/RasterFont.java deleted file mode 100644 index ee4bfba6c..000000000 --- a/src/java/org/apache/fop/render/afp/fonts/RasterFont.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * 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.fonts; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.fo.properties.FixedLength; -import org.apache.fop.render.afp.exceptions.FontRuntimeException; - -/** - * A font where each character is stored as an array of pixels (a bitmap). Such - * fonts are not easily scalable, in contrast to vectored fonts. With this type - * of font, the font metrics information is held in character set files (one for - * each size and style).

      - * - */ -public class RasterFont extends AFPFont { - - /** Static logging instance */ - protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.fonts"); - - private Map charSets = new HashMap(); - - private CharacterSet charSet = null; - - /** - * Constructor for the raster font requires the name, weight and style - * attribute to be available as this forms the key to the font. - * - * @param name - * the name of the font - */ - public RasterFont(String name) { - super(name); - } - - /** - * Adds the character set for the given point size - * @param size point size - * @param characterSet character set - */ - public void addCharacterSet(int size, CharacterSet characterSet) { - this.charSets.put(String.valueOf(size), characterSet); - this.charSet = characterSet; - } - - /** - * Get the character set metrics for the specified point size. - * - * @param size the point size - * @return the character set metrics - */ - public CharacterSet getCharacterSet(int size) { - - String pointsize = String.valueOf(size / 1000); - CharacterSet csm = (CharacterSet) charSets.get(pointsize); - if (csm == null) { - csm = (CharacterSet) charSets.get(size + FixedLength.MPT); - } - if (csm == null) { - // Get char set with nearest font size - int distance = Integer.MAX_VALUE; - for (Iterator it = charSets.entrySet().iterator(); it.hasNext();) { - Map.Entry me = (Map.Entry)it.next(); - String key = (String)me.getKey(); - if (!key.endsWith(FixedLength.MPT)) { - int mpt = Integer.parseInt(key) * 1000; - if (Math.abs(size - mpt) < distance) { - distance = Math.abs(size - mpt); - pointsize = (String)me.getKey(); - csm = (CharacterSet)me.getValue(); - } - } - } - if (csm != null) { - charSets.put(size + FixedLength.MPT, csm); - String msg = "No " + (size / 1000) + "pt font " + getFontName() - + " found, substituted with " + pointsize + "pt font"; - log.warn(msg); - } - } - if (csm == null) { - String msg = "No font found for font " + getFontName() - + " with point size " + pointsize; - log.error(msg); - throw new FontRuntimeException(msg); - } - return csm; - - } - - /** - * Get the first character in this font. - * @return the first character in this font. - */ - public int getFirstChar() { - Iterator it = charSets.values().iterator(); - if (it.hasNext()) { - CharacterSet csm = (CharacterSet) it.next(); - return csm.getFirstChar(); - } else { - String msg = "getFirstChar() - No character set found for font:" + getFontName(); - log.error(msg); - throw new FontRuntimeException(msg); - } - } - - /** - * Get the last character in this font. - * @return the last character in this font. - */ - public int getLastChar() { - - Iterator it = charSets.values().iterator(); - if (it.hasNext()) { - CharacterSet csm = (CharacterSet) it.next(); - return csm.getLastChar(); - } else { - String msg = "getLastChar() - No character set found for font:" + getFontName(); - log.error(msg); - throw new FontRuntimeException(msg); - } - - } - - /** - * The ascender is the part of a lowercase letter that extends above the - * "x-height" (the height of the letter "x"), such as "d", "t", or "h". Also - * used to denote the part of the letter extending above the x-height. - * - * @param size the point size - * @return the ascender for the given point size - */ - public int getAscender(int size) { - return getCharacterSet(size).getAscender(); - } - - /** - * Obtains the height of capital letters for the specified point size. - * - * @param size the point size - * @return the cap height for the specified point size - */ - public int getCapHeight(int size) { - return getCharacterSet(size).getCapHeight(); - } - - /** - * The descender is the part of a lowercase letter that extends below the - * base line, such as "g", "j", or "p". Also used to denote the part of the - * letter extending below the base line. - * - * @param size the point size - * @return the descender for the specified point size - */ - public int getDescender(int size) { - return getCharacterSet(size).getDescender(); - } - - /** - * The "x-height" (the height of the letter "x"). - * - * @param size the point size - * @return the x height for the given point size - */ - public int getXHeight(int size) { - return getCharacterSet(size).getXHeight(); - } - - /** - * Obtain the width of the character for the specified point size. - * @param character the character - * @param size the point size - * @return the width for the given point size - */ - public int getWidth(int character, int size) { - return getCharacterSet(size).getWidth(character); - } - - /** - * Get the getWidth (in 1/1000ths of a point size) of all characters in this - * character set. - * - * @param size - * the point size - * @return the widths of all characters - */ - public int[] getWidths(int size) { - return getCharacterSet(size).getWidths(); - } - - /** - * Get the getWidth (in 1/1000ths of a point size) of all characters in this - * character set. - * - * @return the widths of all characters - */ - public int[] getWidths() { - return getWidths(1000); - } - - /** - * Map a Unicode character to a code point in the font. - * @param c character to map - * @return the mapped character - */ - public char mapChar(char c) { - return charSet.mapChar(c); - } - - /** {@inheritDoc} */ - public String getEncodingName() { - return charSet.getEncoding(); - } - -} diff --git a/src/java/org/apache/fop/render/afp/goca/AbstractGraphicsCoord.java b/src/java/org/apache/fop/render/afp/goca/AbstractGraphicsCoord.java deleted file mode 100644 index dbb7469fe..000000000 --- a/src/java/org/apache/fop/render/afp/goca/AbstractGraphicsCoord.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.goca; - -import org.apache.fop.render.afp.modca.AbstractPreparedAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A base class encapsulating the structure of coordinate based GOCA objects - */ -public abstract class AbstractGraphicsCoord extends AbstractPreparedAFPObject { - - /** array of x/y coordinates */ - protected int[] coords = null; - - /** - * Constructor - * - * @param coords the x/y coordinates for this object - */ - public AbstractGraphicsCoord(int[] coords) { - this.coords = coords; - prepareData(); - } - - /** - * Constructor - * - * @param x the x coordinate for this object - * @param y the y coordinate for this object - */ - public AbstractGraphicsCoord(int x, int y) { - this(new int[] {x, y}); - } - - /** - * Constructor - * - * @param x1 the x1 coordinate for this object - * @param y1 the y1 coordinate for this object - * @param x2 the x2 coordinate for this object - * @param y2 the y2 coordinate for this object - */ - public AbstractGraphicsCoord(int x1, int y1, int x2, int y2) { - this(new int[] {x1, y1, x2, y2}); - } - - /** - * Returns the order code to use - * - * @return the order code to use - */ - protected abstract byte getOrderCode(); - - /** - * Returns the length of this order code (typically this is the same as the coordinate length) - * - * @return the length of this order code - * - */ - protected int getLength() { - return this.coords.length * 2; - } - - /** - * Creates a newly created and initialized byte data - * - * @return a newly created and initialized byte data - */ - protected byte[] createData() { - int len = getLength(); - byte[] data = new byte[len + 2]; - data[0] = getOrderCode(); // ORDER CODE - data[1] = (byte)len; // LENGTH - return data; - } - - /** {@inheritDoc} */ - protected void prepareData() { - super.data = createData(); - int fromIndex = data.length - getLength(); - addCoords(data, fromIndex); - } - - /** - * Adds the coordinates to the structured field data - * - * @param data the structured field data - * @param fromIndex the start index - */ - protected void addCoords(byte[] data, int fromIndex) { - // X/Y POS - for (int i = 0; i < coords.length; i++, fromIndex += 2) { - byte[] coord = BinaryUtils.convert(coords[i], 2); - data[fromIndex] = coord[0]; - data[fromIndex + 1] = coord[1]; - } - } - - /** - * Returns the short name of this GOCA object - * - * @return the short name of this GOCA object - */ - public String getName() { - String className = getClass().getName(); - return className.substring(className.lastIndexOf(".") + 1); - } - - /** {@inheritDoc} */ - public String toString() { - String coordsStr = ""; - for (int i = 0; i < coords.length; i++) { - coordsStr += (i % 2 == 0) ? "x" : "y"; - coordsStr += (i / 2) + "=" + coords[i] + ","; - } - coordsStr = coordsStr.substring(0, coordsStr.length() - 1); - return getName() + "{" + coordsStr + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java b/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java deleted file mode 100644 index 7ad6ede27..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsArea.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.goca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractPreparedObjectContainer; - -/** - * A GOCA graphics area (container for filled shapes/objects) - */ -public final class GraphicsArea extends AbstractPreparedObjectContainer { - - private static final int RES1 = 1; - private static final int BOUNDARY = 2; - private static final int NO_BOUNDARY = 0; - - /** draw boundary lines around this area */ - private boolean drawBoundary = false; - - /** - * Sets whether boundary lines are drawn - * - * @param drawBoundaryLines whether boundary lines are drawn - */ - public void setDrawBoundaryLines(boolean drawBoundaryLines) { - this.drawBoundary = drawBoundaryLines; - } - - /** {@inheritDoc} */ - public int getDataLength() { - // start len + end len + data len - return 4 + super.getDataLength(); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[] { - (byte)0x68, // GBAR order code - (byte)(RES1 + (drawBoundary ? BOUNDARY : NO_BOUNDARY)) - }; - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] endData = new byte[] { - (byte)0x60, // GEAR order code - 0x00, // LENGTH - }; - os.write(endData); - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsArea{drawBoundary=" + drawBoundary + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsBox.java b/src/java/org/apache/fop/render/afp/goca/GraphicsBox.java deleted file mode 100644 index 3daa437f2..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsBox.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.goca; - -/** - * A GOCA graphics rectangular box - */ -public final class GraphicsBox extends AbstractGraphicsCoord { - - /** - * Constructor - * - * @param coords the x/y coordinates for this object - */ - public GraphicsBox(int[] coords) { - super(coords); - } - - /** {@inheritDoc} */ - protected byte getOrderCode() { - return (byte)0xC0; - } - - /** {@inheritDoc} */ - protected int getLength() { - return 10; - } - - /** {@inheritDoc} */ - protected void prepareData() { - super.data = createData(); - final int fromIndex = 4; - addCoords(data, fromIndex); - } - - /** {@inheritDoc} */ - protected byte[] createData() { - byte[] data = super.createData(); - data[2] = (byte)0x20; // CONTROL draw control flags - data[3] = 0x00; // reserved - return data; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java b/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java deleted file mode 100644 index ba4ccea86..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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.goca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractPreparedObjectContainer; -import org.apache.fop.render.afp.modca.PreparedAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA graphics segment - */ -public final class GraphicsChainedSegment extends AbstractPreparedObjectContainer { - - /** The maximum segment data length */ - protected static final int MAX_DATA_LEN = 8192; - - /** the current area */ - private GraphicsArea currentArea = null; - - /** the previous segment in the chain */ - private GraphicsChainedSegment previous = null; - - /** the next segment in the chain */ - private GraphicsChainedSegment next = null; - - /** - * Main constructor - * - * @param name - * the name of this graphics segment - */ - public GraphicsChainedSegment(String name) { - super(name); - } - - /** - * Constructor - * - * @param name - * the name of this graphics segment - * @param previous - * the previous graphics segment in this chain - */ - public GraphicsChainedSegment(String name, GraphicsChainedSegment previous) { - super(name); - previous.next = this; - this.previous = previous; - } - - /** {@inheritDoc} */ - public int getDataLength() { - return 14 + super.getDataLength(); - } - - private static final byte APPEND_NEW_SEGMENT = 0; -// private static final byte PROLOG = 4; -// private static final byte APPEND_TO_EXISING = 48; - - private static final int NAME_LENGTH = 4; - - /** {@inheritDoc} */ - protected int getNameLength() { - return NAME_LENGTH; - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - - byte[] data = new byte[14]; - data[0] = 0x70; // BEGIN_SEGMENT - data[1] = 0x0C; // Length of following parameters - - // segment name - byte[] nameBytes = getNameBytes(); - System.arraycopy(nameBytes, 0, data, 2, NAME_LENGTH); - - data[6] = 0x00; // FLAG1 (ignored) - data[7] = APPEND_NEW_SEGMENT; - - int dataLength = super.getDataLength(); - byte[] len = BinaryUtils.convert(dataLength, 2); - data[8] = len[0]; // SEGL - data[9] = len[1]; - - // P/S NAME (predecessor name) - if (previous != null) { - nameBytes = previous.getNameBytes(); - System.arraycopy(nameBytes, 0, data, 10, NAME_LENGTH); - } - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - // I am the first segment in the chain so write out the rest - if (previous == null) { - for (GraphicsChainedSegment segment = next; segment != null; segment = segment.next) { - segment.writeToStream(os); - } - } // else nothing todo - } - - /** Begins a graphics area (start of fill) */ - protected void beginArea() { - this.currentArea = new GraphicsArea(); - super.addObject(currentArea); - } - - /** Ends a graphics area (end of fill) */ - protected void endArea() { - this.currentArea = null; - } - - /** {@inheritDoc} */ - public void addObject(PreparedAFPObject drawingOrder) { - if (currentArea != null) { - currentArea.addObject(drawingOrder); - } else { - super.addObject(drawingOrder); - } - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsChainedSegment(name=" + super.getName() + ")"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsData.java b/src/java/org/apache/fop/render/afp/goca/GraphicsData.java deleted file mode 100644 index 538933a03..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsData.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.goca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractPreparedObjectContainer; -import org.apache.fop.render.afp.modca.PreparedAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; -import org.apache.fop.render.afp.tools.StringUtils; - -/** - * A GOCA graphics data - */ -public final class GraphicsData extends AbstractPreparedObjectContainer { - - /** The maximum graphics data length */ - public static final int MAX_DATA_LEN = 32767; - - /** The graphics segment */ - private GraphicsChainedSegment currentSegment = null; - - /** {@inheritDoc} */ - public int getDataLength() { - return 8 + super.getDataLength(); - } - - /** - * Begins a graphics area (start of fill) - */ - public void beginArea() { - getSegment().beginArea(); - } - - /** - * Ends a graphics area (end of fill) - */ - public void endArea() { - getSegment().endArea(); - } - - /** - * Returns a new segment name - * - * @return a new segment name - */ - private String createSegmentName() { - return StringUtils.lpad(String.valueOf( - (super.objects != null ? super.objects.size() : 0) + 1), - '0', 4); - } - - /** - * Returns the current graphics segment, creating one if one does not exist - * - * @return the current graphics chained segment - */ - private GraphicsChainedSegment getSegment() { - if (currentSegment == null) { - newSegment(); - } - return this.currentSegment; - } - - /** - * Creates a new graphics segment - * - * @return a newly created graphics segment - */ - public GraphicsChainedSegment newSegment() { - String name = createSegmentName(); - if (currentSegment == null) { - this.currentSegment = new GraphicsChainedSegment(name); - } else { - this.currentSegment = new GraphicsChainedSegment(name, currentSegment); - } - super.addObject(currentSegment); - return currentSegment; - } - - /** {@inheritDoc} */ - public void addObject(PreparedAFPObject drawingOrder) { - if (currentSegment == null - || (currentSegment.getDataLength() + drawingOrder.getDataLength()) - >= GraphicsChainedSegment.MAX_DATA_LEN) { - newSegment(); - } - currentSegment.addObject(drawingOrder); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[9]; - copySF(data, SF_CLASS, Type.DATA, Category.GRAPHICS); - int dataLength = getDataLength(); - byte[] len = BinaryUtils.convert(dataLength, 2); - data[1] = len[0]; // Length byte 1 - data[2] = len[1]; // Length byte 2 - os.write(data); - - // get first segment in chain and write (including all its connected segments) - GraphicsChainedSegment firstSegment = (GraphicsChainedSegment)objects.get(0); - firstSegment.writeToStream(os); - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsData"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsFillet.java b/src/java/org/apache/fop/render/afp/goca/GraphicsFillet.java deleted file mode 100644 index cc1cedf2a..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsFillet.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.goca; - -/** - * A GOCA graphics curved tangential line to a specified set of - * straight lines drawn from the given position or current position - */ -public final class GraphicsFillet extends AbstractGraphicsCoord { - - /** - * Constructor - * - * @param coords the x/y coordinates for this object - */ - public GraphicsFillet(int[] coords) { - super(coords); - } - - /** {@inheritDoc} */ - protected byte getOrderCode() { - return (byte)0xC5; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsFullArc.java b/src/java/org/apache/fop/render/afp/goca/GraphicsFullArc.java deleted file mode 100644 index 41347280e..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsFullArc.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.goca; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA graphics arc (circle/ellipse) - */ -public class GraphicsFullArc extends AbstractGraphicsCoord { - /** the integer portion of the multiplier */ - private final int mh; - - /** the fractional portion of the multiplier */ - private final int mhr; - - /** - * Constructor - * - * @param x the x coordinate of the center of the circle/ellipse - * @param y the y coordinate of the center of the circle/ellipse - * @param mh the integer portion of the multiplier - * @param mhr the fractional portion of the multiplier - */ - public GraphicsFullArc(int x, int y, int mh, int mhr) { - super(x, y); - this.mh = mh; - this.mhr = mhr; - // integer portion of multiplier - data[data.length - 2] = BinaryUtils.convert(mh, 1)[0]; - // fractional portion of multiplier - data[data.length - 1] = BinaryUtils.convert(mhr, 1)[0]; - } - - /** {@inheritDoc} */ - protected byte getOrderCode() { - return (byte)0xC7; - } - - /** {@inheritDoc} */ - protected int getLength() { - return super.getLength() + 2; - } - - /** {@inheritDoc} */ - protected void prepareData() { - super.data = super.createData(); - final int fromIndex = 2; - super.addCoords(data, fromIndex); - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsFullArc{" - + ", centerx=" + coords[0] - + ", centery=" + coords[1] - + ", mh=" + mh - + ", mhr=" + mhr - + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java b/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java deleted file mode 100644 index ed8c1b386..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsImage.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.goca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractStructuredAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA Image - */ -public class GraphicsImage extends AbstractStructuredAFPObject { - - /** x coordinate */ - private final int x; - - /** y coordinate */ - private final int y; - - /** width */ - private final int width; - - /** height */ - private final int height; - - /** image data */ - private final byte[] imageData; - - /** - * Main constructor - * - * @param x the x coordinate of the image - * @param y the y coordinate of the image - * @param width the image width - * @param height the image height - * @param imageData the image data - */ - public GraphicsImage(int x, int y, int width, int height, byte[] imageData) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.imageData = imageData; - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] xcoord = BinaryUtils.convert(x, 2); - byte[] ycoord = BinaryUtils.convert(y, 2); - byte[] w = BinaryUtils.convert(width, 2); - byte[] h = BinaryUtils.convert(height, 2); - byte[] data = new byte[] { - (byte) 0xD1, // GBIMG order code - (byte) 0x0A, // LENGTH - xcoord[0], - xcoord[1], - ycoord[0], - ycoord[1], - 0x00, // FORMAT - 0x00, // RES - w[0], // WIDTH - w[1], // - h[0], // HEIGHT - h[1] // - }; - os.write(data); - } - - /** the maximum image data length */ - public static final short MAX_DATA_LEN = 255; - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - byte[] dataHeader = new byte[] { - (byte) 0x92 // GIMD - }; - final int lengthOffset = 1; - writeChunksToStream(imageData, dataHeader, lengthOffset, MAX_DATA_LEN, os); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - (byte) 0x93, // GEIMG order code - 0x00 // LENGTH - }; - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsImage{x=" + x - + ", y=" + y - + ", width=" + width - + ", height=" + height - + "}"; - } -} diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsLine.java b/src/java/org/apache/fop/render/afp/goca/GraphicsLine.java deleted file mode 100644 index f09d24d98..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsLine.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.goca; - - -/** - * A GOCA graphics straight line drawn from the - * given position or current position. - */ -public class GraphicsLine extends AbstractGraphicsCoord { - - /** - * Constructor - * - * @param coords the x/y coordinates for this object - */ - public GraphicsLine(int[] coords) { - super(coords); - } - - /** {@inheritDoc} */ - protected byte getOrderCode() { - return (byte)0xC1; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsSetArcParameters.java b/src/java/org/apache/fop/render/afp/goca/GraphicsSetArcParameters.java deleted file mode 100644 index 26735ed30..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsSetArcParameters.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.goca; - -/** - * Sets the arc parameters for a GOCA graphics arc (circle/ellipse) - */ -public class GraphicsSetArcParameters extends AbstractGraphicsCoord { - - /** - * Constructor - * - * @param xmaj x coordinate of the major axis point - * @param ymin y coordinate of the minor axis point - * @param xmin x coordinate of the minor axis point - * @param ymaj y coordinate of the major axis point - */ - public GraphicsSetArcParameters(int xmaj, int ymin, int xmin, int ymaj) { - super(xmaj, ymin, xmin, ymaj); - } - - /** {@inheritDoc} */ - protected byte getOrderCode() { - return 0x22; - } - - /** {@inheritDoc} */ - public String toString() { - return getName() + "{xmaj=" + coords[0] - + ",ymin=" + coords[1] - + ",xmin=" + coords[2] - + ",ymaj=" + coords[3] + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsSetCharacterSet.java b/src/java/org/apache/fop/render/afp/goca/GraphicsSetCharacterSet.java deleted file mode 100644 index f3d8b186b..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsSetCharacterSet.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.goca; - -import org.apache.fop.render.afp.modca.AbstractPreparedAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * Sets the current character set (font) to be used for following graphics strings - */ -public class GraphicsSetCharacterSet extends AbstractPreparedAFPObject { - - /** font character set reference */ - private final int fontReference; - - /** - * @param fontReference character set font reference - */ - public GraphicsSetCharacterSet(int fontReference) { - this.fontReference = fontReference; - prepareData(); - } - - /** {@inheritDoc} */ - protected void prepareData() { - super.data = new byte[] { - 0x38, // GSCS order code - BinaryUtils.convert(fontReference)[0] - }; - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsSetCharacterSet(" + fontReference + ")"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsSetCurrentPosition.java b/src/java/org/apache/fop/render/afp/goca/GraphicsSetCurrentPosition.java deleted file mode 100644 index 7b68d0f17..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsSetCurrentPosition.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.goca; - - -/** - * Sets the current painting position of the graphics object - */ -public class GraphicsSetCurrentPosition extends AbstractGraphicsCoord { - - /** - * Constructor - * - * @param coords the x/y coordinates for this object - */ - public GraphicsSetCurrentPosition(int[] coords) { - super(coords); - } - - /** {@inheritDoc} */ - protected byte getOrderCode() { - return (byte)0x21; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineType.java b/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineType.java deleted file mode 100644 index febf2dfb2..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineType.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.goca; - -import org.apache.fop.render.afp.modca.AbstractPreparedAFPObject; - -/** - * Sets the value of the current line type attribute when stroking GOCA shapes (structured fields) - */ -public class GraphicsSetLineType extends AbstractPreparedAFPObject { - - /** the default line type */ - public static final byte DEFAULT = 0x00; // normally SOLID - - /** the default line type */ - public static final byte DOTTED = 0x01; - - /** short dashed line type */ - public static final byte SHORT_DASHED = 0x02; - - /** dashed dotted line type */ - public static final byte DASH_DOT = 0x03; - - /** double dotted line type */ - public static final byte DOUBLE_DOTTED = 0x04; - - /** long dashed line type */ - public static final byte LONG_DASHED = 0x05; - - /** dash double dotted line type */ - public static final byte DASH_DOUBLE_DOTTED = 0x06; - - /** solid line type */ - public static final byte SOLID = 0x07; - - /** invisible line type */ - public static final byte INVISIBLE = 0x08; - - /** line type */ - private byte type = DEFAULT; - - /** - * Main constructor - * - * @param type line type - */ - public GraphicsSetLineType(byte type) { - this.type = type; - prepareData(); - } - - /** {@inheritDoc} */ - protected void prepareData() { - super.data = new byte[] { - 0x18, // GSLW order code - type // line type - }; - } - - private static final String[] TYPES = { - "default (solid)", "dotted", "short dashed", "dash dotted", "double dotted", - "long dashed", "dash double dotted", "solid", "invisible" - }; - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsSetLineType{type=" + TYPES[type] + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineWidth.java b/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineWidth.java deleted file mode 100644 index 82163d29e..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsSetLineWidth.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.goca; - -import org.apache.fop.render.afp.modca.AbstractPreparedAFPObject; - -/** - * Sets the line width to use when stroking GOCA shapes (structured fields) - */ -public class GraphicsSetLineWidth extends AbstractPreparedAFPObject { - /** line width multiplier */ - private int multiplier = 1; - - /** - * Main constructor - * - * @param multiplier the line width multiplier - */ - public GraphicsSetLineWidth(int multiplier) { - this.multiplier = multiplier; - prepareData(); - } - - /** {@inheritDoc} */ - protected void prepareData() { - super.data = new byte[] { - 0x19, // GSLW order code - (byte)multiplier // MH (line-width) - }; - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsSetLineWidth{multiplier=" + multiplier + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsSetMix.java b/src/java/org/apache/fop/render/afp/goca/GraphicsSetMix.java deleted file mode 100644 index 99a04d3ee..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsSetMix.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.goca; - -import org.apache.fop.render.afp.modca.AbstractPreparedAFPObject; - -public class GraphicsSetMix extends AbstractPreparedAFPObject { - - public static final byte MODE_DEFAULT = 0x00; - public static final byte MODE_OVERPAINT = 0x02; - - /** the mix mode value */ - private final byte mode; - - /** - * Main constructor - * - * @param mode the mix mode value - */ - public GraphicsSetMix(byte mode) { - this.mode = mode; - prepareData(); - } - - /** {@inheritDoc} */ - protected void prepareData() { - super.data = new byte[] { - 0x0C, // GSMX order code - mode // MODE (mix mode value) - }; - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsSetMix{mode=" + mode + "}"; - } - -} diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsSetPatternSymbol.java b/src/java/org/apache/fop/render/afp/goca/GraphicsSetPatternSymbol.java deleted file mode 100644 index bdc7b1233..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsSetPatternSymbol.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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.goca; - -import org.apache.fop.render.afp.modca.AbstractPreparedAFPObject; - -/** - * Sets the pattern symbol to use when filling following GOCA structured fields - */ -public class GraphicsSetPatternSymbol extends AbstractPreparedAFPObject { - /** dotted density 1 */ - public static final byte DOTTED_DENSITY_1 = 0x01; - - /** dotted density 2 */ - public static final byte DOTTED_DENSITY_2 = 0x02; - - /** dotted density 3 */ - public static final byte DOTTED_DENSITY_3 = 0x03; - - /** dotted density 4 */ - public static final byte DOTTED_DENSITY_4 = 0x04; - - /** dotted density 5 */ - public static final byte DOTTED_DENSITY_5 = 0x05; - - /** dotted density 6 */ - public static final byte DOTTED_DENSITY_6 = 0x06; - - /** dotted density 7 */ - public static final byte DOTTED_DENSITY_7 = 0x07; - - /** dotted density 8 */ - public static final byte DOTTED_DENSITY_8 = 0x08; - - /** dotted density 9 */ - public static final byte VERTICAL_LINES = 0x09; - - /** horizontal lines */ - public static final byte HORIZONTAL_LINES = 0x0A; - - /** diagonal lines, bottom left to top right 1 */ - public static final byte DIAGONAL_LINES_BLTR_1 = 0x0B; - - /** diagonal lines, bottom left to top right 2 */ - public static final byte DIAGONAL_LINES_BLTR_2 = 0x0C; - - /** diagonal lines, top left to bottom right 1 */ - public static final byte DIAGONAL_LINES_TLBR_1 = 0x0D; - - /** diagonal lines, top left to bottom right 2 */ - public static final byte DIAGONAL_LINES_TLBR_2 = 0x0E; - - /** no fill */ - public static final byte NO_FILL = 0x0F; - - /** solid fill */ - public static final byte SOLID_FILL = 0x10; - - /** blank (same as no fill) */ - public static final byte BLANK = 0x40; // processed same as NO_FILL - - /** the graphics pattern symbol to use */ - private final byte symbol; - - /** - * Main constructor - * - * @param symb the pattern symbol to use - */ - public GraphicsSetPatternSymbol(byte symb) { - this.symbol = symb; - prepareData(); - } - - /** {@inheritDoc} */ - protected void prepareData() { - super.data = new byte[] { - 0x28, // GSPT order code - symbol - }; - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsSetPatternSymbol(fill=" - + (symbol == SOLID_FILL ? true : false) + ")"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsSetProcessColor.java b/src/java/org/apache/fop/render/afp/goca/GraphicsSetProcessColor.java deleted file mode 100644 index aa98b95c2..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsSetProcessColor.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.goca; - -import java.awt.Color; -import java.awt.color.ColorSpace; - -import org.apache.fop.render.afp.modca.AbstractPreparedAFPObject; - -/** - * Sets the current processing color for the following GOCA structured fields - */ -public class GraphicsSetProcessColor extends AbstractPreparedAFPObject { - /** the color to set */ - private final Color color; - - /** - * Main constructor - * - * @param color the color to set - */ - public GraphicsSetProcessColor(Color color) { - this.color = color; - prepareData(); - } - - /** {@inheritDoc} */ - protected void prepareData() { - // COLSPCE - byte colspace; - int colSpaceType = color.getColorSpace().getType(); - if (colSpaceType == ColorSpace.TYPE_CMYK) { - colspace = 0x04; - } else if (colSpaceType == ColorSpace.TYPE_RGB) { - colspace = 0x01; - } else { - log.error("unsupported colorspace " + colSpaceType); - colspace = 0x01; - } - - // COLSIZE(S) - float[] colcomp = color.getColorComponents(null); - byte[] colsizes = new byte[] {0x00, 0x00, 0x00, 0x00}; - for (int i = 0; i < colcomp.length; i++) { - colsizes[i] = (byte)8; - } - - int len = 10 + colcomp.length; - super.data = new byte[len + 2]; - data[0] = (byte)0xB2; // GSPCOL order code - data[1] = (byte)len; // LEN - data[2] = 0x00; // reserved; must be zero - data[3] = colspace; // COLSPCE - data[4] = 0x00; // reserved; must be zero - data[5] = 0x00; // reserved; must be zero - data[6] = 0x00; // reserved; must be zero - data[7] = 0x00; // reserved; must be zero - data[8] = colsizes[0]; // COLSIZE(S) - data[9] = colsizes[1]; - data[10] = colsizes[2]; - data[11] = colsizes[3]; - // COLVALUE(S) - for (int i = 0; i < colcomp.length; i++) { - data[i + 12] = (byte)(colcomp[i] * 255); - } - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsSetProcessColor(col=" + color + ")"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/goca/GraphicsString.java b/src/java/org/apache/fop/render/afp/goca/GraphicsString.java deleted file mode 100644 index a67774b6d..000000000 --- a/src/java/org/apache/fop/render/afp/goca/GraphicsString.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.goca; - -import java.io.UnsupportedEncodingException; - -import org.apache.fop.render.afp.AFPConstants; -import org.apache.fop.render.afp.modca.AbstractPreparedAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A GOCA graphics string - */ -public class GraphicsString extends AbstractPreparedAFPObject { - /** Up to 255 bytes of character data */ - private static final int MAX_STR_LEN = 255; - - /** drawn from the current position */ - private boolean fromCurrentPosition = false; - - /** the string to draw */ - private String str = null; - - /** x coordinate */ - private int x; - - /** y coordinate */ - private int y; - - /** - * Constructor - * - * @param str the character string - */ - public GraphicsString(String str) { - this.str = str; - fromCurrentPosition = true; - prepareData(); - } - - /** - * Constructor - * - * @param str the character string - * @param x the x coordinate - * @param y the y coordinate - */ - public GraphicsString(String str, int x, int y) { - this.str = str; - this.x = x; - this.y = y; - prepareData(); - } - - /** {@inheritDoc} */ - protected void prepareData() { - int maxStrLen = MAX_STR_LEN - (fromCurrentPosition ? 0 : 4); - if (str.length() > maxStrLen) { - str = str.substring(0, maxStrLen); - log.warn("truncated character string, longer than " + maxStrLen + " chars"); - } - byte[] strData = null; - try { - strData = str.getBytes(AFPConstants.EBCIDIC_ENCODING); - } catch (UnsupportedEncodingException ex) { - log.error("unsupported encoding: " + ex.getMessage()); - } - int len = strData.length; - if (fromCurrentPosition) { - data = new byte[len + 2]; - data[0] = (byte)0x83; - data[1] = (byte)len; - System.arraycopy(strData, 0, data, 2, strData.length); - } else { - len += 4; // x/y coordinates - byte[] osx = BinaryUtils.convert(x, 2); - byte[] osy = BinaryUtils.convert(y, 2); - data = new byte[len + 2]; - data[0] = (byte)0xC3; - data[1] = (byte)len; - data[2] = osx[0]; - data[3] = osx[1]; - data[4] = osy[0]; - data[5] = osy[1]; - System.arraycopy(strData, 0, data, 6, strData.length); - } - } - - /** {@inheritDoc} */ - public String toString() { - String string = "GraphicsString{str='" + str + "'"; - if (!fromCurrentPosition) { - string += ",x=" + x + ",y=" + y; - } - string += "}"; - return string; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ioca/ImageCellPosition.java b/src/java/org/apache/fop/render/afp/ioca/ImageCellPosition.java deleted file mode 100644 index 4faac0c6e..000000000 --- a/src/java/org/apache/fop/render/afp/ioca/ImageCellPosition.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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.ioca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The IM Image Cell Position structured field specifies the placement, - * size, and replication of IM image cells. - */ -public class ImageCellPosition extends AbstractAFPObject { - - /** - * Offset of image cell in X direction - */ - private int xOffset = 0; - - /** - * Offset of image cell in Y direction - */ - private int yOffset = 0; - - /** - * Size of image cell in X direction - */ - private final byte[] xSize = new byte[] {(byte)0xFF, (byte)0xFF}; - - /** - * Size of image cell in Y direction - */ - private final byte[] ySize = new byte[] {(byte)0xFF, (byte)0xFF}; - - /** - * Size of fill rectangle in X direction - */ - private final byte[] xFillSize = new byte[] {(byte)0xFF, (byte)0xFF}; - - /** - * Size of fill rectangle in Y direction - */ - private final byte[] yFillSize = new byte[] {(byte)0xFF, (byte)0xFF}; - - /** - * Constructor for the ImageCellPosition - * @param x The offset of image cell in X direction - * @param y The offset of image cell in Y direction - */ - public ImageCellPosition(int x, int y) { - xOffset = x; - yOffset = y; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[21]; - copySF(data, Type.POSITION, Category.IM_IMAGE); - - data[1] = 0x00; // length - data[2] = 0x14; - - /** - * Specifies the offset along the Xp direction, in image points, - * of this image cell from the IM image object area origin. - */ - byte[] x1 = BinaryUtils.convert(xOffset, 2); - data[9] = x1[0]; - data[10] = x1[1]; - - /** - * Specifies the offset along the Yp direction, in image points, - * of this image cell from the IM image object area origin. - */ - byte[] x2 = BinaryUtils.convert(yOffset, 2); - data[11] = x2[0]; - data[12] = x2[1]; - - data[13] = xSize[0]; - data[14] = xSize[1]; - - data[15] = ySize[0]; - data[16] = ySize[1]; - - data[17] = xFillSize[0]; - data[18] = xFillSize[1]; - - data[19] = yFillSize[0]; - data[20] = yFillSize[1]; - - os.write(data); - } - - /** - * Specifies the extent in the X direction, in image points, - * of this image cell. A value of X'FFFF' indicates that the - * default extent specified in bytes 28 and 29 of the Image - * Input Descriptor (IID) is to be used. - * - * @param xcSize The size to set. - */ - public void setXSize(int xcSize) { - byte[] x = BinaryUtils.convert(xcSize, 2); - xSize[0] = x[0]; - xSize[1] = x[1]; - } - - /** - * Specifies the extent of the fill rectangle in the X direction, - * in image points. This value can be smaller than, equal to, or - * larger than the image cell extent in the X direction (XCSize). - * A value of X'FFFF' indicates that the image cell X-extent should - * be used as the fill rectangle X-extent. The fill rectangle is - * filled in the X direction by repeating the image cell in the - * X direction. The image cell can be truncated to fit the rectangle. - * - * @param size The size to set. - */ - public void setXFillSize(int size) { - byte[] x = BinaryUtils.convert(size, 2); - this.xFillSize[0] = x[0]; - this.xFillSize[1] = x[1]; - } - - /** - * Specifies the extent in the Y direction, in image points, - * of this image cell. A value of X'FFFF' indicates that the - * default extent specified in bytes 30 and 31 of the Image - * Input Descriptor (IID) is to be used. - * - * @param size The size to set. - */ - public void setYSize(int size) { - byte[] x = BinaryUtils.convert(size, 2); - this.ySize[0] = x[0]; - this.ySize[1] = x[1]; - } - - /** - * Specifies the extent of the fill rectangle in the Y direction, - * in image points. This value can be smaller than, equal to, or - * larger than the image cell extent in the Y direction (YCSize). - * A value of X'FFFF' indicates that the image cell Y-extent should - * be used as the fill rectangle Y-extent. The fill rectangle is - * filled in the Y direction by repeating the image cell in the - * Y direction. The image cell can be truncated to fit the rectangle. - * - * @param size The size to set. - */ - public void setYFillSize(int size) { - byte[] x = BinaryUtils.convert(size, 2); - this.yFillSize[0] = x[0]; - this.yFillSize[1] = x[1]; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ioca/ImageContent.java b/src/java/org/apache/fop/render/afp/ioca/ImageContent.java deleted file mode 100644 index 7143b986c..000000000 --- a/src/java/org/apache/fop/render/afp/ioca/ImageContent.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * 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.ioca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractStructuredAFPObject; - -/** - */ -public class ImageContent extends AbstractStructuredAFPObject { - - /** - * The CCITT T.4 Group 3 Coding Standard (G3 MH-Modified Huffman) is a - * compression method standardized by the International Telegraph and - * Telephone Consultative Committee (CCITT) for facsimile. It enables - * one-dimensional compression. - */ - public static final byte COMPID_G3_MH = (byte)0x80; - - /** - * The CCITT T.4 Group 3 Coding Option (G3 MR-Modified READ) is a - * compression method standardized by the International Telegraph and - * Telephone Consultative Committee (CCITT) for facsimile. It enables - * two-dimensional compression. - */ - public static final byte COMPID_G3_MR = (byte)0x81; - - /** - * The CCITT T.6 Group 4 Coding Standard (G4 MMR-Modified Modified READ) is a - * compression method standardized by the International Telegraph and - * Telephone Consultative Committee (CCITT) for facsimile. It enables - * two-dimensional compression. - */ - public static final byte COMPID_G3_MMR = (byte)0x82; - - /** - * The image size parameter - */ - private ImageSizeParameter imageSizeParameter = null; - - /** - * The image encoding - */ - private byte encoding = (byte)0x03; - - /** - * The image ide size - */ - private byte size = 1; - - /** - * The image compression - */ - private byte compression = (byte)0xC0; - - /** - * The image color model - */ - private byte colorModel = (byte)0x01; - - /** - * The image data - */ - private byte[] data; - - /** - * Constructor for the image content - */ - public ImageContent() { - } - - /** - * Sets the image size parameter - * - * @param imageSizeParameter the image size parameter. - */ - public void setImageSizeParameter(ImageSizeParameter imageSizeParameter) { - this.imageSizeParameter = imageSizeParameter; - } - - /** - * Sets the image encoding. - * - * @param enc The image encoding. - */ - public void setImageEncoding(byte enc) { - this.encoding = enc; - } - - /** - * Sets the image compression. - * - * @param comp The image compression. - */ - public void setImageCompression(byte comp) { - this.compression = comp; - } - - /** - * Sets the image IDE size. - * - * @param s The IDE size. - */ - public void setImageIDESize(byte s) { - this.size = s; - } - - /** - * Sets the image IDE color model. - * - * @param color the IDE color model. - */ - public void setImageIDEColorModel(byte color) { - this.colorModel = color; - } - - /** - * Set the data image store information. - * - * @param imageData the image data - */ - public void setImageData(byte[] imageData) { - this.data = imageData; - } - - private static final int MAX_DATA_LEN = 65535; - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - if (imageSizeParameter != null) { - imageSizeParameter.writeToStream(os); - } - - // TODO convert to triplet/parameter class - os.write(getImageEncodingParameter()); - - os.write(getImageIDESizeParameter()); - - os.write(getIDEStructureParameter()); - - os.write(getExternalAlgorithmParameter()); - - // Image Data - if (data != null) { - final byte[] dataHeader = new byte[] { - (byte)0xFE, // ID - (byte)0x92, // ID - 0x00, // length - 0x00 // length - }; - final int lengthOffset = 2; - writeChunksToStream(this.data, dataHeader, lengthOffset, MAX_DATA_LEN, os); - } - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - final byte[] startData = new byte[] { - (byte)0x91, // ID - 0x01, // Length - (byte)0xff, // Object Type = IOCA Image Object - }; - os.write(startData); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - final byte[] endData = new byte[] { - (byte)0x93, // ID - 0x00, // Length - }; - os.write(endData); - } - - /** - * Helper method to return the image encoding parameter. - * - * @return byte[] The data stream. - */ - private byte[] getImageEncodingParameter() { - final byte[] encodingData = new byte[] { - (byte)0x95, // ID - 0x02, // Length - encoding, - 0x01, // RECID - }; - return encodingData; - } - - /** - * Helper method to return the external algorithm parameter. - * - * @return byte[] The data stream. - */ - private byte[] getExternalAlgorithmParameter() { - if (encoding == (byte)0x83 && compression != 0) { - final byte[] extAlgData = new byte[] { - (byte)0x95, // ID - 0x00, // Length - 0x10, // ALGTYPE = Compression Algorithm - 0x00, // Reserved - (byte)0x83, // COMPRID = JPEG - 0x00, // Reserved - 0x00, // Reserved - 0x00, // Reserved - compression, // MARKER - 0x00, // Reserved - 0x00, // Reserved - 0x00, // Reserved - }; - extAlgData[1] = (byte)(extAlgData.length - 2); - return extAlgData; - } - return new byte[0]; - } - - /** - * Helper method to return the image encoding parameter. - * - * @return byte[] The data stream. - */ - private byte[] getImageIDESizeParameter() { - final byte[] ideSizeData = new byte[] { - (byte)0x96, // ID - 0x01, // Length - size, - }; - return ideSizeData; - } - - /** - * Helper method to return the external algorithm parameter. - * - * @return byte[] The data stream. - */ - private byte[] getIDEStructureParameter() { - if (colorModel != 0 && size == 24) { - final byte bits = (byte)(size / 3); - final byte[] ideStructData = new byte[] { - (byte)0x9B, // ID - 0x00, // Length - 0x00, // FLAGS - 0x00, // Reserved - colorModel, // COLOR MODEL - 0x00, // Reserved - 0x00, // Reserved - 0x00, // Reserved - bits, - bits, - bits, - }; - ideStructData[1] = (byte)(ideStructData.length - 2); - return ideStructData; - } - return new byte[0]; - } - -} diff --git a/src/java/org/apache/fop/render/afp/ioca/ImageInputDescriptor.java b/src/java/org/apache/fop/render/afp/ioca/ImageInputDescriptor.java deleted file mode 100644 index cb6595eaf..000000000 --- a/src/java/org/apache/fop/render/afp/ioca/ImageInputDescriptor.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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.ioca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The IM Image Input Descriptor structured field contains the - * descriptor data for an IM image data object. This data specifies - * the resolution, size, and color of the IM image. - */ -public class ImageInputDescriptor extends AbstractAFPObject { - - /** - * The resolution of the raster image (default 240) - */ - private int resolution = 240; - - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - - byte[] data = new byte[45]; - copySF(data, Type.DESCRIPTOR, Category.IM_IMAGE); - - data[1] = 0x00; // length - data[2] = 0x2C; - - // Constant data. - data[9] = 0x00; - data[10] = 0x00; - data[11] = 0x09; - data[12] = 0x60; - data[13] = 0x09; - data[14] = 0x60; - data[15] = 0x00; - data[16] = 0x00; - data[17] = 0x00; - data[18] = 0x00; - data[19] = 0x00; - data[20] = 0x00; - - // X Base (Fixed x00) - data[21] = 0x00; - // Y Base (Fixed x00) - data[22] = 0x00; - - byte[] imagepoints = BinaryUtils.convert(resolution * 10, 2); - - /** - * Specifies the number of image points per unit base for the X axis - * of the image. This value is ten times the resolution of the image - * in the X direction. - */ - data[23] = imagepoints[0]; - data[24] = imagepoints[1]; - - /** - * Specifies the number of image points per unit base for the Y axis - * of the image. This value is ten times the resolution of the image - * in the Y direction. - */ - data[25] = imagepoints[0]; - data[26] = imagepoints[1]; - - /** - * Specifies the extent in the X direction, in image points, of an - * non-celled (simple) image. - */ - data[27] = 0x00; - data[28] = 0x01; - - /** - * Specifies the extent in the Y direction, in image points, of an - * non-celled (simple) image. - */ - data[29] = 0x00; - data[30] = 0x01; - - // Constant Data - data[31] = 0x00; - data[32] = 0x00; - data[33] = 0x00; - data[34] = 0x00; - data[35] = 0x2D; - data[36] = 0x00; - - // Default size of image cell in X direction - data[37] = 0x00; - data[38] = 0x01; - - // Default size of image cell in Y direction - data[39] = 0x00; - data[40] = 0x01; - - // Constant Data - data[41] = 0x00; - data[42] = 0x01; - - // Image Color - data[43] = (byte)0xFF; - data[44] = (byte)0xFF; - - os.write(data); - } - - /** - * Sets the resolution information for the raster image - * the default value is a resolution of 240 dpi. - * - * @param resolution The resolution value - */ - public void setResolution(int resolution) { - this.resolution = resolution; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ioca/ImageOutputControl.java b/src/java/org/apache/fop/render/afp/ioca/ImageOutputControl.java deleted file mode 100644 index 1758f4a16..000000000 --- a/src/java/org/apache/fop/render/afp/ioca/ImageOutputControl.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * 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.ioca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The IM Image Output Control structured field specifies the position and - * orientation of the IM image object area and the mapping of the image points - * to presentation device pels. - * - */ -public class ImageOutputControl extends AbstractAFPObject { - - /** - * The orientation of the image - */ - private int orientation = 0; - - /** - * Specifies the offset, along the X-axis, of the IM image object area - * origin to the origin of the including page - */ - private int xCoord = 0; - - /** - * Specifies the offset, along the Y-axis, of the IM image object area - * origin to the origin of the including page - */ - private int yCoord = 0; - - /** - * Map an image point to a single presentation device - */ - private boolean singlePoint = true; - - /** - * Constructor for the ImageOutputControl The x parameter specifies the - * offset, along the X-axis, of the IM image object area origin to the - * origin of the including page and the y parameter specifies the offset - * along the Y-axis. The offset is specified in image points and is resolved - * using the units of measure specified for the image in the IID structured - * field. - * - * @param x - * The X-axis offset. - * @param y - * The Y-axis offset. - */ - public ImageOutputControl(int x, int y) { - xCoord = x; - yCoord = y; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - - byte[] data = new byte[33]; - - data[0] = 0x5A; - data[1] = 0x00; - data[2] = 0x20; - data[3] = (byte) 0xD3; - data[4] = (byte) 0xA7; - data[5] = (byte) 0x7B; - data[6] = 0x00; - data[7] = 0x00; - data[8] = 0x00; - - // XoaOset - byte[] x1 = BinaryUtils.convert(xCoord, 3); - data[9] = x1[0]; - data[10] = x1[1]; - data[11] = x1[2]; - - // YoaOset - byte[] x2 = BinaryUtils.convert(yCoord, 3); - data[12] = x2[0]; - data[13] = x2[1]; - data[14] = x2[2]; - - switch (orientation) { - case 0: - // 0 and 90 degrees respectively - data[15] = 0x00; - data[16] = 0x00; - data[17] = 0x2D; - data[18] = 0x00; - break; - case 90: - // 90 and 180 degrees respectively - data[15] = 0x2D; - data[16] = 0x00; - data[17] = 0x5A; - data[18] = 0x00; - break; - case 180: - // 180 and 270 degrees respectively - data[15] = 0x5A; - data[16] = 0x00; - data[17] = (byte) 0x87; - data[18] = 0x00; - break; - case 270: - // 270 and 0 degrees respectively - data[15] = (byte) 0x87; - data[16] = 0x00; - data[17] = 0x00; - data[18] = 0x00; - break; - default: - // 0 and 90 degrees respectively - data[15] = 0x00; - data[16] = 0x00; - data[17] = 0x2D; - data[18] = 0x00; - break; - - } - - // Constant Data - data[19] = 0x00; - data[20] = 0x00; - data[21] = 0x00; - data[22] = 0x00; - data[23] = 0x00; - data[24] = 0x00; - data[25] = 0x00; - data[26] = 0x00; - - if (singlePoint) { - data[27] = 0x03; - data[28] = (byte) 0xE8; - data[29] = 0x03; - data[30] = (byte) 0xE8; - } else { - data[27] = 0x07; - data[28] = (byte) 0xD0; - data[29] = 0x07; - data[30] = (byte) 0xD0; - } - - // Constant Data - data[31] = (byte) 0xFF; - data[32] = (byte) 0xFF; - - os.write(data); - } - - /** - * Sets the orientation which specifies the amount of clockwise rotation of - * the IM image object area. - * - * @param orientation - * The orientation to set. - */ - public void setOrientation(int orientation) { - - if (orientation == 0 || orientation == 90 || orientation == 180 - || orientation == 270) { - this.orientation = orientation; - } else { - throw new IllegalArgumentException( - "The orientation must be one of the values 0, 90, 180, 270"); - } - } - - /** - * Sets the singlepoint, if true map an image point to a single presentation - * device pel in the IM image object area. If false map an image point to - * two presentation device pels in the IM image object area (double-dot) - * - * @param singlepoint - * Use the singlepoint basis when true. - */ - public void setSinglepoint(boolean singlepoint) { - singlePoint = singlepoint; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ioca/ImageRasterData.java b/src/java/org/apache/fop/render/afp/ioca/ImageRasterData.java deleted file mode 100644 index 0c863e1e7..000000000 --- a/src/java/org/apache/fop/render/afp/ioca/ImageRasterData.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.ioca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractAFPObject; -import org.apache.fop.render.afp.modca.AbstractAFPObject.Category; -import org.apache.fop.render.afp.modca.AbstractAFPObject.Type; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * Contains the image points that define the IM image raster pattern. - * - * A raster pattern is the array of presentation device pels that forms - * the image. The image data is uncompressed. Bits are grouped into - * bytes and are ordered from left to right within each byte. Each bit - * in the image data represents an image point and is mapped to - * presentation device pels as specified in the IOC structured field. - * A bit with value B'1' indicates a significant image point; a bit - * with value B'0' indicates an insignificant image point. - * Image points are recorded from left to right in rows that represents - * scan lines (X direction), and rows representing scan lines are - * recorded from top to bottom (Y direction). When the image is - * presented, all image points in a row are presented before any - * image points in the next sequential row are presented, and all rows - * have the same number of image points. If the total number of image - * points is not a multiple of 8, the last byte of the image data is - * padded to a byte boundary. The padding bits do not represent image - * points and are ignored by presentation devices. - */ -public class ImageRasterData extends AbstractAFPObject { - - /** - * The image raster data - */ - private final byte[] rasterData; - - /** - * Constructor for the image raster data object - * @param data The raster image data - */ - public ImageRasterData(byte[] data) { - this.rasterData = data; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[9]; - copySF(data, Type.DATA, Category.IM_IMAGE); - // The size of the structured field - byte[] len = BinaryUtils.convert(rasterData.length + 8, 2); - data[1] = len[0]; - data[2] = len[1]; - os.write(data); - - os.write(rasterData); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ioca/ImageRasterPattern.java b/src/java/org/apache/fop/render/afp/ioca/ImageRasterPattern.java deleted file mode 100644 index 9619c40ff..000000000 --- a/src/java/org/apache/fop/render/afp/ioca/ImageRasterPattern.java +++ /dev/null @@ -1,759 +0,0 @@ -/* - * 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.ioca; - -/** - * Raster data is a grid of cells covering an area of interest. - * Each pixel, the smallest unit of information in the grid, displays - * a unique attribute. This static class generates raster data for different - * shades of grey (betweeen 0 and 16) the lower the number being the - * darker the shade. The image data dimensions are 64 x 8. - */ -public class ImageRasterPattern { - - /** - * The Raster Pattern for Greyscale 16 - */ - private static final byte[] GREYSCALE16 = new byte[] { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - }; - - /** - * The Raster Pattern for Greyscale 15 - */ - private static final byte[] GREYSCALE15 = new byte[] { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - }; - - /** - * The Raster Pattern for Greyscale 14 - */ - private static final byte[] GREYSCALE14 = new byte[] { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - }; - - - /** - * The Raster Pattern for Greyscale 13 - */ - private static final byte[] GREYSCALE13 = new byte[] { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - }; - - /** - * The Raster Pattern for Greyscale 12 - */ - private static final byte[] GREYSCALE12 = new byte[] { - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - }; - - /** - * The Raster Pattern for Greyscale 11 - */ - private static final byte[] GREYSCALE11 = new byte[] { - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - }; - - /** - * The Raster Pattern for Greyscale 10 - */ - private static final byte[] GREYSCALE10 = new byte[] { - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - 0x44, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - }; - - /** - * The Raster Pattern for Greyscale 9 - */ - private static final byte[] GREYSCALE09 = new byte[] { - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - 0x11, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - }; - - /** - * The Raster Pattern for Greyscale 8 - */ - private static final byte[] GREYSCALE08 = new byte[] { - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - }; - - - /** - * The Raster Pattern for Greyscale 7 - */ - private static final byte[] GREYSCALE07 = new byte[] { - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - }; - - - /** - * The Raster Pattern for Greyscale 6 - */ - private static final byte[] GREYSCALE06 = new byte[] { - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - }; - - /** - * The Raster Pattern for Greyscale 5 - */ - private static final byte[] GREYSCALE05 = new byte[] { - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xEE, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - }; - - - /** - * The Raster Pattern for Greyscale 4 - */ - private static final byte[] GREYSCALE04 = new byte[] { - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xAA, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - }; - - /** - * The Raster Pattern for Greyscale 3 - */ - private static final byte[] GREYSCALE03 = new byte[] { - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - 0x55, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xBB, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - }; - - /** - * The Raster Pattern for Greyscale 2 - */ - private static final byte[] GREYSCALE02 = new byte[] { - 0x77, - 0x77, - 0x77, - 0x77, - 0x77, - 0x77, - 0x77, - 0x77, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xDD, - (byte)0xDD, - (byte)0xDD, - (byte)0xDD, - (byte)0xDD, - (byte)0xDD, - (byte)0xDD, - (byte)0xDD, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - }; - - - /** - * The Raster Pattern for Greyscale 1 - */ - private static final byte[] GREYSCALE01 = new byte[] { - 0x77, - 0x77, - 0x77, - 0x77, - 0x77, - 0x77, - 0x77, - 0x77, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - }; - - - /** - * The Raster Pattern for Greyscale 00 - */ - private static final byte[] GREYSCALE00 = new byte[] { - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - (byte)0xFF, - }; - - /** - * Static method to return the raster image data for the - * grey scale specified. The scale should be between 0 (darkest) - * and 16 (lightest). - * @param greyscale The grey scale value (0 - 16) - * @return the raster data byte array for the given greyscale value - */ - public static byte[] getRasterData(int greyscale) { - - int repeat = 16; - - byte[] greypattern = new byte[32]; - byte[] rasterdata = new byte[32 * repeat]; - - switch (greyscale) { - case 0: - System.arraycopy(GREYSCALE00, 0, greypattern, 0, 32); - break; - case 1: - System.arraycopy(GREYSCALE01, 0, greypattern, 0, 32); - break; - case 2: - System.arraycopy(GREYSCALE02, 0, greypattern, 0, 32); - break; - case 3: - System.arraycopy(GREYSCALE03, 0, greypattern, 0, 32); - break; - case 4: - System.arraycopy(GREYSCALE04, 0, greypattern, 0, 32); - break; - case 5: - System.arraycopy(GREYSCALE05, 0, greypattern, 0, 32); - break; - case 6: - System.arraycopy(GREYSCALE06, 0, greypattern, 0, 32); - break; - case 7: - System.arraycopy(GREYSCALE07, 0, greypattern, 0, 32); - break; - case 8: - System.arraycopy(GREYSCALE08, 0, greypattern, 0, 32); - break; - case 9: - System.arraycopy(GREYSCALE09, 0, greypattern, 0, 32); - break; - case 10: - System.arraycopy(GREYSCALE10, 0, greypattern, 0, 32); - break; - case 11: - System.arraycopy(GREYSCALE11, 0, greypattern, 0, 32); - break; - case 12: - System.arraycopy(GREYSCALE12, 0, greypattern, 0, 32); - break; - case 13: - System.arraycopy(GREYSCALE13, 0, greypattern, 0, 32); - break; - case 14: - System.arraycopy(GREYSCALE14, 0, greypattern, 0, 32); - break; - case 15: - System.arraycopy(GREYSCALE15, 0, greypattern, 0, 32); - break; - case 16: - System.arraycopy(GREYSCALE16, 0, greypattern, 0, 32); - break; - default : - System.arraycopy(GREYSCALE00, 0, greypattern, 0, 32); - break; - } - - for (int i = 0; i < repeat; i++) { - System.arraycopy(greypattern, 0, rasterdata, i * 32, 32); - } - return rasterdata; - } -} diff --git a/src/java/org/apache/fop/render/afp/ioca/ImageSegment.java b/src/java/org/apache/fop/render/afp/ioca/ImageSegment.java deleted file mode 100644 index 8f6e6a59c..000000000 --- a/src/java/org/apache/fop/render/afp/ioca/ImageSegment.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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.ioca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.render.afp.modca.Factory; - -/** - * An Image Segment is represented by a set of self-defining fields, fields - * that describe their own contents. It starts with a Begin Segment, and - * ends with an End Segment. - * - * Between the Begin Segment and End Segment is the image information to - * be processed, called the Image Content. - * - * Only one Image Content can exist within a single IOCA Image Segment. - */ -public class ImageSegment extends AbstractNamedAFPObject { - - /** - * The ImageContent for the image segment - */ - private ImageContent imageContent = null; - - private final Factory factory; - - /** - * Constructor for the image segment with the specified name, - * the name must be a fixed length of eight characters. - * @param factory the object factory - * - * @param name the name of the image. - */ - public ImageSegment(Factory factory, String name) { - super(name); - this.factory = factory; - } - - private ImageContent getImageContent() { - if (imageContent == null) { - this.imageContent = factory.createImageContent(); - } - return imageContent; - } - - /** - * Sets the image size parameters resolution, hsize and vsize. - * - * @param hsize The horizontal size of the image. - * @param vsize The vertical size of the image. - * @param hresol The horizontal resolution of the image. - * @param vresol The vertical resolution of the image. - */ - public void setImageSize(int hsize, int vsize, int hresol, int vresol) { - ImageSizeParameter imageSizeParameter - = factory.createImageSizeParameter(hsize, vsize, hresol, vresol); - getImageContent().setImageSizeParameter(imageSizeParameter); - } - - /** - * Sets the image encoding. - * - * @param encoding The image encoding. - */ - public void setEncoding(byte encoding) { - getImageContent().setImageEncoding(encoding); - } - - /** - * Sets the image compression. - * - * @param compression The image compression. - */ - public void setCompression(byte compression) { - getImageContent().setImageCompression(compression); - } - - /** - * Sets the image IDE size. - * - * @param size The IDE size. - */ - public void setIDESize(byte size) { - getImageContent().setImageIDESize(size); - } - - /** - * Sets the image IDE color model. - * - * @param colorModel the IDE color model. - */ - public void setIDEColorModel(byte colorModel) { - getImageContent().setImageIDEColorModel(colorModel); - } - - /** - * Set the data image data. - * - * @param data the image data - */ - public void setData(byte[] data) { - getImageContent().setImageData(data); - } - - /** {@inheritDoc} */ - public void writeContent(OutputStream os) throws IOException { - if (imageContent != null) { - imageContent.writeToStream(os); - } - } - - private static final int NAME_LENGTH = 4; - - /** {@inheritDoc} */ - protected int getNameLength() { - return NAME_LENGTH; - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] nameBytes = getNameBytes(); - byte[] data = new byte[] { - 0x70, // ID - 0x04, // Length - nameBytes[0], // Name byte 1 - nameBytes[1], // Name byte 2 - nameBytes[2], // Name byte 3 - nameBytes[3], // Name byte 4 - }; - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - 0x71, // ID - 0x00, // Length - }; - os.write(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/ioca/ImageSizeParameter.java b/src/java/org/apache/fop/render/afp/ioca/ImageSizeParameter.java deleted file mode 100644 index e2c408200..000000000 --- a/src/java/org/apache/fop/render/afp/ioca/ImageSizeParameter.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.ioca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.AbstractAFPObject; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * Describes the measurement characteristics of the image when it is created. - */ -public class ImageSizeParameter extends AbstractAFPObject { - - private int hSize = 0; - private int vSize = 0; - private int hRes = 0; - private int vRes = 0; - - /** - * Constructor for a ImageSizeParameter for the specified - * resolution, hsize and vsize. - * - * @param hsize The horizontal size of the image. - * @param vsize The vertical size of the image. - * @param hresol The horizontal resolution of the image. - * @param vresol The vertical resolution of the image. - */ - public ImageSizeParameter(int hsize, int vsize, int hresol, int vresol) { - this.hSize = hsize; - this.vSize = vsize; - this.hRes = hresol; - this.vRes = vresol; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[] { - (byte)0x94, // ID = Image Size Parameter - 0x09, // Length - 0x00, // Unit base - 10 Inches - 0x00, // HRESOL - 0x00, // - 0x00, // VRESOL - 0x00, // - 0x00, // HSIZE - 0x00, // - 0x00, // VSIZE - 0x00, // - }; - - byte[] x = BinaryUtils.convert(hRes, 2); - data[3] = x[0]; - data[4] = x[1]; - - byte[] y = BinaryUtils.convert(vRes, 2); - data[5] = y[0]; - data[6] = y[1]; - - byte[] w = BinaryUtils.convert(hSize, 2); - data[7] = w[0]; - data[8] = w[1]; - - byte[] h = BinaryUtils.convert(vSize, 2); - data[9] = h[0]; - data[10] = h[1]; - - os.write(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java deleted file mode 100644 index 87ae21cda..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Collection; -import java.util.Iterator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.Streamable; - -/** - * This is the base class for all data stream objects. Page objects are - * responsible for building and generating the binary datastream in an - * AFP format. - */ -public abstract class AbstractAFPObject implements Streamable { - - /** Static logging instance */ - protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.modca"); - - /** the structured field class id */ - protected static final byte SF_CLASS = (byte)0xD3; - - private static final byte[] SF_HEADER = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - SF_CLASS, // Structured field id byte 1 - (byte) 0x00, // Structured field id byte 2 - (byte) 0x00, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - }; - - /** - * Copies the template structured field data array to the given byte array - * - * @param data the structured field data byte array - * @param type the type code - * @param category the category code - */ - protected void copySF(byte[] data, byte type, byte category) { - copySF(data, SF_CLASS, type, category); - } - - /** - * Copies the template structured field data array to the given byte array - * - * @param data the structured field data byte array - * @param clazz the class code - * @param type the type code - * @param category the category code - */ - protected static void copySF(byte[] data, byte clazz, byte type, byte category) { - System.arraycopy(SF_HEADER, 0, data, 0, SF_HEADER.length); - data[3] = clazz; - data[4] = type; - data[5] = category; - } - - /** - * Help method to write a set of AFPObjects to the AFP datastream. - * - * @param objects a list of AFPObjects - * @param os The stream to write to - * @throws java.io.IOException an I/O exception of some sort has occurred. - */ - protected void writeObjects(Collection/**/ objects, OutputStream os) - throws IOException { - if (objects != null && objects.size() > 0) { - Iterator it = objects.iterator(); - while (it.hasNext()) { - Object object = it.next(); - if (object instanceof Streamable) { - ((Streamable)object).writeToStream(os); - it.remove(); // once written, immediately remove the object - } - } - } - } - - /** structured field type codes */ - public interface Type { - - /** Attribute */ - byte ATTRIBUTE = (byte)0x0A; - - /** Copy Count */ - byte COPY_COUNT = (byte)0xA2; - - /** Descriptor */ - byte DESCRIPTOR = (byte)0xA6; - - /** Control */ - byte CONTROL = (byte)0xA7; - - /** Begin */ - byte BEGIN = (byte)0xA8; - - /** End */ - byte END = (byte)0xA9; - - /** Map */ - byte MAP = (byte)0xAB; - - /** Position */ - byte POSITION = (byte)0xAC; - - /** Process */ - byte PROCESS = (byte)0xAD; - - /** Include */ - byte INCLUDE = (byte)0xAF; - - /** Table */ - byte TABLE = (byte)0xB0; - - /** Migration */ - byte MIGRATION = (byte)0xB1; - - /** Variable */ - byte VARIABLE = (byte)0xB2; - - /** Link */ - byte LINK = (byte)0xB4; - - /** Data */ - byte DATA = (byte)0xEE; - } - - /** structured field category codes */ - public interface Category { - - /** Page Segment */ - byte PAGE_SEGMENT = (byte)0x5F; - - /** Object Area */ - byte OBJECT_AREA = (byte)0x6B; - - /** Color Attribute Table */ - byte COLOR_ATTRIBUTE_TABLE = (byte)0x77; - - /** IM Image */ - byte IM_IMAGE = (byte)0x7B; - - /** Medium */ - byte MEDIUM = (byte)0x88; - - /** Coded Font */ - byte CODED_FONT = (byte)0x8A; - - /** Process Element */ - byte PROCESS_ELEMENT = (byte)0x90; - - /** Object Container */ - byte OBJECT_CONTAINER = (byte)0x92; - - /** Presentation Text */ - byte PRESENTATION_TEXT = (byte)0x9B; - - /** Index */ - byte INDEX = (byte)0xA7; - - /** Document */ - byte DOCUMENT = (byte)0xA8; - - /** Page Group */ - byte PAGE_GROUP = (byte)0xAD; - - /** Page */ - byte PAGE = (byte)0xAF; - - /** Graphics */ - byte GRAPHICS = (byte)0xBB; - - /** Data Resource */ - byte DATA_RESOURCE = (byte)0xC3; - - /** Document Environment Group (DEG) */ - byte DOCUMENT_ENVIRONMENT_GROUP = (byte)0xC4; - - /** Resource Group */ - byte RESOURCE_GROUP = (byte)0xC6; - - /** Object Environment Group (OEG) */ - byte OBJECT_ENVIRONMENT_GROUP = (byte)0xC7; - - /** Active Environment Group (AEG) */ - byte ACTIVE_ENVIRONMENT_GROUP = (byte)0xC9; - - /** Medium Map */ - byte MEDIUM_MAP = (byte)0xCC; - - /** Form Map */ - byte FORM_MAP = (byte)0xCD; - - /** Name Resource */ - byte NAME_RESOURCE = (byte)0xCE; - - /** Page Overlay */ - byte PAGE_OVERLAY = (byte)0xD8; - - /** Resource Environment Group (REG) */ - byte RESOURCE_ENVIROMENT_GROUP = (byte)0xD9; - - /** Overlay */ - byte OVERLAY = (byte)0xDF; - - /** Data Suppression */ - byte DATA_SUPRESSION = (byte)0xEA; - - /** Bar Code */ - byte BARCODE = (byte)0xEB; - - /** No Operation */ - byte NO_OPERATION = (byte)0xEE; - - /** Image */ - byte IMAGE = (byte)0xFB; - } - -} - diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java deleted file mode 100644 index b59af4157..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.AFPDataObjectInfo; -import org.apache.fop.render.afp.AFPObjectAreaInfo; -import org.apache.fop.render.afp.AFPResourceInfo; -import org.apache.fop.render.afp.AFPResourceLevel; - -/** - * Abstract base class used by the ImageObject and GraphicsObject which both - * have define an ObjectEnvironmentGroup - */ -public abstract class AbstractDataObject extends AbstractNamedAFPObject { - - /** the object environment group */ - protected ObjectEnvironmentGroup objectEnvironmentGroup = null; - - /** the object factory */ - protected final Factory factory; - - /** - * Named constructor - * - * @param factory the object factory - * @param name data object name - */ - public AbstractDataObject(Factory factory, String name) { - super(name); - this.factory = factory; - } - - /** - * Sets the object view port (area position and size). - * - * @param dataObjectInfo - * the object area info - */ - public void setViewport(AFPDataObjectInfo dataObjectInfo) { - AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - - // object area descriptor - int width = objectAreaInfo.getWidth(); - int height = objectAreaInfo.getHeight(); - int widthRes = objectAreaInfo.getWidthRes(); - int heightRes = objectAreaInfo.getHeightRes(); - ObjectAreaDescriptor objectAreaDescriptor - = factory.createObjectAreaDescriptor(width, height, widthRes, heightRes); - getObjectEnvironmentGroup().setObjectAreaDescriptor(objectAreaDescriptor); - - // object area position - AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); - AFPResourceLevel resourceLevel = resourceInfo.getLevel(); - ObjectAreaPosition objectAreaPosition = null; - if (resourceLevel.isInline()) { - int x = objectAreaInfo.getX(); - int y = objectAreaInfo.getY(); - int rotation = objectAreaInfo.getRotation(); - objectAreaPosition = factory.createObjectAreaPosition(x, y, rotation); - } else { - // positional values are specified in the oaOffset of the include object - objectAreaPosition = factory.createObjectAreaPosition(0, 0, 0); - } - getObjectEnvironmentGroup().setObjectAreaPosition(objectAreaPosition); - } - - /** - * Gets the ObjectEnvironmentGroup - * - * @return the object environment group - */ - public ObjectEnvironmentGroup getObjectEnvironmentGroup() { - if (objectEnvironmentGroup == null) { - this.objectEnvironmentGroup = factory.createObjectEnvironmentGroup(); - } - return objectEnvironmentGroup; - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); // write triplets - if (objectEnvironmentGroup != null) { - objectEnvironmentGroup.writeToStream(os); - } - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java b/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java deleted file mode 100644 index 2ec5feac2..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.modca; - -/** - * Base class for AFP descriptor objects - */ -public abstract class AbstractDescriptor extends AbstractStructuredAFPObject { - /** width of this descriptor */ - protected int width = 0; - /** height of this descriptor */ - protected int height = 0; - /** width resolution of this descriptor */ - protected int widthRes = 0; - /** height resolution of this descriptor */ - protected int heightRes = 0; - - /** - * Default constructor - */ - public AbstractDescriptor() { - } - - /** - * Constructor a PresentationTextDescriptor for the specified - * width and height. - * - * @param width The width of the page. - * @param height The height of the page. - * @param widthRes The width resolution of the page. - * @param heightRes The height resolution of the page. - */ - public AbstractDescriptor(int width, int height, int widthRes, int heightRes) { - this.width = width; - this.height = height; - this.widthRes = widthRes; - this.heightRes = heightRes; - } - - /** {@inheritDoc} */ - public String toString() { - return "width=" + width - + ", height=" + height - + ", widthRes=" + widthRes - + ", heightRes=" + heightRes; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java deleted file mode 100644 index 7e81e4934..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractEnvironmentGroup.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -/** - * A base class that encapsulates common features of - * ActiveEnvironmentGroup and ResourceEnvironmentGroup - */ -public abstract class AbstractEnvironmentGroup extends AbstractNamedAFPObject { - - /** - * The collection of MapPageOverlay objects - */ - protected List mapPageOverlays = null; - - /** - * Main constructor - * - * @param name the object name - */ - public AbstractEnvironmentGroup(String name) { - super(name); - } - - private List getMapPageOverlays() { - if (mapPageOverlays == null) { - mapPageOverlays = new java.util.ArrayList(); - } - return mapPageOverlays; - } - - /** - * Actually creates the MPO object. - * Also creates the supporting object (an IPO) - * - * @param name the name of the overlay to be used - */ - public void createOverlay(String name) { - MapPageOverlay mpo = getCurrentMapPageOverlay(); - if (mpo == null) { - mpo = new MapPageOverlay(); - getMapPageOverlays().add(mpo); - } - - try { - mpo.addOverlay(name); - } catch (MaximumSizeExceededException msee) { - mpo = new MapPageOverlay(); - getMapPageOverlays().add(mpo); - try { - mpo.addOverlay(name); - } catch (MaximumSizeExceededException ex) { - // Should never happen (but log just in case) - log.error("createOverlay():: resulted in a MaximumSizeExceededException"); - } - } - } - - /** - * Getter method for the most recent MapPageOverlay added to the - * Active Environment Group (returns null if no MapPageOverlay exist) - * - * @return the most recent Map Coded Font - */ - private MapPageOverlay getCurrentMapPageOverlay() { - if (mapPageOverlays != null && mapPageOverlays.size() > 0) { - return (MapPageOverlay) mapPageOverlays.get(mapPageOverlays.size() - 1); - } else { - return null; - } - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - if (mapPageOverlays != null) { - writeObjects(mapPageOverlays, os); - } - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java deleted file mode 100644 index 31a4b8430..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.modca; - -import java.io.UnsupportedEncodingException; - -import org.apache.fop.render.afp.AFPConstants; - -/** - * This is the base class for all named data stream objects. - * A named data stream object has an 8 byte EBCIDIC name. - */ -public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject { - - private static final int DEFAULT_NAME_LENGTH = 8; - - /** - * 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. - * - * @param name the object name - */ - protected AbstractNamedAFPObject(String name) { - this.name = name; - } - - /** - * Returns the name length - * - * @return the name length - */ - protected int getNameLength() { - return DEFAULT_NAME_LENGTH; - } - - /** - * Returns the name as a byte array in EBCIDIC encoding - * - * @return the name as a byte array in EBCIDIC encoding - */ - protected byte[] getNameBytes() { - int nameLen = getNameLength(); - if (name.length() < nameLen) { - name = (name + " ").substring(0, nameLen); - } else if (name.length() > nameLen) { - String truncatedName = name.substring(0, nameLen); - log.warn("Constructor:: name '" + name + "'" - + " truncated to " + nameLen + " chars" - + " ('" + truncatedName + "')"); - } - byte[] nameBytes = null; - try { - nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING); - } catch (UnsupportedEncodingException usee) { - nameBytes = name.getBytes(); - log.warn( - "Constructor:: UnsupportedEncodingException translating the name " - + name); - } - return nameBytes; - } - - /** {@inheritDoc} */ - protected void copySF(byte[] data, byte type, byte category) { - super.copySF(data, type, category); - byte[] nameData = getNameBytes(); - System.arraycopy(nameData, 0, data, 9, nameData.length); - } - - /** - * Returns the name of this object - * - * @return the name of this object - */ - public String getName() { - return name; - } - - /** {@inheritDoc} */ - public String toString() { - return getName(); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java deleted file mode 100644 index 6b03adee0..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -import org.apache.fop.render.afp.AFPLineDataInfo; -import org.apache.fop.render.afp.AFPTextDataInfo; -import org.apache.fop.render.afp.fonts.AFPFont; - -/** - * Pages contain the data objects that comprise a presentation document. Each - * page has a set of data objects associated with it. Each page within a - * document is independent from any other page, and each must establish its own - * environment parameters. - * - * The page is the level in the document component hierarchy that is used for - * printing or displaying a document's content. The data objects contained in - * the page envelope in the data stream are presented when the page is - * presented. Each data object has layout information associated with it that - * directs the placement and orientation of the data on the page. In addition, - * each page contains layout information that specifies the measurement units, - * page width, and page depth. - * - * A page is initiated by a begin page structured field and terminated by an end - * page structured field. Structured fields that define objects and active - * environment groups or that specify attributes of the page may be encountered - * in page state. - * - */ -public abstract class AbstractPageObject extends AbstractNamedAFPObject { - - /** The active environment group for the page */ - protected ActiveEnvironmentGroup activeEnvironmentGroup = null; - - /** The current presentation text object */ - private PresentationTextObject currentPresentationTextObject = null; - - /** The list of tag logical elements */ - protected List/**/ tagLogicalElements = null; - - /** The list of the include page segments */ - protected List/**/ includePageSegments = null; - - /** The list of objects within this resource container */ - protected List/**/ objects = new java.util.ArrayList(); - - /** The page width */ - private int width; - - /** The page height */ - private int height; - - /** The page rotation */ - protected int rotation = 0; - - /** The page state */ - protected boolean complete = false; - - /** The width resolution */ - private int widthRes; - - /** The height resolution */ - private int heightRes; - - /** the object factory */ - protected final Factory factory; - - /** - * Default constructor - * - * @param factory the object factory - */ - public AbstractPageObject(Factory factory) { - this.factory = factory; - } - - /** - * Main constructor - * - * @param factory the object factory - * @param name the name of this page object - */ - public AbstractPageObject(Factory factory, String name) { - super(name); - this.factory = factory; - } - - /** - * Construct a new page object for the specified name argument, the page - * name should be an 8 character identifier. - * - * @param factory - * the object factory. - * @param name - * the name of the page. - * @param width - * the width of the page. - * @param height - * the height of the page. - * @param rotation - * the rotation of the page. - * @param widthRes - * the width resolution of the page. - * @param heightRes - * the height resolution of the page. - */ - public AbstractPageObject(Factory factory, - String name, int width, int height, int rotation, - int widthRes, int heightRes) { - super(name); - - this.factory = factory; - this.width = width; - this.height = height; - this.rotation = rotation; - this.widthRes = widthRes; - this.heightRes = heightRes; - } - - /** - * Helper method to create a map coded font object on the current page, this - * method delegates the construction of the map coded font object to the - * active environment group on the page. - * - * @param fontReference - * the font number used as the resource identifier - * @param font - * the font - * @param size - * the point size of the font - */ - public void createFont(int fontReference, AFPFont font, int size) { - getActiveEnvironmentGroup().createFont(fontReference, font, size, 0); - } - - /** - * Helper method to create a line on the current page, this method delegates - * to the presentation text object in order to construct the line. - * - * @param lineDataInfo the line data information. - */ - public void createLine(AFPLineDataInfo lineDataInfo) { - getPresentationTextObject().createLineData(lineDataInfo); - } - - /** - * Helper method to create text on the current page, this method delegates - * to the presentation text object in order to construct the text. - * - * @param textDataInfo - * the afp text data - */ - public void createText(AFPTextDataInfo textDataInfo) { - getPresentationTextObject().createTextData(textDataInfo); - } - - /** - * Helper method to mark the end of the page. This should end the control - * sequence on the current presentation text object. - */ - public void endPage() { - if (currentPresentationTextObject != null) { - currentPresentationTextObject.endControlSequence(); - } - complete = true; - } - - /** - * Ends the presentation text object - */ - protected void endPresentationObject() { - if (currentPresentationTextObject != null) { - currentPresentationTextObject.endControlSequence(); - currentPresentationTextObject = null; - } - } - - /** - * Helper method to create a presentation text object - * on the current page and to return the object. - * - * @return the presentation text object - */ - private PresentationTextObject getPresentationTextObject() { - if (currentPresentationTextObject == null) { - PresentationTextObject presentationTextObject - = factory.createPresentationTextObject(); - addObject(presentationTextObject); - this.currentPresentationTextObject = presentationTextObject; - } - return currentPresentationTextObject; - } - - /** - * Creates a TagLogicalElement on the page. - * - * @param name - * the name of the tag - * @param value - * the value of the tag - */ - public void createTagLogicalElement(String name, String value) { - TagLogicalElement tle = new TagLogicalElement(name, value); - if (tagLogicalElements == null) { - tagLogicalElements = new java.util.ArrayList/**/(); - } - tagLogicalElements.add(tle); - } - - /** - * Creates a NoOperation on the page. - * - * @param content the byte data - */ - public void createNoOperation(String content) { - addObject(new NoOperation(content)); - } - - /** - * Creates an IncludePageSegment on the current page. - * - * @param name - * the name of the page segment - * @param x - * the x coordinate of the page segment. - * @param y - * the y coordinate of the page segment. - */ - public void createIncludePageSegment(String name, int x, int y) { - IncludePageSegment ips = factory.createIncludePageSegment(name, x, y); - getIncludePageSegments().add(ips); - } - - /** - * Returns the include page segments list - * - * @return the include page segments list - */ - private List getIncludePageSegments() { - if (this.includePageSegments == null) { - this.includePageSegments = new java.util.ArrayList/**/(); - } - return this.includePageSegments; - } - - /** - * Returns the ActiveEnvironmentGroup associated with this page. - * - * @return the ActiveEnvironmentGroup object - */ - public ActiveEnvironmentGroup getActiveEnvironmentGroup() { - if (activeEnvironmentGroup == null) { - // every page object must have an ActiveEnvironmentGroup - this.activeEnvironmentGroup - = factory.createActiveEnvironmentGroup(width, height, widthRes, heightRes); - - if (rotation != 0) { - switch (rotation) { - case 90: - activeEnvironmentGroup.setObjectAreaPosition(width, 0, rotation); - break; - case 180: - activeEnvironmentGroup.setObjectAreaPosition(width, height, rotation); - break; - case 270: - activeEnvironmentGroup.setObjectAreaPosition(0, height, rotation); - break; - default: - } - } - } - return activeEnvironmentGroup; - } - - /** - * Returns an indication if the page is complete - * - * @return whether this page is complete - */ - public boolean isComplete() { - return complete; - } - - /** - * Returns the height of the page - * - * @return the height of the page - */ - public int getHeight() { - return height; - } - - /** - * Returns the width of the page - * - * @return the width of the page - */ - public int getWidth() { - return width; - } - - /** - * Returns the rotation of the page - * - * @return the rotation of the page - */ - public int getRotation() { - return rotation; - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - writeObjects(this.objects, os); - } - - /** - * Adds an AFP object reference to this page - * - * @param obj an AFP object - */ - public void addObject(Object obj) { - objects.add(obj); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java deleted file mode 100644 index 42b729cf0..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractPreparedAFPObject.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * A base class that carries out early preparation of structured field data - * for the AFP object (so the data length can be pre-calculated) - */ -public abstract class AbstractPreparedAFPObject extends AbstractNamedAFPObject -implements PreparedAFPObject { - - /** structured field data to be written */ - protected byte[] data = null; - - /** - * Default constructor - */ - public AbstractPreparedAFPObject() { - } - - /** - * Named constructor - * - * @param name the name of this AFP object - */ - public AbstractPreparedAFPObject(String name) { - super(name); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); // write triplets - if (this.data != null) { - os.write(this.data); - } - } - - /** - * Return the start data length of this structured field - * - * @return the start data length of this structured field - */ - protected int getStartDataLength() { - return 0; - } - - /** - * Return the data length of the structured field data of this AFP object - * - * @return the data length of the structured field data of this AFP object - */ - public int getDataLength() { - if (this.data != null) { - return this.data.length; - } - return 0; - } - - /** - * Return the structured field length - * - * @return the structured field length - */ - protected int getLength() { - return getStartDataLength() + getTripletDataLength() + getDataLength(); - } - - /** - * Sets the data - * - * @param data the data - */ - protected void setData(byte[] data) { - this.data = data; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java b/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java deleted file mode 100644 index 5d32a6b9b..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Iterator; -import java.util.List; - -/** - * A base container of prepared structured AFP objects - */ -public abstract class AbstractPreparedObjectContainer extends AbstractNamedAFPObject -implements PreparedAFPObject { - - /** list of objects contained within this container */ - protected List/**/ objects - = new java.util.ArrayList/**/(); - - /** - * Default constructor - */ - protected AbstractPreparedObjectContainer() { - } - - /** - * Named constructor - * - * @param name the name of the container - */ - protected AbstractPreparedObjectContainer(String name) { - super(name); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - writeObjects(objects, os); - } - - /** - * Adds a given prepared object to this container - * - * @param preparedObject the prepared object - */ - public void addObject(PreparedAFPObject preparedObject) { - objects.add(preparedObject); - } - - /** - * Returns the current data length - * - * @return the current data length of this container including - * all enclosed objects (and their containers) - */ - public int getDataLength() { - int dataLen = 0; - Iterator it = objects.iterator(); - while (it.hasNext()) { - Object obj = it.next(); - if (obj instanceof PreparedAFPObject) { - PreparedAFPObject prepObj = (PreparedAFPObject)obj; - dataLen += prepObj.getDataLength(); - } - } - return dataLen; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java b/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java deleted file mode 100644 index 1a5cc86d6..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - - -/** - * An abstract class which encapsulates the common features of - * Document and PageGroup resource containers - */ -public abstract class AbstractResourceEnvironmentGroupContainer - extends AbstractResourceGroupContainer { - - /** - * The resource environment group used to store complex resources - */ - protected ResourceEnvironmentGroup resourceEnvironmentGroup = null; - - /** - * Main constructor - * - * @param factory the object factory - * @param name the name of this resource container - */ - public AbstractResourceEnvironmentGroupContainer( - Factory factory, String name) { - super(factory, name); - } - - /** - * Adds a page to the resource container. - * - * @param page - the Page object - */ - public void addPage(PageObject page) { - addObject(page); - } - - /** - * Adds a PageGroup to the resource container. - * - * @param pageGroup the PageGroup object - */ - public void addPageGroup(PageGroup pageGroup) { - addObject(pageGroup); - } - - /** - * Creates an InvokeMediaMap on the page. - * - * @param name - * the name of the media map - */ - public void createInvokeMediumMap(String name) { - InvokeMediumMap invokeMediumMap = factory.createInvokeMediumMap(name); - addObject(invokeMediumMap); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - if (resourceEnvironmentGroup != null) { - resourceEnvironmentGroup.writeToStream(os); - } - } - - /** - * Returns the resource environment group - * - * @return the resource environment group - */ - protected ResourceEnvironmentGroup getResourceEnvironmentGroup() { - if (resourceEnvironmentGroup == null) { - this.resourceEnvironmentGroup = factory.createResourceEnvironmentGroup(); - } - return this.resourceEnvironmentGroup; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java b/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java deleted file mode 100644 index 9a29f7486..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Collection; -import java.util.Iterator; - -import org.apache.fop.render.afp.Streamable; - - -/** - * An abstract container of resource objects - */ -public abstract class AbstractResourceGroupContainer extends AbstractPageObject -implements Streamable { - - /** The container started state */ - protected boolean started = false; - - /** the resource group object */ - protected ResourceGroup resourceGroup = null; - - /** - * Default constructor - * - * @param factory the object factory - */ - public AbstractResourceGroupContainer(Factory factory) { - super(factory); - } - - /** - * Named constructor - * - * @param factory the object factory - * @param name the name of this resource container - */ - public AbstractResourceGroupContainer(Factory factory, String name) { - super(factory, name); - } - - /** - * Construct a new page object for the specified name argument, the page - * name should be an 8 character identifier. - * - * @param factory - * the object factory - * @param name - * the name of the page. - * @param width - * the width of the page. - * @param height - * the height of the page. - * @param rotation - * the rotation of the page. - * @param widthRes - * the width resolution of the page. - * @param heightRes - * the height resolution of the page. - */ - public AbstractResourceGroupContainer(Factory factory, - String name, int width, int height, int rotation, int widthRes, int heightRes) { - super(factory, name, width, height, rotation, widthRes, heightRes); - } - - /** - * Return the number of resources in this container - * - * @return the number of resources in this container - */ - protected int getResourceCount() { - if (resourceGroup != null) { - return resourceGroup.getResourceCount(); - } - return 0; - } - - /** - * Returns true if this resource group container contains resources - * - * @return true if this resource group container contains resources - */ - protected boolean hasResources() { - return resourceGroup != null && resourceGroup.getResourceCount() > 0; - } - - /** - * Returns the resource group in this resource group container - * - * @return the resource group in this resource group container - */ - protected ResourceGroup getResourceGroup() { - if (resourceGroup == null) { - resourceGroup = factory.createResourceGroup(); - } - return resourceGroup; - } - -// /** {@inheritDoc} */ -// protected void writeContent(OutputStream os) throws IOException { -// if (resourceGroup != null) { -// resourceGroup.writeToStream(os); -// } -// super.writeContent(os); -// } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - if (!started) { - writeStart(os); - started = true; - } - - writeContent(os); - - if (complete) { - writeEnd(os); - } - } - - /** {@inheritDoc} */ - protected void writeObjects(Collection/**/ objects, OutputStream os) - throws IOException { - if (objects != null && objects.size() > 0) { - Iterator it = objects.iterator(); - while (it.hasNext()) { - AbstractAFPObject ao = (AbstractAFPObject)it.next(); - if (canWrite(ao)) { - ao.writeToStream(os); - it.remove(); - } else { - break; - } - } - } - } - - /** - * Returns true if this object can be written - * - * @param obj an AFP object - * @return true if this object can be written - */ - protected boolean canWrite(AbstractAFPObject obj) { - return obj instanceof AbstractPageObject && ((AbstractPageObject)obj).isComplete(); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java deleted file mode 100644 index 89b7f8cdb..000000000 --- a/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.fop.render.afp.modca.Registry.ObjectType; -import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; -import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet; -import org.apache.fop.render.afp.modca.triplets.Triplet; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * An abstract class encapsulating an MODCA structured object - */ -public abstract class AbstractStructuredAFPObject extends AbstractAFPObject { - /** - * list of object triplets - */ - protected List/**/ triplets = null; - - /** - * triplet data created from triplet list - */ - protected byte[] tripletData = null; - - /** - * Default constructor - */ - protected AbstractStructuredAFPObject() { - } - - /** - * Returns the triplet data length - * - * @return the triplet data length - */ - protected int getTripletDataLength() { - if (tripletData == null) { - try { - getTripletData(); - } catch (IOException e) { - log.error("failed to get triplet data"); - } - } - if (tripletData != null) { - return tripletData.length; - } - return 0; - } - - /** - * Returns the triplet data - * - * @return the triplet data - * @throws IOException throws an I/O exception if one occurred - */ - protected byte[] getTripletData() throws IOException { - if (tripletData == null && triplets != null) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - writeObjects(triplets, baos); - this.tripletData = baos.toByteArray(); - triplets = null; // gc - } - return this.tripletData; - } - - /** - * Writes any triplet data - * - * @param os The stream to write to - * @throws IOException The stream to write to - */ - protected void writeTriplets(OutputStream os) throws IOException { - if (tripletData != null) { - os.write(tripletData); - } else if (triplets != null) { - writeObjects(triplets, os); - triplets = null; // gc - } - } - - /** - * Helper method to write the start of the Object. - * - * @param os The stream to write to - * @throws IOException throws an I/O exception if one occurred - */ - protected void writeStart(OutputStream os) throws IOException { - getTripletData(); - } - - /** - * Helper method to write the end of the Object. - * - * @param os The stream to write to - * @throws IOException an I/O exception if one occurred - */ - protected void writeEnd(OutputStream os) throws IOException { - } - - /** - * Helper method to write the contents of the Object. - * - * @param os The stream to write to - * @throws IOException throws an I/O exception if one occurred - */ - protected void writeContent(OutputStream os) throws IOException { - writeTriplets(os); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - writeStart(os); - writeContent(os); - writeEnd(os); - } - - /** - * Returns the first matching triplet found in the structured field triplet list - * - * @param tripletId the triplet identifier - */ - private Triplet getTriplet(byte tripletId) { - Iterator it = getTriplets().iterator(); - while (it.hasNext()) { - Triplet triplet = (Triplet)it.next(); - if (triplet.getId() == tripletId) { - return triplet; - } - } - return null; - } - - /** - * Returns true of this structured field has the given triplet - * - * @param tripletId the triplet identifier - * @return true if the structured field has the given triplet - */ - public boolean hasTriplet(byte tripletId) { - return getTriplet(tripletId) != null; - } - - /** - * Adds a triplet to this structured object - * - * @param triplet the triplet to add - */ - protected void addTriplet(Triplet triplet) { - getTriplets().add(triplet); - } - - /** - * Adds a list of triplets to the triplets contained within this structured field - * - * @param tripletCollection a collection of triplets - */ - public void addTriplets(Collection/**/ tripletCollection) { - if (tripletCollection != null) { - getTriplets().addAll(tripletCollection); - } - } - - /** @return the triplet list pertaining to this resource */ - protected List/**/ getTriplets() { - if (triplets == null) { - triplets = new java.util.ArrayList(); - } - return triplets; - } - - /** - * Sets the fully qualified name of this resource - * - * @param fqnType the fully qualified name type of this resource - * @param fqnFormat the fully qualified name format of this resource - * @param fqName the fully qualified name of this resource - */ - public void setFullyQualifiedName(byte fqnType, byte fqnFormat, String fqName) { - addTriplet(new FullyQualifiedNameTriplet(fqnType, fqnFormat, fqName)); - } - - /** @return the fully qualified name of this triplet or null if it does not exist */ - public String getFullyQualifiedName() { - FullyQualifiedNameTriplet fqNameTriplet - = (FullyQualifiedNameTriplet)getTriplet(Triplet.FULLY_QUALIFIED_NAME); - if (fqNameTriplet != null) { - return fqNameTriplet.getFullyQualifiedName(); - } - log.warn(this + " has no fully qualified name"); - return null; - } - - /** - * Sets the objects classification - * - * @param objectClass the classification of the object - * @param objectType the MOD:CA registry object type entry for the given - * object/component type of the object - * @param dataInContainer whether the data resides in the container - * @param containerHasOEG whether the container has an object environment group - * @param dataInOCD whether the data resides in a object container data structured field - */ - public void setObjectClassification( - byte objectClass, ObjectType objectType, - boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD) { - addTriplet( - new ObjectClassificationTriplet( - objectClass, objectType, dataInContainer, containerHasOEG, dataInOCD)); - } - - /** - * Sets a comment on this resource - * - * @param comment a comment string - */ - public void setComment(String comment) { - try { - addTriplet(new Triplet(Triplet.COMMENT, comment)); - } catch (UnsupportedEncodingException e) { - log.error(e.getMessage()); - } - } - - /** - * Reads data chunks from an inputstream - * and then formats them with a structured header to a given outputstream - * - * @param dataHeader the header data - * @param lengthOffset offset of length field in data chunk - * @param maxChunkLength the maximum chunk length - * @param inputStream the inputstream to read from - * @param outputStream the outputstream to write to - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - protected static void copyChunks(byte[] dataHeader, int lengthOffset, - int maxChunkLength, InputStream inputStream, OutputStream outputStream) - throws IOException { - int headerLen = dataHeader.length - lengthOffset; - // length field is just before data so do not include in data length - if (headerLen == 2) { - headerLen = 0; - } - byte[] data = new byte[maxChunkLength]; - int numBytesRead = 0; - while ((numBytesRead = inputStream.read(data, 0, maxChunkLength)) > 0) { - byte[] len = BinaryUtils.convert(headerLen + numBytesRead, 2); - dataHeader[lengthOffset] = len[0]; // Length byte 1 - dataHeader[lengthOffset + 1] = len[1]; // Length byte 2 - outputStream.write(dataHeader); - outputStream.write(data, 0, numBytesRead); - } - } - - /** - * Writes data chunks to a given outputstream - * - * @param data the data byte array - * @param dataHeader the header data - * @param lengthOffset offset of length field in data chunk - * @param maxChunkLength the maximum chunk length - * @param os the outputstream to write to - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - protected static void writeChunksToStream(byte[] data, byte[] dataHeader, - int lengthOffset, int maxChunkLength, OutputStream os) throws IOException { - int dataLength = data.length; - int numFullChunks = dataLength / maxChunkLength; - int lastChunkLength = dataLength % maxChunkLength; - - int headerLen = dataHeader.length - lengthOffset; - // length field is just before data so do not include in data length - if (headerLen == 2) { - headerLen = 0; - } - - byte[] len; - int off = 0; - if (numFullChunks > 0) { - // write out full data chunks - len = BinaryUtils.convert(headerLen + maxChunkLength, 2); - dataHeader[lengthOffset] = len[0]; // Length byte 1 - dataHeader[lengthOffset + 1] = len[1]; // Length byte 2 - for (int i = 0; i < numFullChunks; i++, off += maxChunkLength) { - os.write(dataHeader); - os.write(data, off, maxChunkLength); - } - } - - if (lastChunkLength > 0) { - // write last data chunk - len = BinaryUtils.convert(headerLen + lastChunkLength, 2); - dataHeader[lengthOffset] = len[0]; // Length byte 1 - dataHeader[lengthOffset + 1] = len[1]; // Length byte 2 - os.write(dataHeader); - os.write(data, off, lastChunkLength); - } - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java deleted file mode 100644 index da418aca6..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -import org.apache.fop.render.afp.fonts.AFPFont; - -/** - * An Active Environment Group (AEG) is associated with each page, - * and is contained in the page's begin-end envelope in the data stream. - * The active environment group contains layout and formatting information - * that defines the measurement units and size of the page, and may contain - * resource information. - * - * Any objects that are required for page presentation and that are to be - * treated as resource objects must be mapped with a map structured field - * in the AEG. The scope of an active environment group is the scope of its - * containing page or overlay. - * - */ -public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { - - /** The collection of MapCodedFont objects */ - private final List/**/ mapCodedFonts - = new java.util.ArrayList/**/(); - - /** the collection of MapDataResource objects */ - private final List mapDataResources = null; - - /** the Object Area Descriptor for the active environment group */ - private ObjectAreaDescriptor objectAreaDescriptor = null; - - /** the Object Area Position for the active environment group */ - private ObjectAreaPosition objectAreaPosition = null; - - /** the PresentationTextDescriptor for the active environment group */ - private PresentationTextDescriptor presentationTextDataDescriptor = null; - - /** the PageDescriptor for the active environment group */ - private PageDescriptor pageDescriptor = null; - - /** the resource manager */ - private final Factory factory; - - /** - * Constructor for the ActiveEnvironmentGroup, this takes a - * name parameter which must be 8 characters long. - * - * @param factory the object factory - * @param name the active environment group name - * @param width the page width - * @param height the page height - * @param widthRes the page width resolution - * @param heightRes the page height resolution - */ - public ActiveEnvironmentGroup(Factory factory, - String name, int width, int height, int widthRes, int heightRes) { - super(name); - - this.factory = factory; - - // Create PageDescriptor - this.pageDescriptor - = factory.createPageDescriptor(width, height, widthRes, heightRes); - - // Create ObjectAreaDescriptor - this.objectAreaDescriptor - = factory.createObjectAreaDescriptor(width, height, widthRes, heightRes); - - // Create PresentationTextDataDescriptor - this.presentationTextDataDescriptor - = factory.createPresentationTextDataDescriptor(width, height, - widthRes, heightRes); - } - - /** - * Set the position of the object area - * - * @param x the x offset - * @param y the y offset - * @param rotation the rotation - */ - public void setObjectAreaPosition(int x, int y, int rotation) { - this.objectAreaPosition = factory.createObjectAreaPosition(x, y, rotation); - } - - /** - * Accessor method to obtain the PageDescriptor object of the - * active environment group. - * - * @return the page descriptor object - */ - public PageDescriptor getPageDescriptor() { - return pageDescriptor; - } - - /** - * Accessor method to obtain the PresentationTextDataDescriptor object of - * the active environment group. - * - * @return the presentation text descriptor - */ - public PresentationTextDescriptor getPresentationTextDataDescriptor() { - return presentationTextDataDescriptor; - } - - /** {@inheritDoc} */ - public void writeContent(OutputStream os) throws IOException { - super.writeTriplets(os); - - writeObjects(mapCodedFonts, os); - writeObjects(mapDataResources, os); - writeObjects(mapPageOverlays, os); - - if (pageDescriptor != null) { - pageDescriptor.writeToStream(os); - } - if (objectAreaDescriptor != null && objectAreaPosition != null) { - objectAreaDescriptor.writeToStream(os); - objectAreaPosition.writeToStream(os); - } - if (presentationTextDataDescriptor != null) { - presentationTextDataDescriptor.writeToStream(os); - } - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.ACTIVE_ENVIRONMENT_GROUP); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.ACTIVE_ENVIRONMENT_GROUP); - os.write(data); - } - - /** - * Method to create a map coded font object - * - * @param fontRef the font number used as the resource identifier - * @param font the font - * @param size the point size of the font - * @param orientation the orientation of the font (e.g. 0, 90, 180, 270) - */ - public void createFont(int fontRef, AFPFont font, int size, int orientation) { - MapCodedFont mapCodedFont = getCurrentMapCodedFont(); - if (mapCodedFont == null) { - mapCodedFont = factory.createMapCodedFont(); - mapCodedFonts.add(mapCodedFont); - } - - try { - mapCodedFont.addFont(fontRef, font, size, orientation); - } catch (MaximumSizeExceededException msee) { - mapCodedFont = factory.createMapCodedFont(); - mapCodedFonts.add(mapCodedFont); - - try { - mapCodedFont.addFont(fontRef, font, size, orientation); - } catch (MaximumSizeExceededException ex) { - // Should never happen (but log just in case) - log.error("createFont():: resulted in a MaximumSizeExceededException"); - } - } - } - - /** - * Getter method for the most recent MapCodedFont added to the - * Active Environment Group (returns null if no MapCodedFonts exist) - * - * @return the most recent Map Coded Font. - */ - private MapCodedFont getCurrentMapCodedFont() { - int size = mapCodedFonts.size(); - if (size > 0) { - return (MapCodedFont)mapCodedFonts.get(size - 1); - } else { - return null; - } - } - -// private List getMapDataResources() { -// if (mapDataResources == null) { -// mapDataResources = new java.util.ArrayList(); -// } -// return mapDataResources; -//} - -// /** -// * Method to create a map data resource object -// * @param dataObjectAccessor a data object accessor -// */ -// protected void createMapDataResource(DataObjectAccessor dataObjectAccessor) { -// getMapDataResources().add(new MapDataResource(dataObjectAccessor)); -// } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java deleted file mode 100644 index 224b25112..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * Container data descriptor (to maintain compatibility with pre-year 2000 applications) - */ -public class ContainerDataDescriptor extends AbstractDescriptor { - - /** - * Main constructor - * - * @param width the container data width - * @param height the container data height - * @param widthRes the container width resolution - * @param heightRes the container height resolution - */ - public ContainerDataDescriptor(int width, int height, int widthRes, - int heightRes) { - super(width, height, widthRes, heightRes); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[21]; - copySF(data, Type.DESCRIPTOR, Category.OBJECT_CONTAINER); - - // SF length - byte[] len = BinaryUtils.convert(data.length - 1, 2); - data[1] = len[0]; - data[2] = len[1]; - - // XocBase = 10 inches - data[9] = 0x00; - - // YocBase = 10 inches - data[10] = 0x00; - - // XocUnits - byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); - data[11] = xdpi[0]; - data[12] = xdpi[1]; - - // YocUnits - byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2); - data[13] = ydpi[0]; - data[14] = ydpi[1]; - - // XocSize - byte[] xsize = BinaryUtils.convert(width, 3); - data[15] = xsize[0]; - data[16] = xsize[1]; - data[17] = xsize[2]; - - // YocSize - byte[] ysize = BinaryUtils.convert(height, 3); - data[18] = ysize[0]; - data[19] = ysize[1]; - data[20] = ysize[2]; - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/DataStream.java b/src/java/org/apache/fop/render/afp/modca/DataStream.java deleted file mode 100644 index 2f5336f20..000000000 --- a/src/java/org/apache/fop/render/afp/modca/DataStream.java +++ /dev/null @@ -1,636 +0,0 @@ -/* - * 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.modca; - -import java.awt.Color; -import java.awt.Point; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Iterator; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.AFPFontAttributes; -import org.apache.fop.render.afp.AFPLineDataInfo; -import org.apache.fop.render.afp.AFPResourceLevel; -import org.apache.fop.render.afp.AFPState; -import org.apache.fop.render.afp.AFPTextDataInfo; -import org.apache.fop.render.afp.fonts.AFPFont; -import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; - -/** - * A data stream is a continuous ordered stream of data elements and objects - * conforming to a given format. Application programs can generate data streams - * destined for a presentation service, archive library, presentation device or - * another application program. The strategic presentation data stream - * architectures used is Mixed Object Document Content Architecture (MO:DCA). - * - * The MO:DCA architecture defines the data stream used by applications to - * describe documents and object envelopes for interchange with other - * applications and application services. Documents defined in the MO:DCA format - * may be archived in a database, then later retrieved, viewed, annotated and - * printed in local or distributed systems environments. Presentation fidelity - * is accommodated by including resource objects in the documents that reference - * them. - */ -public class DataStream { - - /** Static logging instance */ - protected static Log log = LogFactory.getLog("org.apache.fop.render.afp.modca"); - - /** Boolean completion indicator */ - private boolean complete = false; - - /** The application producing the AFP document */ - // not used - // private String producer = null; - - /** The AFP document object */ - private Document document = null; - - /** The current page group object */ - private PageGroup currentPageGroup = null; - - /** The current page object */ - private PageObject currentPageObject = null; - - /** The current overlay object */ - private Overlay currentOverlay = null; - - /** The current page */ - private AbstractPageObject currentPage = null; - -// /** The portrait rotation */ -// private int portraitRotation = 0; -// -// /** The landscape rotation */ -// private int landscapeRotation = 270; - - /** The MO:DCA interchange set in use (default to MO:DCA-P IS/2 set) */ - private InterchangeSet interchangeSet - = InterchangeSet.valueOf(InterchangeSet.MODCA_PRESENTATION_INTERCHANGE_SET_2); - - private final Factory factory; - - private OutputStream outputStream; - - /** the afp state */ - private final AFPState state; - - /** - * Default constructor for the AFPDocumentStream. - * - * @param factory the resource factory - * @param state the afp state - * @param outputStream the outputstream to write to - */ - public DataStream(Factory factory, AFPState state, OutputStream outputStream) { - this.state = state; - this.factory = factory; - this.outputStream = outputStream; - } - - /** - * Returns the outputstream - * - * @return the outputstream - */ - public OutputStream getOutputStream() { - return this.outputStream; - } - - /** - * Returns the document object - * - * @return the document object - */ - private Document getDocument() { - return this.document; - } - - /** - * Returns the current page - * - * @return the current page - */ - public AbstractPageObject getCurrentPage() { - return this.currentPage; - } - - /** - * The document is started by invoking this method which creates an instance - * of the AFP Document object. - * - * @param name - * the name of this document. - */ - public void setDocumentName(String name) { - if (name != null) { - getDocument().setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_BEGIN_DOCUMENT_REF, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, name); - } - } - - /** {@inheritDoc} */ - public void endDocument() throws IOException { - if (complete) { - String msg = "Invalid state - document already ended."; - log.warn("endDocument():: " + msg); - throw new IllegalStateException(msg); - } - - if (currentPageObject != null) { - // End the current page if necessary - endPage(); - } - - if (currentPageGroup != null) { - // End the current page group if necessary - endPageGroup(); - } - - // Write out document - if (document != null) { - document.endDocument(); - document.writeToStream(this.outputStream); - } - - this.outputStream.flush(); - - this.complete = true; - - this.document = null; - - this.outputStream = null; - } - - /** - * Start a new page. When processing has finished on the current page, the - * {@link #endPage()}method must be invoked to mark the page ending. - * - * @param pageWidth - * the width of the page - * @param pageHeight - * the height of the page - * @param pageRotation - * the rotation of the page - * @param pageWidthRes - * the width resolution of the page - * @param pageHeightRes - * the height resolution of the page - */ - public void startPage(int pageWidth, int pageHeight, int pageRotation, - int pageWidthRes, int pageHeightRes) { - currentPageObject = factory.createPage(pageWidth, pageHeight, - pageRotation, pageWidthRes, pageHeightRes); - currentPage = currentPageObject; - currentOverlay = null; - } - - /** - * Start a new overlay. When processing has finished on the current overlay, - * the {@link #endOverlay()}method must be invoked to mark the overlay - * ending. - * - * @param x - * the x position of the overlay on the page - * @param y - * the y position of the overlay on the page - * @param width - * the width of the overlay - * @param height - * the height of the overlay - * @param widthRes - * the width resolution of the overlay - * @param heightRes - * the height resolution of the overlay - * @param overlayRotation - * the rotation of the overlay - */ - public void startOverlay(int x, int y, int width, int height, int widthRes, - int heightRes, int overlayRotation) { - this.currentOverlay = factory.createOverlay( - width, height, widthRes, heightRes, overlayRotation); - - String overlayName = currentOverlay.getName(); - currentPageObject.createIncludePageOverlay(overlayName, x, y, 0); - currentPage = currentOverlay; - } - - /** - * Helper method to mark the end of the current overlay. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void endOverlay() throws IOException { - if (currentOverlay != null) { - currentOverlay.endPage(); - currentOverlay = null; - currentPage = currentPageObject; - } - } - - /** - * Helper method to save the current page. - * - * @return current page object that was saved - */ - public PageObject savePage() { - PageObject pageObject = currentPageObject; - if (currentPageGroup != null) { - currentPageGroup.addPage(currentPageObject); - } else { - document.addPage(currentPageObject); - } - currentPageObject = null; - currentPage = null; - return pageObject; - } - - /** - * Helper method to restore the current page. - * - * @param pageObject - * page object - */ - public void restorePage(PageObject pageObject) { - currentPageObject = pageObject; - currentPage = pageObject; - } - - /** - * Helper method to mark the end of the current page. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void endPage() throws IOException { - if (currentPageObject != null) { - currentPageObject.endPage(); - if (currentPageGroup != null) { - currentPageGroup.addPage(currentPageObject); - currentPageGroup.writeToStream(this.outputStream); - } else { - document.addPage(currentPageObject); - document.writeToStream(this.outputStream); - } - currentPageObject = null; - currentPage = null; - } - } - - /** - * Creates the given page fonts in the current page - * - * @param pageFonts - * a collection of AFP font attributes - */ - public void addFontsToCurrentPage(Map pageFonts) { - Iterator iter = pageFonts.values().iterator(); - while (iter.hasNext()) { - AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter - .next(); - createFont(afpFontAttributes.getFontReference(), afpFontAttributes - .getFont(), afpFontAttributes.getPointSize()); - } - } - - /** - * Helper method to create a map coded font object on the current page, this - * method delegates the construction of the map coded font object to the - * active environment group on the current page. - * - * @param fontReference - * the font number used as the resource identifier - * @param font - * the font - * @param size - * the point size of the font - */ - public void createFont(int fontReference, AFPFont font, int size) { - currentPage.createFont(fontReference, font, size); - } - - /** - * Returns a point on the current page - * - * @param x the X-coordinate - * @param y the Y-coordinate - * @return a point on the current page - */ - private Point getPoint(int x, int y) { - Point p = new Point(); - int rotation = state.getRotation(); - switch (rotation) { - case 90: - p.x = y; - p.y = currentPage.getWidth() - x; - break; - case 180: - p.x = currentPage.getWidth() - x; - p.y = currentPage.getHeight() - y; - break; - case 270: - p.x = currentPage.getHeight() - y; - p.y = x; - break; - default: - p.x = x; - p.y = y; - break; - } - return p; - } - - /** - * Helper method to create text on the current page, this method delegates - * to the current presentation text object in order to construct the text. - * - * @param textDataInfo - * the afp text data - */ - public void createText(AFPTextDataInfo textDataInfo) { - int rotation = state.getRotation(); - if (rotation != 0) { - textDataInfo.setRotation(rotation); - Point p = getPoint(textDataInfo.getX(), textDataInfo.getY()); - textDataInfo.setX(p.x); - textDataInfo.setY(p.y); - } - currentPage.createText(textDataInfo); - } - - /** - * Method to create a line on the current page. - * - * @param lineDataInfo the line data information. - */ - public void createLine(AFPLineDataInfo lineDataInfo) { - currentPage.createLine(lineDataInfo); - } - - /** - * This method will create shading on the page using the specified - * coordinates (the shading contrast is controlled via the red, green, blue - * parameters, by converting this to grey scale). - * - * @param x - * the x coordinate of the shading - * @param y - * the y coordinate of the shading - * @param w - * the width of the shaded area - * @param h - * the height of the shaded area - * @param col - * the shading color - */ - public void createShading(int x, int y, int w, int h, Color col) { - currentPageObject.createShading(x, y, w, h, col.getRed(), col.getGreen(), col.getBlue()); - } - - /** - * Helper method which allows creation of the MPO object, via the AEG. And - * the IPO via the Page. (See actual object for descriptions.) - * - * @param name - * the name of the static overlay - */ - public void createIncludePageOverlay(String name) { - currentPageObject.createIncludePageOverlay(name, 0, 0, state.getRotation()); - currentPageObject.getActiveEnvironmentGroup().createOverlay(name); - } - - /** - * Helper method which allows creation of the IMM object. - * - * @param name - * the name of the medium map - */ - public void createInvokeMediumMap(String name) { - currentPageGroup.createInvokeMediumMap(name); - } - - /** - * Creates an IncludePageSegment on the current page. - * - * @param name - * the name of the include page segment - * @param x - * the x coordinate for the overlay - * @param y - * the y coordinate for the overlay - */ - public void createIncludePageSegment(String name, int x, int y) { - int xOrigin; - int yOrigin; - int orientation = state.getRotation(); - switch (orientation) { - case 90: - xOrigin = currentPage.getWidth() - y; - yOrigin = x; - break; - case 180: - xOrigin = currentPage.getWidth() - x; - yOrigin = currentPage.getHeight() - y; - break; - case 270: - xOrigin = y; - yOrigin = currentPage.getHeight() - x; - break; - default: - xOrigin = x; - yOrigin = y; - break; - } - currentPage.createIncludePageSegment(name, xOrigin, yOrigin); - } - - /** - * Creates a TagLogicalElement on the current page. - * - * @param attributes - * the array of key value pairs. - */ - public void createPageTagLogicalElement(TagLogicalElementBean[] attributes) { - for (int i = 0; i < attributes.length; i++) { - String name = attributes[i].getKey(); - String value = attributes[i].getValue(); - currentPage.createTagLogicalElement(name, value); - } - } - - /** - * Creates a TagLogicalElement on the current page group. - * - * @param attributes - * the array of key value pairs. - */ - public void createPageGroupTagLogicalElement(TagLogicalElementBean[] attributes) { - for (int i = 0; i < attributes.length; i++) { - String name = attributes[i].getKey(); - String value = attributes[i].getValue(); - currentPageGroup.createTagLogicalElement(name, value); - } - } - - /** - * Creates a TagLogicalElement on the current page or page group - * - * @param name - * The tag name - * @param value - * The tag value - */ - public void createTagLogicalElement(String name, String value) { - if (currentPageGroup != null) { - currentPageGroup.createTagLogicalElement(name, value); - } else { - currentPage.createTagLogicalElement(name, value); - } - } - - /** - * Creates a NoOperation item - * - * @param content - * byte data - */ - public void createNoOperation(String content) { - currentPage.createNoOperation(content); - } - - /** - * Returns the current page group - * - * @return the current page group - */ - public PageGroup getCurrentPageGroup() { - return this.currentPageGroup; - } - - /** - * Start a new document. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void startDocument() throws IOException { - this.document = factory.createDocument(); - document.writeToStream(this.outputStream); - } - - /** - * Start a new page group. When processing has finished on the current page - * group the {@link #endPageGroup()}method must be invoked to mark the page - * group ending. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void startPageGroup() throws IOException { - endPageGroup(); - this.currentPageGroup = factory.createPageGroup(); - } - - /** - * Helper method to mark the end of the page group. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void endPageGroup() throws IOException { - if (currentPageGroup != null) { - currentPageGroup.endPageGroup(); - document.addPageGroup(currentPageGroup); - document.writeToStream(outputStream); - currentPageGroup = null; - } - } - - /** - * Sets the MO:DCA interchange set to use - * - * @param interchangeSet the MO:DCA interchange set - */ - public void setInterchangeSet(InterchangeSet interchangeSet) { - this.interchangeSet = interchangeSet; - } - - /** - * Returns the MO:DCA interchange set in use - * - * @return the MO:DCA interchange set in use - */ - public InterchangeSet getInterchangeSet() { - return this.interchangeSet; - } - - /** - * Returns the resource group for a given resource info - * - * @param level a resource level - * @return a resource group for the given resource info - */ - public ResourceGroup getResourceGroup(AFPResourceLevel level) { - ResourceGroup resourceGroup = null; - if (level.isDocument()) { - resourceGroup = document.getResourceGroup(); - } else if (level.isPageGroup()) { - resourceGroup = currentPageGroup.getResourceGroup(); - } else if (level.isPage()) { - resourceGroup = currentPageObject.getResourceGroup(); - } - return resourceGroup; - } - - /** - * Sets the rotation to be used for portrait pages, valid values are 0 - * (default), 90, 180, 270. - * - * @param pageRotation the rotation in degrees. - * @deprecated not used - */ - public void setPortraitRotation(int pageRotation) { - } - - /** - * Sets the rotation to be used for landscape pages, valid values are 0, 90, - * 180, 270 (default). - * - * @param pageRotation the rotation in degrees. - * @deprecated not used - */ - public void setLandscapeRotation(int pageRotation) { - } - - /** - * Sets the offsets to be used for element positioning - * - * @param xOff - * the offset in the x direction - * @param yOff - * the offset in the y direction - * @param orientation - * the orientation - * @deprecated not used - */ - public void setOffsets(int xOff, int yOff, int orientation) { - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/Document.java b/src/java/org/apache/fop/render/afp/modca/Document.java deleted file mode 100644 index 30fa8e557..000000000 --- a/src/java/org/apache/fop/render/afp/modca/Document.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * The document is the highest level of the MO:DCA data-stream document - * component hierarchy. Documents can be made up of pages, and the pages, which - * are at the intermediate level, can be made up of objects. Objects are at the - * lowest level, and can be bar codes, graphics, images, and presentation text. - * - * At each level of the hierarchy certain sets of MO:DCA data structures, called - * structured fields, are permissible. The document, pages and objects are - * bounded by structured fields that define their beginnings and their ends. - * These structured fields, called begin-end pairs, provide an envelope for the - * data-stream components. This feature enables a processor of the data stream - * that is not fully compliant with the architecture to bypass those objects - * that are beyond its scope, and to process the data stream to the best of its - * abilities. - * - * A presentation document is one that has been formatted and is intended for - * presentation, usually on a printer or display device. A data stream - * containing a presentation document should produce the same document content - * in the same format on different printers or display devices dependent, - * however, on the capabilities of each of the printers or display devices. A - * presentation document can reference resources that are to be included as part - * of the document to be presented. - * - */ -public final class Document extends AbstractResourceEnvironmentGroupContainer { - - /** - * Constructor for the document object. - * - * @param factory - * the object factory - * @param name - * the name of the document - */ - public Document(Factory factory, String name) { - super(factory, name); - } - - /** - * Method to mark the end of the page group. - */ - public void endDocument() { - complete = true; - } - - /** - * Returns an indication if the page group is complete - * - * @return whether or not this page group is complete - */ - public boolean isComplete() { - return complete; - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.DOCUMENT); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.DOCUMENT); - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return this.name; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/Factory.java b/src/java/org/apache/fop/render/afp/modca/Factory.java deleted file mode 100644 index 468912b50..000000000 --- a/src/java/org/apache/fop/render/afp/modca/Factory.java +++ /dev/null @@ -1,606 +0,0 @@ -/* - * 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.modca; - -import java.io.OutputStream; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.AFPState; -import org.apache.fop.render.afp.goca.GraphicsData; -import org.apache.fop.render.afp.ioca.ImageContent; -import org.apache.fop.render.afp.ioca.ImageRasterData; -import org.apache.fop.render.afp.ioca.ImageSegment; -import org.apache.fop.render.afp.ioca.ImageSizeParameter; -import org.apache.fop.render.afp.tools.StringUtils; - -/** - * Creator of MO:DCA data objects (mostly) - */ -public class Factory { - - /** Static logging instance */ - private static final Log log = LogFactory.getLog(Factory.class); - - private static final String OBJECT_ENVIRONMENT_GROUP_NAME_PREFIX = "OEG"; - - private static final String ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX = "AEG"; - - private static final String IMAGE_NAME_PREFIX = "IMG"; - - private static final String GRAPHIC_NAME_PREFIX = "GRA"; - - private static final String BARCODE_NAME_PREFIX = "BAR"; - -// private static final String OTHER_NAME_PREFIX = "OTH"; - - private static final String OBJECT_CONTAINER_NAME_PREFIX = "OC"; - - private static final String RESOURCE_NAME_PREFIX = "RES"; - - private static final String RESOURCE_GROUP_NAME_PREFIX = "RG"; - - private static final String PAGE_GROUP_NAME_PREFIX = "PGP"; - - private static final String PAGE_NAME_PREFIX = "PGN"; - - private static final String OVERLAY_NAME_PREFIX = "OVL"; - - private static final String PRESENTATION_TEXT_NAME_PREFIX = "PT"; - - private static final String DOCUMENT_NAME_PREFIX = "DOC"; - - private static final String IM_IMAGE_NAME_PREFIX = "IMIMG"; - - private static final String IMAGE_SEGMENT_NAME_PREFIX = "IS"; - - - /** the page group count */ - private int pageGroupCount = 0; - - /** the page count */ - private int pageCount = 0; - - /** the image count */ - private int imageCount = 0; - - /** the im image count */ - private int imImageCount = 0; - - /** the image segment count */ - private int imageSegmentCount = 0; - - /** the graphic count */ - private int graphicCount = 0; - - /** the object container count */ - private int objectContainerCount = 0; - - /** the resource count */ - private int resourceCount = 0; - - /** the resource group count */ - private int resourceGroupCount = 0; - - /** the overlay count */ - private int overlayCount = 0; - - /** the presentation text object count */ - private int textObjectCount = 0; - - /** the active environment group count */ - private int activeEnvironmentGroupCount = 0; - - /** the document count */ - private int documentCount = 0; - - /** the object environment group count */ - private int objectEnvironmentGroupCount = 0; - - /** - * Main constructor - */ - public Factory() { - } - - /** - * Creates a new IOCA {@link ImageObject} - * - * @return a new {@link ImageObject} - */ - public ImageObject createImageObject() { - String name = IMAGE_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++imageCount), '0', 5); - ImageObject imageObject = new ImageObject(this, name); - return imageObject; - } - - /** - * Creates an IOCA {@link IMImageObject} - * - * @return a new {@link IMImageObject} - */ - public IMImageObject createIMImageObject() { - String name = IM_IMAGE_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++imImageCount), '0', 3); - IMImageObject imImageObject = new IMImageObject(name); - return imImageObject; - } - - /** - * Creates a new GOCA {@link GraphicsObject} - * - * @return a new {@link GraphicsObject} - */ - public GraphicsObject createGraphicsObject() { - String name = GRAPHIC_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++graphicCount), '0', 5); - GraphicsObject graphicsObj = new GraphicsObject(this, name); - return graphicsObj; - } - - /** - * Creates a new MO:DCA {@link ObjectContainer} - * - * @return a new {@link ObjectContainer} - */ - public ObjectContainer createObjectContainer() { - String name = OBJECT_CONTAINER_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++objectContainerCount), '0', 6); - return new ObjectContainer(this, name); - } - - /** - * Creates a new MO:DCA {@link ResourceObject} - * - * @param resourceName the resource object name - * @return a new {@link ResourceObject} - */ - public ResourceObject createResource(String resourceName) { - return new ResourceObject(resourceName); - } - - /** - * Creates a new MO:DCA {@link ResourceObject} - * - * @return a new {@link ResourceObject} - */ - public ResourceObject createResource() { - String name = RESOURCE_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++resourceCount), '0', 5); - return createResource(name); - } - - /** - * Creates a new MO:DCA {@link PageGroup} - * - * @return a new {@link PageGroup} - */ - public PageGroup createPageGroup() { - String name = PAGE_GROUP_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++pageGroupCount), '0', 5); - return new PageGroup(this, name); - } - - /** - * Creates a new MO:DCA {@link ActiveEnvironmentGroup} - * - * @param width the page width - * @param height the page height - * @param widthRes the page width resolution - * @param heightRes the page height resolution - * @return a new {@link ActiveEnvironmentGroup} - */ - public ActiveEnvironmentGroup createActiveEnvironmentGroup( - int width, int height, int widthRes, int heightRes) { - String name = ACTIVE_ENVIRONMENT_GROUP_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++activeEnvironmentGroupCount ), '0', 5); - return new ActiveEnvironmentGroup(this, name, width, height, widthRes, heightRes); - } - - /** - * Creates a new MO:DCA {@link ResourceGroup} - * - * @return a new {@link ResourceGroup} - */ - public ResourceGroup createResourceGroup() { - String name = RESOURCE_GROUP_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++resourceGroupCount), '0', 6); - return new ResourceGroup(name); - } - - /** - * Creates a new MO:DCA {@link StreamedResourceGroup} - * - * @param os the outputstream of the streamed resource group - * @return a new {@link StreamedResourceGroup} - */ - public StreamedResourceGroup createStreamedResourceGroup(OutputStream os) { - String name = RESOURCE_GROUP_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++resourceGroupCount), '0', 6); - return new StreamedResourceGroup(name, os); - } - - /** - * Creates a new MO:DCA {@link PageObject}. - * - * @param pageWidth - * the width of the page - * @param pageHeight - * the height of the page - * @param pageRotation - * the rotation of the page - * @param pageWidthRes - * the width resolution of the page - * @param pageHeightRes - * the height resolution of the page - * - * @return a new {@link PageObject} - */ - public PageObject createPage(int pageWidth, int pageHeight, int pageRotation, - int pageWidthRes, int pageHeightRes) { - String pageName = PAGE_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++pageCount), '0', 5); - return new PageObject(this, pageName, pageWidth, pageHeight, - pageRotation, pageWidthRes, pageHeightRes); - } - - - /** - * Creates a new MO:DCA {@link PresentationTextObject}. - * - * @return a new {@link PresentationTextObject} - */ - public PresentationTextObject createPresentationTextObject() { - String textObjectName = PRESENTATION_TEXT_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++textObjectCount), '0', 6); - return new PresentationTextObject(textObjectName); - } - - - /** - * Creates a new MO:DCA {@link Overlay}. - * - * @param width - * the width of the overlay - * @param height - * the height of the overlay - * @param widthRes - * the width resolution of the overlay - * @param heightRes - * the height resolution of the overlay - * @param overlayRotation - * the rotation of the overlay - * - * @return a new {@link Overlay}. - */ - public Overlay createOverlay(int width, int height, - int widthRes, int heightRes, int overlayRotation) { - String overlayName = OVERLAY_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++overlayCount), '0', 5); - Overlay overlay = new Overlay(this, overlayName, width, height, - overlayRotation, widthRes, heightRes); - return overlay; - } - - /** - * Creates a MO:DCA {@link Document} - * - * @return a new {@link Document} - */ - public Document createDocument() { - String documentName = DOCUMENT_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++documentCount), '0', 5); - Document document = new Document(this, documentName); - return document; - } - - /** - * Creates a MO:DCA {@link MapCodedFont} - * - * @return a new {@link MapCodedFont} - */ - public MapCodedFont createMapCodedFont() { - MapCodedFont mapCodedFont = new MapCodedFont(); - return mapCodedFont; - } - - /** - * Creates a MO:DCA {@link IncludePageSegment} - * - * @param name the page segment name - * @param x the x coordinate - * @param y the y coordinate - * - * @return a new {@link IncludePageSegment} - */ - public IncludePageSegment createIncludePageSegment(String name, int x, int y) { - IncludePageSegment includePageSegment = new IncludePageSegment(name, x, y); - return includePageSegment; - } - - /** - * Creates a MO:DCA {@link IncludeObject} - * - * @param name the name of this include object - * @return a new {@link IncludeObject} - */ - public IncludeObject createInclude(String name) { - IncludeObject includeObject = new IncludeObject(name); - return includeObject; - } - - /** - * Creates a MO:DCA {@link TagLogicalElement} - * - * @param name name of the element - * @param value value of the element - * @return a new {@link TagLogicalElement} - */ - public TagLogicalElement createTagLogicalElement(String name, String value) { - TagLogicalElement tle = new TagLogicalElement(name, value); - return tle; - } - - /** - * Creates a new {@link DataStream} - * - * @param state the afp state - * @param outputStream an outputstream to write to - * @return a new {@link DataStream} - */ - public DataStream createDataStream(AFPState state, OutputStream outputStream) { - DataStream dataStream = new DataStream(this, state, outputStream); - return dataStream; - } - - /** - * Creates a new MO:DCA {@link PageDescriptor} - * - * @param width the page width. - * @param height the page height. - * @param widthRes the page width resolution. - * @param heightRes the page height resolution. - * @return a new {@link PageDescriptor} - */ - public PageDescriptor createPageDescriptor(int width, int height, int widthRes, int heightRes) { - PageDescriptor pageDescriptor = new PageDescriptor(width, height, widthRes, heightRes); - return pageDescriptor; - } - - /** - * Returns a new MO:DCA {@link ObjectEnvironmentGroup} - * - * @return a new {@link ObjectEnvironmentGroup} - */ - public ObjectEnvironmentGroup createObjectEnvironmentGroup() { - String oegName = OBJECT_ENVIRONMENT_GROUP_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++objectEnvironmentGroupCount), '0', 5); - ObjectEnvironmentGroup objectEnvironmentGroup = new ObjectEnvironmentGroup(oegName); - return objectEnvironmentGroup; - } - - /** - * Creates a new GOCA {@link GraphicsData} - * - * @return a new {@link GraphicsData} - */ - public GraphicsData createGraphicsData() { - GraphicsData graphicsData = new GraphicsData(); - return graphicsData; - } - - /** - * Creates a new {@link ObjectAreaDescriptor} - * - * @param width the object width. - * @param height the object height. - * @param widthRes the object width resolution. - * @param heightRes the object height resolution. - * @return a new {@link ObjectAreaDescriptor} - */ - public ObjectAreaDescriptor createObjectAreaDescriptor( - int width, int height, int widthRes, int heightRes) { - ObjectAreaDescriptor objectAreaDescriptor - = new ObjectAreaDescriptor(width, height, widthRes, heightRes); - return objectAreaDescriptor; - } - - /** - * Creates a new {@link ObjectAreaPosition} - * - * @param x the x coordinate. - * @param y the y coordinate. - * @param rotation the coordinate system rotation (must be 0, 90, 180, 270). - * @return a new {@link ObjectAreaPosition} - */ - public ObjectAreaPosition createObjectAreaPosition(int x, int y, - int rotation) { - ObjectAreaPosition objectAreaPosition = new ObjectAreaPosition( - x, y, rotation); - return objectAreaPosition; - } - - /** - * Creates a new {@link ImageDataDescriptor} - * - * @param width the image width - * @param height the image height - * @param widthRes the x resolution of the image - * @param heightRes the y resolution of the image - * @return a new {@link ImageDataDescriptor} - */ - public ImageDataDescriptor createImageDataDescriptor( - int width, int height, int widthRes, int heightRes) { - ImageDataDescriptor imageDataDescriptor = new ImageDataDescriptor( - width, height, widthRes, heightRes); - return imageDataDescriptor; - } - - /** - * Creates a new GOCA {@link GraphicsDataDescriptor} - * - * @param xlwind the left edge of the graphics window - * @param xrwind the right edge of the graphics window - * @param ybwind the top edge of the graphics window - * @param ytwind the bottom edge of the graphics window - * @param widthRes the x resolution of the graphics window - * @param heightRes the y resolution of the graphics window - * @return a new {@link GraphicsDataDescriptor} - */ - public GraphicsDataDescriptor createGraphicsDataDescriptor( - int xlwind, int xrwind, int ybwind, int ytwind, int widthRes, int heightRes) { - GraphicsDataDescriptor graphicsDataDescriptor = new GraphicsDataDescriptor( - xlwind, xrwind, ybwind, ytwind, widthRes, heightRes); - return graphicsDataDescriptor; - } - - /** - * Creates a new MO:DCA {@link ContainerDataDescriptor} - * - * @param dataWidth the container data width - * @param dataHeight the container data height - * @param widthRes the container data width resolution - * @param heightRes the container data height resolution - * @return a new {@link ContainerDataDescriptor} - */ - public ContainerDataDescriptor createContainerDataDescriptor( - int dataWidth, int dataHeight, int widthRes, int heightRes) { - ContainerDataDescriptor containerDataDescriptor - = new ContainerDataDescriptor(dataWidth, dataHeight, widthRes, heightRes); - return containerDataDescriptor; - } - - /** - * Creates a new MO:DCA {@link MapContainerData} - * - * @param optionValue the option value - * @return a new {@link MapContainerData} - */ - public MapContainerData createMapContainerData(byte optionValue) { - MapContainerData mapContainerData = new MapContainerData(optionValue); - return mapContainerData; - } - - /** - * Creates a new MO:DCA {@link MapDataResource} - * - * @return a new {@link MapDataResource} - */ - public MapDataResource createMapDataResource() { - MapDataResource mapDataResource = new MapDataResource(); - return mapDataResource; - } - - /** - * Creates a new PTOCA {@link PresentationTextDescriptor} - * - * @return a new {@link PresentationTextDescriptor} - */ - public PresentationTextDescriptor createPresentationTextDataDescriptor( - int width, int height, int widthRes, int heightRes) { - PresentationTextDescriptor presentationTextDescriptor - = new PresentationTextDescriptor(width, height, - widthRes, heightRes); - return presentationTextDescriptor; - } - - /** - * Creates a new MO:DCA {@link PresentationEnvironmentControl} - * - * @return a new {@link PresentationEnvironmentControl} - */ - public PresentationEnvironmentControl createPresentationEnvironmentControl() { - PresentationEnvironmentControl presentationEnvironmentControl - = new PresentationEnvironmentControl(); - return presentationEnvironmentControl; - } - - /** - * Creates a new MO:DCA {@link InvokeMediumMap} - * - * @param name the object name - * @return a new {@link InvokeMediumMap} - */ - public InvokeMediumMap createInvokeMediumMap(String name) { - InvokeMediumMap invokeMediumMap = new InvokeMediumMap(name); - return invokeMediumMap; - } - - /** - * Creates a new MO:DCA {@link ResourceEnvironmentGroup} - * - * @return a new {@link ResourceEnvironmentGroup} - */ - public ResourceEnvironmentGroup createResourceEnvironmentGroup() { - ResourceEnvironmentGroup resourceEnvironmentGroup = new ResourceEnvironmentGroup(); - return resourceEnvironmentGroup; - } - - /** - * Creates a new IOCA {@link ImageSegment} - * - * @return a new {@link ImageSegment} - */ - public ImageSegment createImageSegment() { - String name = IMAGE_SEGMENT_NAME_PREFIX - + StringUtils.lpad(String.valueOf(++imageSegmentCount), '0', 2); - ImageSegment imageSegment = new ImageSegment(this, name); - return imageSegment; - } - - /** - * Creates an new IOCA {@link ImageContent} - * - * @return an {@link ImageContent} - */ - public ImageContent createImageContent() { - ImageContent imageContent = new ImageContent(); - return imageContent; - } - - /** - * Creates a new IOCA {@link ImageRasterData} - * - * @param rasterData raster data - * @return a new {@link ImageRasterData} - */ - public ImageRasterData createImageRasterData(byte[] rasterData) { - ImageRasterData imageRasterData = new ImageRasterData(rasterData); - return imageRasterData; - } - - /** - * Creates an new IOCA {@link ImageSizeParameter}. - * - * @param hsize The horizontal size of the image. - * @param vsize The vertical size of the image. - * @param hresol The horizontal resolution of the image. - * @param vresol The vertical resolution of the image. - * @return a new {@link ImageSizeParameter} - */ - public ImageSizeParameter createImageSizeParameter(int hsize, int vsize, - int hresol, int vresol) { - ImageSizeParameter imageSizeParameter - = new ImageSizeParameter(hsize, vsize, hresol, vresol); - return imageSizeParameter; - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java b/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java deleted file mode 100644 index 7ee0e07f5..000000000 --- a/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * GOCA Graphics Data Descriptor - */ -public class GraphicsDataDescriptor extends AbstractDescriptor { - - private final int xlwind; - - private final int xrwind; - - private final int ybwind; - - private final int ytwind; - - /** - * Main constructor - * - * @param xlwind - * the left edge of the graphics window - * @param xrwind - * the right edge of the graphics window - * @param ybwind - * the top edge of the graphics window - * @param ytwind - * the bottom edge of the graphics window - * @param widthRes - * the width resolution of the graphics window - * @param heightRes - * the height resolution of the graphics window - */ - protected GraphicsDataDescriptor(int xlwind, int xrwind, int ybwind, - int ytwind, int widthRes, int heightRes) { - this.xlwind = xlwind; - this.xrwind = xrwind; - this.ybwind = ybwind; - this.ytwind = ytwind; - super.widthRes = widthRes; - super.heightRes = heightRes; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] headerData = new byte[9]; - copySF(headerData, Type.DESCRIPTOR, Category.GRAPHICS); - - byte[] drawingOrderSubsetData = getDrawingOrderSubset(); - - byte[] windowSpecificationData = getWindowSpecification(); - - byte[] len = BinaryUtils.convert(headerData.length - + drawingOrderSubsetData.length - + windowSpecificationData.length - 1, 2); - headerData[1] = len[0]; - headerData[2] = len[1]; - - os.write(headerData); - os.write(drawingOrderSubsetData); - os.write(windowSpecificationData); - } - - /** - * Returns the drawing order subset data - * - * @return the drawing order subset data - */ - private byte[] getDrawingOrderSubset() { - final byte[] data = new byte[] { - // Drawing order subset - (byte) 0xF7, - 7, // LENGTH - (byte) 0xB0, // drawing order subset - 0x00, // reserved (must be zero) - 0x00, // reserved (must be zero) - 0x02, // SUBLEV - 0x00, // VERSION 0 - 0x01, // LENGTH (of following field) - 0x00 // GEOM - }; - return data; - } - - private static final int ABS = 2; - private static final int IMGRES = 8; - - /** - * Returns the window specification data - * - * @return the window specification data - */ - private byte[] getWindowSpecification() { - byte[] xlcoord = BinaryUtils.convert(xlwind, 2); - byte[] xrcoord = BinaryUtils.convert(xrwind, 2); - byte[] xbcoord = BinaryUtils.convert(ybwind, 2); - byte[] ytcoord = BinaryUtils.convert(ytwind, 2); - byte[] xResol = BinaryUtils.convert(widthRes * 10, 2); - byte[] yResol = BinaryUtils.convert(heightRes * 10, 2); - byte[] imxyres = xResol; - - // Window specification - final byte[] data = new byte[] { - (byte) 0xF6, - 18, // LENGTH - (ABS + IMGRES), // FLAGS (ABS) - 0x00, // reserved (must be zero) - 0x00, // CFORMAT (coordinate format - 16bit high byte first signed) - 0x00, // UBASE (unit base - ten inches) - - xResol[0], // XRESOL - xResol[1], - yResol[0], // YRESOL - yResol[1], - - imxyres[0], // IMXYRES (Number of image points per ten inches - imxyres[1], // in X and Y directions) - - xlcoord[0], // XLWIND - xlcoord[1], - xrcoord[0], // XRWIND - xrcoord[1], - xbcoord[0], // YBWIND - xbcoord[1], - ytcoord[0], // YTWIND - ytcoord[1] - }; - return data; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java deleted file mode 100644 index 4d33b28de..000000000 --- a/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * 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.modca; - -import java.awt.Color; -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -import org.apache.fop.render.afp.AFPDataObjectInfo; -import org.apache.fop.render.afp.AFPObjectAreaInfo; -import org.apache.fop.render.afp.goca.GraphicsBox; -import org.apache.fop.render.afp.goca.GraphicsData; -import org.apache.fop.render.afp.goca.GraphicsFillet; -import org.apache.fop.render.afp.goca.GraphicsFullArc; -import org.apache.fop.render.afp.goca.GraphicsLine; -import org.apache.fop.render.afp.goca.GraphicsSetArcParameters; -import org.apache.fop.render.afp.goca.GraphicsSetCharacterSet; -import org.apache.fop.render.afp.goca.GraphicsSetCurrentPosition; -import org.apache.fop.render.afp.goca.GraphicsSetLineType; -import org.apache.fop.render.afp.goca.GraphicsSetLineWidth; -import org.apache.fop.render.afp.goca.GraphicsSetPatternSymbol; -import org.apache.fop.render.afp.goca.GraphicsSetProcessColor; -import org.apache.fop.render.afp.goca.GraphicsString; - -/** - * Top-level GOCA graphics object. - * - * Acts as container and factory of all other graphic objects - */ -public class GraphicsObject extends AbstractDataObject { - - /** The graphics data */ - private GraphicsData currentGraphicsData = null; - - /** list of objects contained within this container */ - protected List/**/ objects - = new java.util.ArrayList/**/(); - - /** - * Default constructor - * - * @param factory the object factory - * @param name the name of graphics object - */ - public GraphicsObject(Factory factory, String name) { - super(factory, name); - } - - /** {@inheritDoc} */ - public void setViewport(AFPDataObjectInfo dataObjectInfo) { - super.setViewport(dataObjectInfo); - - AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - int width = objectAreaInfo.getWidth(); - int height = objectAreaInfo.getHeight(); - int widthRes = objectAreaInfo.getWidthRes(); - int heightRes = objectAreaInfo.getHeightRes(); - final int leftEdge = 0; - final int topEdge = 0; - GraphicsDataDescriptor graphicsDataDescriptor = factory.createGraphicsDataDescriptor( - leftEdge, width, topEdge, height, widthRes, heightRes); - - getObjectEnvironmentGroup().setDataDescriptor(graphicsDataDescriptor); - } - - /** {@inheritDoc} */ - public void addObject(PreparedAFPObject drawingOrder) { - if (currentGraphicsData == null - || (currentGraphicsData.getDataLength() + drawingOrder.getDataLength()) - >= GraphicsData.MAX_DATA_LEN) { - newData(); - } - currentGraphicsData.addObject(drawingOrder); - } - - /** - * Gets the current graphics data, creating a new one if necessary - * - * @return the current graphics data - */ - private GraphicsData getData() { - if (this.currentGraphicsData == null) { - return newData(); - } - return this.currentGraphicsData; - } - - /** - * Creates a new graphics data - * - * @return a newly created graphics data - */ - private GraphicsData newData() { - this.currentGraphicsData = factory.createGraphicsData(); - objects.add(currentGraphicsData); - return currentGraphicsData; - } - - /** - * Sets the current color - * - * @param color the active color to use - */ - public void setColor(Color color) { - addObject(new GraphicsSetProcessColor(color)); - } - - /** - * Sets the current position - * - * @param coords the x and y coordinates of the current position - */ - public void setCurrentPosition(int[] coords) { - addObject(new GraphicsSetCurrentPosition(coords)); - } - - /** - * Sets the line width - * - * @param multiplier the line width multiplier - */ - public void setLineWidth(int multiplier) { - GraphicsSetLineWidth graphicsSetLineWidth = new GraphicsSetLineWidth(multiplier); - addObject(graphicsSetLineWidth); - } - - /** - * Sets the line type - * - * @param type the line type - */ - public void setLineType(byte type) { - GraphicsSetLineType graphicsSetLineType = new GraphicsSetLineType(type); - addObject(graphicsSetLineType); - } - - /** - * Sets whether to fill the next shape - * - * @param fill whether to fill the next shape - */ - public void setFill(boolean fill) { - GraphicsSetPatternSymbol graphicsSetPattern = new GraphicsSetPatternSymbol( - fill ? GraphicsSetPatternSymbol.SOLID_FILL - : GraphicsSetPatternSymbol.NO_FILL - ); - addObject(graphicsSetPattern); - } - - /** - * Sets the character set to use - * - * @param fontReference the character set (font) reference - */ - public void setCharacterSet(int fontReference) { - addObject(new GraphicsSetCharacterSet(fontReference)); - } - - /** - * Adds a line at the given x/y coordinates - * - * @param coords the x/y coordinates (can be a series) - */ - public void addLine(int[] coords) { - addObject(new GraphicsLine(coords)); - } - - /** - * Adds a box at the given coordinates - * - * @param coords the x/y coordinates - */ - public void addBox(int[] coords) { - addObject(new GraphicsBox(coords)); - } - - /** - * Adds a fillet (curve) at the given coordinates - * - * @param coords the x/y coordinates - */ - public void addFillet(int[] coords) { - addObject(new GraphicsFillet(coords)); - } - - /** - * Sets the arc parameters - * - * @param xmaj the maximum value of the x coordinate - * @param ymin the minimum value of the y coordinate - * @param xmin the minimum value of the x coordinate - * @param ymaj the maximum value of the y coordinate - */ - public void setArcParams(int xmaj, int ymin, int xmin, int ymaj) { - addObject(new GraphicsSetArcParameters(xmaj, ymin, xmin, ymaj)); - } - - /** - * Adds an arc - * - * @param x the x coordinate - * @param y the y coordinate - * @param mh the integer portion of the multiplier - * @param mhr the fractional portion of the multiplier - */ - public void addFullArc(int x, int y, int mh, int mhr) { - addObject(new GraphicsFullArc(x, y, mh, mhr)); - } - -// /** -// * Adds an image -// * -// * @param x the x coordinate -// * @param y the y coordinate -// * @param width the image width -// * @param height the image height -// * @param imgData the image data -// */ -// public void addImage(int x, int y, int width, int height, byte[] imgData) { -// addObject(new GraphicsImage(x, y, width, height, imgData)); -// } - - /** - * Adds a string - * - * @param str the string - * @param x the x coordinate - * @param y the y coordinate - */ - public void addString(String str, int x, int y) { - addObject(new GraphicsString(str, x, y)); - } - - /** - * Begins a graphics area (start of fill) - */ - public void beginArea() { - if (currentGraphicsData == null) { - newData(); - } - currentGraphicsData.beginArea(); - } - - /** - * Ends a graphics area (end of fill) - */ - public void endArea() { - if (currentGraphicsData != null) { - currentGraphicsData.endArea(); - } - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsObject: " + getName(); - } - - /** - * Creates a new graphics segment - */ - public void newSegment() { - getData().newSegment(); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.GRAPHICS); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - super.writeObjects(objects, os); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.GRAPHICS); - os.write(data); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/IMImageObject.java b/src/java/org/apache/fop/render/afp/modca/IMImageObject.java deleted file mode 100644 index 63fff8cdc..000000000 --- a/src/java/org/apache/fop/render/afp/modca/IMImageObject.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.ioca.ImageCellPosition; -import org.apache.fop.render.afp.ioca.ImageInputDescriptor; -import org.apache.fop.render.afp.ioca.ImageOutputControl; -import org.apache.fop.render.afp.ioca.ImageRasterData; - -/** - * An IM image data object specifies the contents of a raster image and - * its placement on a page, overlay, or page segment. An IM image can be - * either simple or complex. A simple image is composed of one or more Image - * Raster Data (IRD) structured fields that define the raster pattern for the - * entire image. A complex image is divided into regions called image cells. - * Each image cell is composed of one or more IRD structured fields that define - * the raster pattern for the image cell, and one Image Cell Position (ICP) - * structured field that defines the position of the image cell relative to - * the origin of the entire image. Each ICP also specifies the size of the - * image cell and a fill rectangle into which the cell is replicated. - *

      - */ -public class IMImageObject extends AbstractNamedAFPObject { - - /** - * The image output control - */ - private ImageOutputControl imageOutputControl = null; - - /** - * The image input descriptor - */ - private ImageInputDescriptor imageInputDescriptor = null; - - /** - * The image cell position - */ - private ImageCellPosition imageCellPosition = null; - - /** - * The image rastor data - */ - private ImageRasterData imageRasterData = null; - - /** - * Constructor for the image object with the specified name, - * the name must be a fixed length of eight characters. - * - * @param name The name of the image. - */ - public IMImageObject(String name) { - super(name); - } - - /** - * Sets the ImageOutputControl. - * - * @param imageOutputControl The imageOutputControl to set - */ - public void setImageOutputControl(ImageOutputControl imageOutputControl) { - this.imageOutputControl = imageOutputControl; - } - - /** - * Sets the ImageCellPosition. - * - * @param imageCellPosition The imageCellPosition to set - */ - public void setImageCellPosition(ImageCellPosition imageCellPosition) { - this.imageCellPosition = imageCellPosition; - } - - /** - * Sets the ImageInputDescriptor. - * - * @param imageInputDescriptor The imageInputDescriptor to set - */ - public void setImageInputDescriptor(ImageInputDescriptor imageInputDescriptor) { - this.imageInputDescriptor = imageInputDescriptor; - } - - /** - * Sets the ImageRastorData. - * - * @param imageRasterData The imageRasterData to set - */ - public void setImageRasterData(ImageRasterData imageRasterData) { - this.imageRasterData = imageRasterData; - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - if (imageOutputControl != null) { - imageOutputControl.writeToStream(os); - } - if (imageInputDescriptor != null) { - imageInputDescriptor.writeToStream(os); - } - if (imageCellPosition != null) { - imageCellPosition.writeToStream(os); - } - if (imageRasterData != null) { - imageRasterData.writeToStream(os); - } - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.IM_IMAGE); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.IM_IMAGE); - os.write(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java deleted file mode 100644 index 430f6590c..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * ImageDataDescriptor - */ -public class ImageDataDescriptor extends AbstractDescriptor { - - /** - * Constructor for a ImageDataDescriptor for the specified - * resolution, width and height. - * - * @param width The width of the image. - * @param height The height of the height. - * @param widthRes The horizontal resolution of the image. - * @param heightRes The vertical resolution of the image. - */ - public ImageDataDescriptor(int width, int height, int widthRes, int heightRes) { - super(width, height, widthRes, heightRes); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[22]; - copySF(data, Type.DESCRIPTOR, Category.IMAGE); - - // SF length - byte[] len = BinaryUtils.convert(data.length - 1, 2); - data[1] = len[0]; - data[2] = len[1]; - - byte[] x = BinaryUtils.convert(widthRes, 2); - data[10] = x[0]; - data[11] = x[1]; - - byte[] y = BinaryUtils.convert(heightRes, 2); - data[12] = y[0]; - data[13] = y[1]; - - byte[] w = BinaryUtils.convert(width, 2); - data[14] = w[0]; - data[15] = w[1]; - - byte[] h = BinaryUtils.convert(height, 2); - data[16] = h[0]; - data[17] = h[1]; - - data[18] = (byte)0xF7; // ID = Set IOCA Function Set - data[19] = 0x02; // Length - data[20] = 0x01; // Category = Function set identifier - data[21] = 0x0B; // FCNSET = IOCA FS 11 - - os.write(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/ImageObject.java b/src/java/org/apache/fop/render/afp/modca/ImageObject.java deleted file mode 100644 index 005bae176..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ImageObject.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.fop.render.afp.AFPDataObjectInfo; -import org.apache.fop.render.afp.AFPImageObjectInfo; -import org.apache.fop.render.afp.AFPObjectAreaInfo; -import org.apache.fop.render.afp.ioca.ImageSegment; - -/** - * An IOCA Image Data Object - */ -public class ImageObject extends AbstractDataObject { - - private static final int MAX_DATA_LEN = 32759; - - /** the image segment */ - private ImageSegment imageSegment = null; - - /** - * Constructor for the image object with the specified name, - * the name must be a fixed length of eight characters. - * - * @param name The name of the image. - * @param factory the resource manager - */ - public ImageObject(Factory factory, String name) { - super(factory, name); - } - - private ImageSegment getImageSegment() { - if (imageSegment == null) { - this.imageSegment = factory.createImageSegment(); - } - return imageSegment; - } - - /** {@inheritDoc} */ - public void setViewport(AFPDataObjectInfo dataObjectInfo) { - super.setViewport(dataObjectInfo); - - AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)dataObjectInfo; - int dataWidth = imageObjectInfo.getDataWidth(); - int dataHeight = imageObjectInfo.getDataHeight(); - - AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - int widthRes = objectAreaInfo.getWidthRes(); - int heightRes = objectAreaInfo.getHeightRes(); - - ImageDataDescriptor imageDataDescriptor - = factory.createImageDataDescriptor(dataWidth, dataHeight, widthRes, heightRes); - getObjectEnvironmentGroup().setDataDescriptor(imageDataDescriptor); - - getImageSegment().setImageSize(dataWidth, dataHeight, widthRes, heightRes); - } - - /** - * Sets the image encoding. - * - * @param encoding The image encoding. - */ - public void setEncoding(byte encoding) { - getImageSegment().setEncoding(encoding); - } - - /** - * Sets the image compression. - * - * @param compression The image compression. - */ - public void setCompression(byte compression) { - getImageSegment().setCompression(compression); - } - - /** - * Sets the image IDE size. - * - * @param size The IDE size. - */ - public void setIDESize(byte size) { - getImageSegment().setIDESize(size); - } - - /** - * Sets the image IDE color model. - * - * @param colorModel the IDE color model. - */ - public void setIDEColorModel(byte colorModel) { - getImageSegment().setIDEColorModel(colorModel); - } - - /** - * Set the data of the image. - * - * @param data the image data - */ - public void setData(byte[] data) { - getImageSegment().setData(data); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.IMAGE); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - - if (imageSegment != null) { - final byte[] dataHeader = new byte[9]; - copySF(dataHeader, SF_CLASS, Type.DATA, Category.IMAGE); - final int lengthOffset = 1; - - // TODO save memory! - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - imageSegment.writeToStream(baos); - byte[] data = baos.toByteArray(); - writeChunksToStream(data, dataHeader, lengthOffset, MAX_DATA_LEN, os); - } - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.IMAGE); - os.write(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/IncludeObject.java b/src/java/org/apache/fop/render/afp/modca/IncludeObject.java deleted file mode 100644 index 9e5216f6f..000000000 --- a/src/java/org/apache/fop/render/afp/modca/IncludeObject.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet; -import org.apache.fop.render.afp.modca.triplets.MeasurementUnitsTriplet; -import org.apache.fop.render.afp.modca.triplets.ObjectAreaSizeTriplet; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * An Include Object structured field references an object on a page or overlay. - * It optionally contains parameters that identify the object and that specify - * presentation parameters such as object position, size, orientation, mapping, - * and default color. - *

      - * Where the presentation parameters conflict with parameters specified in the - * object's environment group (OEG), the parameters in the Include Object - * structured field override. If the referenced object is a page segment, the - * IOB parameters override the corresponding environment group parameters on all - * data objects in the page segment. - *

      - */ -public class IncludeObject extends AbstractNamedAFPObject { - - /** the object referenced is of type page segment */ - public static final byte TYPE_PAGE_SEGMENT = (byte)0x5F; - - /** the object referenced is of type other */ - public static final byte TYPE_OTHER = (byte)0x92; - - /** the object referenced is of type graphic */ - public static final byte TYPE_GRAPHIC = (byte)0xBB; - - /** the object referenced is of type barcode */ - public static final byte TYPE_BARCODE = (byte)0xEB; - - /** the object referenced is of type image */ - public static final byte TYPE_IMAGE = (byte)0xFB; - - - /** the object type referenced (default is other) */ - private byte objectType = TYPE_OTHER; - - /** the X-axis origin of the object area */ - private int xoaOset = 0; - - /** the Y-axis origin of the object area */ - private int yoaOset = 0; - - /** the orientation of the referenced object */ - private int oaOrent = 0; - - /** the X-axis origin defined in the object */ - private int xocaOset = -1; - - /** the Y-axis origin defined in the object */ - private int yocaOset = -1; - - /** - * Constructor for the include object with the specified name, the name must - * be a fixed length of eight characters and is the name of the referenced - * object. - * - * @param name the name of this include object - */ - public IncludeObject(String name) { - super(name); - } - - /** - * Sets the orientation to use for the Include Object. - * - * @param orientation - * The orientation (0,90, 180, 270) - */ - public void setObjectAreaOrientation(int orientation) { - if (orientation == 0 || orientation == 90 || orientation == 180 - || orientation == 270) { - this.oaOrent = orientation; - } else { - throw new IllegalArgumentException( - "The orientation must be one of the values 0, 90, 180, 270"); - } - } - - /** - * Sets the x and y offset to the origin in the object area - * - * @param x the X-axis origin of the object area - * @param y the Y-axis origin of the object area - */ - public void setObjectAreaOffset(int x, int y) { - this.xoaOset = x; - this.yoaOset = y; - } - - /** - * Sets the x and y offset of the content area to the object area - * used in conjunction with the {@link MappingOptionTriplet.POSITION} and - * {@link MappingOptionTriplet.POSITION_AND_TRIM}. - * - * @param x the X-axis origin defined in the object - * @param y the Y-axis origin defined in the object - */ - public void setContentAreaOffset(int x, int y) { - this.xocaOset = x; - this.yocaOset = y; - } - - /** - * Sets the data object type - * - * @param type the data object type - */ - public void setObjectType(byte type) { - this.objectType = type; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[36]; - super.copySF(data, Type.INCLUDE, Category.DATA_RESOURCE); - - // Set the total record length - int tripletDataLength = getTripletDataLength(); - byte[] len = BinaryUtils.convert(35 + tripletDataLength, 2); //Ignore first byte - data[1] = len[0]; - data[2] = len[1]; - - data[17] = 0x00; // reserved - data[18] = objectType; - - //XoaOset (object area) - if (xoaOset > -1) { - byte[] x = BinaryUtils.convert(xoaOset, 3); - data[19] = x[0]; - data[20] = x[1]; - data[21] = x[2]; - } else { - data[19] = (byte)0xFF; - data[20] = (byte)0xFF; - data[21] = (byte)0xFF; - } - - // YoaOset (object area) - if (yoaOset > -1) { - byte[] y = BinaryUtils.convert(yoaOset, 3); - data[22] = y[0]; - data[23] = y[1]; - data[24] = y[2]; - } else { - data[22] = (byte)0xFF; - data[23] = (byte)0xFF; - data[24] = (byte)0xFF; - } - - // XoaOrent/YoaOrent - switch (oaOrent) { - case -1: // use x/y axis orientation defined in object - data[25] = (byte)0xFF; // x axis rotation - data[26] = (byte)0xFF; // - data[27] = (byte)0xFF; // y axis rotation - data[28] = (byte)0xFF; - break; - case 90: - data[25] = 0x2D; - data[26] = 0x00; - data[27] = 0x5A; - data[28] = 0x00; - break; - case 180: - data[25] = 0x5A; - data[25] = 0x00; - data[27] = (byte)0x87; - data[28] = 0x00; - break; - case 270: - data[25] = (byte)0x87; - data[26] = 0x00; - data[27] = 0x00; - data[28] = 0x00; - break; - default: // 0 degrees - data[25] = 0x00; - data[26] = 0x00; - data[27] = 0x2D; - data[28] = 0x00; - break; - } - - // XocaOset (object content) - if (xocaOset > -1) { - byte[] x = BinaryUtils.convert(xocaOset, 3); - data[29] = x[0]; - data[30] = x[1]; - data[31] = x[2]; - } else { - data[29] = (byte)0xFF; - data[30] = (byte)0xFF; - data[31] = (byte)0xFF; - } - - // YocaOset (object content) - if (yocaOset > -1) { - byte[] y = BinaryUtils.convert(yocaOset, 3); - data[32] = y[0]; - data[33] = y[1]; - data[34] = y[2]; - } else { - data[32] = (byte)0xFF; - data[33] = (byte)0xFF; - data[34] = (byte)0xFF; - } - // RefCSys (Reference coordinate system) - data[35] = 0x01; // Page or overlay coordinate system - - // Write structured field data - os.write(data); - - // Write triplet for FQN internal/external object reference - if (tripletData != null) { - os.write(tripletData); - } - } - - private String getObjectTypeName() { - String objectTypeName = null; - if (objectType == TYPE_PAGE_SEGMENT) { - objectTypeName = "page segment"; - } else if (objectType == TYPE_OTHER) { - objectTypeName = "other"; - } else if (objectType == TYPE_GRAPHIC) { - objectTypeName = "graphic"; - } else if (objectType == TYPE_BARCODE) { - objectTypeName = "barcode"; - } else if (objectType == TYPE_IMAGE) { - objectTypeName = "image"; - } - return objectTypeName; - } - - /** {@inheritDoc} */ - public String toString() { - return "IncludeObject{name=" + this.getName() - + ", objectType=" + getObjectTypeName() - + ", xoaOset=" + xoaOset - + ", yoaOset=" + yoaOset - + ", oaOrent" + oaOrent - + ", xocaOset=" + xocaOset - + ", yocaOset=" + yocaOset - + "}"; - } - - /** - * Sets the mapping option - * - * @param optionValue the mapping option value - */ - public void setMappingOption(byte optionValue) { - addTriplet(new MappingOptionTriplet(optionValue)); - } - - /** - * Sets the extent of an object area in the X and Y directions - * - * @param x the x direction extent - * @param y the y direction extent - */ - public void setObjectAreaSize(int x, int y) { - addTriplet(new ObjectAreaSizeTriplet(x, y)); - } - - /** - * Sets the measurement units used to specify the units of measure - * - * @param xRes units per base on the x-axis - * @param yRes units per base on the y-axis - */ - public void setMeasurementUnits(int xRes, int yRes) { - addTriplet(new MeasurementUnitsTriplet(xRes, xRes)); - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java b/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java deleted file mode 100644 index be1ef870f..000000000 --- a/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * - * The Include Page Overlay structured field references an overlay resource - * definition that is to be positioned on the page. A page overlay can be - * referenced at any time during the page state, but not during an object state. - * The overlay contains its own active environment group definition. - * - * Note: There is no need for the triplets, so I have ignored them. - * - * A real example of where this will be used is for static overlays, such as an - * address on the page. - * - */ -public class IncludePageOverlay extends AbstractNamedAFPObject { - - /** - * The x coordinate - */ - private int x = 0; - - /** - * The y coordinate - */ - private int y = 0; - - /** - * The orientation - */ - private int orientation = 0; - - /** - * Constructor for the Include Page Overlay - * - * @param overlayName Name of the page segment - * @param x The x position - * @param y The y position - * @param orientation The orientation - */ - public IncludePageOverlay(String overlayName, int x, int y, int orientation) { - super(overlayName); - - this.x = x; - this.y = y; - setOrientation(orientation); - } - - /** - * Sets the orientation to use for the overlay. - * - * @param orientation - * The orientation (0,90, 180, 270) - */ - public void setOrientation(int orientation) { - if (orientation == 0 || orientation == 90 || orientation == 180 - || orientation == 270) { - this.orientation = orientation; - } else { - throw new IllegalArgumentException( - "The orientation must be one of the values 0, 90, 180, 270"); - } - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[25]; //(9 +16) - copySF(data, Type.INCLUDE, Category.PAGE_OVERLAY); - - // Set the total record length - byte[] len = BinaryUtils.convert(24, 2); //Ignore first byte - data[1] = len[0]; - data[2] = len[1]; - - byte[] xPos = BinaryUtils.convert(x, 3); - data[17] = xPos[0]; // x coordinate - data[18] = xPos[1]; - data[19] = xPos[2]; - - byte[] yPos = BinaryUtils.convert(y, 3); - data[20] = yPos[0]; // y coordinate - data[21] = yPos[1]; - data[22] = yPos[2]; - - switch (orientation) { - case 90: - data[23] = 0x2D; - data[24] = 0x00; - break; - case 180: - data[23] = 0x5A; - data[24] = 0x00; - break; - case 270: - data[23] = (byte) 0x87; - data[24] = 0x00; - break; - default: - data[23] = 0x00; - data[24] = 0x00; - break; - } - os.write(data); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java b/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java deleted file mode 100644 index a9d247553..000000000 --- a/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Include Page Segment structured field references a page segment resource - * object that is to be presented on the page or overlay presentation space. The IPS - * specifies a reference point on the including page or overlay coordinate system that - * may be used to position objects contained in the page segment. A page segment - * can be referenced at any time during page or overlay state, but not during an - * object state. The page segment inherits the active environment group definition of - * the including page or overlay. - * - * Note : No use for Triplets. - * - * A 'real' example for where this will be used is for - * the dynamic placing of overlay objects, such as signatures - * that may have to be placed at different positions on a document. - * - */ -public class IncludePageSegment extends AbstractNamedAFPObject { - - /** - * The x position where we need to put this object on the page - */ - private int x; - - /** - * The y position where we need to put this object on the page - */ - private int y; - - /** - * Constructor for the Include Page Segment - * - * @param name Name of the page segment - * @param x The x position - * @param y The y position - */ - public IncludePageSegment(String name, int x, int y) { - super(name); - - this.x = x; - this.y = y; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[23]; //(9 +14) - copySF(data, Type.INCLUDE, Category.PAGE_SEGMENT); - - // Set the total record length - byte[] len = BinaryUtils.convert(22, 2); //Ignore first byte - data[1] = len[0]; - data[2] = len[1]; - - byte[] xPos = BinaryUtils.convert(x, 3); - data[17] = xPos[0]; // x coordinate - data[18] = xPos[1]; - data[19] = xPos[2]; - - byte[] yPos = BinaryUtils.convert(y, 3); - data[20] = yPos[0]; // y coordinate - data[21] = yPos[1]; - data[22] = yPos[2]; - - os.write(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java b/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java deleted file mode 100644 index 4d52df3d3..000000000 --- a/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.modca; - -/** - * MO:DCA Interchange Set - */ -public class InterchangeSet { - /** interchange set 1 string value */ - public static final String MODCA_PRESENTATION_INTERCHANGE_SET_1 = "MO:DCA-P IS/1"; - - /** interchange set 2 string value */ - public static final String MODCA_PRESENTATION_INTERCHANGE_SET_2 = "MO:DCA-P IS/2"; - - /** resource interchange set string value */ - public static final String MODCA_RESOURCE_INTERCHANGE_SET = "MO:DCA-L"; - - private static final String[] NAMES = { - MODCA_PRESENTATION_INTERCHANGE_SET_1, - MODCA_PRESENTATION_INTERCHANGE_SET_2, - MODCA_RESOURCE_INTERCHANGE_SET - }; - - private static final int SET_1 = 0; - private static final int SET_2 = 1; - private static final int RESOURCE_SET = 2; - - /** the actual interchange set in use */ - private int value; - - /** - * Returns the interchange set value of a given string - * - * @param str an interchange set value - * @return an interchange set - */ - public static InterchangeSet valueOf(String str) { - if (MODCA_PRESENTATION_INTERCHANGE_SET_1.equals(str)) { - return new InterchangeSet(SET_1); - } else if (MODCA_PRESENTATION_INTERCHANGE_SET_2.equals(str)) { - return new InterchangeSet(SET_2); - } else if (MODCA_RESOURCE_INTERCHANGE_SET.equals(str)) { - return new InterchangeSet(RESOURCE_SET); - } else { - throw new IllegalArgumentException("Invalid MO:DCA interchange set :" + str); - } - } - - /** - * Main constructor - * - * @param value the interchange set value - */ - public InterchangeSet(int value) { - this.value = value; - } - - /** - * Returns true if complies with MOD:CA interchange set 1 - * - * @return true if complies with MOD:CA interchange set 1 - */ - protected boolean is1() { - return value == SET_1; - } - - /** - * Returns true if complies with MOD:CA interchange set 2 - * - * @return true if complies with MOD:CA interchange set 2 - */ - public boolean is2() { - return value == SET_2; - } - - /** - * Returns true if complies with MOD:CA resource set - * - * @return true if complies with MOD:CA resource set - */ - public boolean isResource() { - return value == RESOURCE_SET; - } - - /** {@inheritDoc} */ - public String toString() { - return NAMES[value]; - } - - /** - * Returns true if MOD:CA interchange set 2 (resource groups) is supported - * - * @return true if MOD:CA interchange set 2 (resource groups) is supported - */ - public boolean supportsLevel2() { - return is2() || isResource(); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java b/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java deleted file mode 100644 index cee7711e6..000000000 --- a/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Invoke Medium Map structured field identifies the Medium Map that is to - * become active for the document. An Invoke Medium Map structured field affects - * the document's current environment. The Medium Map's effect on current environment - * parameter values lasts until a new Medium Map is invoked. - */ -public class InvokeMediumMap extends AbstractNamedAFPObject { - - /** - * Constructor for the Invoke Medium Map - * - * @param name the name of the medium map - */ - public InvokeMediumMap(String name) { - super(name); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - - byte[] data = new byte[17]; - copySF(data, Type.MAP, Category.MEDIUM_MAP); - - // Set the total record length - byte[] len = BinaryUtils.convert(16, 2); //Ignore first byte - data[1] = len[0]; - data[2] = len[1]; - - os.write(data); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java b/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java deleted file mode 100644 index f305630bc..000000000 --- a/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * 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.modca; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.util.Iterator; -import java.util.List; - -import org.apache.fop.render.afp.AFPConstants; -import org.apache.fop.render.afp.exceptions.FontRuntimeException; -import org.apache.fop.render.afp.fonts.AFPFont; -import org.apache.fop.render.afp.fonts.CharacterSet; -import org.apache.fop.render.afp.fonts.OutlineFont; -import org.apache.fop.render.afp.fonts.RasterFont; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Map Coded Font structured field maps a unique coded font resource local - * ID, which may be embedded one or more times within an object's data and - * descriptor, to the identifier of a coded font resource object. Additionally, - * the Map Coded Font structured field specifies a set of resource attributes - * for the coded font. - * - * @author Pete Townsend - */ -public class MapCodedFont extends AbstractStructuredAFPObject { - - /** - * The collection of map coded fonts (maximum of 254) - */ - private List/**/ fontList = new java.util.ArrayList(); - - /** - * Constructor for the MapCodedFont - */ - public MapCodedFont() { - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - byte[] startData = new byte[9]; - copySF(startData, Type.MAP, Category.CODED_FONT); - baos.write(startData); - - Iterator iter = fontList.iterator(); - while (iter.hasNext()) { - FontDefinition fd = (FontDefinition) iter.next(); - - // Start of repeating groups (occurs 1 to 254) - baos.write(0x00); - - if (fd.scale == 0) { - // Raster Font - baos.write(0x22); // Length of 34 - } else { - // Outline Font - baos.write(0x3A); // Length of 58 - } - - // Font Character Set Name Reference - baos.write(0x0C); - baos.write(0x02); - baos.write((byte) 0x86); - baos.write(0x00); - baos.write(fd.characterSet); - - // Font Code Page Name Reference - baos.write(0x0C); - baos.write(0x02); - baos.write((byte) 0x85); - baos.write(0x00); - baos.write(fd.codePage); - - // Character Rotation - baos.write(0x04); - baos.write(0x26); - baos.write(fd.orientation); - baos.write(0x00); - - // Resource Local Identifier - baos.write(0x04); - baos.write(0x24); - baos.write(0x05); - baos.write(fd.fontReferenceKey); - - if (fd.scale != 0) { - // Outline Font (triplet '1F') - baos.write(0x14); - baos.write(0x1F); - baos.write(0x00); - baos.write(0x00); - - baos.write(BinaryUtils.convert(fd.scale, 2)); // Height - baos.write(new byte[] {0x00, 0x00}); // Width - - baos.write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00}); - - baos.write(0x60); - - // Outline Font (triplet '5D') - baos.write(0x04); - baos.write(0x5D); - baos.write(BinaryUtils.convert(fd.scale, 2)); - } - } - - byte[] data = baos.toByteArray(); - - // Set the total record length - byte[] rl1 = BinaryUtils.convert(data.length - 1, 2); - data[1] = rl1[0]; - data[2] = rl1[1]; - - os.write(data); - } - - /** - * Add a font definition on the the map coded font object. - * - * @param fontReference - * the font number used as the resource identifier - * @param font - * the font - * @param size - * the size of the font - * @param orientation - * the orientation of the font - * @throws MaximumSizeExceededException if the maximum number of fonts have been exceeded - */ - public void addFont(int fontReference, AFPFont font, int size, int orientation) - throws MaximumSizeExceededException { - - FontDefinition fd = new FontDefinition(); - - fd.fontReferenceKey = BinaryUtils.convert(fontReference)[0]; - - switch (orientation) { - case 90: - fd.orientation = 0x2D; - break; - case 180: - fd.orientation = 0x5A; - break; - case 270: - fd.orientation = (byte) 0x87; - break; - default: - fd.orientation = 0x00; - break; - } - - try { - if (font instanceof RasterFont) { - RasterFont raster = (RasterFont) font; - CharacterSet cs = raster.getCharacterSet(size); - if (cs == null) { - String msg = "Character set not found for font " - + font.getFontName() + " with point size " + size; - log.error(msg); - throw new FontRuntimeException(msg); - } - - fd.characterSet = cs.getNameBytes(); - - if (fd.characterSet.length != 8) { - throw new IllegalArgumentException("The character set " - + new String(fd.characterSet, - AFPConstants.EBCIDIC_ENCODING) - + " must have a fixed length of 8 characters."); - } - - fd.codePage = cs.getCodePage().getBytes( - AFPConstants.EBCIDIC_ENCODING); - - if (fd.codePage.length != 8) { - throw new IllegalArgumentException("The code page " - + new String(fd.codePage, - AFPConstants.EBCIDIC_ENCODING) - + " must have a fixed length of 8 characters."); - } - - } else if (font instanceof OutlineFont) { - OutlineFont outline = (OutlineFont) font; - CharacterSet cs = outline.getCharacterSet(); - fd.characterSet = cs.getNameBytes(); - - // There are approximately 72 points to 1 inch or 20 1440ths per point. - - fd.scale = ((size / 1000) * 20); - - fd.codePage = cs.getCodePage().getBytes( - AFPConstants.EBCIDIC_ENCODING); - - if (fd.codePage.length != 8) { - throw new IllegalArgumentException("The code page " - + new String(fd.codePage, - AFPConstants.EBCIDIC_ENCODING) - + " must have a fixed length of 8 characters."); - } - } else { - String msg = "Font of type " + font.getClass().getName() - + " not recognized."; - log.error(msg); - throw new FontRuntimeException(msg); - } - - if (fontList.size() > 253) { - // Throw an exception if the size is exceeded - throw new MaximumSizeExceededException(); - } else { - fontList.add(fd); - } - - } catch (UnsupportedEncodingException ex) { - throw new FontRuntimeException("Failed to create font " - + " due to a UnsupportedEncodingException", ex); - } - } - - - /** - * Private utility class used as a container for font attributes - */ - private class FontDefinition { - - /** - * The code page of the font - */ - private byte[] codePage; - - /** - * The character set of the font - */ - private byte[] characterSet; - - /** - * The font reference key - */ - private byte fontReferenceKey; - - /** - * The orientation of the font - */ - private byte orientation; - - /** - * The scale (only specified for outline fonts) - */ - private int scale = 0; - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/MapContainerData.java b/src/java/org/apache/fop/render/afp/modca/MapContainerData.java deleted file mode 100644 index 9ec157ee8..000000000 --- a/src/java/org/apache/fop/render/afp/modca/MapContainerData.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Map Container Data structured field specifies how a presentation data object - * that is carried in an Object Container is mapped into its object area. - */ -public class MapContainerData extends AbstractStructuredAFPObject { - - /** - * Main constructor - * - * @param optionValue the mapping option value - */ - public MapContainerData(byte optionValue) { - super.addTriplet(new MappingOptionTriplet(optionValue)); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[11]; - copySF(data, Type.MAP, Category.OBJECT_CONTAINER); - int tripletLen = getTripletDataLength(); - byte[] len = BinaryUtils.convert(10 + tripletLen, 2); - data[1] = len[0]; - data[2] = len[1]; - len = BinaryUtils.convert(2 + tripletLen, 2); - data[9] = len[0]; - data[10] = len[1]; - os.write(data); - os.write(tripletData); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/MapDataResource.java b/src/java/org/apache/fop/render/afp/modca/MapDataResource.java deleted file mode 100644 index 09b18b9a7..000000000 --- a/src/java/org/apache/fop/render/afp/modca/MapDataResource.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Map Data Resource structured field specifies resources that are - * required for presentation. - */ -public class MapDataResource extends AbstractStructuredAFPObject { - - /** - * Main constructor - */ - public MapDataResource() { - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - super.writeStart(os); - byte[] data = new byte[11]; - copySF(data, Type.MAP, Category.DATA_RESOURCE); - - int tripletDataLen = getTripletDataLength(); - - byte[] len = BinaryUtils.convert(10 + tripletDataLen, 2); - data[1] = len[0]; - data[2] = len[1]; - - len = BinaryUtils.convert(2 + tripletDataLen, 2); - data[9] = len[0]; - data[10] = len[1]; - - os.write(data); - os.write(tripletData); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java b/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java deleted file mode 100644 index 3143e80a0..000000000 --- a/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.util.List; - -import org.apache.fop.render.afp.AFPConstants; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Map Page Overlay structured field maps a Resource Local ID to the name of - * a Begin Overlay structured field. A Map Page Overlay structured field may - * contain from one to 254 repeating groups. - */ -public class MapPageOverlay extends AbstractAFPObject { - - private static final int MAX_SIZE = 253; - - /** - * The collection of overlays (maximum of 254 stored as byte[]) - */ - private List overLays = null; - - /** - * Constructor for the Map Page Overlay - */ - public MapPageOverlay() { - } - - private List getOverlays() { - if (overLays == null) { - this.overLays = new java.util.ArrayList(); - } - return this.overLays; - } - - /** - * Add an overlay to to the map page overlay object. - * - * @param name - * The name of the overlay. - * @throws MaximumSizeExceededException if the maximum size is reached - */ - public void addOverlay(String name) throws MaximumSizeExceededException { - if (getOverlays().size() > MAX_SIZE) { - throw new MaximumSizeExceededException(); - } - if (name.length() != 8) { - throw new IllegalArgumentException("The name of overlay " + name - + " must be 8 characters"); - } - if (log.isDebugEnabled()) { - log.debug("addOverlay():: adding overlay " + name); - } - try { - byte[] data = name.getBytes(AFPConstants.EBCIDIC_ENCODING); - getOverlays().add(data); - } catch (UnsupportedEncodingException usee) { - log.error("addOverlay():: UnsupportedEncodingException translating the name " - + name); - } - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - int oLayCount = getOverlays().size(); - int recordlength = oLayCount * 18; - - byte[] data = new byte[recordlength + 9]; - - data[0] = 0x5A; - - // Set the total record length - byte[] rl1 = BinaryUtils.convert(recordlength + 8, 2); //Ignore the - // first byte in - // the length - data[1] = rl1[0]; - data[2] = rl1[1]; - - // Structured field ID for a MPO - data[3] = (byte) 0xD3; - data[4] = (byte) Type.MAP; - data[5] = (byte) Category.PAGE_OVERLAY; - - data[6] = 0x00; // Reserved - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - - int pos = 8; - - //For each overlay - byte olayref = 0x00; - - for (int i = 0; i < oLayCount; i++) { - olayref = (byte) (olayref + 1); - - data[++pos] = 0x00; - data[++pos] = 0x12; //the length of repeating group - - data[++pos] = 0x0C; //Fully Qualified Name - data[++pos] = 0x02; - data[++pos] = (byte) 0x84; - data[++pos] = 0x00; - - //now add the name - byte[] name = (byte[]) overLays.get(i); - - for (int j = 0; j < name.length; j++) { - data[++pos] = name[j]; - } - - data[++pos] = 0x04; //Resource Local Identifier (RLI) - data[++pos] = 0x24; - data[++pos] = 0x02; - - //now add the unique id to the RLI - data[++pos] = olayref; - } - os.write(data); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java b/src/java/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java deleted file mode 100644 index a66fa9b30..000000000 --- a/src/java/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.modca; - -/** - * An exception to handle maximum sizes being exceeded. - * - */ -public class MaximumSizeExceededException extends Exception { - - private static final long serialVersionUID = 7823120005542216446L; - - /** - * Default constructor - */ - public MaximumSizeExceededException() { - super(); - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/NoOperation.java b/src/java/org/apache/fop/render/afp/modca/NoOperation.java deleted file mode 100644 index 258fcf47d..000000000 --- a/src/java/org/apache/fop/render/afp/modca/NoOperation.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.AFPConstants; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The No Operation structured field may be used to carry comments - * or any other type of unarchitected data. Although not recommended, - * it may also be used to carry semantic data in private or exchange data - * streams. However, because receivers of interchange data streams should - * ignore the content of No Operation structured fields and because - * receiver-generator products are not required to propagate - * No Operation structured fields, no semantics should be attached to - * 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 - */ - 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 writeToStream(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]; - - // Structured field ID for a TLE - data[3] = (byte) 0xD3; - data[4] = (byte) 0xEE; - data[5] = (byte) 0xEE; - - data[6] = 0x00; // Reserved - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - - int pos = 9; - for (int i = 0; i < contentLen; i++) { - data[pos++] = contentData[i]; - } - os.write(data); - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java b/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java deleted file mode 100644 index 3bd271d5b..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.fop.render.afp.modca.triplets.MeasurementUnitsTriplet; -import org.apache.fop.render.afp.modca.triplets.ObjectAreaSizeTriplet; -import org.apache.fop.render.afp.modca.triplets.PresentationSpaceResetMixingTriplet; -import org.apache.fop.render.afp.modca.triplets.Triplet; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Object Area Descriptor structured field specifies the size and attributes - * of an object area presentation space. - */ -public class ObjectAreaDescriptor extends AbstractDescriptor { - - /** - * Construct an object area descriptor for the specified object width - * and object height. - * - * @param width the object width. - * @param height the object height. - * @param widthRes the object width resolution. - * @param heightRes the object height resolution. - */ - public ObjectAreaDescriptor(int width, int height, int widthRes, int heightRes) { - super(width, height, widthRes, heightRes); - } - - /** {@inheritDoc} */ - protected byte[] getTripletData() throws IOException { - if (tripletData == null) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - // Specifies the associated ObjectAreaPosition structured field - final byte oapId = 0x01; - Triplet triplet = new Triplet(Triplet.DESCRIPTOR_POSITION, oapId); - triplet.writeToStream(baos); - - triplet = new MeasurementUnitsTriplet(widthRes, heightRes); - triplet.writeToStream(baos); - - triplet = new ObjectAreaSizeTriplet(width, height); - triplet.writeToStream(baos); - - triplet = new PresentationSpaceResetMixingTriplet( - PresentationSpaceResetMixingTriplet.NOT_RESET); - triplet.writeToStream(baos); - - this.tripletData = baos.toByteArray(); - } - return this.tripletData; - } - - /** {@inheritDoc} */ - public void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - byte[] data = new byte[9]; - copySF(data, Type.DESCRIPTOR, Category.OBJECT_AREA); - byte[] len = BinaryUtils.convert(data.length + tripletData.length - 1, 2); - data[1] = len[0]; // Length - data[2] = len[1]; - os.write(data); - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java b/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java deleted file mode 100644 index fbe8c7089..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Object Area Position structured field specifies the origin and - * orientation of the object area, and the origin and orientation of the - * object content within the object area. - */ -public class ObjectAreaPosition extends AbstractAFPObject { - - private final int x; - private final int y; - private final int rotation; - private int xOffset; - private int yOffset; - - /** - * Construct an object area position for the specified object y, y position. - * - * @param x The x coordinate. - * @param y The y coordinate. - * @param rotation The coordinate system rotation (must be 0, 90, 180, 270). - */ - public ObjectAreaPosition(int x, int y, int rotation) { - this.x = x; - this.y = y; - this.rotation = rotation; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[33]; - copySF(data, Type.POSITION, Category.OBJECT_AREA); - - byte[] len = BinaryUtils.convert(32, 2); - data[1] = len[0]; // Length - data[2] = len[1]; - - data[9] = 0x01; // OAPosID = 1 - data[10] = 0x17; // RGLength = 23 - - byte[] xcoord = BinaryUtils.convert(x, 3); - data[11] = xcoord[0]; // XoaOSet - data[12] = xcoord[1]; - data[13] = xcoord[2]; - - byte[] ycoord = BinaryUtils.convert(y, 3); - data[14] = ycoord[0]; // YoaOSet - data[15] = ycoord[1]; - data[16] = ycoord[2]; - - byte xorient = (byte)(rotation / 2); - data[17] = xorient; // XoaOrent - - byte yorient = (byte)(rotation / 2 + 45); - data[19] = yorient; // YoaOrent - - byte[] xoffset = BinaryUtils.convert(xOffset, 3); - data[22] = xoffset[0]; // XocaOSet - data[23] = xoffset[1]; - data[24] = xoffset[2]; - - byte[] yoffset = BinaryUtils.convert(yOffset, 3); - data[25] = yoffset[0]; // YocaOSet - data[26] = yoffset[1]; - data[27] = yoffset[2]; - - data[28] = 0x00; // XocaOrent - data[29] = 0x00; - - data[30] = 0x2D; // YocaOrent - data[31] = 0x00; - - data[32] = 0x01; // RefCSys - - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return "ObjectAreaPosition{" - + "x=" + x - + ", y=" + y - + ", rotation=" + rotation - + ", rotation=" + rotation - + ", xOffset=" + xOffset - + ", yOffset=" + yOffset; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java b/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java deleted file mode 100644 index d9a7c2895..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.commons.io.IOUtils; -import org.apache.fop.render.afp.AFPDataObjectInfo; -import org.apache.fop.render.afp.AFPObjectAreaInfo; -import org.apache.fop.render.afp.AFPResourceInfo; -import org.apache.fop.render.afp.AFPResourceLevel; -import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * Object containers are MO:DCA objects that envelop and carry object data. - */ -public class ObjectContainer extends AbstractDataObject { - - /** the object container data maximum length */ - private static final int MAX_DATA_LEN = 32759; - - private InputStream inputStream; - - /** - * Main constructor - * - * @param factory the object factory - * @param name the name of this object container - */ - public ObjectContainer(Factory factory, String name) { - super(factory, name); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] headerData = new byte[17]; - copySF(headerData, Type.BEGIN, Category.OBJECT_CONTAINER); - - // Set the total record length - int containerLen = headerData.length + getTripletDataLength() - 1; - byte[] len = BinaryUtils.convert(containerLen, 2); - headerData[1] = len[0]; // Length byte 1 - headerData[2] = len[1]; // Length byte 2 - - os.write(headerData); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); // write triplets and OEG - - // write OCDs - byte[] dataHeader = new byte[9]; - copySF(dataHeader, SF_CLASS, Type.DATA, Category.OBJECT_CONTAINER); - final int lengthOffset = 1; - - copyChunks(dataHeader, lengthOffset, MAX_DATA_LEN, inputStream, os); - IOUtils.closeQuietly(inputStream); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.OBJECT_CONTAINER); - os.write(data); - } - - /** {@inheritDoc} */ - public void setViewport(AFPDataObjectInfo dataObjectInfo) { - AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); - AFPResourceLevel resourceLevel = resourceInfo.getLevel(); - - // only need to set MCD and CDD when OC when is inlined (pre-2000 apps) - if (resourceLevel.isInline()) { - super.setViewport(dataObjectInfo); - - MapContainerData mapContainerData - = factory.createMapContainerData(MappingOptionTriplet.SCALE_TO_FIT); - getObjectEnvironmentGroup().setMapContainerData(mapContainerData); - - int dataWidth = dataObjectInfo.getDataWidth(); - int dataHeight = dataObjectInfo.getDataHeight(); - - AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - int widthRes = objectAreaInfo.getWidthRes(); - int heightRes = objectAreaInfo.getHeightRes(); - - ContainerDataDescriptor containerDataDescriptor - = factory.createContainerDataDescriptor( - dataWidth, dataHeight, widthRes, heightRes); - getObjectEnvironmentGroup().setDataDescriptor(containerDataDescriptor); - } - } - - /** - * Sets the inputstream for the the object container data - * - * @param inputStream the inputstream for the object container data - */ - public void setInputStream(InputStream inputStream) { - this.inputStream = inputStream; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java deleted file mode 100644 index 7c44701bf..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * An Object Environment Group (OEG) may be associated with an object and is contained - * within the object's begin-end envelope. - * The object environment group defines the object's origin and orientation on the page, - * and can contain font and color attribute table information. The scope of an object - * environment group is the scope of its containing object. - * - * An application that creates a data-stream document may omit some of the parameters - * normally contained in the object environment group, or it may specify that one or - * more default values are to be used. - */ -public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { - - /** the PresentationEnvironmentControl for the object environment group */ - private PresentationEnvironmentControl presentationEnvironmentControl = null; - - /** the ObjectAreaDescriptor for the object environment group */ - private ObjectAreaDescriptor objectAreaDescriptor = null; - - /** the ObjectAreaPosition for the object environment group */ - private ObjectAreaPosition objectAreaPosition = null; - - /** the DataDescriptor for the object environment group */ - private AbstractDescriptor dataDescriptor; - - /** the MapDataResource for the object environment group */ - private MapDataResource mapDataResource; - - /** the MapContainerData for the object environment group */ - private MapContainerData mapContainerData; - - /** - * Constructor for the ObjectEnvironmentGroup, this takes a - * name parameter which must be 8 characters long. - * - * @param name the object environment group name - */ - public ObjectEnvironmentGroup(String name) { - super(name); - } - - /** - * Sets the Object Area Descriptor - * - * @param objectAreaDescriptor the object area descriptor - */ - public void setObjectAreaDescriptor(ObjectAreaDescriptor objectAreaDescriptor) { - this.objectAreaDescriptor = objectAreaDescriptor; - } - - /** - * Sets the Object Area Position - * - * @param objectAreaPosition the object area position - */ - public void setObjectAreaPosition(ObjectAreaPosition objectAreaPosition) { - this.objectAreaPosition = objectAreaPosition; - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.OBJECT_ENVIRONMENT_GROUP); - - int tripletDataLength = getTripletDataLength(); - int sfLen = data.length + tripletDataLength - 1; - byte[] len = BinaryUtils.convert(sfLen, 2); - data[1] = len[0]; - data[2] = len[1]; - - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - - if (presentationEnvironmentControl != null) { - presentationEnvironmentControl.writeToStream(os); - } - - if (objectAreaDescriptor != null) { - objectAreaDescriptor.writeToStream(os); - } - - if (objectAreaPosition != null) { - objectAreaPosition.writeToStream(os); - } - - if (mapContainerData != null) { - mapContainerData.writeToStream(os); - } - - if (mapDataResource != null) { - mapDataResource.writeToStream(os); - } - - if (dataDescriptor != null) { - dataDescriptor.writeToStream(os); - } - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.OBJECT_ENVIRONMENT_GROUP); - os.write(data); - } - - /** - * Sets the presentation environment control - * - * @param presentationEnvironmentControl the presentation environment control - */ - public void setPresentationEnvironmentControl( - PresentationEnvironmentControl presentationEnvironmentControl) { - this.presentationEnvironmentControl = presentationEnvironmentControl; - } - - /** - * Sets the data descriptor - * - * @param dataDescriptor the data descriptor - */ - public void setDataDescriptor(AbstractDescriptor dataDescriptor) { - this.dataDescriptor = dataDescriptor; - } - - /** - * Sets the map data resource - * - * @param mapDataResource the map data resource - */ - public void setMapDataResource(MapDataResource mapDataResource) { - this.mapDataResource = mapDataResource; - } - - /** - * Sets the map container data - * - * @param mapContainerData the map container data - */ - public void setMapContainerData(MapContainerData mapContainerData) { - this.mapContainerData = mapContainerData; - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/Overlay.java b/src/java/org/apache/fop/render/afp/modca/Overlay.java deleted file mode 100644 index 2791d3a15..000000000 --- a/src/java/org/apache/fop/render/afp/modca/Overlay.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - - -/** - * 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. - */ -public class Overlay extends PageObject { - - /** - * Construct a new overlay object for the specified name argument, the overlay - * name should be an 8 character identifier. - * - * @param factory - * the resource manager of the page. - * @param name - * the name of the page. - * @param width - * the width of the page. - * @param height - * the height of the page. - * @param rotation - * the rotation of the page. - * @param widthResolution - * the width resolution of the page. - * @param heightResolution - * the height resolution of the page. - */ - public Overlay(Factory factory, - String name, int width, int height, int rotation, - int widthResolution, int heightResolution) { - super(factory, name, width, height, rotation, widthResolution, heightResolution); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.OVERLAY); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - - getActiveEnvironmentGroup().writeToStream(os); - - writeObjects(includePageSegments, os); - writeObjects(tagLogicalElements, os); - writeObjects(objects, os); - } - - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.OVERLAY); - os.write(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java b/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java deleted file mode 100644 index 8f0d0dfae..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PageDescriptor.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Page Descriptor structured field specifies the size and attributes of - * a page or overlay presentation space. - * - */ -public class PageDescriptor extends AbstractDescriptor { - - /** - * Construct a page descriptor for the specified page width - * and page height. - * - * @param width The page width. - * @param height The page height. - * @param widthRes The page width resolution - * @param heightRes The page height resolution - */ - public PageDescriptor(int width, int height, int widthRes, int heightRes) { - super(width, height, widthRes, heightRes); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[24]; - copySF(data, Type.DESCRIPTOR, Category.PAGE); - data[2] = 0x17; - - // XpgBase - data[9] = 0x00; // XpgBase = 10 inches - - // YpgBase - data[10] = 0x00; // YpgBase = 10 inches - - // XpgUnits - byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); - data[11] = xdpi[0]; - data[12] = xdpi[1]; - - // YpgUnits - 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]; - data[16] = x[1]; - data[17] = x[2]; - - // YpgSize - byte[] y = BinaryUtils.convert(height, 3); - data[18] = y[0]; - data[19] = y[1]; - data[20] = y[2]; - - data[21] = 0x00; // Reserved - data[22] = 0x00; // Reserved - data[23] = 0x00; // Reserved - - os.write(data); - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/PageGroup.java b/src/java/org/apache/fop/render/afp/modca/PageGroup.java deleted file mode 100644 index f56e945e3..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PageGroup.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -/** - * A page group is used in the data stream to define a named, logical grouping - * of sequential pages. Page groups are delimited by begin-end structured fields - * that carry the name of the page group. Page groups are defined so that the - * pages that comprise the group can be referenced or processed as a single - * entity. Page groups are often processed in stand-alone fashion; that is, they - * are indexed, retrieved, and presented outside the context of the containing - * document. - */ -public class PageGroup extends AbstractResourceEnvironmentGroupContainer { - - /** The tag logical elements contained within this group */ - private List tagLogicalElements = null; - - /** - * Constructor for the PageGroup. - * - * @param factory the resource manager - * @param name the name of the page group - */ - public PageGroup(Factory factory, String name) { - super(factory, name); - } - - private List getTagLogicalElements() { - if (tagLogicalElements == null) { - this.tagLogicalElements = new java.util.ArrayList(); - } - return this.tagLogicalElements; - } - - /** - * Creates a TagLogicalElement on the page. - * - * @param name - * the name of the tag - * @param value - * the value of the tag - */ - public void createTagLogicalElement(String name, String value) { - TagLogicalElement tle = factory.createTagLogicalElement(name, value); - if (!getTagLogicalElements().contains(tle)) { - getTagLogicalElements().add(tle); - } - } - - /** - * Method to mark the end of the page group. - */ - protected void endPageGroup() { - complete = true; - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - writeObjects(tagLogicalElements, os); - super.writeContent(os); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.PAGE_GROUP); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.PAGE_GROUP); - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return this.getName(); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/PageObject.java b/src/java/org/apache/fop/render/afp/modca/PageObject.java deleted file mode 100644 index fae4a6252..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PageObject.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.ioca.ImageCellPosition; -import org.apache.fop.render.afp.ioca.ImageInputDescriptor; -import org.apache.fop.render.afp.ioca.ImageOutputControl; -import org.apache.fop.render.afp.ioca.ImageRasterData; -import org.apache.fop.render.afp.ioca.ImageRasterPattern; - -/** - * Pages contain the data objects that comprise a presentation document. Each - * page has a set of data objects associated with it. Each page within a - * document is independent from any other page, and each must establish its own - * environment parameters. - * - * The page is the level in the document component hierarchy that is used for - * printing or displaying a document's content. The data objects contained in - * the page envelope in the data stream are presented when the page is - * presented. Each data object has layout information associated with it that - * directs the placement and orientation of the data on the page. In addition, - * each page contains layout information that specifies the measurement units, - * page width, and page depth. - * - * A page is initiated by a begin page structured field and terminated by an end - * page structured field. Structured fields that define objects and active - * environment groups or that specify attributes of the page may be encountered - * in page state. - * - */ -public class PageObject extends AbstractResourceGroupContainer { - - /** - * Construct a new page object for the specified name argument, the page - * name should be an 8 character identifier. - * - * @param factory the resource manager - * - * @param name - * the name of the page. - * @param width - * the width of the page. - * @param height - * the height of the page. - * @param rotation - * the rotation of the page. - * @param widthRes - * the width resolution of the page. - * @param heightRes - * the height resolution of the page. - */ - public PageObject(Factory factory, - String name, int width, int height, int rotation, - int widthRes, int heightRes) { - super(factory, name, width, height, rotation, widthRes, heightRes); - } - - /** - * Creates an IncludePageOverlay on the page. - * - * @param name - * the name of the overlay - * @param x - * the x position of the overlay - * @param y - * the y position of the overlay - * @param orientation - * the orientation required for the overlay - */ - public void createIncludePageOverlay(String name, int x, int y, int orientation) { - getActiveEnvironmentGroup().createOverlay(name); - IncludePageOverlay ipo = new IncludePageOverlay(name, x, y, orientation); - addObject(ipo); - } - - /** - * This method will create shading on the page using the specified - * coordinates (the shading contrast is controlled via the red, green blue - * parameters, by converting this to grayscale). - * - * @param x - * the x coordinate of the shading - * @param y - * the y coordinate of the shading - * @param w - * the width of the shaded area - * @param h - * the height of the shaded area - * @param red - * the red value - * @param green - * the green value - * @param blue - * the blue value - */ - public void createShading(int x, int y, int w, int h, int red, int green, int blue) { - int xCoord = 0; - int yCoord = 0; - int areaWidth = 0; - int areaHeight = 0; - switch (rotation) { - case 90: - xCoord = areaWidth - y - h; - yCoord = x; - areaWidth = h; - areaHeight = w; - break; - case 180: - xCoord = areaWidth - x - w; - yCoord = areaHeight - y - h; - areaWidth = w; - areaHeight = h; - break; - case 270: - xCoord = y; - yCoord = areaHeight - x - w; - areaWidth = h; - areaHeight = w; - break; - default: - xCoord = x; - yCoord = y; - areaWidth = w; - areaHeight = h; - break; - } - - // Convert the color to grey scale - float shade = (float) ((red * 0.3) + (green * 0.59) + (blue * 0.11)); - - int grayscale = Math.round((shade / 255) * 16); - - IMImageObject imImageObject = factory.createIMImageObject(); - - ImageOutputControl imageOutputControl = new ImageOutputControl(0, 0); - ImageInputDescriptor imageInputDescriptor = new ImageInputDescriptor(); - ImageCellPosition imageCellPosition = new ImageCellPosition(xCoord, yCoord); - imageCellPosition.setXFillSize(areaWidth); - imageCellPosition.setYFillSize(areaHeight); - imageCellPosition.setXSize(64); - imageCellPosition.setYSize(8); - - //defining this as a resource - byte[] rasterData = ImageRasterPattern.getRasterData(grayscale); - ImageRasterData imageRasterData = factory.createImageRasterData(rasterData); - - imImageObject.setImageOutputControl(imageOutputControl); - imImageObject.setImageInputDescriptor(imageInputDescriptor); - imImageObject.setImageCellPosition(imageCellPosition); - imImageObject.setImageRasterData(imageRasterData); - addObject(imImageObject); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.PAGE); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - writeTriplets(os); - - getActiveEnvironmentGroup().writeToStream(os); - - writeObjects(includePageSegments, os); - writeObjects(tagLogicalElements, os); - writeObjects(objects, os); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.PAGE); - os.write(data); - } - - /** - * Adds an AFP object reference to this page - * - * @param obj an AFP object - */ - public void addObject(Object obj) { - endPresentationObject(); - super.addObject(obj); - } - - /** {@inheritDoc} */ - public String toString() { - return this.getName(); - } - - /** {@inheritDoc} */ - protected boolean canWrite(AbstractAFPObject ao) { - return true; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/PageSegment.java b/src/java/org/apache/fop/render/afp/modca/PageSegment.java deleted file mode 100644 index 292deb1b1..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PageSegment.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -/** - * A page segment 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. - * Page segments contain any combination of IOCA image objects and - * GOCA graphics objects. - */ -public class PageSegment extends AbstractNamedAFPObject { - - private List/**/ objects = null; - - /** - * Main constructor - * - * @param name the name of this object - */ - public PageSegment(String name) { - super(name); - } - - /** - * Returns a list of objects contained withing this page segment - * - * @return a list of objects contained within this page segment - */ - public List/**/ getObjects() { - if (objects == null) { - objects = new java.util.ArrayList(); - } - return objects; - } - - /** - * Adds a resource object (image/graphic) to this page segment - * - * @param object the resource objec to add to this page segment - */ - public void addObject(AbstractAFPObject object) { - getObjects().add(object); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.PAGE_SEGMENT); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); - writeObjects(objects, os); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.PAGE_SEGMENT); - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return this.name; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/PreparedAFPObject.java b/src/java/org/apache/fop/render/afp/modca/PreparedAFPObject.java deleted file mode 100644 index 6856d3287..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PreparedAFPObject.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.modca; - -/** - * An AFP object which is able to know its own data length before write() - */ -public interface PreparedAFPObject { - - /** - * Returns the current data length of this container - * - * @return the current data length of this container including - * all enclosed GOCA drawing objects - */ - int getDataLength(); -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java b/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java deleted file mode 100644 index 000988a3d..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Preprocess Presentation Object structured field specifies presentation - * parameters for a data object that has been mapped as a resource. - */ -public class PreprocessPresentationObject extends AbstractStructuredAFPObject { - private static final byte TYPE_OTHER = (byte)0x92; - private static final byte TYPE_OVERLAY = (byte)0xDF; - private static final byte TYPE_IMAGE = (byte)0xFB; - - private byte objType = TYPE_OTHER; - private byte objOrent = 0; // object always processed at 0 degree orientation - private int objXOffset = -1; - private int objYOffset = -1; - - /** - * Main constructor - * - * @param prePresObj the presentation object to be preprocessed - */ - public PreprocessPresentationObject(AbstractStructuredAFPObject prePresObj) { - if (prePresObj instanceof ImageObject || prePresObj instanceof Overlay) { - if (prePresObj instanceof ImageObject) { - this.objType = TYPE_IMAGE; - } else { - this.objType = TYPE_OVERLAY; - } - setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, - prePresObj.getFullyQualifiedName()); - } else { - this.objType = TYPE_OTHER; - } - } - - public static final byte ORIENTATION_ZERO_DEGREES = 1; - public static final byte ORIENTATION_90_DEGREES = 2; - public static final byte ORIENTATION_180_DEGREES = 4; - public static final byte ORIENTATION_270_DEGREES = 8; - - /** - * Sets the object orientations relative to media leading edge - * - * @param orientation the object orientations relative to media leading edge - */ - public void setOrientation(byte orientation) { - objOrent = (byte)orientation; - } - - /** - * Sets the X axis origin for object content - * - * @param xOffset the X axis origin for object content - */ - public void setXOffset(int xOffset) { - this.objXOffset = xOffset; - } - - /** - * Sets the Y axis origin for object content - * - * @param yOffset the Y axis origin for object content - */ - public void setYOffset(int yOffset) { - this.objYOffset = yOffset; - } - - /** {@inheritDoc} */ - public void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - - byte[] data = new byte[9]; - copySF(data, Type.PROCESS, Category.DATA_RESOURCE); - - byte[] l = BinaryUtils.convert(19 + getTripletDataLength(), 2); - data[1] = l[0]; // Length byte 1 - data[2] = l[1]; // Length byte 1 - - os.write(data); - } - - /** {@inheritDoc} */ - public void writeContent(OutputStream os) throws IOException { - byte[] data = new byte[12]; - byte[] l = BinaryUtils.convert(12 + getTripletDataLength(), 2); - data[0] = l[0]; // RGLength - data[1] = l[1]; // RGLength - data[2] = objType; // ObjType - data[3] = 0x00; // Reserved - data[4] = 0x00; // Reserved - data[5] = objOrent; // ObjOrent - if (objXOffset > 0) { - byte[] xOff = BinaryUtils.convert(objYOffset, 3); - data[6] = xOff[0]; // XocaOset (not specified) - data[7] = xOff[1]; // XocaOset - data[8] = xOff[2]; // XocaOset - } else { - data[6] = (byte)0xFF; // XocaOset (not specified) - data[7] = (byte)0xFF; // XocaOset - data[8] = (byte)0xFF; // XocaOset - } - if (objYOffset > 0) { - byte[] yOff = BinaryUtils.convert(objYOffset, 3); - data[9] = yOff[0]; // YocaOset (not specified) - data[10] = yOff[1]; // YocaOset - data[11] = yOff[2]; // YocaOset - } else { - data[9] = (byte)0xFF; // YocaOset (not specified) - data[10] = (byte)0xFF; // YocaOset - data[11] = (byte)0xFF; // YocaOset - } - os.write(data); - - // Triplets - super.writeContent(os); - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationEnvironmentControl.java b/src/java/org/apache/fop/render/afp/modca/PresentationEnvironmentControl.java deleted file mode 100644 index f186f930c..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PresentationEnvironmentControl.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.triplets.Triplet; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Presentation Environment Control structured field specifies parameters that - * affect the rendering of presentation data and the appearance that is to be assumed - * by the presentation device. - */ -public class PresentationEnvironmentControl extends AbstractStructuredAFPObject { - - /** - * Main constructor - */ - public PresentationEnvironmentControl() { - } - - /** - * Sets the object offset - */ - public void setObjectOffset() { - addTriplet(new ObjectOffsetTriplet()); - } - - /** - * Sets the rendering intent - */ - public void setRenderingIntent() { - addTriplet(new RenderingIntentTriplet()); - } - - /** - * Sets the device appearance - */ - public void setDeviceAppearance() { - addTriplet(new DeviceAppearanceTriplet()); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[11]; - copySF(data, Type.CONTROL, Category.DOCUMENT); - int tripletDataLen = getTripletDataLength(); - byte[] len = BinaryUtils.convert(10 + tripletDataLen); - data[1] = len[0]; - data[2] = len[1]; - data[9] = 0x00; // Reserved; must be zero - data[10] = 0x00; // Reserved; must be zero - - os.write(data); - os.write(tripletData); - } - - // TODO - private class DeviceAppearanceTriplet extends Triplet { - public DeviceAppearanceTriplet() { - super(Triplet.DEVICE_APPEARANCE); - } - } - - // TODO - private class RenderingIntentTriplet extends Triplet { - public RenderingIntentTriplet() { - super(Triplet.RENDERING_INTENT); - } - } - - // TODO - private class ObjectOffsetTriplet extends Triplet { - public ObjectOffsetTriplet() { - super(Triplet.OBJECT_OFFSET); - } - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java deleted file mode 100644 index dc0512b6d..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java +++ /dev/null @@ -1,569 +0,0 @@ -/* - * 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.modca; - -import java.awt.Color; -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.fop.render.afp.AFPLineDataInfo; -import org.apache.fop.render.afp.AFPTextDataInfo; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * Presentation text data contains the graphic characters and the control - * sequences necessary to position the characters within the object space. The - * data consists of: - graphic characters to be presented - control sequences - * that position them - modal control sequences that adjust the positions by - * small amounts - other functions causing text to be presented with differences - * in appearance. - * - * The graphic characters are expected to conform to a coded font representation - * so that they can be translated from the code point in the object data to the - * character in the coded font. The units of measure for linear displacements - * are derived from the PresentationTextDescriptor or from the hierarchical - * defaults. - * - * In addition to graphic character code points, Presentation Text data can - * contain embedded control sequences. These are strings of two or more bytes - * which signal an alternate mode of processing for the content of the current - * Presentation Text data. - * - */ -public class PresentationTextData extends AbstractAFPObject { - - /** - * The maximum size of the presentation text data. - */ - private static final int MAX_SIZE = 8192; - - /** - * The afp data relating to this presentation text data. - */ - private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - /** - * The current x coordinate. - */ - private int currentX = -1; - - /** - * The current y cooridnate - */ - private int currentY = -1; - - /** - * The current font - */ - private String currentFont = ""; - - /** - * The current orientation - */ - private int currentOrientation = 0; - - /** - * The current color - */ - private Color currentColor = new Color(0, 0, 0); - - /** - * The current variable space increment - */ - private int currentVariableSpaceCharacterIncrement = 0; - - /** - * The current inter character adjustment - */ - private int currentInterCharacterAdjustment = 0; - - /** - * Default constructor for the PresentationTextData. - */ - public PresentationTextData() { - this(false); - } - - /** - * Constructor for the PresentationTextData, the boolean flag indicate - * whether the control sequence prefix should be set to indicate the start - * of a new control sequence. - * - * @param controlInd - * The control sequence indicator. - */ - public PresentationTextData(boolean controlInd) { - final byte[] data = { - 0x5A, // Structured field identifier - 0x00, // Record length byte 1 - 0x00, // Record length byte 2 - (byte) 0xD3, // PresentationTextData identifier byte 1 - (byte) 0xEE, // PresentationTextData identifier byte 2 - (byte) 0x9B, // PresentationTextData identifier byte 3 - 0x00, // Flag - 0x00, // Reserved - 0x00, // Reserved - }; - baos.write(data, 0, 9); - - if (controlInd) { - baos.write(new byte[] {0x2B, (byte) 0xD3}, 0, 2); - } - } - - /** - * The Set Coded Font Local control sequence activates a coded font and - * specifies the character attributes to be used. This is a modal control - * sequence. - * - * @param font - * The font local identifier. - * @param afpdata - * The output stream to which data should be written. - */ - private void setCodedFont(byte font, ByteArrayOutputStream afpdata) { - // Avoid unnecessary specification of the font - if (String.valueOf(font).equals(currentFont)) { - return; - } else { - currentFont = String.valueOf(font); - } - - afpdata.write(new byte[] {0x03, (byte) 0xF1, font}, 0, 3); - } - - /** - * Establishes the current presentation position on the baseline at a new - * I-axis coordinate, which is a specified number of measurement units from - * the B-axis. There is no change to the current B-axis coordinate. - * - * @param coordinate - * The coordinate for the inline move. - * @param afpdata - * The output stream to which data should be written. - */ - private void absoluteMoveInline(int coordinate, - ByteArrayOutputStream afpdata) { - byte[] b = BinaryUtils.convert(coordinate, 2); - afpdata.write(new byte[] {0x04, (byte) 0xC7, b[0], b[1]}, 0, 4); - currentX = coordinate; - } - - /** - * Establishes the baseline and the current presentation position at a new - * B-axis coordinate, which is a specified number of measurement units from - * the I-axis. There is no change to the current I-axis coordinate. - * - * @param coordinate - * The coordinate for the baseline move. - * @param afpdata - * The output stream to which data should be written. - */ - private void absoluteMoveBaseline(int coordinate, - ByteArrayOutputStream afpdata) { - byte[] b = BinaryUtils.convert(coordinate, 2); - afpdata.write(new byte[] {0x04, (byte) 0xD3, b[0], b[1]}, 0, 4); - currentY = coordinate; - } - - private static final int TRANSPARENT_MAX_SIZE = 253; - - /** - * The Transparent Data control sequence contains a sequence of code points - * that are presented without a scan for embedded control sequences. - * - * @param data - * The text data to add. - * @param afpdata - * The output stream to which data should be written. - */ - private void addTransparentData(byte[] data, ByteArrayOutputStream afpdata) { - // Calculate the length - int l = data.length + 2; - if (l > 255) { - // Check that we are not exceeding the maximum length - throw new IllegalArgumentException( - "Transparent data is longer than " + TRANSPARENT_MAX_SIZE + " bytes: " + data); - } - afpdata.write(new byte[] {BinaryUtils.convert(l)[0], (byte) 0xDB}, - 0, 2); - afpdata.write(data, 0, data.length); - } - - /** - * Draws a line of specified length and specified width in the B-direction - * from the current presentation position. The location of the current - * presentation position is unchanged. - * - * @param length - * The length of the rule. - * @param width - * The width of the rule. - * @param afpdata - * The output stream to which data should be written. - */ - private void drawBaxisRule(int length, int width, - ByteArrayOutputStream afpdata) { - afpdata.write(new byte[] { - 0x07, // Length - (byte) 0xE7, // Type - }, 0, 2); - // Rule length - byte[] data1 = BinaryUtils.shortToByteArray((short) length); - afpdata.write(data1, 0, data1.length); - // Rule width - byte[] data2 = BinaryUtils.shortToByteArray((short) width); - afpdata.write(data2, 0, data2.length); - // Rule width fraction - afpdata.write(0x00); - } - - /** - * Draws a line of specified length and specified width in the I-direction - * from the current presentation position. The location of the current - * presentation position is unchanged. - * - * @param length - * The length of the rule. - * @param width - * The width of the rule. - * @param afpdata - * The output stream to which data should be written. - */ - private void drawIaxisRule(int length, int width, - ByteArrayOutputStream afpdata) { - afpdata.write(new byte[] { - 0x07, // Length - (byte) 0xE5, // Type - }, 0, 2); - // Rule length - byte[] data1 = BinaryUtils.shortToByteArray((short) length); - afpdata.write(data1, 0, data1.length); - // Rule width - byte[] data2 = BinaryUtils.shortToByteArray((short) width); - afpdata.write(data2, 0, data2.length); - // Rule width fraction - afpdata.write(0x00); - } - - /** - * Create the presentation text data for the byte array of data. - * - * @param textDataInfo - * the afp text data - * @throws MaximumSizeExceededException - * thrown if the maximum number of text data is exceeded - */ - public void createTextData(AFPTextDataInfo textDataInfo) - throws MaximumSizeExceededException { - - ByteArrayOutputStream afpdata = new ByteArrayOutputStream(); - - int rotation = textDataInfo.getRotation(); - if (currentOrientation != rotation) { - setTextOrientation(rotation, afpdata); - currentOrientation = rotation; - currentX = -1; - currentY = -1; - } - - // Avoid unnecessary specification of the Y coordinate - int y = textDataInfo.getY(); - if (currentY != y) { - absoluteMoveBaseline(y, afpdata); - currentX = -1; - } - - // Avoid unnecessary specification of the X coordinate - int x = textDataInfo.getX(); - if (currentX != x) { - absoluteMoveInline(x, afpdata); - } - - // Avoid unnecessary specification of the variable space increment - if (textDataInfo.getVariableSpaceCharacterIncrement() - != currentVariableSpaceCharacterIncrement) { - setVariableSpaceCharacterIncrement(textDataInfo - .getVariableSpaceCharacterIncrement(), afpdata); - currentVariableSpaceCharacterIncrement = textDataInfo - .getVariableSpaceCharacterIncrement(); - } - - // Avoid unnecessary specification of the inter character adjustment - if (textDataInfo.getInterCharacterAdjustment() != currentInterCharacterAdjustment) { - setInterCharacterAdjustment(textDataInfo.getInterCharacterAdjustment(), - afpdata); - currentInterCharacterAdjustment = textDataInfo - .getInterCharacterAdjustment(); - } - - // Avoid unnecessary specification of the text color - if (!textDataInfo.getColor().equals(currentColor)) { - setExtendedTextColor(textDataInfo.getColor(), afpdata); - currentColor = textDataInfo.getColor(); - } - - setCodedFont(BinaryUtils.convert(textDataInfo.getFontReference())[0], - afpdata); - - // Add transparent data - byte[] data = textDataInfo.getData(); - if (data.length <= TRANSPARENT_MAX_SIZE) { - addTransparentData(data, afpdata); - } else { - // data size greater than TRANSPARENT_MAX_SIZE so slice - int numTransData = data.length / TRANSPARENT_MAX_SIZE; - byte[] buff = new byte[TRANSPARENT_MAX_SIZE]; - int currIndex = 0; - for (int transDataCnt = 0; transDataCnt < numTransData; transDataCnt++) { - currIndex = transDataCnt * TRANSPARENT_MAX_SIZE; - System.arraycopy(data, currIndex, buff, 0, TRANSPARENT_MAX_SIZE); - addTransparentData(buff, afpdata); - } - int remainingTransData = data.length / TRANSPARENT_MAX_SIZE; - buff = new byte[remainingTransData]; - System.arraycopy(data, currIndex, buff, 0, remainingTransData); - addTransparentData(buff, afpdata); - } - currentX = -1; - - int dataSize = afpdata.size(); - - if (baos.size() + dataSize > MAX_SIZE) { - currentX = -1; - currentY = -1; - throw new MaximumSizeExceededException(); - } - - byte[] outputdata = afpdata.toByteArray(); - baos.write(outputdata, 0, outputdata.length); - } - - private int ensurePositive(int value) { - if (value < 0) { - return 0; - } - return value; - } - - /** - * Drawing of lines using the starting and ending coordinates, thickness and - * colour arguments. - * - * @param lineDataInfo the line data information. - * @throws MaximumSizeExceededException - * thrown if the maximum number of line data has been exceeded - */ - public void createLineData(AFPLineDataInfo lineDataInfo) throws MaximumSizeExceededException { - - ByteArrayOutputStream afpdata = new ByteArrayOutputStream(); - - int orientation = lineDataInfo.getRotation(); - if (currentOrientation != orientation) { - setTextOrientation(orientation, afpdata); - currentOrientation = orientation; - } - - // Avoid unnecessary specification of the Y coordinate - int y1 = ensurePositive(lineDataInfo.getY1()); - if (y1 != currentY) { - absoluteMoveBaseline(y1, afpdata); - } - - // Avoid unnecessary specification of the X coordinate - int x1 = ensurePositive(lineDataInfo.getX1()); - if (x1 != currentX) { - absoluteMoveInline(x1, afpdata); - } - - Color color = lineDataInfo.getColor(); - if (!color.equals(currentColor)) { - setExtendedTextColor(color, afpdata); - currentColor = color; - } - - int x2 = ensurePositive(lineDataInfo.getX2()); - int y2 = ensurePositive(lineDataInfo.getY2()); - int thickness = lineDataInfo.getThickness(); - if (y1 == y2) { - drawIaxisRule(x2 - x1, thickness, afpdata); - } else if (x1 == x2) { - drawBaxisRule(y2 - y1, thickness, afpdata); - } else { - log.error("Invalid axis rule unable to draw line"); - return; - } - - int dataSize = afpdata.size(); - - if (baos.size() + dataSize > MAX_SIZE) { - currentX = -1; - currentY = -1; - throw new MaximumSizeExceededException(); - } - - byte[] outputdata = afpdata.toByteArray(); - baos.write(outputdata, 0, outputdata.length); - } - - /** - * The Set Text Orientation control sequence establishes the I-direction and - * B-direction for the subsequent text. This is a modal control sequence. - * - * Semantics: This control sequence specifies the I-axis and B-axis - * orientations with respect to the Xp-axis for the current Presentation - * Text object. The orientations are rotational values expressed in degrees - * and minutes. - * - * @param orientation - * The text orientation (0, 90, 180, 270). - * @param os - * The output stream to which data should be written. - */ - private void setTextOrientation(int orientation, - ByteArrayOutputStream os) { - os.write(new byte[] {0x06, (byte) 0xF7, }, 0, 2); - switch (orientation) { - case 90: - os.write(0x2D); - os.write(0x00); - os.write(0x5A); - os.write(0x00); - break; - case 180: - os.write(0x5A); - os.write(0x00); - os.write(0x87); - os.write(0x00); - break; - case 270: - os.write(0x87); - os.write(0x00); - os.write(0x00); - os.write(0x00); - break; - default: - os.write(0x00); - os.write(0x00); - os.write(0x2D); - os.write(0x00); - break; - } - } - - /** - * The Set Extended Text Color control sequence specifies a color value and - * defines the color space and encoding for that value. The specified color - * value is applied to foreground areas of the text presentation space. This - * is a modal control sequence. - * - * @param col - * The color to be set. - * @param os - * The output stream to which data should be written. - */ - private void setExtendedTextColor(Color col, ByteArrayOutputStream os) { - byte[] colorData = new byte[] { - 15, // Control sequence length - (byte) 0x81, // Control sequence function type - 0x00, // Reserved; must be zero - 0x01, // Color space - 0x01 = RGB - 0x00, // Reserved; must be zero - 0x00, // Reserved; must be zero - 0x00, // Reserved; must be zero - 0x00, // Reserved; must be zero - 8, // Number of bits in component 1 - 8, // Number of bits in component 2 - 8, // Number of bits in component 3 - 0, // Number of bits in component 4 - (byte) (col.getRed()), // Red intensity - (byte) (col.getGreen()), // Green intensity - (byte) (col.getBlue()), // Blue intensity - }; - - os.write(colorData, 0, colorData.length); - } - - /** - * //TODO This is a modal control sequence. - * - * @param incr - * The increment to be set. - * @param os - * The output stream to which data should be written. - */ - private void setVariableSpaceCharacterIncrement(int incr, - ByteArrayOutputStream os) { - byte[] b = BinaryUtils.convert(incr, 2); - - os.write(new byte[] { - 4, // Control sequence length - (byte) 0xC5, // Control sequence function type - b[0], b[1] }, - 0, 4); - } - - /** - * //TODO This is a modal control sequence. - * - * @param incr - * The increment to be set. - * @param os - * The output stream to which data should be written. - */ - private void setInterCharacterAdjustment(int incr, ByteArrayOutputStream os) { - byte[] b = BinaryUtils.convert(Math.abs(incr), 2); - os.write(new byte[] { - 5, // Control sequence length - (byte) 0xC3, // Control sequence function type - b[0], b[1], (byte) (incr >= 0 ? 0 : 1) // Direction - }, 0, 5); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = baos.toByteArray(); - byte[] size = BinaryUtils.convert(data.length - 1, 2); - data[1] = size[0]; - data[2] = size[1]; - os.write(data); - } - - /** - * A control sequence is a sequence of bytes that specifies a control - * function. A control sequence consists of a control sequence introducer - * and zero or more parameters. The control sequence can extend multiple - * presentation text data objects, but must eventually be terminated. This - * method terminates the control sequence. - * - * @throws MaximumSizeExceededException - * thrown in the event that maximum size has been exceeded - */ - public void endControlSequence() throws MaximumSizeExceededException { - byte[] data = new byte[2]; - data[0] = 0x02; - data[1] = (byte) 0xF8; - if (data.length + baos.size() > MAX_SIZE) { - throw new MaximumSizeExceededException(); - } - baos.write(data, 0, data.length); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java deleted file mode 100644 index 807aba4d7..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Presentation Text Descriptor specifies the units of measure for the - * Presentation Text object space, the size of the Presentation Text object - * space, and the initial values for modal parameters, called initial text - * conditions. Initial values not provided are defaulted by the controlling - * environment or the receiving device. - * - * The Presentation Text Descriptor provides the following initial values: - * - Unit base - * - Xp-units per unit base - * - Yp-units per unit base - * - Xp-extent of the presentation space - * - Yp-extent of the presentation space - * - Initial text conditions. - * - * The initial text conditions are values provided by the Presentation Text - * Descriptor to initialize the modal parameters of the control sequences. - * Modal control sequences typically are characterized by the word set in - * the name of the control sequence. Modal parameters are identified as such - * in their semantic descriptions. - * - */ -public class PresentationTextDescriptor extends AbstractDescriptor { - - /** - * Constructor a PresentationTextDescriptor for the specified - * width and height. - * - * @param width The width of the page. - * @param height The height of the page. - * @param widthRes The width resolution of the page. - * @param heightRes The height resolution of the page. - */ - public PresentationTextDescriptor(int width, int height, - int widthRes, int heightRes) { - super(width, height, widthRes, heightRes); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = new byte[23]; - - copySF(data, Type.MIGRATION, Category.PRESENTATION_TEXT); - - data[1] = 0x00; // length - data[2] = 0x16; - - data[9] = 0x00; - data[10] = 0x00; - - byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2); - data[11] = xdpi[0]; // xdpi - data[12] = xdpi[1]; - - byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2); - data[13] = ydpi[0]; // ydpi - data[14] = ydpi[1]; - - byte[] x = BinaryUtils.convert(width, 3); - data[15] = x[0]; - data[16] = x[1]; - data[17] = x[2]; - - byte[] y = BinaryUtils.convert(height, 3); - data[18] = y[0]; - data[19] = y[1]; - data[20] = y[2]; - - data[21] = 0x00; - data[22] = 0x00; - - os.write(data); - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java b/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java deleted file mode 100644 index 4071ebb9d..000000000 --- a/src/java/org/apache/fop/render/afp/modca/PresentationTextObject.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -import org.apache.fop.render.afp.AFPLineDataInfo; -import org.apache.fop.render.afp.AFPTextDataInfo; - -/** - * The Presentation Text object is the data object used in document processing - * environments for representing text which has been prepared for presentation. - * Text, as used here, means an ordered string of characters, such as graphic - * symbols, numbers, and letters, that are suitable for the specific purpose of - * representing coherent information. Text which has been prepared for - * presentation has been reduced to a primitive form through explicit - * specification of the characters and their placement in the presentation - * space. Control sequences which designate specific control functions may be - * embedded within the text. These functions extend the primitive form by - * applying specific characteristics to the text when it is presented. The - * collection of the graphic characters and control codes is called Presentation - * Text, and the object that contains the Presentation Text is called the - * PresentationText object. - */ -public class PresentationTextObject extends AbstractNamedAFPObject { - - /** - * The current presentation text data - */ - private PresentationTextData currentPresentationTextData = null; - - /** - * The presentation text data list - */ - private List/**/ presentationTextDataList = null; - - /** - * Construct a new PresentationTextObject for the specified name argument, - * the name should be an 8 character identifier. - * - * @param name the name of this presentation object - */ - public PresentationTextObject(String name) { - super(name); - } - - /** - * Create the presentation text data for the byte array of data. - * - * @param textDataInfo - * The afp text data - */ - public void createTextData(AFPTextDataInfo textDataInfo) { - if (currentPresentationTextData == null) { - startPresentationTextData(); - } - try { - currentPresentationTextData.createTextData(textDataInfo); - } catch (MaximumSizeExceededException msee) { - endPresentationTextData(); - createTextData(textDataInfo); - } - } - - /** - * Drawing of lines using the starting and ending coordinates, thickness and - * orientation arguments. - * - * @param lineDataInfo the line data information. - */ - public void createLineData(AFPLineDataInfo lineDataInfo) { - if (currentPresentationTextData == null) { - startPresentationTextData(); - } - try { - currentPresentationTextData.createLineData(lineDataInfo); - } catch (MaximumSizeExceededException msee) { - endPresentationTextData(); - createLineData(lineDataInfo); - } - } - - /** - * Helper method to mark the start of the presentation text data - */ - private void startPresentationTextData() { - if (presentationTextDataList == null) { - presentationTextDataList = new java.util.ArrayList/**/(); - } - if (presentationTextDataList.size() == 0) { - currentPresentationTextData = new PresentationTextData(true); - } else { - currentPresentationTextData = new PresentationTextData(); - } - presentationTextDataList.add(currentPresentationTextData); - } - - /** - * Helper method to mark the end of the presentation text data - */ - private void endPresentationTextData() { - this.currentPresentationTextData = null; - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.PRESENTATION_TEXT); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - writeObjects(this.presentationTextDataList, os); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.PRESENTATION_TEXT); - os.write(data); - } - - /** - * A control sequence is a sequence of bytes that specifies a control - * function. A control sequence consists of a control sequence introducer - * and zero or more parameters. The control sequence can extend multiple - * presentation text data objects, but must eventually be terminated. This - * method terminates the control sequence. - */ - public void endControlSequence() { - if (currentPresentationTextData == null) { - startPresentationTextData(); - } - try { - currentPresentationTextData.endControlSequence(); - } catch (MaximumSizeExceededException msee) { - endPresentationTextData(); - endControlSequence(); - } - } - - /** {@inheritDoc} */ - public String toString() { - if (presentationTextDataList != null) { - return presentationTextDataList.toString(); - } - return null; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/Registry.java b/src/java/org/apache/fop/render/afp/modca/Registry.java deleted file mode 100644 index 3311817eb..000000000 --- a/src/java/org/apache/fop/render/afp/modca/Registry.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * 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.modca; - -import java.util.Collections; - -import org.apache.xmlgraphics.util.MimeConstants; - -/** - * MOD:CA Registry of object types - */ -public final class Registry { - /** IOB supported object types */ - private static final byte COMPID_IOCA_FS10 = 5; - private static final byte COMPID_IOCA_FS11 = 11; - private static final byte COMPID_IOCA_FS45 = 12; - private static final byte COMPID_EPS = 13; - private static final byte COMPID_TIFF = 14; - private static final byte COMPID_GIF = 22; - private static final byte COMPID_JFIF = 23; // jpeg file interchange format - private static final byte COMPID_PDF_SINGLE_PAGE = 25; - private static final byte COMPID_PCL_PAGE_OBJECT = 34; - - /** mime type entry mapping */ - private final java.util.Map/**/ mimeObjectTypeMap - = Collections.synchronizedMap( - new java.util.HashMap/**/()); - - /** singleton instance */ - private static Registry instance = null; - - /** - * Returns a single instance of a MO:DCA Registry - * - * @return a single instance of an MO:DCA Registry - */ - public static Registry getInstance() { - synchronized (Registry.class) { - if (instance == null) { - instance = new Registry(); - } - } - return instance; - } - - /** - * private constructor - */ - private Registry() { - init(); - } - - /** - * Initializes the mimetype map - */ - private void init() { - mimeObjectTypeMap.put( - MimeConstants.MIME_AFP_IOCA_FS10, - new ObjectType( - COMPID_IOCA_FS10, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x05}, - "IOCA FS10", - true, - MimeConstants.MIME_AFP_IOCA_FS10 - ) - ); - mimeObjectTypeMap.put( - MimeConstants.MIME_AFP_IOCA_FS11, - new ObjectType( - COMPID_IOCA_FS11, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x11}, - "IOCA FS11", - true, - MimeConstants.MIME_AFP_IOCA_FS11 - ) - ); - mimeObjectTypeMap.put( - MimeConstants.MIME_AFP_IOCA_FS45, - new ObjectType( - COMPID_IOCA_FS45, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x12}, - "IOCA FS45", - true, - MimeConstants.MIME_AFP_IOCA_FS45 - ) - ); - mimeObjectTypeMap.put( - MimeConstants.MIME_EPS, - new ObjectType( - COMPID_EPS, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0D}, - "Encapsulated Postscript", - true, - MimeConstants.MIME_EPS - ) - ); - mimeObjectTypeMap.put( - MimeConstants.MIME_TIFF, - new ObjectType( - COMPID_TIFF, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0E}, - "TIFF", - true, - MimeConstants.MIME_TIFF - ) - ); - mimeObjectTypeMap.put( - MimeConstants.MIME_GIF, - new ObjectType( - COMPID_GIF, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x16}, - "GIF", - true, - MimeConstants.MIME_GIF - ) - ); - mimeObjectTypeMap.put( - MimeConstants.MIME_JPEG, - new ObjectType( - COMPID_JFIF, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x17}, - "JFIF", - true, - MimeConstants.MIME_JPEG - ) - ); - mimeObjectTypeMap.put(MimeConstants.MIME_PDF, - new ObjectType( - COMPID_PDF_SINGLE_PAGE, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x19}, - "PDF Single-page Object", - true, - MimeConstants.MIME_PDF - ) - ); - mimeObjectTypeMap.put( - MimeConstants.MIME_PCL, - new ObjectType( - COMPID_PCL_PAGE_OBJECT, - new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x22}, - "PCL Page Object", - true, - MimeConstants.MIME_PCL - ) - ); - } - - /** - * Returns the MOD:CA object type given a mimetype - * - * @param mimeType the object mimetype - * @return the MOD:CA object type - */ - public ObjectType getObjectType(String mimeType) { - return (ObjectType)mimeObjectTypeMap.get(mimeType); - } - - /** - * Encapsulates a MOD:CA Registry Object Type entry - */ - public class ObjectType { - private final byte componentId; - private final byte[] oid; - private final String name; - private final boolean includable; - private final String mimeType; - - /** - * Main constructor - * - * @param componentId the component id of this object type - * @param oid the object id of this object type - * @param name the object type name - * @param includable true if this object can be included with an IOB structured field - * @param mimeType the mime type associated with this object type - */ - public ObjectType(byte componentId, byte[] oid, String name, - boolean includable, String mimeType) { - this.name = name; - this.includable = includable; - this.mimeType = mimeType; - this.componentId = componentId; - this.oid = oid; - } - - /** - * Returns a MOD:CA object type OID from a given a componentId - * - * @return the corresponding object type id for a given component id - * or null if the component id is unknown and the object type OID was not found. - */ - public byte[] getOID() { - return this.oid; - } - - /** - * Returns the object type name for the given componentId - * - * @return the object type name for the given componentId - */ - public String getName() { - return this.name; - } - - /** - * Returns the compontentId for this entry - * - * @return the compontentId for this entry - */ - public byte getComponentId() { - return this.componentId; - } - - /** - * Returns true if this component can be included with an IOB structured field - * - * @return true if this component can be included with an IOB structured field - */ - public boolean isIncludable() { - return this.includable; - } - - /** - * Returns the mime type associated with this object type - * - * @return the mime type associated with this object type - */ - public String getMimeType() { - return this.mimeType; - } - - /** {@inheritDoc} */ - public String toString() { - return this.getName(); - } - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java deleted file mode 100644 index 1d66f560f..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -/** - * A Resource Environment Group contains a set of resources for a document - * or for a group of pages in a document. - */ -public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup { - /** - * Default name for the resource group - */ - private static final String DEFAULT_NAME = "REG00001"; - - /** - * The maps data resources contained in this resource environment group - */ - private List/**/ mapDataResources = null; - - /** - * The maps page overlays contained in this resource environment group - */ - private List mapPageOverlays = null; - - /** - * The pre-process presentation objects contained in this resource environment group - */ - private List/**/ preProcessPresentationObjects = null; - - /** - * The resource environment group state - */ - private boolean complete = false; - - /** - * Default constructor - */ - public ResourceEnvironmentGroup() { - this(DEFAULT_NAME); - } - - private List/**/ getMapDataResources() { - if (mapDataResources == null) { - this.mapDataResources = new java.util.ArrayList/**/(); - } - return this.mapDataResources; - } - - private List getMapPageOverlays() { - if (mapPageOverlays == null) { - this.mapPageOverlays = new java.util.ArrayList(); - } - return this.mapPageOverlays; - } - - private List/**/ getPreprocessPresentationObjects() { - if (preProcessPresentationObjects == null) { - this.preProcessPresentationObjects - = new java.util.ArrayList/**/(); - } - return this.preProcessPresentationObjects; - } - - /** - * Constructor for the ResourceEnvironmentGroup, this takes a - * name parameter which must be 8 characters long. - * @param name the resource environment group name - */ - public ResourceEnvironmentGroup(String name) { - super(name); - } - -// /** -// * Adds an AFP object mapping reference to this resource environment group -// * @param obj the object to add -// */ -// public void addObject(AbstractStructuredAFPObject obj) { -// getMapDataResources().add(new MapDataResource(obj)); -// createOverlay(obj.get); -// getPreprocessPresentationObjects().add(new PreprocessPresentationObject(obj)); -// } - - /** - * Returns an indication if the resource environment group is complete - * - * @return whether or not this resource environment group is complete or not - */ - public boolean isComplete() { - return complete; - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.RESOURCE_ENVIROMENT_GROUP); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.RESOURCE_ENVIROMENT_GROUP); - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - writeObjects(mapDataResources, os); - writeObjects(mapPageOverlays, os); - writeObjects(preProcessPresentationObjects, os); - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java b/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java deleted file mode 100644 index c412f85f7..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Iterator; -import java.util.Set; - -import org.apache.fop.render.afp.Streamable; - -/** - * A Resource Group contains a set of overlays. - */ -public class ResourceGroup extends AbstractNamedAFPObject { - - /** Set of resource uri */ - private final Set/**/ resourceSet = new java.util.HashSet/**/(); - - /** - * Constructor for the ResourceGroup, this takes a - * name parameter which must be 8 characters long. - * - * @param name the resource group name - */ - public ResourceGroup(String name) { - super(name); - } - - /** - * Add this named object to this resource group - * - * @param namedObject a named object - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public void addObject(AbstractNamedAFPObject namedObject) throws IOException { - resourceSet.add(namedObject); - } - - /** - * Returns the number of resources contained in this resource group - * - * @return the number of resources contained in this resource group - */ - public int getResourceCount() { - return resourceSet.size(); - } - - /** - * Returns true if the resource exists within this resource group, - * false otherwise. - * - * @param uri the uri of the resource - * @return true if the resource exists within this resource group - */ - public boolean resourceExists(String uri) { - return resourceSet.contains(uri); - } - - /** {@inheritDoc} */ - public void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.BEGIN, Category.RESOURCE_GROUP); - os.write(data); - } - - /** {@inheritDoc} */ - public void writeContent(OutputStream os) throws IOException { - Iterator it = resourceSet.iterator(); - while (it.hasNext()) { - Object object = it.next(); - if (object instanceof Streamable) { - Streamable streamableObject = (Streamable)object; - streamableObject.writeToStream(os); - } - } - } - - /** {@inheritDoc} */ - public void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.RESOURCE_GROUP); - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return this.name + " " + resourceSet/*getResourceMap()*/; - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/ResourceObject.java b/src/java/org/apache/fop/render/afp/modca/ResourceObject.java deleted file mode 100644 index edbe30226..000000000 --- a/src/java/org/apache/fop/render/afp/modca/ResourceObject.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -import org.apache.fop.render.afp.modca.triplets.Triplet; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * This resource structured field begins an envelope that is used to carry - * resource objects in print-file-level (external) resource groups. - */ -public class ResourceObject extends AbstractPreparedAFPObject { - - private AbstractNamedAFPObject namedObject; - - /** - * Default constructor - * - * @param name the name of this resource (reference id) - */ - public ResourceObject(String name) { - super(name); - } - - /** - * Sets the data object referenced by this resource object - * - * @param obj the named data object - */ - public void setDataObject(AbstractNamedAFPObject obj) { - this.namedObject = obj; - } - - /** - * Returns the data object referenced by this resource object - * - * @return the data object referenced by this resource object - */ - public AbstractNamedAFPObject getDataObject() { - return namedObject; - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - - byte[] data = new byte[19]; - copySF(data, Type.BEGIN, Category.NAME_RESOURCE); - - // Set the total record length - int tripletDataLength = getTripletDataLength(); - byte[] len = BinaryUtils.convert(18 + tripletDataLength, 2); - data[1] = len[0]; // Length byte 1 - data[2] = len[1]; // Length byte 2 - - // Set reserved bits - data[17] = 0x00; // Reserved - data[18] = 0x00; // Reserved - - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); // write triplets - if (namedObject != null) { - namedObject.writeToStream(os); - } - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[17]; - copySF(data, Type.END, Category.NAME_RESOURCE); - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return this.getName(); - } - - /** - * Sets Resource Object Type triplet - * - * @param type the resource object type - */ - public void setType(byte type) { - getTriplets().add(new ResourceObjectTypeTriplet(type)); - } - - /** graphics object type */ - public static final byte TYPE_GRAPHIC = 0x03; - - /** barcode object type */ - public static final byte TYPE_BARCODE = 0x05; - - /** image object type */ - public static final byte TYPE_IMAGE = 0x06; - - /** font character set type */ - public static final byte TYPE_FONT_CHARACTER_SET = 0x40; - - /** code page type */ - public static final byte TYPE_CODE_PAGE = 0x41; - - /** coded font type */ - public static final byte TYPE_CODED_FONT = 0x42; - - /** object container type */ - public static final byte TYPE_OBJECT_CONTAINER = (byte) 0x92; - - /** document object type */ - public static final byte TYPE_DOCUMENT = (byte) 0xA8; - - /** page segment object type */ - public static final byte TYPE_PAGE_SEGMENT = (byte) 0xFB; - - /** overlay object type */ - public static final byte TYPE_OVERLAY_OBJECT = (byte) 0xFC; - - /** page def type */ - public static final byte TYPE_PAGEDEF = (byte) 0xFD; - - /** form def type */ - public static final byte TYPE_FORMDEF = (byte) 0xFE; - - - /** resource object type triplet */ - private class ResourceObjectTypeTriplet extends Triplet { - - private static final byte RESOURCE_OBJECT = 0x21; - - /** - * Main constructor - * - * @param objectType the resource object type - */ - public ResourceObjectTypeTriplet(byte objectType) { - super(RESOURCE_OBJECT, - new byte[] { - objectType, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Constant Data - } - ); - } - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java b/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java deleted file mode 100644 index abe2e1547..000000000 --- a/src/java/org/apache/fop/render/afp/modca/StreamedResourceGroup.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * A print-file resource group - */ -public class StreamedResourceGroup extends ResourceGroup { - /** the outputstream to write to */ - private final OutputStream os; - - private boolean started = false; - - private boolean complete = false; - - /** - * Main constructor - * - * @param name the resource group name - * @param os the outputstream - */ - public StreamedResourceGroup(String name, OutputStream os) { - super(name); - this.os = os; - } - - /** - * Adds a resource to the external resource group - * - * @param namedObject a named object - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public void addObject(AbstractNamedAFPObject namedObject) throws IOException { - if (!started) { - writeStart(os); - started = true; - } - try { - namedObject.writeToStream(os); - } finally { - os.flush(); - } - } - - /** - * Closes this external resource group file - * - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public void close() throws IOException { - writeEnd(os); - complete = true; - } - - /** - * Returns true if this resource group is complete - * - * @return true if this resource group is complete - */ - public boolean isComplete() { - return this.complete; - } - - /** - * Returns the outputstream - * - * @return the outputstream - */ - public OutputStream getOutputStream() { - return this.os; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java b/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java deleted file mode 100644 index 64160c087..000000000 --- a/src/java/org/apache/fop/render/afp/modca/TagLogicalElement.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.modca; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; - -import org.apache.fop.render.afp.AFPConstants; -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * A Tag Logical Element structured field assigns an attribute name and an - * attribute value to a page or page group. The Tag Logical Element structured - * field may be embedded directly in the page or page group, or it may reference - * the page or page group from a document index. When a Tag Logical Element - * structured field references a page or is embedded in a page following the - * active environment group, it is associated with the page. When a Tag Logical - * Element structured field references a page group or is embedded in a page - * group following the Begin Named Page Group structured field, it is associated - * with the page group. When a Tag Logical Element structured field is associated - * with a page group, the parameters of the Tag Logical Element structured field - * are inherited by all pages in the page group and by all other page groups - * that are nested in the page group. The scope of a Tag Logical Element is - * determined by its position with respect to other TLEs that reference, or are - * embedded in, the same page or page group. The Tag Logical Element structured - * field does not provide any presentation specifications and therefore has no - * effect on the appearance of a document when it is presented. - *

      - */ -public class TagLogicalElement extends AbstractAFPObject { - - /** - * Name of the key, used within the TLE - */ - private String name = null; - - /** - * Value returned by the key - */ - private String value = null; - - /** - * Construct a tag logical element with the name and value specified. - * - * @param name the name of the tag logical element - * @param value the value of the tag logical element - */ - public TagLogicalElement(String name, String value) { - this.name = name; - this.value = value; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - - byte[] data = new byte[17 + name.length() + value.length()]; - - data[0] = 0x5A; - // Set the total record length - byte[] rl1 - = BinaryUtils.convert(16 + name.length() + value.length(), 2); - //Ignore first byte - data[1] = rl1[0]; - data[2] = rl1[1]; - - // Structured field ID for a TLE - data[3] = (byte) 0xD3; - data[4] = (byte) Type.ATTRIBUTE; - data[5] = (byte) Category.PROCESS_ELEMENT; - - data[6] = 0x00; // Reserved - data[7] = 0x00; // Reserved - data[8] = 0x00; // Reserved - - //Use 2 triplets, attrubute name and value (the key for indexing) - - byte[] rl2 = BinaryUtils.convert(name.length() + 4, 1); - data[9] = rl2[0]; // length of the triplet, including this field - data[10] = 0x02; //Identifies it as a FQN triplet - data[11] = 0x0B; // GID format - data[12] = 0x00; - - byte[] tleByteName = null; - byte[] tleByteValue = null; - try { - tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING); - tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING); - } catch (UnsupportedEncodingException usee) { - tleByteName = name.getBytes(); - tleByteValue = value.getBytes(); - log.warn( - "Constructor:: UnsupportedEncodingException translating the name " - + name); - } - - int pos = 13; - for (int i = 0; i < tleByteName.length; i++) { - data[pos++] = tleByteName[i]; - } - - byte[] rl3 = BinaryUtils.convert(tleByteValue.length + 4, 1); - data[pos++] = rl3[0]; // length of the triplet, including this field - data[pos++] = 0x36; //Identifies the triplet, attribute value - data[pos++] = 0x00; // Reserved - data[pos++] = 0x00; // Reserved - - for (int i = 0; i < tleByteValue.length; i++) { - data[pos++] = tleByteValue[i]; - } - os.write(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java b/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java deleted file mode 100644 index c47abe9b2..000000000 --- a/src/java/org/apache/fop/render/afp/modca/TagLogicalElementBean.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.modca; - -/** - * The TagLogicalElementBean provides a bean for holding the attributes of - * a tag logical element as key value pairs. - *

      - */ -public class TagLogicalElementBean { - - /** The key attribute */ - private String key; - - /** The value attribute */ - private String value; - - /** - * Constructor for the TagLogicalElementBean. - * - * @param key the key attribute - * @param value the value attribute - */ - public TagLogicalElementBean(String key, String value) { - this.key = key; - this.value = value; - } - - /** - * Getter for the key attribute. - * - * @return the key - */ - public String getKey() { - return key; - } - - /** - * Getter for the value attribute. - * - * @return the value - */ - public String getValue() { - return value; - } - -} diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java deleted file mode 100644 index a2d42feb9..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.modca.triplets; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Extended Resource Local Identifier triplet specifies a resource type and a - * four byte local identifier or LID. The LID usually is associated with a specific - * resource name by a map structured field, such as a Map Data Resource structured - * field, or a Map Media Type structured field. - */ -public class ExtendedResourceLocalIdentifierTriplet extends Triplet { - - /** the image resource type */ - public static final byte TYPE_IMAGE_RESOURCE = 0x10; - - /** the retired value type */ - public static final byte TYPE_RETIRED_VALUE = 0x30; - - /** the retired value type */ - public static final byte TYPE_MEDIA_RESOURCE = 0x40; - - /** - * Main constructor - * - * @param type the resource type - * @param localId the resource local id - */ - public ExtendedResourceLocalIdentifierTriplet(byte type, int localId) { - super(Triplet.EXTENDED_RESOURCE_LOCAL_IDENTIFIER); - byte[] data = new byte[5]; - data[0] = type; - byte[] resLID = BinaryUtils.convert(localId, 4); - System.arraycopy(resLID, 0, data, 1, resLID.length); - super.setData(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java deleted file mode 100644 index 68bef3e56..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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.modca.triplets; - -import java.io.UnsupportedEncodingException; - -import org.apache.fop.render.afp.AFPConstants; - -/** - * A Fully Qualified Name triplet enable the identification and referencing of - * objects using Gloabl Identifiers (GIDs). - */ -public class FullyQualifiedNameTriplet extends Triplet { - - // Specifies how the GID will be used - - /** This GID replaces the first parameter in the structured field that contains a GID name. */ - public static final byte TYPE_REPLACE_FIRST_GID_NAME = 0x01; - - /** This triplet contains the name of a font family. */ - public static final byte TYPE_FONT_FAMILY_NAME = 0x07; - - /** This triplet contains the name of a font typeface. */ - public static final byte TYPE_FONT_TYPEFACE_NAME = 0x08; - - /** This triplet specifies a reference to the MO:DCA resource hierarchy. */ - public static final byte TYPE_MODCA_RESOURCE_HIERARCHY_REF = 0x09; - - /** The triplet contains a GID reference to a begin resource group structured field. */ - public static final byte TYPE_BEGIN_RESOURCE_GROUP_REF = 0x0A; - - /** The triplet contains a GID reference to a document attribute. */ - public static final byte TYPE_ATTRIBUTE_GID = 0x0B; - - /** The triplet contains the GID of a process element. */ - public static final byte TYPE_PROCESS_ELEMENT_GID = 0x0C; - - /** The triplet contains a reference to a begin page group structured field. */ - public static final byte TYPE_BEGIN_PAGE_GROUP_REF = 0x0D; - - /** The triplet contains a reference to a media type. */ - public static final byte TYPE_MEDIA_TYPE_REF = 0x11; - - /** The triplet contains a reference to a color management resource. */ - public static final byte TYPE_COLOR_MANAGEMENT_RESOURCE_REF = 0x41; - - /** The triplet contains a reference to a data-object font file that defines a base font. */ - public static final byte TYPE_DATA_OBJECT_FONT_BASE_FONT_ID = 0x6E; - - /** The triplet contains a reference to a data-object font file that defines a linked font. */ - public static final byte TYPE_DATA_OBJECT_FONT_LINKED_FONT_ID = 0x7E; - - /** The triplet contains a reference to a begin document structured field. */ - public static final byte TYPE_BEGIN_DOCUMENT_REF = (byte)0x83; - - /** - * The triplet contains a reference to a begin structured field associated with a resource; - * or contains a GID reference to a coded font. - */ - public static final byte TYPE_BEGIN_RESOURCE_OBJECT_REF = (byte)0x84; - - /** - * The triplet contains a GID reference to a code page that specifies the code points and - * graphic character names for a coded font. - */ - public static final byte TYPE_CODE_PAGE_NAME_REF = (byte)0x85; - - /** - * The triplet contains a GID name reference to a font character set that specifies - * a set of graphics characters. - */ - public static final byte TYPE_FONT_CHARSET_NAME_REF = (byte)0x86; - - /** The triplet contains a GID reference to a begin page structured field. */ - public static final byte TYPE_BEGIN_PAGE_REF = (byte)0x87; - - /** The triplet contains a GID reference to a begin medium map structured field. */ - public static final byte TYPE_BEGIN_MEDIUM_MAP_REF = (byte)0x8D; - - /** - * The triplet contains a GID reference to a coded font, which identifies a specific - * code page and a specific font character set. - */ - public static final byte TYPE_CODED_FONT_NAME_REF = (byte)0x8E; - - /** The triplet contains a GID reference to a begin document index structured field. */ - public static final byte TYPE_BEGIN_DOCUMENT_INDEX_REF = (byte)0x98; - - /** The triplet contains a GID reference to a begin overlay structured field. */ - public static final byte TYPE_BEGIN_OVERLAY_REF = (byte)0xB0; - - /** The triplet contains a GID reference to a resource used by a data object. */ - public static final byte TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF = (byte)0xBE; - - /** The triplet contains a GID reference to an index element structured field. */ - public static final byte TYPE_INDEX_ELEMENT_GID = (byte)0xCA; - - /** - * The triplet contains a reference to other object data which may or may - * not be defined by an IBM presentation architecture. - */ - public static final byte TYPE_OTHER_OBJECT_DATA_REF = (byte)0xCE; - - /** - * The triplet contains a reference to a resource used by a data object. - * The GID may be a filename or any other identifier associated with the - * resource and is used to located the resource object in the resource hierarchy. - * The data object that uses the resource may or may not be defined by an - * IBM presentation architecture. - */ - public static final byte TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF = (byte)0xDE; - - - // GID Format - - /** The GID is a character encoded name. */ - public static final byte FORMAT_CHARSTR = (byte)0x00; - - /** the GID is a ASN.1 object identifier (OID). */ - public static final byte FORMAT_OID = (byte)0x10; - - /** the GID is a uniform resource locator (URL). */ - public static final byte FORMAT_URL = (byte)0x20; - - - private String fqName; - - /** - * @return the actual fully qualified name of this triplet - */ - public String getFullyQualifiedName() { - return fqName; - } - - /** - * Main constructor - * - * @param type the fully qualified name type - * @param format the fully qualified name format - * @param fqName the fully qualified name - */ - public FullyQualifiedNameTriplet(byte type, byte format, String fqName) { - super(FULLY_QUALIFIED_NAME); - - this.fqName = fqName; - - byte[] fqNameBytes; - String encoding = AFPConstants.EBCIDIC_ENCODING; - if (format == FORMAT_URL) { - encoding = AFPConstants.US_ASCII_ENCODING; - } - try { - fqNameBytes = fqName.getBytes(encoding); - } catch (UnsupportedEncodingException e) { - throw new IllegalArgumentException( - encoding + " encoding failed"); - } - - byte[] data = new byte[2 + fqNameBytes.length]; - data[0] = type; - data[1] = format; - // FQName - System.arraycopy(fqNameBytes, 0, data, 2, fqNameBytes.length); - - super.setData(data); - } - - /** - * {@inheritDoc} - */ - public String toString() { - return this.fqName; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/MappingOptionTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/MappingOptionTriplet.java deleted file mode 100644 index daebb6183..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/MappingOptionTriplet.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.modca.triplets; - -/** - * Specifies the mapping of data object presentation space to object area - */ -public class MappingOptionTriplet extends Triplet { - /** - * the data object is placed in the upper left corner, all data must be presented - * within the object area extents - */ - public static final byte POSITION = 0x00; - - /** - * the data object is placed in the upper left corner, all data that falls within - * the object area extents will be presented but data that falls outside will not be presented - */ - public static final byte POSITION_AND_TRIM = 0x10; - - /** - * the data object is centred and symmetrically scaled up or down - * while preserving aspect ratio - */ - public static final byte SCALE_TO_FIT = 0x20; - - /** - * the data object is centred, all data that falls within the object area extents - * will be presented but data that falls outside will not be presented - */ - public static final byte CENTER_AND_TRIM = 0x30; - -// public static final byte MIGRATION_MAPPING_1 = 0x41; -// public static final byte MIGRATION_MAPPING_2 = 0x42; -// public static final byte MIGRATION_MAPPING_3 = 0x50; - - /** the data object is centred, aspect ratio is not always preserved */ - public static final byte SCALE_TO_FILL = 0x60; - - /** used to map ip3i print data objects */ - public static final byte UP3I_PRINT_DATA = 0x70; - - /** - * Main constructor - * - * @param mapValue the mapping option to use - */ - public MappingOptionTriplet(byte mapValue) { - super(Triplet.MAPPING_OPTION, mapValue); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java deleted file mode 100644 index 71da6e059..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/MeasurementUnitsTriplet.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.modca.triplets; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Measurement Units triplet is used to specify the units of measure - * for a presentation space - */ -public class MeasurementUnitsTriplet extends Triplet { - - private static final byte TEN_INCHES = 0x00; - private static final byte TEN_CM = 0x01; - - /** - * Main constructor - * - * @param xRes units per base on the x-axis - * @param yRes units per base on the y-axis - */ - public MeasurementUnitsTriplet(int xRes, int yRes) { - super(MEASUREMENT_UNITS); - //TODO: units correct? - byte[] xUnits = BinaryUtils.convert(xRes * 10, 2); - byte[] yUnits = BinaryUtils.convert(yRes * 10, 2); - byte[] data = new byte[] { - TEN_INCHES, // XoaBase - TEN_INCHES, // YoaBase - xUnits[0], // XoaUnits (x units per unit base) - xUnits[1], - yUnits[0], // YoaUnits (y units per unit base) - yUnits[1] - }; - super.setData(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java deleted file mode 100644 index 6b9e25a69..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/ObjectAreaSizeTriplet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.modca.triplets; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Object Area Size triplet is used to specify the extent of an object area - * in the X and Y directions - */ -public class ObjectAreaSizeTriplet extends Triplet { - - /** - * Main constructor - * - * @param x the object area extent for the X axis - * @param y the object area extent for the Y axis - * @param type the object area size type - */ - public ObjectAreaSizeTriplet(int x, int y, byte type) { - super(Triplet.OBJECT_AREA_SIZE); - byte[] xOASize = BinaryUtils.convert(x, 3); - byte[] yOASize = BinaryUtils.convert(y, 3); - byte[] data = new byte[] { - type, // SizeType - xOASize[0], // XoaSize - Object area extent for X axis - xOASize[1], - xOASize[2], - yOASize[0], // YoaSize - Object area extent for Y axis - yOASize[1], - yOASize[2] - }; - super.setData(data); - } - - /** - * Main constructor - * - * @param x the object area extent for the X axis - * @param y the object area extent for the Y axis - */ - public ObjectAreaSizeTriplet(int x, int y) { - this(x, y, (byte)0x02); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/ObjectByteExtentTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/ObjectByteExtentTriplet.java deleted file mode 100644 index b98a46a72..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/ObjectByteExtentTriplet.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.modca.triplets; - -import org.apache.fop.render.afp.tools.BinaryUtils; - -/** - * The Object Byte Extent triplet is used to specify the number of bytes contained in an object - */ -public class ObjectByteExtentTriplet extends Triplet { - - /** - * Main constructor - * - * @param byteExt the number of bytes contained in the object - */ - public ObjectByteExtentTriplet(int byteExt) { - super(OBJECT_BYTE_EXTENT); - byte[] data = BinaryUtils.convert(byteExt, 4); - super.setData(data); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java deleted file mode 100644 index 8ba97b61d..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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.modca.triplets; - -import java.io.UnsupportedEncodingException; - -import org.apache.fop.render.afp.AFPConstants; -import org.apache.fop.render.afp.modca.Registry.ObjectType; -import org.apache.fop.render.afp.tools.StringUtils; - -/** - * The Object Classification is used to classify and identify object data. - * The object data may or may not be defined by an IBM presentation architecture - */ -public class ObjectClassificationTriplet extends Triplet { - - /** - * The scope of this object is the including page or overlay - */ - public static final byte CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT = 0x01; - - /** - * The scope of this object is not defined - */ - public static final byte CLASS_TIME_VARIANT_PRESENTATION_OBJECT = 0x10; - - /** - * This is not a presentation object, the scope of this object is not defined - */ - public static final byte CLASS_EXECUTABLE_PROGRAM = 0x20; - - /** - * Setup information file, document level. This is not a presentation object, - */ - public static final byte CLASS_SETUP_FILE = 0x30; - - /** - * This is a resource used by a presentation object that may itself be a resource. - * The scope of the resource is the object that uses the resource. - */ - public static final byte CLASS_SECONDARY_RESOURCE = 0x40; - - /** - * Data object font. This is a non-FOCA font resource used to present - * text in a data object. The scope of the resource is the object that - * uses the resource. - */ - public static final byte CLASS_DATA_OBJECT_FONT = 0x41; - - /** - * Main constructor - * - * @param objectClass the object class type - * @param objectType the object type registry entry - * @param dataInContainer whether the data resides in the container - * @param containerHasOEG whether the container has an object environment group - * @param dataInOCD whether the data resides in a object container data structured field - */ - public ObjectClassificationTriplet(byte objectClass, ObjectType objectType, - boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD) { - // no object level or company name specified - this(objectClass, objectType, dataInContainer, containerHasOEG, dataInOCD, null, null); - } - - - private static final int OBJECT_LEVEL_LEN = 8; - private static final int OBJECT_TYPE_NAME_LEN = 32; - private static final int COMPANY_NAME_LEN = 32; - - /** - * Fully parameterized constructor - * - * @param objectClass the object class type - * @param objectType the object type registry entry - * @param dataInContainer whether the data resides in the container - * @param containerHasOEG whether the container has an object environment group - * @param dataInOCD whether the data resides in a object container data structured field - * @param objLev the release level or version number of the object type - * @param compName the name of the company or organization that owns the object definition - */ - public ObjectClassificationTriplet(byte objectClass, ObjectType objectType, - boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD, - String objLev, String compName) { - super(OBJECT_CLASSIFICATION); - - if (objectType == null) { - throw new IllegalArgumentException("MO:DCA Registry object type is null"); - } - - byte[] data = new byte[94]; - data[0] = 0x00; // reserved (must be zero) - data[1] = objectClass; // ObjClass - data[2] = 0x00; // reserved (must be zero) - data[3] = 0x00; // reserved (must be zero) - - // StrucFlgs - Information on the structure of the object container - byte[] strucFlgs = getStrucFlgs(dataInContainer, containerHasOEG, dataInOCD); - data[4] = strucFlgs[0]; - data[5] = strucFlgs[1]; - - byte[] oid = objectType.getOID(); - // RegObjId - MOD:CA-registered ASN.1 OID for object type (8-23) - System.arraycopy(oid, 0, data, 6, oid.length); - - // ObjTpName - name of object type (24-55) - byte[] objTpName; - try { - objTpName = StringUtils.rpad(objectType.getName(), ' ', OBJECT_TYPE_NAME_LEN).getBytes( - AFPConstants.EBCIDIC_ENCODING); - System.arraycopy(objTpName, 0, data, 22, objTpName.length); - } catch (UnsupportedEncodingException e) { - throw new IllegalArgumentException("an encoding exception occurred"); - } - - // ObjLev - release level or version number of object type (56-63) - byte[] objectLevel; - try { - objectLevel = StringUtils.rpad(objLev, ' ', OBJECT_LEVEL_LEN).getBytes( - AFPConstants.EBCIDIC_ENCODING); - } catch (UnsupportedEncodingException e) { - throw new IllegalArgumentException("an encoding exception occurred"); - } - System.arraycopy(objectLevel, 0, data, 54, objectLevel.length); - - // CompName - name of company or organization that owns object definition (64-95) - byte[] companyName; - try { - companyName = StringUtils.rpad(compName, ' ', COMPANY_NAME_LEN).getBytes( - AFPConstants.EBCIDIC_ENCODING); - } catch (UnsupportedEncodingException e) { - throw new IllegalArgumentException("an encoding exception occurred"); - } - System.arraycopy(companyName, 0, data, 62, companyName.length); - - super.setData(data); - } - - /** - * Returns the structured field flags - * - * @param dataInContainer true if the object data in carried in the object container - * @param containerHasOEG true if the object container has an object environment group - * @param dataInOCD true if the object container data carries the object data - * - * @return the byte value of this structure - */ - public byte[] getStrucFlgs(boolean dataInContainer, boolean containerHasOEG, - boolean dataInOCD) { - byte[] strucFlgs = new byte[2]; - // Object Container (BOC/EOC) - if (dataInContainer) { - strucFlgs[0] |= 3 << 6; - } else { - strucFlgs[0] |= 1 << 6; - } - // Object Environment Group (OEG) - if (containerHasOEG) { - strucFlgs[0] |= 3 << 4; - } else { - strucFlgs[0] |= 1 << 4; - } - // Object Container Data (OCD) structured fields - if (dataInOCD) { - strucFlgs[0] |= 3 << 2; - } else { - strucFlgs[0] |= 1 << 2; - } - strucFlgs[1] = 0x00; - return strucFlgs; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java deleted file mode 100644 index 0f2def9bf..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.modca.triplets; - -/** - * This triplet is used to specify the resulting appearance when data in a new - * presentation space is merged with data in an existing presentation space. - */ -public class PresentationSpaceMixingRulesTriplet extends Triplet { - - /** background on background mixing rule */ - public static final byte RULE_BACK_ON_BACK = 0x70; - - /** background on foreground mixing rule */ - public static final byte RULE_BACK_ON_FORE = 0x71; - - /** foreground on background mixing rule */ - public static final byte RULE_FORE_ON_BACK = 0x72; - - /** foreground on foreground mixing rule */ - public static final byte RULE_FORE_ON_FORE = 0x73; - - - /** overpaint */ - public static final byte OVERPAINT = (byte)0x01; - - /** underpaint */ - public static final byte UNDERPAINT = (byte)0x02; - - /** blend */ - public static final byte BLEND = (byte)0x03; - - /** MO:DCA default mixing */ - public static final byte DEFAULT = (byte)0xFF; - - - /** - * Main constructor - * - * @param rules the mixing rules - */ - public PresentationSpaceMixingRulesTriplet(byte[] rules) { - super(PRESENTATION_SPACE_MIXING_RULE, rules); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/PresentationSpaceResetMixingTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/PresentationSpaceResetMixingTriplet.java deleted file mode 100644 index ebba65df5..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/PresentationSpaceResetMixingTriplet.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.modca.triplets; - -/** - * This triplet is used to specify the resulting appearance when data in a new - * presentation space is merged with data in an existing presentation space. - */ -public class PresentationSpaceResetMixingTriplet extends Triplet { - - /** - * Do not reset to the color of the medium prior to - * placing data into this MO:DCA presentation space. - */ - public static final byte NOT_RESET = 0x00; - - /** - * Reset to the color of the medium prior to placing - * data into this MO:DCA presentation space. - */ - public static final byte RESET = 0x01; - - /** - * Main constructor - * - * @param backgroundMixFlag the background mixing flag - */ - public PresentationSpaceResetMixingTriplet(byte backgroundMixFlag) { - super(PRESENTATION_SPACE_RESET_MIXING, backgroundMixFlag); - } -} diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/ResourceObjectTypeTriplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/ResourceObjectTypeTriplet.java deleted file mode 100644 index c157659d6..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/ResourceObjectTypeTriplet.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.modca.triplets; - diff --git a/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java b/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java deleted file mode 100644 index 9c88f6862..000000000 --- a/src/java/org/apache/fop/render/afp/modca/triplets/Triplet.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.modca.triplets; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; - -import org.apache.fop.render.afp.AFPConstants; -import org.apache.fop.render.afp.Streamable; - -/** - * A simple implementation of a MOD:CA triplet - */ -public class Triplet implements Streamable { - public static final byte CODED_GRAPHIC_CHARACTER_SET_GLOBAL_IDENTIFIER = 0x01; - - /** Triplet identifiers */ - public static final byte FULLY_QUALIFIED_NAME = 0x02; - public static final byte MAPPING_OPTION = 0x04; - public static final byte OBJECT_CLASSIFICATION = 0x10; - public static final byte MODCA_INTERCHANGE_SET = 0x18; - public static final byte FONT_DESCRIPTOR_SPECIFICATION = 0x1F; - public static final byte OBJECT_FUNCTION_SET_SPECIFICATION = 0x21; - public static final byte EXTENDED_RESOURCE_LOCAL_IDENTIFIER = 0x22; - public static final byte RESOURCE_LOCAL_IDENTIFIER = 0x24; - public static final byte RESOURCE_SECTION_NUMBER = 0x25; - public static final byte CHARACTER_ROTATION = 0x26; - public static final byte OBJECT_BYTE_OFFSET = 0x2D; - public static final byte ATTRIBUTE_VALUE = 0x36; - public static final byte DESCRIPTOR_POSITION = 0x43; - public static final byte MEDIA_EJECT_CONTROL = 0x45; - public static final byte PAGE_OVERLAY_CONDITIONAL_PROCESSING = 0x46; - public static final byte RESOURCE_USAGE_ATTRIBUTE = 0x47; - public static final byte MEASUREMENT_UNITS = 0x4B; - public static final byte OBJECT_AREA_SIZE = 0x4C; - public static final byte AREA_DEFINITION = 0x4D; - public static final byte COLOR_SPECIFICATION = 0x4E; - public static final byte ENCODING_SCHEME_ID = 0x50; - public static final byte MEDIUM_MAP_PAGE_NUMBER = 0x56; - public static final byte OBJECT_BYTE_EXTENT = 0x57; - public static final byte OBJECT_STRUCTURED_FIELD_OFFSET = 0x58; - public static final byte OBJECT_STRUCTURED_FIELD_EXTENT = 0x59; - public static final byte OBJECT_OFFSET = 0x5A; - public static final byte FONT_HORIZONTAL_SCALE_FACTOR = 0x5D; - public static final byte OBJECT_COUNT = 0x5E; - public static final byte OBJECT_DATE_AND_TIMESTAMP = 0x62; - public static final byte COMMENT = 0x65; - public static final byte MEDIUM_ORIENTATION = 0x68; - public static final byte RESOURCE_OBJECT_INCLUDE = 0x6C; - public static final byte PRESENTATION_SPACE_RESET_MIXING = 0x70; - public static final byte PRESENTATION_SPACE_MIXING_RULE = 0x71; - public static final byte UNIVERSAL_DATE_AND_TIMESTAMP = 0x72; - public static final byte TONER_SAVER = 0x74; - public static final byte COLOR_FIDELITY = 0x75; - public static final byte FONT_FIDELITY = 0x78; - public static final byte ATTRIBUTE_QUALIFIER = (byte)0x80; - public static final byte PAGE_POSITION_INFORMATION = (byte)0x81; - public static final byte PARAMETER_VALUE = (byte)0x82; - public static final byte PRESENTATION_CONTROL = (byte)0x83; - public static final byte FONT_RESOLUTION_AND_METRIC_TECHNOLOGY = (byte)0x84; - public static final byte FINISHING_OPERATION = (byte)0x85; - public static final byte TEXT_FIDELITY = (byte)0x86; - public static final byte MEDIA_FIDELITY = (byte)0x87; - public static final byte FINISHING_FIDELITY = (byte)0x88; - public static final byte DATA_OBJECT_FONT_DESCRIPTOR = (byte)0x8B; - public static final byte LOCALE_SELECTOR = (byte)0x8C; - public static final byte UP3I_FINISHING_OPERATION = (byte)0x8E; - public static final byte COLOR_MANAGEMENT_RESOURCE_DESCRIPTOR = (byte)0x91; - public static final byte RENDERING_INTENT = (byte)0x95; - public static final byte CMR_TAG_FIDELITY = (byte)0x96; - public static final byte DEVICE_APPEARANCE = (byte)0x97; - - /** the triplet identifier */ - private final byte id; - - /** the triplet's data contents */ - private byte[] data; - - /** - * Main constructor - * - * @param id the triplet identifier (see static definitions above) - * @param data the data item contained in this triplet - */ - public Triplet(byte id, byte[] data) { - this(id); - setData(data); - } - - /** - * Constructor - * - * @param id the triplet identifier (see static definitions above) - */ - public Triplet(byte id) { - this.id = id; - } - - /** - * Constructor - * - * @param id the triplet identifier (see static definitions above) - * @param content the content byte data - */ - public Triplet(byte id, byte content) { - this(id, new byte[] {content}); - } - - /** - * Constructor - * - * @param id the triplet identifier (see static definitions above) - * @param data the data item (in String form) contained in this triplet - * @throws UnsupportedEncodingException EBCIDIC encoding is not supported - */ - public Triplet(byte id, String data) throws UnsupportedEncodingException { - this(id, data.getBytes(AFPConstants.EBCIDIC_ENCODING)); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - os.write((byte)data.length + 2); - os.write(id); - os.write(data); - } - - /** - * Returns the triplet identifier - * - * @return the triplet identifier - */ - public byte getId() { - return this.id; - } - - /** - * Sets the data contents of this triplet - * - * @param data the data contents - */ - protected void setData(byte[] data) { - this.data = data; - } -} diff --git a/src/java/org/apache/fop/render/afp/tools/BinaryUtils.java b/src/java/org/apache/fop/render/afp/tools/BinaryUtils.java deleted file mode 100644 index 31ba45bcf..000000000 --- a/src/java/org/apache/fop/render/afp/tools/BinaryUtils.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.tools; - -import java.io.ByteArrayOutputStream; - -/** - * Library of utility useful conversion methods. - * - */ -public final class BinaryUtils { - - /** - * Convert an int into the corresponding byte array by encoding each - * two hexadecimal digits as a char. This will return a byte array - * to the length specified by bufsize. - * @param integer The int representation. - * @param bufsize The required byte array size. - * @return the hexadecimal digits as a byte array - */ - public static byte[] convert(int integer, int bufsize) { - StringBuffer buf = new StringBuffer(Integer.toHexString(integer)); - //Convert to an even number of digits - if (buf.length() % 2 != 0) { - buf.insert(0, "0"); - } - int size = buf.length() / 2; - if (size > bufsize) { - buf.delete(0, buf.length() - (bufsize * 2)); - } else { - while (size < bufsize) { - buf.insert(0, "00"); - size++; - } - } - return convert(buf.toString()); - } - - /** - * Convert an int into the corresponding byte array by encoding each - * two hexadecimal digits as a char. - * @param integer The int representation - * @return the hexadecimal digits as a byte array - */ - public static byte[] convert(int integer) { - return convert(Integer.toHexString(integer)); - } - - /** - * Convert a String of hexadecimal digits into the corresponding - * byte array by encoding each two hexadecimal digits as a byte. - * @param digits The hexadecimal digits representation. - * @return the hexadecimal digits as a byte array - */ - public static byte[] convert(String digits) { - - if (digits.length() % 2 == 0) { - // Even number of digits, so ignore - } else { - // Convert to an even number of digits - digits = "0" + digits; - } - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - for (int i = 0; i < digits.length(); i += 2) { - char c1 = digits.charAt(i); - char c2 = digits.charAt(i + 1); - byte b = 0; - if ((c1 >= '0') && (c1 <= '9')) { - b += ((c1 - '0') * 16); - } else if ((c1 >= 'a') && (c1 <= 'f')) { - b += ((c1 - 'a' + 10) * 16); - } else if ((c1 >= 'A') && (c1 <= 'F')) { - b += ((c1 - 'A' + 10) * 16); - } else { - throw new IllegalArgumentException("Bad hexadecimal digit"); - } - - if ((c2 >= '0') && (c2 <= '9')) { - b += (c2 - '0'); - } else if ((c2 >= 'a') && (c2 <= 'f')) { - b += (c2 - 'a' + 10); - } else if ((c2 >= 'A') && (c2 <= 'F')) { - b += (c2 - 'A' + 10); - } else { - throw new IllegalArgumentException("Bad hexadecimal digit"); - } - baos.write(b); - } - return (baos.toByteArray()); - } - - /** - * Convert the specified short into a byte array. - * @param value The value to be converted. - * @param array The array to receive the data. - * @param offset The offset into the byte array for the start of the value. - */ - public static void shortToByteArray( - short value, - byte[] array, - int offset) { - array[offset] = (byte) (value >>> 8); - array[offset + 1] = (byte) value; - } - - /** - * Convert the specified short into a byte array. - * @param value The value to be converted. - * @return The byte array - */ - public static byte[] shortToByteArray(short value) { - byte[] serverValue = new byte[2]; - shortToByteArray(value, serverValue, 0); - return serverValue; - } - -} diff --git a/src/java/org/apache/fop/render/afp/tools/DTDEntityResolver.java b/src/java/org/apache/fop/render/afp/tools/DTDEntityResolver.java deleted file mode 100644 index e9554ecea..000000000 --- a/src/java/org/apache/fop/render/afp/tools/DTDEntityResolver.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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.tools; - -import java.io.IOException; -import java.net.URL; - -import org.apache.fop.render.afp.exceptions.FontRuntimeException; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; - -/** - * An entity resolver for both DOM and SAX models of the SAX document. - *

      - * The entity resolver only handles queries for the DTD. It will find any URI - * with a recognised public id and return an {@link org.xml.sax.InputSource}. - *

      - * @author Joe Schmetzer - */ -public class DTDEntityResolver implements EntityResolver { - - /** Public ID for the AFP fonts 1.0 DTD. */ - public static final String AFP_DTD_1_0_ID - = "-//APACHE/DTD AFP Installed Font Definition DTD 1.0//EN"; - - /** Resource location for the AFP fonts 1.0 DTD. */ - public static final String AFP_DTD_1_0_RESOURCE - = "afp-fonts-1.0.dtd"; - - /** Public ID for the AFP fonts 1.1 DTD. */ - public static final String AFP_DTD_1_1_ID - = "-//APACHE/DTD AFP Installed Font Definition DTD 1.1//EN"; - - /** Resource location for the AFP fonts 1.1 DTD. */ - public static final String AFP_DTD_1_1_RESOURCE - = "afp-fonts-1.1.dtd"; - - /** Public ID for the AFP fonts 1.2 DTD. */ - public static final String AFP_DTD_1_2_ID - = "-//APACHE/DTD AFP Installed Font Definition DTD 1.2//EN"; - - /** Resource location for the AFP fonts 1.2 DTD. */ - public static final String AFP_DTD_1_2_RESOURCE - = "afp-fonts-1.2.dtd"; - - /** - * Resolve the combination of system and public identifiers. - * If this resolver recognises the publicId, it will handle the resolution - * from the classpath, otherwise it will return null and allow the default - * resolution to occur. - * - * @param publicId the public identifier to use - * @param systemId the system identifier to resolve - * @return An input source to the entity or null if not handled - * @throws IOException an error reading the stream - */ - public InputSource resolveEntity(String publicId, String systemId) - throws IOException { - - URL resource = null; - if ( AFP_DTD_1_2_ID.equals(publicId) ) { - resource = getResource( AFP_DTD_1_2_RESOURCE ); - } else if ( AFP_DTD_1_1_ID.equals(publicId) ) { - resource = getResource( AFP_DTD_1_1_RESOURCE ); - } else if ( AFP_DTD_1_0_ID.equals(publicId) ) { - throw new FontRuntimeException( - "The AFP Installed Font Definition 1.0 DTD is not longer supported" ); - } else if (systemId != null && systemId.indexOf("afp-fonts.dtd") >= 0 ) { - throw new FontRuntimeException( - "The AFP Installed Font Definition DTD must be specified using the public id" ); - } else { - return null; - } - - InputSource inputSource = new InputSource( resource.openStream() ); - inputSource.setPublicId( publicId ); - inputSource.setSystemId( systemId ); - - return inputSource; - } - - /** - * Returns the URL of a resource on the classpath - * @param resourceName the path to the resource relative to the root of the - * classpath. - * @return the URL of the required resource - * @throws FontRuntimeException if the resource could not be found. - */ - private URL getResource(String resourcePath) { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl == null) { - cl = ClassLoader.getSystemClassLoader(); - } - - URL resource = cl.getResource( resourcePath ); - if (resource == null) { - throw new FontRuntimeException( "Resource " + resourcePath - + "could not be found on the classpath" ); - } - - return resource; - } -} diff --git a/src/java/org/apache/fop/render/afp/tools/StringUtils.java b/src/java/org/apache/fop/render/afp/tools/StringUtils.java deleted file mode 100644 index c49509aa0..000000000 --- a/src/java/org/apache/fop/render/afp/tools/StringUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.tools; - -/** - * Library of utility methods useful in dealing with strings. - * - */ -public class StringUtils { - - /** - * Padds the string to the left with the given character for - * the specified length. - * @param input The input string. - * @param padding The char used for padding. - * @param length The length of the new string. - * @return The padded string. - */ - public static String lpad(String input, char padding, int length) { - - if (input == null) { - input = new String(); - } - - if (input.length() >= length) { - return input; - } else { - StringBuffer result = new StringBuffer(); - int numChars = length - input.length(); - for (int i = 0; i < numChars; i++) { - result.append(padding); - } - result.append(input); - return result.toString(); - } - } - - /** - * Padds the string to the right with the given character for - * the specified length. - * @param input The input string. - * @param padding The char used for padding. - * @param length The length of the new string. - * @return The padded string. - */ - public static String rpad(String input, char padding, int length) { - - if (input == null) { - input = new String(); - } - - if (input.length() >= length) { - return input; - } else { - StringBuffer result = new StringBuffer(input); - int numChars = length - input.length(); - for (int i = 0; i < numChars; i++) { - result.append(padding); - } - return result.toString(); - } - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java b/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java deleted file mode 100644 index 48beff023..000000000 --- a/src/java/org/apache/fop/render/afp/tools/StructuredFieldReader.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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.tools; - -import java.io.IOException; -import java.io.InputStream; - -/** - * A helper class to read structured fields from a MO:DCA document. Each - * component of a mixed object document is explicitly defined and delimited - * in the data. This is accomplished through the use of MO:DCA data structures, - * called structured fields. Structured fields are used to envelop document - * components and to provide commands and information to applications using - * the data. Structured fields may contain one or more parameters. Each - * parameter provides one value from a set of values defined by the architecture. - *

      - * MO:DCA structured fields consist of two parts: an introducer that identifies - * the length and type of the structured field, and data that provides the - * structured field's effect. The data is contained in a set of parameters, - * which can consist of other data structures and data elements. The maximum - * length of a structured field is 32767 bytes. - *

      - */ -public class StructuredFieldReader { - - /** - * The input stream to read - */ - private InputStream inputStream = null; - - /** - * The constructor for the StructuredFieldReader - * @param inputStream the input stream to process - */ - public StructuredFieldReader(InputStream inputStream) { - this.inputStream = inputStream; - } - - /** - * Get the next structured field as identified by the identifer - * parameter (this must be a valid MO:DCA structured field. - * @param identifier the three byte identifier - * @throws IOException if an I/O exception occurred - * @return the next structured field or null when there are no more - */ - public byte[] getNext(byte[] identifier) throws IOException { - - int bufferPointer = 0; - byte[] bufferData = new byte[identifier.length + 2]; - for (int x = 0; x < identifier.length; x++) { - bufferData[x] = 0x00; - } - - int c; - while ((c = inputStream.read()) > -1) { - - bufferData[bufferPointer] = (byte) c; - - // Check the last characters in the buffer - int index = 0; - boolean found = true; - - for (int i = identifier.length - 1; i > -1; i--) { - - int p = bufferPointer - index; - if (p < 0) { - p = bufferData.length + p; - } - - index++; - - if (identifier[i] != bufferData[p]) { - found = false; - break; - } - - } - - if (found) { - - byte[] length = new byte[2]; - - int a = bufferPointer - identifier.length; - if (a < 0) { - a = bufferData.length + a; - } - - int b = bufferPointer - identifier.length - 1; - if (b < 0) { - b = bufferData.length + b; - } - - length[0] = bufferData[b]; - length[1] = bufferData[a]; - - int reclength = ((length[0] & 0xFF) << 8) - + (length[1] & 0xFF) - identifier.length - 2; - - byte[] retval = new byte[reclength]; - - inputStream.read(retval, 0, reclength); - - return retval; - - } - - bufferPointer++; - if (bufferPointer >= bufferData.length) { - bufferPointer = 0; - } - - } - - return null; - } -} diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 61ed1ff07..cc1caea03 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -50,6 +50,7 @@ import org.apache.xmlgraphics.xmp.Metadata; import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter; import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema; +import org.apache.fop.AbstractState; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; @@ -112,7 +113,6 @@ import org.apache.fop.pdf.PDFTextUtil; import org.apache.fop.pdf.PDFXMode; import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.AbstractPathOrientedRenderer; -import org.apache.fop.render.AbstractState; import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.util.CharUtilities; diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java index 31cb4b605..7c525dbf7 100644 --- a/src/java/org/apache/fop/render/ps/PSTextPainter.java +++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java @@ -38,6 +38,9 @@ import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontTriplet; import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; import org.apache.xmlgraphics.java2d.TextHandler; @@ -51,9 +54,6 @@ import org.apache.batik.gvt.text.TextPaintInfo; import org.apache.batik.gvt.font.GVTFontFamily; import org.apache.batik.gvt.renderer.StrokingTextPainter; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontTriplet; /** * Renders the attributed character iterator of a TextNode. diff --git a/src/java/org/apache/fop/store/FileStore.java b/src/java/org/apache/fop/store/FileStore.java deleted file mode 100644 index 131daf32b..000000000 --- a/src/java/org/apache/fop/store/FileStore.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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.store; - -import java.io.File; -import java.io.FileDescriptor; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.RandomAccessFile; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.xmlgraphics.image.loader.ImageManager; - -/** - * A useful class which is able to easily store and retrieve large resources (such as images) - */ -public class FileStore { - - /** logger */ - protected static Log log = LogFactory.getLog(ImageManager.class); - - /** Internal temporary storage buffer size */ - private static final int BUFFER_SIZE = 4096; - - /** Used for storage of data objects */ - protected RandomAccessFile raFile; - - /** The temporary cache file */ - private File tempFile; - - /** The file outputstream */ - protected FileOutputStream fos; - - /** - * Default constructor - * - * @param prefix file store prefix - */ - public FileStore(String prefix) { - try { - this.tempFile = File.createTempFile(prefix, null); - this.raFile = new RandomAccessFile(tempFile, "rw"); - FileDescriptor fd = raFile.getFD(); - this.fos = new FileOutputStream(fd); - } catch (IOException e) { - // TODO - log.error(e.getMessage()); - } - } - - /** - * Clears the resource store. - * - * @throws IOException if an error occurs while clearing the store - */ - public void clear() throws IOException { - if (tempFile != null) { - raFile.close(); - raFile = null; - fos = null; - if (tempFile.exists() && !tempFile.delete()) { - throw new IOException("Could not delete temporary file: " + tempFile); - } - tempFile = null; - } - } - - /** {@inheritDoc} */ - public void finalize() throws Throwable { - try { - clear(); - } finally { - super.finalize(); - } - } - - /** - * Returns the storer of a given object - * - * @param object an object to be stored - * @return a storer of the object - */ - protected Storer getStorer(Object object) { - Storer storer; - if (object instanceof Writable) { - storer = new WritableStorer(this, (Writable)object); - } else if (object instanceof InputStream) { - storer = new InputStreamStorer(this, (InputStream)object); - } else { - throw new IllegalArgumentException("Unsupported object " + object); - } - return storer; - } - - /** - * Stores an object in the cache - * - * @param object the object to store - * @return a new save information record - * - * @throws java.io.IOException an I/O exception of some sort has occurred. - */ - public StoreRecord write(Object object) throws IOException { - return getStorer(object).store(); - } - - /** - * Reads all the data from a given store information record - * and returns it in a byte array. - * This is potentially a memory hungry operation so use with care. - * - * @param storeInfo a store information record - * @return the stored data in a byte array. - * @throws java.io.IOException an I/O exception of some sort has occurred. - */ - public byte[] read(StoreRecord storeInfo) throws IOException { - raFile.seek(storeInfo.position); - byte[] buff = new byte[storeInfo.size]; - raFile.read(buff); - return buff; - } - - /** - * Writes out the resource in full using the store information to the given outputstream. - * - * @param storeInfo the save information - * @param os the outputstream to write to - * - * @throws java.io.IOException an I/O exception of some sort has occurred. - */ - public void writeToStream(StoreRecord storeInfo, OutputStream os) throws IOException { - if (storeInfo == null) { - throw new IllegalArgumentException("save is null"); - } - double chunkCount = storeInfo.size / BUFFER_SIZE; - byte[] buffer = new byte[BUFFER_SIZE]; - raFile.seek(storeInfo.position); - for (int cnt = 0; cnt < chunkCount; cnt++) { - raFile.read(buffer, 0, BUFFER_SIZE); - os.write(buffer, 0, BUFFER_SIZE); - } - int lastChunkLength = storeInfo.size % BUFFER_SIZE; - raFile.read(buffer, 0, lastChunkLength); - os.write(buffer, 0, lastChunkLength); - } -} diff --git a/src/java/org/apache/fop/store/InputStreamStorer.java b/src/java/org/apache/fop/store/InputStreamStorer.java deleted file mode 100644 index 5d72c932f..000000000 --- a/src/java/org/apache/fop/store/InputStreamStorer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.store; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.commons.io.IOUtils; - -/** - * Storer of InputStreams - */ -public final class InputStreamStorer extends Storer { - - /** an inputstream */ - private final InputStream in; - - /** - * Constructor - * - * @param store our resource store - * @param in an inputstream - */ - protected InputStreamStorer(FileStore store, InputStream in) { - super(store); - this.in = in; - } - - /** {@inheritDoc} */ - protected void doStore() throws IOException { - IOUtils.copy(in, store.fos); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/store/StoreRecord.java b/src/java/org/apache/fop/store/StoreRecord.java deleted file mode 100644 index f4dd8ff49..000000000 --- a/src/java/org/apache/fop/store/StoreRecord.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.store; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * Store save information - */ -public class StoreRecord { - - /** the resource store associated with this store information */ - private final FileStore store; - - /** data position */ - protected long position; - - /** data chunk size */ - protected int size; - - /** - * Main constructor - * - * @param store our resource store - */ - public StoreRecord(FileStore store) { - this.store = store; - } - - /** - * Returns the storage position - * - * @return the storage position - */ - public long getPosition() { - return this.position; - } - - /** - * Returns the storage size - * - * @return the storage size - */ - public int getLength() { - return this.size; - } - - /** - * Returns the resource store associated with this store record - * - * @return the resource store associated with this store record - */ - public FileStore getStore() { - return this.store; - } - - /** - * Convenience method used to writes the data referenced - * by this storage record to an outputstream - * - * @param os the outputstream to write to - * @throws java.io.IOException an I/O exception of some sort has occurred. - */ - public void writeToStream(OutputStream os) throws IOException { - store.writeToStream(this, os); - } - - /** {@inheritDoc} */ - public String toString() { - return "pos=" + position + ", size=" + size; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/store/Storer.java b/src/java/org/apache/fop/store/Storer.java deleted file mode 100644 index d8dbab191..000000000 --- a/src/java/org/apache/fop/store/Storer.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.store; - -import java.io.IOException; - -/** - * Base storer class - */ -public class Storer { - - /** write session */ - protected final WriteSession session; - - /** file store */ - protected final FileStore store; - - /** - * Constructor - * - * @param store our resource store - */ - public Storer(FileStore store) { - this.store = store; - this.session = new WriteSession(this); - } - - /** - * Instantiates the store information record - * - * @return a new store information record - */ - protected StoreRecord createRecord() { - return new StoreRecord(store); - } - - /** - * Stores the object - * - * @return a store information record - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public StoreRecord store() throws IOException { - StoreRecord record = null; - session.begin(); - try { - doStore(); - } finally { - record = session.end(); - } - return record; - } - - /** - * Actually performs the store operation - * - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - protected void doStore() throws IOException { - } - - /** - * Returns the file store associated with this storer - * - * @return the file store associated with this storer - */ - protected FileStore getStore() { - return store; - } -} diff --git a/src/java/org/apache/fop/store/Writable.java b/src/java/org/apache/fop/store/Writable.java deleted file mode 100644 index 8f6052261..000000000 --- a/src/java/org/apache/fop/store/Writable.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.store; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * Implementing object is able to write to an OutputStream - */ -public interface Writable { - - /** - * DataStream objects must implement the writeToStream() - * method to write its data to the given OutputStream - * - * @param outputStream The outputsteam stream - * @throws java.io.IOException an I/O exception of some sort has occurred. - */ - void writeToStream(OutputStream outputStream) throws IOException; -} diff --git a/src/java/org/apache/fop/store/WritableStorer.java b/src/java/org/apache/fop/store/WritableStorer.java deleted file mode 100644 index bba11287e..000000000 --- a/src/java/org/apache/fop/store/WritableStorer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.store; - -import java.io.IOException; - -/** - * Storer of objects that implement the Writable interface - */ -public class WritableStorer extends Storer { - - /** a Writable object */ - protected final Writable writable; - - /** - * Constructor - * - * @param store our resource store - * @param writable an object implementing the Writable interface - */ - public WritableStorer(FileStore store, Writable writable) { - super(store); - this.writable = writable; - } - - /** {@inheritDoc} */ - protected void doStore() throws IOException { - writable.writeToStream(store.fos); - } -} diff --git a/src/java/org/apache/fop/store/WriteSession.java b/src/java/org/apache/fop/store/WriteSession.java deleted file mode 100644 index 034357355..000000000 --- a/src/java/org/apache/fop/store/WriteSession.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.store; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * A Write session - */ -public class WriteSession { - /** true if the session output was flushed */ - protected boolean flushed = false; - - /** the session storer */ - private final Storer storer; - - /** the storer's file store */ - private final FileStore store; - - /** the store information record */ - protected StoreRecord record; - - /** - * Constructor - * - * @param store our store - */ - public WriteSession(FileStore store) { - this.storer = new Storer(store); - this.store = store; - } - - /** - * Constructor - * - * @param storer our storer - */ - public WriteSession(Storer storer) { - this.storer = storer; - this.store = storer.getStore(); - } - - /** - * Begins the session - * - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public void begin() throws IOException { - // always write to the end of the store - long length = store.raFile.length(); - if (store.raFile.getFilePointer() < length) { - store.raFile.seek(length); - } - - this.record = storer.createRecord(); - record.position = store.raFile.getFilePointer(); - } - - /** - * Ends the session - * - * @return a new store information record - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public StoreRecord end() throws IOException { - if (!flushed) { - store.fos.flush(); - flushed = true; - } - record.size = (int)(store.raFile.getFilePointer() - record.position); - return record; - } - - /** - * Returns the outputstream of this store - * - * @return the outputstream of this store - */ - public OutputStream getOutputStream() { - return store.fos; - } - - /** - * Returns the store record - * - * @return the store record - */ - public StoreRecord getRecord() { - return record; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/svg/GraphicsConfiguration.java b/src/java/org/apache/fop/svg/GraphicsConfiguration.java index ca3b3363c..881096b9a 100644 --- a/src/java/org/apache/fop/svg/GraphicsConfiguration.java +++ b/src/java/org/apache/fop/svg/GraphicsConfiguration.java @@ -17,7 +17,6 @@ /* $Id$ */ - package org.apache.fop.svg; import java.awt.image.VolatileImage; diff --git a/src/java/org/apache/fop/svg/PDFBridgeContext.java b/src/java/org/apache/fop/svg/PDFBridgeContext.java index fdf83784f..6aa29cfa1 100644 --- a/src/java/org/apache/fop/svg/PDFBridgeContext.java +++ b/src/java/org/apache/fop/svg/PDFBridgeContext.java @@ -26,11 +26,11 @@ import org.apache.batik.bridge.Bridge; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.DocumentLoader; import org.apache.batik.bridge.UserAgent; +import org.apache.fop.fonts.FontInfo; import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; -import org.apache.fop.fonts.FontInfo; /** * BridgeContext which registers the custom bridges for PDF output. diff --git a/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java b/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java index 83a431d5e..0204a2756 100644 --- a/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java +++ b/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java @@ -26,6 +26,7 @@ import java.awt.image.ColorModel; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; + /** * Our implementation of the class that returns information about * roughly what we can handle and want to see (alpha for example). -- cgit v1.2.3 From c550e0349a64c0c66d6cee0f2e6f1baa97e14ad2 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Fri, 31 Oct 2008 09:58:46 +0000 Subject: Fix for test/layoutengine/standard-testcases/block-container_absolute-position_fixed.xml. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@709373 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/AbstractData.java | 128 ++++++++++++ src/java/org/apache/fop/AbstractState.java | 232 +++++++-------------- src/java/org/apache/fop/StateStack.java | 31 +++ src/java/org/apache/fop/afp/AFPState.java | 8 +- src/java/org/apache/fop/pdf/PDFState.java | 22 +- .../fop/render/AbstractPathOrientedRenderer.java | 13 +- .../org/apache/fop/render/afp/AFPRenderer.java | 20 +- .../org/apache/fop/render/pdf/PDFRenderer.java | 32 +-- 8 files changed, 284 insertions(+), 202 deletions(-) create mode 100644 src/java/org/apache/fop/AbstractData.java create mode 100644 src/java/org/apache/fop/StateStack.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/AbstractData.java b/src/java/org/apache/fop/AbstractData.java new file mode 100644 index 000000000..b689165a0 --- /dev/null +++ b/src/java/org/apache/fop/AbstractData.java @@ -0,0 +1,128 @@ +package org.apache.fop; + +import java.awt.Color; +import java.awt.geom.AffineTransform; +import java.io.Serializable; + +/** + * A base state data holding object + */ +public abstract class AbstractData implements Cloneable, Serializable { + + private static final long serialVersionUID = 5208418041189828624L; + + /** The current color */ + protected Color color = null; + + /** The current background color */ + protected Color backColor = null; + + /** The current font name */ + protected String fontName = null; + + /** The current font size */ + protected int fontSize = 0; + + /** The current line width */ + protected float lineWidth = 0; + + /** The dash array for the current basic stroke (line type) */ + protected float[] dashArray = null; + + /** The current transform */ + protected AffineTransform transform = null; + + /** + * Returns a newly create data object + * + * @return a new data object + */ + protected abstract AbstractData instantiate(); + + /** + * Concatenate the given AffineTransform with the current thus creating + * a new viewport. Note that all concatenation operations are logged + * so they can be replayed if necessary (ex. for block-containers with + * "fixed" positioning. + * + * @param at Transformation to perform + */ + public void concatenate(AffineTransform at) { + getTransform().concatenate(at); + } + + /** + * Get the current AffineTransform. + * + * @return the current transform + */ + public AffineTransform getTransform() { + if (transform == null) { + transform = new AffineTransform(); + } + return transform; + } + + /** + * Sets the current AffineTransform. + */ + public void setTransform(AffineTransform baseTransform) { + this.transform = baseTransform; + } + + /** + * Resets the current AffineTransform. + */ + public void clearTransform() { + transform = new AffineTransform(); + } + + /** + * Returns the derived rotation from the current transform + * + * @return the derived rotation from the current transform + */ + public int getDerivedRotation() { + AffineTransform at = getTransform(); + double sx = at.getScaleX(); + double sy = at.getScaleY(); + double shx = at.getShearX(); + double shy = at.getShearY(); + int rotation = 0; + if (sx == 0 && sy == 0 && shx > 0 && shy < 0) { + rotation = 270; + } else if (sx < 0 && sy < 0 && shx == 0 && shy == 0) { + rotation = 180; + } else if (sx == 0 && sy == 0 && shx < 0 && shy > 0) { + rotation = 90; + } else { + rotation = 0; + } + return rotation; + } + + /** {@inheritDoc} */ + public Object clone() { + AbstractData data = instantiate(); + data.color = this.color; + data.backColor = this.backColor; + data.fontName = this.fontName; + data.fontSize = this.fontSize; + data.lineWidth = this.lineWidth; + data.dashArray = this.dashArray; + data.transform = new AffineTransform(this.transform); + return data; + } + + /** {@inheritDoc} */ + public String toString() { + return "color=" + color + + ", backColor=" + backColor + + ", fontName=" + fontName + + ", fontSize=" + fontSize + + ", lineWidth=" + lineWidth + + ", dashArray=" + dashArray + + ", transform=" + transform; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/AbstractState.java b/src/java/org/apache/fop/AbstractState.java index 851c50e76..74719e8f8 100644 --- a/src/java/org/apache/fop/AbstractState.java +++ b/src/java/org/apache/fop/AbstractState.java @@ -23,8 +23,8 @@ import java.awt.Color; import java.awt.geom.AffineTransform; import java.io.Serializable; import java.util.Arrays; -import java.util.Collection; import java.util.Iterator; +import java.util.List; import java.util.Stack; @@ -33,11 +33,13 @@ import java.util.Stack; */ public abstract class AbstractState implements Cloneable, Serializable { + private static final long serialVersionUID = 5998356138437094188L; + /** current state data */ - private AbstractData currentData = null; + private AbstractData data = null; /** the state stack */ - private StateStack stateStack = null; + private StateStack stateStack = new StateStack(); /** * Instantiates a new state data object @@ -59,10 +61,10 @@ public abstract class AbstractState implements Cloneable, Serializable { * @return the currently valid state */ public AbstractData getData() { - if (currentData == null) { - currentData = instantiateData(); + if (data == null) { + data = instantiateData(); } - return currentData; + return data; } /** @@ -212,7 +214,7 @@ public abstract class AbstractState implements Cloneable, Serializable { */ public AffineTransform getTransform() { AffineTransform at = new AffineTransform(); - for (Iterator iter = getStateStack().iterator(); iter.hasNext();) { + for (Iterator iter = stateStack.iterator(); iter.hasNext();) { AbstractData data = (AbstractData)iter.next(); AffineTransform stackTrans = data.getTransform(); at.concatenate(stackTrans); @@ -242,10 +244,10 @@ public abstract class AbstractState implements Cloneable, Serializable { * @return the base transform, or null if the state stack is empty */ public AffineTransform getBaseTransform() { - if (getStateStack().isEmpty()) { + if (stateStack.isEmpty()) { return null; } else { - AbstractData baseData = (AbstractData)getStateStack().get(0); + AbstractData baseData = (AbstractData)stateStack.get(0); return (AffineTransform) baseData.getTransform().clone(); } } @@ -260,12 +262,20 @@ public abstract class AbstractState implements Cloneable, Serializable { } /** - * Resets the current AffineTransform. + * Resets the current AffineTransform to the Base AffineTransform. */ public void resetTransform() { - getData().resetTransform(); + getData().setTransform(getBaseTransform()); + } + + /** + * Clears the current AffineTransform to the Identity AffineTransform + */ + public void clearTransform() { + getData().clearTransform(); } + /** * Push the current state onto the stack. * This call should be used when the Q operator is used @@ -273,7 +283,7 @@ public abstract class AbstractState implements Cloneable, Serializable { */ public void push() { AbstractData copy = (AbstractData)getData().clone(); - getStateStack().push(copy); + stateStack.push(copy); } /** @@ -284,20 +294,62 @@ public abstract class AbstractState implements Cloneable, Serializable { * @return the restored state, null if the stack is empty */ public AbstractData pop() { - if (!getStateStack().isEmpty()) { - this.currentData = (AbstractData)getStateStack().pop(); - return this.currentData; + if (!stateStack.isEmpty()) { + setData((AbstractData)stateStack.pop()); + return this.data; } else { return null; } } + /** + * Pushes all state data in the given list to the stack + * + * @param dataList a state data list + */ + public void pushAll(List/**/ dataList) { + Iterator it = dataList.iterator(); + while (it.hasNext()) { + // save current data on stack + push(); + setData((AbstractData)it.next()); + } + } + + /** + * Pops all state data from the stack + * + * @return a list of state data popped from the stack + */ + public List/**/ popAll() { + List/**/ dataList = new java.util.ArrayList/**/(); + AbstractData data; + while (true) { + data = getData(); + if (pop() == null) { + break; + } + // insert because of stack-popping + dataList.add(0, data); + } + return dataList; + } + + /** + * Sets the current state data + * + * @param currentData state data + */ + protected void setData(AbstractData data) { + this.data = data; + } + /** * Clears the state stack */ public void clear() { - getStateStack().clear(); - currentData = null; + stateStack.clear(); + setData(null); } /** @@ -306,160 +358,20 @@ public abstract class AbstractState implements Cloneable, Serializable { * @return the state stack */ protected Stack/**/ getStateStack() { - if (stateStack == null) { - stateStack = new StateStack(); - } - return stateStack; + return this.stateStack; } /** {@inheritDoc} */ public Object clone() { AbstractState state = instantiateState(); state.stateStack = new StateStack(this.stateStack); - state.currentData = (AbstractData)this.currentData.clone(); + state.data = (AbstractData)this.data.clone(); return state; } /** {@inheritDoc} */ public String toString() { return ", stateStack=" + stateStack - + ", currentData=" + currentData; - } - - /** - * A base state data holding object - */ - public abstract class AbstractData implements Cloneable, Serializable { - - private static final long serialVersionUID = 5208418041189828624L; - - /** The current color */ - private Color color = null; - - /** The current background color */ - private Color backColor = null; - - /** The current font name */ - private String fontName = null; - - /** The current font size */ - private int fontSize = 0; - - /** The current line width */ - private float lineWidth = 0; - - /** The dash array for the current basic stroke (line type) */ - private float[] dashArray = null; - - /** The current transform */ - private AffineTransform transform = null; - - /** - * Concatenate the given AffineTransform with the current thus creating - * a new viewport. Note that all concatenation operations are logged - * so they can be replayed if necessary (ex. for block-containers with - * "fixed" positioning. - * - * @param at Transformation to perform - */ - public void concatenate(AffineTransform at) { - getTransform().concatenate(at); - } - - /** - * Get the current AffineTransform. - * - * @return the current transform - */ - public AffineTransform getTransform() { - if (transform == null) { - transform = new AffineTransform(); - } - return transform; - } - - /** - * Resets the current AffineTransform. - */ - public void resetTransform() { - transform = getBaseTransform(); -// transform = new AffineTransform(); - } - - /** - * Returns the derived rotation from the current transform - * - * @return the derived rotation from the current transform - */ - public int getDerivedRotation() { - AffineTransform at = getTransform(); - double sx = at.getScaleX(); - double sy = at.getScaleY(); - double shx = at.getShearX(); - double shy = at.getShearY(); - int rotation = 0; - if (sx == 0 && sy == 0 && shx > 0 && shy < 0) { - rotation = 270; - } else if (sx < 0 && sy < 0 && shx == 0 && shy == 0) { - rotation = 180; - } else if (sx == 0 && sy == 0 && shx < 0 && shy > 0) { - rotation = 90; - } else { - rotation = 0; - } - return rotation; - } - - /** {@inheritDoc} */ - public Object clone() { - AbstractData data = instantiateData(); - data.color = this.color; - data.backColor = this.backColor; - data.fontName = this.fontName; - data.fontSize = this.fontSize; - data.lineWidth = this.lineWidth; - data.dashArray = this.dashArray; - data.transform = new AffineTransform(this.transform); - return data; - } - - /** {@inheritDoc} */ - public String toString() { - return "color=" + color - + ", backColor=" + backColor - + ", fontName=" + fontName - + ", fontSize=" + fontSize - + ", lineWidth=" + lineWidth - + ", dashArray=" + dashArray - + ", transform=" + transform; - } - } - - /** - * No copy constructor for java.util.Stack so extended and implemented one. - */ - private class StateStack extends java.util.Stack { - - private static final long serialVersionUID = 4897178211223823041L; - - /** - * Default constructor - */ - public StateStack() { - super(); - } - - /** - * Copy constructor - * - * @param c initial contents of stack - */ - public StateStack(Collection c) { - elementCount = c.size(); - // 10% for growth - elementData = new Object[ - (int)Math.min((elementCount * 110L) / 100, Integer.MAX_VALUE)]; - c.toArray(elementData); - } + + ", currentData=" + data; } } diff --git a/src/java/org/apache/fop/StateStack.java b/src/java/org/apache/fop/StateStack.java new file mode 100644 index 000000000..0c73b4829 --- /dev/null +++ b/src/java/org/apache/fop/StateStack.java @@ -0,0 +1,31 @@ +package org.apache.fop; + +import java.util.Collection; + +/** + * No copy constructor for java.util.Stack so extended and implemented one. + */ +class StateStack extends java.util.Stack { + + private static final long serialVersionUID = 4897178211223823041L; + + /** + * Default constructor + */ + public StateStack() { + super(); + } + + /** + * Copy constructor + * + * @param c initial contents of stack + */ + public StateStack(Collection c) { + elementCount = c.size(); + // 10% for growth + elementData = new Object[ + (int)Math.min((elementCount * 110L) / 100, Integer.MAX_VALUE)]; + c.toArray(elementData); + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPState.java b/src/java/org/apache/fop/afp/AFPState.java index 9de3a0c05..7e63ea01e 100644 --- a/src/java/org/apache/fop/afp/AFPState.java +++ b/src/java/org/apache/fop/afp/AFPState.java @@ -21,6 +21,7 @@ package org.apache.fop.afp; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.AbstractData; import org.apache.fop.AbstractState; /** @@ -483,7 +484,7 @@ public class AFPState extends org.apache.fop.AbstractState implements Cloneable /** * Block level state data */ - private class AFPData extends org.apache.fop.AbstractState.AbstractData { + private class AFPData extends org.apache.fop.AbstractData { private static final long serialVersionUID = -1789481244175275686L; /** The current fill status */ @@ -506,6 +507,11 @@ public class AFPState extends org.apache.fop.AbstractState implements Cloneable + ", imageUri=" + imageUri + "}"; } + + /** {@inheritDoc} */ + protected AbstractData instantiate() { + return new AFPData(); + } } } \ No newline at end of file diff --git a/src/java/org/apache/fop/pdf/PDFState.java b/src/java/org/apache/fop/pdf/PDFState.java index 138458552..3804c189a 100644 --- a/src/java/org/apache/fop/pdf/PDFState.java +++ b/src/java/org/apache/fop/pdf/PDFState.java @@ -19,12 +19,13 @@ package org.apache.fop.pdf; -import java.util.Iterator; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.Area; import java.awt.geom.GeneralPath; +import java.util.Iterator; +import org.apache.fop.AbstractData; import org.apache.fop.AbstractState; /** @@ -165,7 +166,19 @@ public class PDFState extends org.apache.fop.AbstractState { return new PDFState(); } - private class PDFData extends org.apache.fop.AbstractState.AbstractData { + /** + * Push the current state onto the stack. + * This call should be used when the q operator is used + * so that the state is known when popped. + */ + public void push() { + AbstractData data = getData(); + AbstractData copy = (AbstractData)data.clone(); + data.clearTransform(); + getStateStack().add(copy); + } + + private class PDFData extends org.apache.fop.AbstractData { private static final long serialVersionUID = 3527950647293177764L; @@ -206,6 +219,11 @@ public class PDFState extends org.apache.fop.AbstractState { + ", clip=" + clip + ", gstate=" + gstate; } + + /** {@inheritDoc} */ + protected AbstractData instantiate() { + return new PDFData(); + } } } diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index 0496cf740..e74a8f319 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -486,14 +486,14 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { CTM ctm = bv.getCTM(); int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore(); - if (bv.getPositioning() == Block.ABSOLUTE - || bv.getPositioning() == Block.FIXED) { + int positioning = bv.getPositioning(); + if (positioning == Block.ABSOLUTE || positioning == Block.FIXED) { //For FIXED, we need to break out of the current viewports to the //one established by the page. We save the state stack for restoration //after the block-container has been painted. See below. List breakOutList = null; - if (bv.getPositioning() == Block.FIXED) { + if (positioning == Block.FIXED) { breakOutList = breakOutOfStateStack(); } @@ -564,8 +564,11 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { restoreGraphicsState(); } - if (breakOutList != null) { - restoreStateStackAfterBreakOut(breakOutList); + //For FIXED, we need to restore break out now we are done + if (positioning == Block.FIXED) { + if (breakOutList != null) { + restoreStateStackAfterBreakOut(breakOutList); + } } currentIPPosition = saveIP; diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index d0737ed70..03945dfee 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -169,7 +169,6 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { private AFPRectanglePainter rectanglePainter; - /** * Constructor for AFPRenderer. */ @@ -509,28 +508,13 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public void restoreStateStackAfterBreakOut(List breakOutList) { log.debug("Block.FIXED --> restoring context after break-out"); - AbstractState.AbstractData data; - Iterator it = breakOutList.iterator(); - while (it.hasNext()) { - data = (AbstractState.AbstractData)it.next(); - saveGraphicsState(); - concatenateTransformationMatrix(data.getTransform()); - } + state.pushAll(breakOutList); } /** {@inheritDoc} */ protected List breakOutOfStateStack() { log.debug("Block.FIXED --> break out"); - List breakOutList = new java.util.ArrayList(); - AbstractState.AbstractData data; - while (true) { - data = state.getData(); - if (state.pop() == null) { - break; - } - breakOutList.add(0, data); //Insert because of stack-popping - } - return breakOutList; + return state.popAll(); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index cc1caea03..9f60d3c86 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -40,17 +40,7 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import org.apache.commons.io.IOUtils; - -import org.apache.xmlgraphics.image.loader.ImageException; -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.image.loader.util.ImageUtil; -import org.apache.xmlgraphics.xmp.Metadata; -import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter; -import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema; - -import org.apache.fop.AbstractState; +import org.apache.fop.AbstractData; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; @@ -118,6 +108,14 @@ import org.apache.fop.render.RendererContext; import org.apache.fop.util.CharUtilities; import org.apache.fop.util.ColorProfileUtil; import org.apache.fop.util.ColorUtil; +import org.apache.xmlgraphics.image.loader.ImageException; +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.image.loader.util.ImageUtil; +import org.apache.xmlgraphics.xmp.Metadata; +import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter; +import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema; /** * Renderer that renders areas to PDF. @@ -263,7 +261,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { protected Map filterMap; /** Image handler registry */ - private PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry(); + private final PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry(); /** * create the PDF renderer @@ -1095,8 +1093,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * @return the saved state stack to recreate later */ protected List breakOutOfStateStack() { +// return currentState.popAll(); List breakOutList = new java.util.ArrayList(); - AbstractState.AbstractData data; + AbstractData data; while (true) { data = currentState.getData(); if (currentState.pop() == null) { @@ -1117,10 +1116,11 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { */ protected void restoreStateStackAfterBreakOut(List breakOutList) { comment("------ restoring context after break-out..."); - AbstractState.AbstractData data; +// currentState.pushAll(breakOutList); + AbstractData data; Iterator i = breakOutList.iterator(); while (i.hasNext()) { - data = (AbstractState.AbstractData)i.next(); + data = (AbstractData)i.next(); saveGraphicsState(); AffineTransform at = data.getTransform(); concatenateTransformationMatrix(at); @@ -1609,7 +1609,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { endTextObject(); putImage(url, pos, foreignAttributes); } - + /** * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced. * @param uri URL of the bitmap -- cgit v1.2.3 From 74355f1f4b9ce01d9ad26c4c42ad025daff1263f Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Tue, 4 Nov 2008 15:30:38 +0000 Subject: "fixed" block container handling fixed (see block-container_absolute-position_fixed.xml). Barcode4J generating barcodes correctly for both GOCA and conversion-mode="bitmap". AbstractGenericSVGHandler now declares use of static final String BITMAP which is used by concrete subclasses and provides overridable methods. for buildGraphicsNode() and createPainter(). *State classes are now renamed *PaintingState. AFPImageGraphics2DFactory - painter is not overriden but is now instead prepared for y-axis inversion. AFPGraphics2DAdapter - commented lines removed. Inlining now only done when the graphic is a non conversion-mode="bitmap". git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@711273 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/AbstractData.java | 128 ----- src/java/org/apache/fop/AbstractState.java | 377 --------------- src/java/org/apache/fop/StateStack.java | 31 -- .../fop/afp/AFPAbstractGraphicsObjectPainter.java | 62 --- src/java/org/apache/fop/afp/AFPBorderPainter.java | 6 +- src/java/org/apache/fop/afp/AFPGraphics2D.java | 20 +- src/java/org/apache/fop/afp/AFPPaintingState.java | 516 ++++++++++++++++++++ .../org/apache/fop/afp/AFPRectanglePainter.java | 4 +- src/java/org/apache/fop/afp/AFPResourceLevel.java | 2 +- .../org/apache/fop/afp/AFPResourceManager.java | 4 +- src/java/org/apache/fop/afp/AFPState.java | 517 -------------------- src/java/org/apache/fop/afp/AFPStreamer.java | 4 +- src/java/org/apache/fop/afp/AFPTextHandler.java | 2 +- src/java/org/apache/fop/afp/AFPUnitConverter.java | 6 +- .../org/apache/fop/afp/AbstractAFPPainter.java | 4 +- src/java/org/apache/fop/afp/Factory.java | 4 +- .../apache/fop/afp/Graphics2DImagePainterGOCA.java | 71 +++ src/java/org/apache/fop/afp/ioca/ImageContent.java | 1 + src/java/org/apache/fop/afp/modca/DataStream.java | 10 +- .../loader/batik/BatikGraphics2DImagePainter.java | 95 ---- .../loader/batik/Graphics2DImagePainterImpl.java | 64 +++ .../image/loader/batik/ImageConverterSVG2G2D.java | 18 +- src/java/org/apache/fop/pdf/PDFPaintingState.java | 229 +++++++++ src/java/org/apache/fop/pdf/PDFState.java | 230 --------- .../fop/render/AbstractGenericSVGHandler.java | 102 ++-- .../fop/render/AbstractGraphics2DAdapter.java | 1 + .../fop/render/afp/AFPAbstractImageFactory.java | 8 +- .../render/afp/AFPBatikGraphicsObjectPainter.java | 72 --- .../fop/render/afp/AFPDataObjectInfoFactory.java | 8 +- .../fop/render/afp/AFPDataObjectInfoProvider.java | 10 +- .../fop/render/afp/AFPGraphics2DAdapter.java | 54 +-- .../fop/render/afp/AFPImageGraphics2DFactory.java | 64 +-- .../fop/render/afp/AFPImageRawStreamFactory.java | 6 +- .../fop/render/afp/AFPImageRenderedFactory.java | 6 +- src/java/org/apache/fop/render/afp/AFPInfo.java | 14 +- .../fop/render/afp/AFPRawCCITTFaxFactory.java | 6 +- .../org/apache/fop/render/afp/AFPRenderer.java | 94 ++-- .../render/afp/AFPRendererContextConstants.java | 4 +- .../org/apache/fop/render/afp/AFPSVGHandler.java | 91 ++-- .../fop/render/afp/GraphicsObjectPainterAFP.java | 89 ++++ .../apache/fop/render/java2d/Java2DSVGHandler.java | 9 +- .../fop/render/pdf/PDFGraphics2DAdapter.java | 4 +- .../org/apache/fop/render/pdf/PDFRenderer.java | 49 +- .../render/pdf/PDFRendererContextConstants.java | 4 +- .../org/apache/fop/render/pdf/PDFSVGHandler.java | 32 +- .../org/apache/fop/svg/PDFDocumentGraphics2D.java | 40 +- src/java/org/apache/fop/svg/PDFGraphics2D.java | 75 +-- .../org/apache/fop/util/AbstractPaintingState.java | 530 +++++++++++++++++++++ 48 files changed, 1888 insertions(+), 1889 deletions(-) delete mode 100644 src/java/org/apache/fop/AbstractData.java delete mode 100644 src/java/org/apache/fop/AbstractState.java delete mode 100644 src/java/org/apache/fop/StateStack.java delete mode 100644 src/java/org/apache/fop/afp/AFPAbstractGraphicsObjectPainter.java create mode 100644 src/java/org/apache/fop/afp/AFPPaintingState.java delete mode 100644 src/java/org/apache/fop/afp/AFPState.java create mode 100644 src/java/org/apache/fop/afp/Graphics2DImagePainterGOCA.java delete mode 100644 src/java/org/apache/fop/image/loader/batik/BatikGraphics2DImagePainter.java create mode 100644 src/java/org/apache/fop/image/loader/batik/Graphics2DImagePainterImpl.java create mode 100644 src/java/org/apache/fop/pdf/PDFPaintingState.java delete mode 100644 src/java/org/apache/fop/pdf/PDFState.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPBatikGraphicsObjectPainter.java create mode 100644 src/java/org/apache/fop/render/afp/GraphicsObjectPainterAFP.java create mode 100644 src/java/org/apache/fop/util/AbstractPaintingState.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/AbstractData.java b/src/java/org/apache/fop/AbstractData.java deleted file mode 100644 index b689165a0..000000000 --- a/src/java/org/apache/fop/AbstractData.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.apache.fop; - -import java.awt.Color; -import java.awt.geom.AffineTransform; -import java.io.Serializable; - -/** - * A base state data holding object - */ -public abstract class AbstractData implements Cloneable, Serializable { - - private static final long serialVersionUID = 5208418041189828624L; - - /** The current color */ - protected Color color = null; - - /** The current background color */ - protected Color backColor = null; - - /** The current font name */ - protected String fontName = null; - - /** The current font size */ - protected int fontSize = 0; - - /** The current line width */ - protected float lineWidth = 0; - - /** The dash array for the current basic stroke (line type) */ - protected float[] dashArray = null; - - /** The current transform */ - protected AffineTransform transform = null; - - /** - * Returns a newly create data object - * - * @return a new data object - */ - protected abstract AbstractData instantiate(); - - /** - * Concatenate the given AffineTransform with the current thus creating - * a new viewport. Note that all concatenation operations are logged - * so they can be replayed if necessary (ex. for block-containers with - * "fixed" positioning. - * - * @param at Transformation to perform - */ - public void concatenate(AffineTransform at) { - getTransform().concatenate(at); - } - - /** - * Get the current AffineTransform. - * - * @return the current transform - */ - public AffineTransform getTransform() { - if (transform == null) { - transform = new AffineTransform(); - } - return transform; - } - - /** - * Sets the current AffineTransform. - */ - public void setTransform(AffineTransform baseTransform) { - this.transform = baseTransform; - } - - /** - * Resets the current AffineTransform. - */ - public void clearTransform() { - transform = new AffineTransform(); - } - - /** - * Returns the derived rotation from the current transform - * - * @return the derived rotation from the current transform - */ - public int getDerivedRotation() { - AffineTransform at = getTransform(); - double sx = at.getScaleX(); - double sy = at.getScaleY(); - double shx = at.getShearX(); - double shy = at.getShearY(); - int rotation = 0; - if (sx == 0 && sy == 0 && shx > 0 && shy < 0) { - rotation = 270; - } else if (sx < 0 && sy < 0 && shx == 0 && shy == 0) { - rotation = 180; - } else if (sx == 0 && sy == 0 && shx < 0 && shy > 0) { - rotation = 90; - } else { - rotation = 0; - } - return rotation; - } - - /** {@inheritDoc} */ - public Object clone() { - AbstractData data = instantiate(); - data.color = this.color; - data.backColor = this.backColor; - data.fontName = this.fontName; - data.fontSize = this.fontSize; - data.lineWidth = this.lineWidth; - data.dashArray = this.dashArray; - data.transform = new AffineTransform(this.transform); - return data; - } - - /** {@inheritDoc} */ - public String toString() { - return "color=" + color - + ", backColor=" + backColor - + ", fontName=" + fontName - + ", fontSize=" + fontSize - + ", lineWidth=" + lineWidth - + ", dashArray=" + dashArray - + ", transform=" + transform; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/AbstractState.java b/src/java/org/apache/fop/AbstractState.java deleted file mode 100644 index 74719e8f8..000000000 --- a/src/java/org/apache/fop/AbstractState.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * 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; - -import java.awt.Color; -import java.awt.geom.AffineTransform; -import java.io.Serializable; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - - -/** - * A base class which holds information about the current rendering state. - */ -public abstract class AbstractState implements Cloneable, Serializable { - - private static final long serialVersionUID = 5998356138437094188L; - - /** current state data */ - private AbstractData data = null; - - /** the state stack */ - private StateStack stateStack = new StateStack(); - - /** - * Instantiates a new state data object - * - * @return a new state data object - */ - protected abstract AbstractData instantiateData(); - - /** - * Instantiates a new state object - * - * @return a new state object - */ - protected abstract AbstractState instantiateState(); - - /** - * Returns the currently valid state - * - * @return the currently valid state - */ - public AbstractData getData() { - if (data == null) { - data = instantiateData(); - } - return data; - } - - /** - * Set the current color. - * Check if the new color is a change and then set the current color. - * - * @param col the color to set - * @return true if the color has changed - */ - public boolean setColor(Color col) { - if (!col.equals(getData().color)) { - getData().color = col; - return true; - } - return false; - } - - /** - * Get the color. - * - * @return the color - */ - public Color getColor() { - if (getData().color == null) { - getData().color = Color.black; - } - return getData().color; - } - - /** - * Get the background color. - * - * @return the background color - */ - public Color getBackColor() { - if (getData().backColor == null) { - getData().backColor = Color.white; - } - return getData().backColor; - } - - /** - * Set the current background color. - * Check if the new background color is a change and then set the current background color. - * - * @param col the background color to set - * @return true if the color has changed - */ - public boolean setBackColor(Color col) { - if (!col.equals(getData().backColor)) { - getData().backColor = col; - return true; - } - return false; - } - - /** - * Set the current font name - * - * @param internalFontName the internal font name - * @return true if the font name has changed - */ - public boolean setFontName(String internalFontName) { - if (!internalFontName.equals(getData().fontName)) { - getData().fontName = internalFontName; - return true; - } - return false; - } - - /** - * Gets the current font name - * - * @return the current font name - */ - public String getFontName() { - return getData().fontName; - } - - /** - * Gets the current font size - * - * @return the current font size - */ - public int getFontSize() { - return getData().fontSize; - } - - /** - * Set the current font size. - * Check if the font size is a change and then set the current font size. - * - * @param size the font size to set - * @return true if the font size has changed - */ - public boolean setFontSize(int size) { - if (size != getData().fontSize) { - getData().fontSize = size; - return true; - } - return false; - } - - /** - * Set the current line width. - * - * @param width the line width in points - * @return true if the line width has changed - */ - public boolean setLineWidth(float width) { - if (getData().lineWidth != width) { - getData().lineWidth = width; - return true; - } - return false; - } - - /** - * Returns the current line width - * - * @return the current line width - */ - public float getLineWidth() { - return getData().lineWidth; - } - - /** - * Sets the dash array (line type) for the current basic stroke - * - * @param dash the line dash array - * @return true if the dash array has changed - */ - public boolean setDashArray(float[] dash) { - if (!Arrays.equals(dash, getData().dashArray)) { - getData().dashArray = dash; - return true; - } - return false; - } - - /** - * Get the current transform. - * This gets the combination of all transforms in the - * current state. - * - * @return the calculate combined transform for the current state - */ - public AffineTransform getTransform() { - AffineTransform at = new AffineTransform(); - for (Iterator iter = stateStack.iterator(); iter.hasNext();) { - AbstractData data = (AbstractData)iter.next(); - AffineTransform stackTrans = data.getTransform(); - at.concatenate(stackTrans); - } - AffineTransform currentTrans = getData().getTransform(); - at.concatenate(currentTrans); - return at; - } - - /** - * Check the current transform. - * The transform for the current state is the combination of all - * transforms in the current state. The parameter is compared - * against this current transform. - * - * @param tf the transform the check against - * @return true if the new transform is different then the current transform - */ - public boolean checkTransform(AffineTransform tf) { - return !tf.equals(getData().getTransform()); - } - - /** - * Get a copy of the base transform for the page. Used to translate - * IPP/BPP values into X,Y positions when positioning is "fixed". - * - * @return the base transform, or null if the state stack is empty - */ - public AffineTransform getBaseTransform() { - if (stateStack.isEmpty()) { - return null; - } else { - AbstractData baseData = (AbstractData)stateStack.get(0); - return (AffineTransform) baseData.getTransform().clone(); - } - } - - /** - * Concatenates the given AffineTransform to the current one. - * - * @param at the transform to concatenate to the current level transform - */ - public void concatenate(AffineTransform at) { - getData().concatenate(at); - } - - /** - * Resets the current AffineTransform to the Base AffineTransform. - */ - public void resetTransform() { - getData().setTransform(getBaseTransform()); - } - - /** - * Clears the current AffineTransform to the Identity AffineTransform - */ - public void clearTransform() { - getData().clearTransform(); - } - - - /** - * Push the current state onto the stack. - * This call should be used when the Q operator is used - * so that the state is known when popped. - */ - public void push() { - AbstractData copy = (AbstractData)getData().clone(); - stateStack.push(copy); - } - - /** - * Pop the state from the stack and set current values to popped state. - * This should be called when a Q operator is used so - * the state is restored to the correct values. - * - * @return the restored state, null if the stack is empty - */ - public AbstractData pop() { - if (!stateStack.isEmpty()) { - setData((AbstractData)stateStack.pop()); - return this.data; - } else { - return null; - } - } - - /** - * Pushes all state data in the given list to the stack - * - * @param dataList a state data list - */ - public void pushAll(List/**/ dataList) { - Iterator it = dataList.iterator(); - while (it.hasNext()) { - // save current data on stack - push(); - setData((AbstractData)it.next()); - } - } - - /** - * Pops all state data from the stack - * - * @return a list of state data popped from the stack - */ - public List/**/ popAll() { - List/**/ dataList = new java.util.ArrayList/**/(); - AbstractData data; - while (true) { - data = getData(); - if (pop() == null) { - break; - } - // insert because of stack-popping - dataList.add(0, data); - } - return dataList; - } - - /** - * Sets the current state data - * - * @param currentData state data - */ - protected void setData(AbstractData data) { - this.data = data; - } - - /** - * Clears the state stack - */ - public void clear() { - stateStack.clear(); - setData(null); - } - - /** - * Return the state stack - * - * @return the state stack - */ - protected Stack/**/ getStateStack() { - return this.stateStack; - } - - /** {@inheritDoc} */ - public Object clone() { - AbstractState state = instantiateState(); - state.stateStack = new StateStack(this.stateStack); - state.data = (AbstractData)this.data.clone(); - return state; - } - - /** {@inheritDoc} */ - public String toString() { - return ", stateStack=" + stateStack - + ", currentData=" + data; - } -} diff --git a/src/java/org/apache/fop/StateStack.java b/src/java/org/apache/fop/StateStack.java deleted file mode 100644 index 0c73b4829..000000000 --- a/src/java/org/apache/fop/StateStack.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.fop; - -import java.util.Collection; - -/** - * No copy constructor for java.util.Stack so extended and implemented one. - */ -class StateStack extends java.util.Stack { - - private static final long serialVersionUID = 4897178211223823041L; - - /** - * Default constructor - */ - public StateStack() { - super(); - } - - /** - * Copy constructor - * - * @param c initial contents of stack - */ - public StateStack(Collection c) { - elementCount = c.size(); - // 10% for growth - elementData = new Object[ - (int)Math.min((elementCount * 110L) / 100, Integer.MAX_VALUE)]; - c.toArray(elementData); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPAbstractGraphicsObjectPainter.java b/src/java/org/apache/fop/afp/AFPAbstractGraphicsObjectPainter.java deleted file mode 100644 index 8c5e84012..000000000 --- a/src/java/org/apache/fop/afp/AFPAbstractGraphicsObjectPainter.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.afp; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.afp.modca.GraphicsObject; -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; - -/** - * A simple AFP Graphics 2D painter - */ -public abstract class AFPAbstractGraphicsObjectPainter implements Graphics2DImagePainter { - /** Static logging instance */ - protected static Log log = LogFactory.getLog(AFPAbstractGraphicsObjectPainter.class); - - private final AFPGraphics2D graphics2D; - - /** - * Default constructor - */ - public AFPAbstractGraphicsObjectPainter() { - final boolean textAsShapes = false; - this.graphics2D = new AFPGraphics2D(textAsShapes); - } - - /** - * Constructor - * - * @param graphics the afp graphics 2d implementation - */ - public AFPAbstractGraphicsObjectPainter(AFPGraphics2D graphics) { - this.graphics2D = graphics; - } - - /** - * Sets the GOCA Graphics Object - * - * @param graphicsObject the GOCA Graphics Object - */ - public void setGraphicsObject(GraphicsObject graphicsObject) { - this.graphics2D.setGraphicsObject(graphicsObject); - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPBorderPainter.java b/src/java/org/apache/fop/afp/AFPBorderPainter.java index 96f9ae78f..86960b7ff 100644 --- a/src/java/org/apache/fop/afp/AFPBorderPainter.java +++ b/src/java/org/apache/fop/afp/AFPBorderPainter.java @@ -33,10 +33,10 @@ public class AFPBorderPainter extends AbstractAFPPainter { /** * Main constructor * - * @param state the unit converter - * @param dataStream the afp datastream + * @param state the AFP painting state converter + * @param dataStream the AFP datastream */ - public AFPBorderPainter(AFPState state, DataStream dataStream) { + public AFPBorderPainter(AFPPaintingState state, DataStream dataStream) { super(state, dataStream); } diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java index 21114bb88..d412e2b94 100644 --- a/src/java/org/apache/fop/afp/AFPGraphics2D.java +++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java @@ -98,7 +98,7 @@ public class AFPGraphics2D extends AbstractGraphics2D { private AFPResourceInfo resourceInfo = null; /** Current AFP state */ - private AFPState state = null; + private AFPPaintingState state = null; /** The AFP FontInfo */ private FontInfo fontInfo; @@ -498,15 +498,15 @@ public class AFPGraphics2D extends AbstractGraphics2D { g2d.fillRect(0, 0, width, height); - int bufferedWidth = bufferedImage.getWidth(); - int bufferedHeight = bufferedImage.getHeight(); - Rectangle clipRect = new Rectangle(0, 0, bufferedWidth, bufferedHeight); + int imageWidth = bufferedImage.getWidth(); + int imageHeight = bufferedImage.getHeight(); + Rectangle clipRect = new Rectangle(0, 0, imageWidth, imageHeight); g2d.clip(clipRect); g2d.setComposite(gc.getComposite()); - boolean drawn = g2d.drawImage(img, 0, 0, bufferedWidth, bufferedHeight, observer); - g2d.dispose(); + boolean drawn = g2d.drawImage(img, 0, 0, imageWidth, imageHeight, observer); + g2d.dispose(); //drawn so dispose immediately to free system resource if (drawn) { try { @@ -575,11 +575,11 @@ public class AFPGraphics2D extends AbstractGraphics2D { } /** - * Sets the AFP state + * Sets the AFP painting state * - * @param state the AFP state + * @param state the AFP painting state */ - public void setState(AFPState state) { + public void setPaintingState(AFPPaintingState state) { this.state = state; } @@ -588,7 +588,7 @@ public class AFPGraphics2D extends AbstractGraphics2D { * * @return the AFP state */ - public AFPState getState() { + public AFPPaintingState getPaintingState() { return this.state; } diff --git a/src/java/org/apache/fop/afp/AFPPaintingState.java b/src/java/org/apache/fop/afp/AFPPaintingState.java new file mode 100644 index 000000000..60e4812b9 --- /dev/null +++ b/src/java/org/apache/fop/afp/AFPPaintingState.java @@ -0,0 +1,516 @@ +/* + * 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.afp; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.util.AbstractPaintingState; + +/** + * This keeps information about the current painting state when writing to an AFP datastream. + */ +public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState implements Cloneable { + + private static final long serialVersionUID = 8206711712452344473L; + + private static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); + + /** the portrait rotation */ + private int portraitRotation = 0; + + /** the landscape rotation */ + private int landscapeRotation = 270; + + /** color image support */ + private boolean colorImages = false; + + /** images are supported in this AFP environment */ + private boolean nativeImages = false; + + /** default value for image depth */ + private int bitsPerPixel = 8; + + /** the output resolution */ + private int resolution = 240; // 240 dpi + + /** the current page */ + private AFPPagePaintingState pagePaintingState = new AFPPagePaintingState(); + +// /** reference orientation */ +// private int orientation = 0; + + /** a unit converter */ + private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this); + + /** + * Sets the rotation to be used for portrait pages, valid values are 0 + * (default), 90, 180, 270. + * + * @param rotation + * The rotation in degrees. + */ + public void setPortraitRotation(int rotation) { + if (rotation == 0 || rotation == 90 || rotation == 180 + || rotation == 270) { + portraitRotation = rotation; + } else { + throw new IllegalArgumentException( + "The portrait rotation must be one" + + " of the values 0, 90, 180, 270"); + + } + } + + /** + * Returns the rotation to be used for portrait pages + * + * @return the rotation to be used for portrait pages + */ + protected int getPortraitRotation() { + return this.portraitRotation; + } + + /** + * Sets the rotation to be used for landscape pages, valid values are 0, 90, + * 180, 270 (default). + * + * @param rotation + * The rotation in degrees. + */ + public void setLandscapeRotation(int rotation) { + if (rotation == 0 || rotation == 90 || rotation == 180 + || rotation == 270) { + landscapeRotation = rotation; + } else { + throw new IllegalArgumentException( + "The landscape rotation must be one" + + " of the values 0, 90, 180, 270"); + } + } + + /** + * Returns the landscape rotation + * + * @return the landscape rotation + */ + protected int getLandscapeRotation() { + return this.landscapeRotation; + } + + /** + * Sets the number of bits used per pixel + * + * @param bitsPerPixel + * number of bits per pixel + */ + public void setBitsPerPixel(int bitsPerPixel) { + switch (bitsPerPixel) { + case 1: + case 4: + case 8: + this.bitsPerPixel = bitsPerPixel; + break; + default: + log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8."); + this.bitsPerPixel = 8; + break; + } + } + + /** + * Returns the number of bits per pixel + * + * @return the number of bits per pixel + */ + public int getBitsPerPixel() { + return this.bitsPerPixel; + } + + /** + * Sets whether images are color or not + * + * @param colorImages + * color image output + */ + public void setColorImages(boolean colorImages) { + this.colorImages = colorImages; + } + + /** + * Returns true if color images are to be used + * + * @return true if color images are to be used + */ + public boolean isColorImages() { + return this.colorImages; + } + + /** + * Sets whether images are natively supported or not in the AFP environment + * + * @param nativeImages true if images are natively supported in this AFP environment + */ + public void setNativeImages(boolean nativeImages) { + this.nativeImages = nativeImages; + } + + /** + * Returns true if images are supported natively in this AFP environment + * + * @return true if images are supported natively in this AFP environment + */ + public boolean isNativeImages() { + return this.nativeImages; + } + + /** + * Sets the output/device resolution + * + * @param resolution + * the output resolution (dpi) + */ + public void setResolution(int resolution) { + if (log.isDebugEnabled()) { + log.debug("renderer-resolution set to: " + resolution + "dpi"); + } + this.resolution = resolution; + } + + /** + * Returns the output/device resolution. + * + * @return the resolution in dpi + */ + public int getResolution() { + return this.resolution; + } + + /** {@inheritDoc} */ + protected AbstractData instantiateData() { + return new AFPData(); + } + + /** {@inheritDoc} */ + protected AbstractPaintingState instantiate() { + return new AFPPaintingState(); + } + + /** + * Returns the painting state of the current page + * + * @return the painting state of the current page + */ + protected AFPPagePaintingState getPagePaintingState() { + return this.pagePaintingState; + } + + /** + * Sets if the current painted shape is to be filled + * + * @param fill true if the current painted shape is to be filled + * @return true if the fill value has changed + */ + protected boolean setFill(boolean fill) { + if (fill != ((AFPData)getData()).filled) { + ((AFPData)getData()).filled = fill; + return true; + } + return false; + } + + /** + * Gets the current page fonts + * + * @return the current page fonts + */ + public AFPPageFonts getPageFonts() { + return pagePaintingState.getFonts(); + } + + /** + * Increments and returns the page font count + * + * @return the page font count + */ + public int incrementPageFontCount() { + return pagePaintingState.incrementFontCount(); + } + + /** + * Sets the page width + * + * @param pageWidth the page width + */ + public void setPageWidth(int pageWidth) { + pagePaintingState.setWidth(pageWidth); + } + + /** + * Returns the page width + * + * @return the page width + */ + public int getPageWidth() { + return pagePaintingState.getWidth(); + } + + /** + * Sets the page height + * + * @param pageHeight the page height + */ + public void setPageHeight(int pageHeight) { + pagePaintingState.setHeight(pageHeight); + } + + /** + * Returns the page height + * + * @return the page height + */ + public int getPageHeight() { + return pagePaintingState.getHeight(); + } + + /** + * Returns the page rotation + * + * @return the page rotation + */ + public int getPageRotation() { + return pagePaintingState.getOrientation(); + } + + /** + * Sets the uri of the current image + * + * @param uri the uri of the current image + */ + public void setImageUri(String uri) { + ((AFPData)getData()).imageUri = uri; + } + + /** + * Gets the uri of the current image + * + * @return the uri of the current image + */ + public String getImageUri() { + return ((AFPData)getData()).imageUri; + } + + /** + * Returns the currently derived rotation + * + * @return the currently derived rotation + */ + public int getRotation() { + return getData().getDerivedRotation(); + } + + /** + * Returns the unit converter + * + * @return the unit converter + */ + public AFPUnitConverter getUnitConverter() { + return this.unitConv; + } + + /** {@inheritDoc} */ + public Object clone() { + AFPPaintingState state = (AFPPaintingState)super.clone(); + state.pagePaintingState = (AFPPagePaintingState)this.pagePaintingState.clone(); + state.portraitRotation = this.portraitRotation; + state.landscapeRotation = this.landscapeRotation; + state.bitsPerPixel = this.bitsPerPixel; + state.colorImages = this.colorImages; + state.resolution = this.resolution; + return state; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPPaintingState{" + "portraitRotation=" + portraitRotation + + ", landscapeRotation=" + landscapeRotation + + ", colorImages=" + colorImages + + ", bitsPerPixel=" + bitsPerPixel + + ", resolution=" + resolution + + ", pageState=" + pagePaintingState + + super.toString() + + "}"; + } + + /** + * Page level state data + */ + private class AFPPagePaintingState implements Cloneable { + /** page width */ + private int width = 0; + + /** page height */ + private int height = 0; + + /** page fonts */ + private AFPPageFonts fonts = new AFPPageFonts(); + + /** page font count */ + private int fontCount = 0; + + /** page orientation */ + private int orientation = 0; + + /** + * Returns the page width + * + * @return the page width + */ + protected int getWidth() { + return width; + } + + /** + * Sets the page width + * + * @param width the page width + */ + protected void setWidth(int width) { + this.width = width; + } + + /** + * Returns the page height + * + * @return the page height + */ + protected int getHeight() { + return height; + } + + /** + * Sets the page height + * + * @param height the page height + */ + protected void setHeight(int height) { + this.height = height; + } + + /** + * Returns the page fonts + * + * @return the page fonts + */ + protected AFPPageFonts getFonts() { + return fonts; + } + + /** + * Sets the current page fonts + * + * @param fonts the current page fonts + */ + protected void setFonts(AFPPageFonts fonts) { + this.fonts = fonts; + } + + /** + * Increments and returns the current page font count + * + * @return increment and return the current page font count + */ + protected int incrementFontCount() { + return ++fontCount; + } + + /** + * Returns the current page orientation + * + * @return the current page orientation + */ + protected int getOrientation() { + return orientation; + } + + /** + * Sets the current page orientation + * + * @param orientation the current page orientation + */ + protected void setOrientation(int orientation) { + this.orientation = orientation; + } + + /** {@inheritDoc} */ + public Object clone() { + AFPPagePaintingState state = new AFPPagePaintingState(); + state.width = this.width; + state.height = this.height; + state.orientation = this.orientation; + state.fonts = new AFPPageFonts(this.fonts); + state.fontCount = this.fontCount; + return state; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPPagePaintingState{width=" + width + + ", height=" + height + + ", orientation=" + orientation + + ", fonts=" + fonts + + ", fontCount=" + fontCount + + "}"; + } + } + + /** + * Block level state data + */ + private class AFPData extends org.apache.fop.util.AbstractPaintingState.AbstractData { + private static final long serialVersionUID = -1789481244175275686L; + + /** The current fill status */ + private boolean filled = false; + + private String imageUri = null; + + /** {@inheritDoc} */ + public Object clone() { + AFPData obj = (AFPData)super.clone(); + obj.filled = this.filled; + obj.imageUri = this.imageUri; + return obj; + } + + /** {@inheritDoc} */ + public String toString() { + return "AFPData{" + super.toString() + + ", filled=" + filled + + ", imageUri=" + imageUri + + "}"; + } + + /** {@inheritDoc} */ + protected AbstractData instantiate() { + return new AFPData(); + } + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPRectanglePainter.java b/src/java/org/apache/fop/afp/AFPRectanglePainter.java index 56c60b440..81915a190 100644 --- a/src/java/org/apache/fop/afp/AFPRectanglePainter.java +++ b/src/java/org/apache/fop/afp/AFPRectanglePainter.java @@ -28,10 +28,10 @@ public class AFPRectanglePainter extends AbstractAFPPainter { /** * Main constructor * - * @param state the afp state + * @param state the AFP painting state * @param dataStream the afp datastream */ - public AFPRectanglePainter(AFPState state, DataStream dataStream) { + public AFPRectanglePainter(AFPPaintingState state, DataStream dataStream) { super(state, dataStream); } diff --git a/src/java/org/apache/fop/afp/AFPResourceLevel.java b/src/java/org/apache/fop/afp/AFPResourceLevel.java index 85cdefb4b..5e8d54aae 100644 --- a/src/java/org/apache/fop/afp/AFPResourceLevel.java +++ b/src/java/org/apache/fop/afp/AFPResourceLevel.java @@ -55,7 +55,7 @@ public class AFPResourceLevel { /** where the resource will reside in the AFP output */ - private int level = PRINT_FILE; // default is print-file level + private int level = PRINT_FILE; // default is print-file level (images) /** the external resource group file path */ private String extFilePath = null; diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java index 111238be8..c912b8b17 100644 --- a/src/java/org/apache/fop/afp/AFPResourceManager.java +++ b/src/java/org/apache/fop/afp/AFPResourceManager.java @@ -68,10 +68,10 @@ public class AFPResourceManager { /** * Sets the outputstream * - * @param state the afp state + * @param state the AFP painting state * @param outputStream the outputstream */ - public void createDataStream(AFPState state, OutputStream outputStream) { + public void createDataStream(AFPPaintingState state, OutputStream outputStream) { this.dataStream = streamer.createDataStream(state); streamer.setOutputStream(outputStream); } diff --git a/src/java/org/apache/fop/afp/AFPState.java b/src/java/org/apache/fop/afp/AFPState.java deleted file mode 100644 index 7e63ea01e..000000000 --- a/src/java/org/apache/fop/afp/AFPState.java +++ /dev/null @@ -1,517 +0,0 @@ -/* - * 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.afp; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.AbstractData; -import org.apache.fop.AbstractState; - -/** - * This keeps information about the current state when writing to an AFP datastream. - */ -public class AFPState extends org.apache.fop.AbstractState implements Cloneable { - - private static final long serialVersionUID = 8206711712452344473L; - - private static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); - - /** the portrait rotation */ - private int portraitRotation = 0; - - /** the landscape rotation */ - private int landscapeRotation = 270; - - /** color image support */ - private boolean colorImages = false; - - /** images are supported in this AFP environment */ - private boolean nativeImages = false; - - /** default value for image depth */ - private int bitsPerPixel = 8; - - /** the output resolution */ - private int resolution = 240; // 240 dpi - - /** the current page */ - private AFPPageState pageState = new AFPPageState(); - -// /** reference orientation */ -// private int orientation = 0; - - /** a unit converter */ - private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this); - - /** - * Sets the rotation to be used for portrait pages, valid values are 0 - * (default), 90, 180, 270. - * - * @param rotation - * The rotation in degrees. - */ - public void setPortraitRotation(int rotation) { - if (rotation == 0 || rotation == 90 || rotation == 180 - || rotation == 270) { - portraitRotation = rotation; - } else { - throw new IllegalArgumentException( - "The portrait rotation must be one" - + " of the values 0, 90, 180, 270"); - - } - } - - /** - * Returns the rotation to be used for portrait pages - * - * @return the rotation to be used for portrait pages - */ - protected int getPortraitRotation() { - return this.portraitRotation; - } - - /** - * Sets the rotation to be used for landscape pages, valid values are 0, 90, - * 180, 270 (default). - * - * @param rotation - * The rotation in degrees. - */ - public void setLandscapeRotation(int rotation) { - if (rotation == 0 || rotation == 90 || rotation == 180 - || rotation == 270) { - landscapeRotation = rotation; - } else { - throw new IllegalArgumentException( - "The landscape rotation must be one" - + " of the values 0, 90, 180, 270"); - } - } - - /** - * Returns the landscape rotation - * - * @return the landscape rotation - */ - protected int getLandscapeRotation() { - return this.landscapeRotation; - } - - /** - * Sets the number of bits used per pixel - * - * @param bitsPerPixel - * number of bits per pixel - */ - public void setBitsPerPixel(int bitsPerPixel) { - switch (bitsPerPixel) { - case 1: - case 4: - case 8: - this.bitsPerPixel = bitsPerPixel; - break; - default: - log.warn("Invalid bits_per_pixel value, must be 1, 4 or 8."); - this.bitsPerPixel = 8; - break; - } - } - - /** - * Returns the number of bits per pixel - * - * @return the number of bits per pixel - */ - public int getBitsPerPixel() { - return this.bitsPerPixel; - } - - /** - * Sets whether images are color or not - * - * @param colorImages - * color image output - */ - public void setColorImages(boolean colorImages) { - this.colorImages = colorImages; - } - - /** - * Returns true if color images are to be used - * - * @return true if color images are to be used - */ - public boolean isColorImages() { - return this.colorImages; - } - - /** - * Sets whether images are natively supported or not in the AFP environment - * - * @param nativeImages true if images are natively supported in this AFP environment - */ - public void setNativeImages(boolean nativeImages) { - this.nativeImages = nativeImages; - } - - /** - * Returns true if images are supported natively in this AFP environment - * - * @return true if images are supported natively in this AFP environment - */ - public boolean isNativeImages() { - return this.nativeImages; - } - - /** - * Sets the output/device resolution - * - * @param resolution - * the output resolution (dpi) - */ - public void setResolution(int resolution) { - if (log.isDebugEnabled()) { - log.debug("renderer-resolution set to: " + resolution + "dpi"); - } - this.resolution = resolution; - } - - /** - * Returns the output/device resolution. - * - * @return the resolution in dpi - */ - public int getResolution() { - return this.resolution; - } - - /** {@inheritDoc} */ - protected AbstractData instantiateData() { - return new AFPData(); - } - - /** {@inheritDoc} */ - protected AbstractState instantiateState() { - return new AFPState(); - } - - /** - * Returns the state of the current page - * - * @return the state of the current page - */ - protected AFPPageState getPageState() { - return this.pageState; - } - - /** - * Sets if the current painted shape is to be filled - * - * @param fill true if the current painted shape is to be filled - * @return true if the fill value has changed - */ - protected boolean setFill(boolean fill) { - if (fill != ((AFPData)getData()).filled) { - ((AFPData)getData()).filled = fill; - return true; - } - return false; - } - - /** - * Gets the current page fonts - * - * @return the current page fonts - */ - public AFPPageFonts getPageFonts() { - return pageState.getFonts(); - } - - /** - * Increments and returns the page font count - * - * @return the page font count - */ - public int incrementPageFontCount() { - return pageState.incrementFontCount(); - } - - /** - * Sets the page width - * - * @param pageWidth the page width - */ - public void setPageWidth(int pageWidth) { - pageState.setWidth(pageWidth); - } - - /** - * Returns the page width - * - * @return the page width - */ - public int getPageWidth() { - return pageState.getWidth(); - } - - /** - * Sets the page height - * - * @param pageHeight the page height - */ - public void setPageHeight(int pageHeight) { - pageState.setHeight(pageHeight); - } - - /** - * Returns the page height - * - * @return the page height - */ - public int getPageHeight() { - return pageState.getHeight(); - } - - /** - * Returns the page rotation - * - * @return the page rotation - */ - public int getPageRotation() { - return pageState.getOrientation(); - } - - /** - * Sets the uri of the current image - * - * @param uri the uri of the current image - */ - public void setImageUri(String uri) { - ((AFPData)getData()).imageUri = uri; - } - - /** - * Gets the uri of the current image - * - * @return the uri of the current image - */ - public String getImageUri() { - return ((AFPData)getData()).imageUri; - } - - /** - * Returns the currently derived rotation - * - * @return the currently derived rotation - */ - public int getRotation() { - return getData().getDerivedRotation(); - } - - /** - * Returns the unit converter - * - * @return the unit converter - */ - public AFPUnitConverter getUnitConverter() { - return this.unitConv; - } - - /** {@inheritDoc} */ - public Object clone() { - AFPState state = (AFPState)super.clone(); - state.pageState = (AFPPageState)this.pageState.clone(); - state.portraitRotation = this.portraitRotation; - state.landscapeRotation = this.landscapeRotation; - state.bitsPerPixel = this.bitsPerPixel; - state.colorImages = this.colorImages; - state.resolution = this.resolution; - return state; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPState{" + "portraitRotation=" + portraitRotation - + ", landscapeRotation=" + landscapeRotation - + ", colorImages=" + colorImages - + ", bitsPerPixel=" + bitsPerPixel - + ", resolution=" + resolution - + ", pageState=" + pageState - + super.toString() - + "}"; - } - - /** - * Page level state data - */ - private class AFPPageState implements Cloneable { - /** page width */ - private int width = 0; - - /** page height */ - private int height = 0; - - /** page fonts */ - private AFPPageFonts fonts = new AFPPageFonts(); - - /** page font count */ - private int fontCount = 0; - - /** page orientation */ - private int orientation = 0; - - /** - * Returns the page width - * - * @return the page width - */ - protected int getWidth() { - return width; - } - - /** - * Sets the page width - * - * @param width the page width - */ - protected void setWidth(int width) { - this.width = width; - } - - /** - * Returns the page height - * - * @return the page height - */ - protected int getHeight() { - return height; - } - - /** - * Sets the page height - * - * @param height the page height - */ - protected void setHeight(int height) { - this.height = height; - } - - /** - * Returns the page fonts - * - * @return the page fonts - */ - protected AFPPageFonts getFonts() { - return fonts; - } - - /** - * Sets the current page fonts - * - * @param fonts the current page fonts - */ - protected void setFonts(AFPPageFonts fonts) { - this.fonts = fonts; - } - - /** - * Increments and returns the current page font count - * - * @return increment and return the current page font count - */ - protected int incrementFontCount() { - return ++fontCount; - } - - /** - * Returns the current page orientation - * - * @return the current page orientation - */ - protected int getOrientation() { - return orientation; - } - - /** - * Sets the current page orientation - * - * @param orientation the current page orientation - */ - protected void setOrientation(int orientation) { - this.orientation = orientation; - } - - /** {@inheritDoc} */ - public Object clone() { - AFPPageState state = new AFPPageState(); - state.width = this.width; - state.height = this.height; - state.orientation = this.orientation; - state.fonts = new AFPPageFonts(this.fonts); - state.fontCount = this.fontCount; - return state; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPPageState{width=" + width - + ", height=" + height - + ", orientation=" + orientation - + ", fonts=" + fonts - + ", fontCount=" + fontCount - + "}"; - } - } - - /** - * Block level state data - */ - private class AFPData extends org.apache.fop.AbstractData { - private static final long serialVersionUID = -1789481244175275686L; - - /** The current fill status */ - private boolean filled = false; - - private String imageUri = null; - - /** {@inheritDoc} */ - public Object clone() { - AFPData obj = (AFPData)super.clone(); - obj.filled = this.filled; - obj.imageUri = this.imageUri; - return obj; - } - - /** {@inheritDoc} */ - public String toString() { - return "AFPData{" + super.toString() - + ", filled=" + filled - + ", imageUri=" + imageUri - + "}"; - } - - /** {@inheritDoc} */ - protected AbstractData instantiate() { - return new AFPData(); - } - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java index 42dcf4412..1d9367ef6 100644 --- a/src/java/org/apache/fop/afp/AFPStreamer.java +++ b/src/java/org/apache/fop/afp/AFPStreamer.java @@ -83,11 +83,11 @@ public class AFPStreamer implements Streamable { /** * Creates a new DataStream - * @param state the afp state * + * @param state the AFP painting state * @return a new {@link DataStream} */ - public DataStream createDataStream(AFPState state) { + public DataStream createDataStream(AFPPaintingState state) { try { this.tempFile = File.createTempFile(AFPDATASTREAM_TEMP_FILE_PREFIX, null); this.documentFile = new RandomAccessFile(tempFile, "rw"); diff --git a/src/java/org/apache/fop/afp/AFPTextHandler.java b/src/java/org/apache/fop/afp/AFPTextHandler.java index 3dee6ca2e..3f5ff7b33 100644 --- a/src/java/org/apache/fop/afp/AFPTextHandler.java +++ b/src/java/org/apache/fop/afp/AFPTextHandler.java @@ -71,7 +71,7 @@ public class AFPTextHandler implements TextHandler { GraphicsObject graphicsObj = g2d.getGraphicsObject(); Color col = g2d.getColor(); - AFPState state = g2d.getState(); + AFPPaintingState state = g2d.getPaintingState(); if (state.setColor(col)) { graphicsObj.setColor(col); } diff --git a/src/java/org/apache/fop/afp/AFPUnitConverter.java b/src/java/org/apache/fop/afp/AFPUnitConverter.java index 69282fc18..c5f37d25f 100644 --- a/src/java/org/apache/fop/afp/AFPUnitConverter.java +++ b/src/java/org/apache/fop/afp/AFPUnitConverter.java @@ -29,14 +29,14 @@ import java.awt.geom.AffineTransform; public class AFPUnitConverter { /** the AFP state */ - private final AFPState state; + private final AFPPaintingState state; /** * Unit converter * - * @param state the AFP state + * @param state the AFP painting state */ - public AFPUnitConverter(AFPState state) { + public AFPUnitConverter(AFPPaintingState state) { this.state = state; } diff --git a/src/java/org/apache/fop/afp/AbstractAFPPainter.java b/src/java/org/apache/fop/afp/AbstractAFPPainter.java index ba6d49fc6..72c6c56e1 100644 --- a/src/java/org/apache/fop/afp/AbstractAFPPainter.java +++ b/src/java/org/apache/fop/afp/AbstractAFPPainter.java @@ -29,7 +29,7 @@ public abstract class AbstractAFPPainter { protected static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); protected final DataStream dataStream; - protected final AFPState state; + protected final AFPPaintingState state; /** * Main constructor @@ -37,7 +37,7 @@ public abstract class AbstractAFPPainter { * @param state the afp state * @param dataStream the afp datastream */ - public AbstractAFPPainter(AFPState state, DataStream dataStream) { + public AbstractAFPPainter(AFPPaintingState state, DataStream dataStream) { this.state = state; this.dataStream = dataStream; } diff --git a/src/java/org/apache/fop/afp/Factory.java b/src/java/org/apache/fop/afp/Factory.java index 840d7b4e8..ef7426330 100644 --- a/src/java/org/apache/fop/afp/Factory.java +++ b/src/java/org/apache/fop/afp/Factory.java @@ -392,11 +392,11 @@ public class Factory { /** * Creates a new {@link DataStream} * - * @param state the afp state + * @param state the AFP painting state * @param outputStream an outputstream to write to * @return a new {@link DataStream} */ - public DataStream createDataStream(AFPState state, OutputStream outputStream) { + public DataStream createDataStream(AFPPaintingState state, OutputStream outputStream) { DataStream dataStream = new DataStream(this, state, outputStream); return dataStream; } diff --git a/src/java/org/apache/fop/afp/Graphics2DImagePainterGOCA.java b/src/java/org/apache/fop/afp/Graphics2DImagePainterGOCA.java new file mode 100644 index 000000000..1a2883e72 --- /dev/null +++ b/src/java/org/apache/fop/afp/Graphics2DImagePainterGOCA.java @@ -0,0 +1,71 @@ +/* + * 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.afp; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +import org.apache.batik.bridge.BridgeContext; +import org.apache.batik.gvt.GraphicsNode; +import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl; +import org.apache.xmlgraphics.java2d.Graphics2DPainterPreparator; + +/** + * Graphics2DImagePainter implementation for GOCA + */ +public class Graphics2DImagePainterGOCA extends Graphics2DImagePainterImpl { + + /** + * Main Constructor + * + * @param root the graphics node root + * @param ctx the bridge context + * @param imageSize the image size + */ + public Graphics2DImagePainterGOCA(GraphicsNode root, BridgeContext ctx, Dimension imageSize) { + super(root, ctx, imageSize); + } + + /** {@inheritDoc} */ + protected Graphics2DPainterPreparator getPreparator() { + return new Graphics2DPainterPreparator() { + + /** {@inheritdoc} */ + public void prepare(Graphics2D g2d, Rectangle2D area) { + double tx = area.getX(); + double ty = area.getHeight() - area.getY(); + if (tx != 0 || ty != 0) { + g2d.translate(tx, ty); + } + + float iw = (float) ctx.getDocumentSize().getWidth(); + float ih = (float) ctx.getDocumentSize().getHeight(); + float w = (float) area.getWidth(); + float h = (float) area.getHeight(); + float sx = w / iw; + float sy = -(h / ih); + if (sx != 1.0 || sy != 1.0) { + g2d.scale(sx, sy); + } + } + }; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/ImageContent.java b/src/java/org/apache/fop/afp/ioca/ImageContent.java index 27147d511..fc8ce0944 100644 --- a/src/java/org/apache/fop/afp/ioca/ImageContent.java +++ b/src/java/org/apache/fop/afp/ioca/ImageContent.java @@ -25,6 +25,7 @@ import java.io.OutputStream; import org.apache.fop.afp.modca.AbstractStructuredAFPObject; /** + * An IOCA Image Content */ public class ImageContent extends AbstractStructuredAFPObject { diff --git a/src/java/org/apache/fop/afp/modca/DataStream.java b/src/java/org/apache/fop/afp/modca/DataStream.java index c1c5e12a7..00d2b6f16 100644 --- a/src/java/org/apache/fop/afp/modca/DataStream.java +++ b/src/java/org/apache/fop/afp/modca/DataStream.java @@ -29,8 +29,8 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.afp.AFPLineDataInfo; +import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceLevel; -import org.apache.fop.afp.AFPState; import org.apache.fop.afp.AFPTextDataInfo; import org.apache.fop.afp.Factory; import org.apache.fop.afp.fonts.AFPFont; @@ -83,17 +83,17 @@ public class DataStream { private OutputStream outputStream; - /** the afp state */ - private final AFPState state; + /** the afp painting state */ + private final AFPPaintingState state; /** * Default constructor for the AFPDocumentStream. * * @param factory the resource factory - * @param state the afp state + * @param state the AFP painting state * @param outputStream the outputstream to write to */ - public DataStream(Factory factory, AFPState state, OutputStream outputStream) { + public DataStream(Factory factory, AFPPaintingState state, OutputStream outputStream) { this.state = state; this.factory = factory; this.outputStream = outputStream; diff --git a/src/java/org/apache/fop/image/loader/batik/BatikGraphics2DImagePainter.java b/src/java/org/apache/fop/image/loader/batik/BatikGraphics2DImagePainter.java deleted file mode 100644 index 983033027..000000000 --- a/src/java/org/apache/fop/image/loader/batik/BatikGraphics2DImagePainter.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.apache.fop.image.loader.batik; - -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.geom.Rectangle2D; - -import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.gvt.GraphicsNode; -import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; - -/** - * A generic graphics 2D image painter implementation - */ -public class BatikGraphics2DImagePainter implements Graphics2DImagePainter { - - protected final ImageXMLDOM svg; - protected final BridgeContext ctx; - protected final GraphicsNode root; - - /** - * Constructor - * - * @param svg the svg image dom - * @param ctx the bridge context - * @param root the graphics node root - */ - public BatikGraphics2DImagePainter(ImageXMLDOM svg, BridgeContext ctx, GraphicsNode root) { - this.svg = svg; - this.ctx = ctx; - this.root = root; - } - - /** - * Initialises the graphics 2d - * - * @param g2d the graphics 2d - * @param area the rectangle drawing area - */ - protected void init(Graphics2D g2d, Rectangle2D area) { - // If no viewbox is defined in the svg file, a viewbox of 100x100 is - // assumed, as defined in SVGUserAgent.getViewportSize() - double tx = area.getX(); - double ty = area.getY(); - if (tx != 0 || ty != 0) { - g2d.translate(tx, ty); - } - - float iw = (float) ctx.getDocumentSize().getWidth(); - float ih = (float) ctx.getDocumentSize().getHeight(); - float w = (float) area.getWidth(); - float h = (float) area.getHeight(); - float sx = w / iw; - float sy = h / ih; - if (sx != 1.0 || sy != 1.0) { - g2d.scale(sx, sy); - } - } - - /** {@inheritDoc} */ - public void paint(Graphics2D g2d, Rectangle2D area) { - init(g2d, area); - root.paint(g2d); - } - - /** {@inheritDoc} */ - public Dimension getImageSize() { - return new Dimension(svg.getSize().getWidthMpt(), svg.getSize().getHeightMpt()); - } - - /** - * Returns the svg image dom - * @return the svg image dom - */ - public ImageXMLDOM getImageXMLDOM() { - return svg; - } - - /** - * Returns the bridge context - * @return the bridge context - */ - public BridgeContext getBridgeContext() { - return ctx; - } - - /** - * Returns the graphics root node - * @return the graphics root node - */ - public GraphicsNode getRoot() { - return root; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/image/loader/batik/Graphics2DImagePainterImpl.java b/src/java/org/apache/fop/image/loader/batik/Graphics2DImagePainterImpl.java new file mode 100644 index 000000000..87907eddf --- /dev/null +++ b/src/java/org/apache/fop/image/loader/batik/Graphics2DImagePainterImpl.java @@ -0,0 +1,64 @@ +package org.apache.fop.image.loader.batik; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +import org.apache.batik.bridge.BridgeContext; +import org.apache.batik.gvt.GraphicsNode; +import org.apache.fop.render.AbstractGraphics2DImagePainter; +import org.apache.xmlgraphics.java2d.Graphics2DPainterPreparator; + +/** + * A generic graphics 2D image painter implementation + */ +public class Graphics2DImagePainterImpl extends AbstractGraphics2DImagePainter { + + protected final BridgeContext ctx; + protected final Dimension imageSize; + + /** + * Main constructor + * + * @param root the graphics node root + * @param ctx the bridge context + * @param imageSize the image size + */ + public Graphics2DImagePainterImpl(GraphicsNode root, BridgeContext ctx, Dimension imageSize) { + super(root); + this.imageSize = imageSize; + this.ctx = ctx; + } + + /** {@inheritDoc} */ + public Dimension getImageSize() { + return imageSize; + } + + /** {@inheritDoc} */ + protected Graphics2DPainterPreparator getPreparator() { + return new Graphics2DPainterPreparator() { + + public void prepare(Graphics2D g2d, Rectangle2D area) { + // If no viewbox is defined in the svg file, a viewbox of 100x100 is + // assumed, as defined in SVGUserAgent.getViewportSize() + double tx = area.getX(); + double ty = area.getY(); + if (tx != 0 || ty != 0) { + g2d.translate(tx, ty); + } + + float iw = (float) ctx.getDocumentSize().getWidth(); + float ih = (float) ctx.getDocumentSize().getHeight(); + float w = (float) area.getWidth(); + float h = (float) area.getHeight(); + float sx = w / iw; + float sy = h / ih; + if (sx != 1.0 || sy != 1.0) { + g2d.scale(sx, sy); + } + } + }; + } + +} \ No newline at end of file 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 40dc600be..81c12a628 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java @@ -19,6 +19,7 @@ package org.apache.fop.image.loader.batik; +import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.util.Map; @@ -33,6 +34,7 @@ import org.apache.fop.svg.SimpleSVGUserAgent; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageProcessingHints; import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor; import org.apache.xmlgraphics.image.loader.impl.AbstractImageConverter; @@ -82,8 +84,14 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter { } //Create the painter - Graphics2DImagePainter painter = createPainter(svg, ctx, root); - ImageGraphics2D g2dImage = new ImageGraphics2D(src.getInfo(), painter); + int width = svg.getSize().getWidthMpt(); + int height = svg.getSize().getHeightMpt(); + Dimension imageSize = new Dimension(width, height); + Graphics2DImagePainter painter = createPainter(ctx, root, imageSize); + + //Create g2d image + ImageInfo imageInfo = src.getInfo(); + ImageGraphics2D g2dImage = new ImageGraphics2D(imageInfo, painter); return g2dImage; } @@ -109,14 +117,14 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter { /** * Creates a Graphics 2D image painter * - * @param svg the svg image dom * @param ctx the bridge context * @param root the graphics node root + * @param imageSize the image size * @return the newly created graphics 2d image painter */ protected Graphics2DImagePainter createPainter( - final ImageXMLDOM svg, final BridgeContext ctx, final GraphicsNode root) { - return new BatikGraphics2DImagePainter(svg, ctx, root); + BridgeContext ctx, GraphicsNode root, Dimension imageSize) { + return new Graphics2DImagePainterImpl(root, ctx, imageSize); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/pdf/PDFPaintingState.java b/src/java/org/apache/fop/pdf/PDFPaintingState.java new file mode 100644 index 000000000..7dd876c25 --- /dev/null +++ b/src/java/org/apache/fop/pdf/PDFPaintingState.java @@ -0,0 +1,229 @@ +/* + * 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.pdf; + +import java.awt.Paint; +import java.awt.Shape; +import java.awt.geom.Area; +import java.awt.geom.GeneralPath; +import java.util.Iterator; + +import org.apache.fop.util.AbstractPaintingState; + +/** + * This keeps information about the current painting state when writing to pdf. + * It allows for creating new graphics states with the q operator. + * This class is only used to store the information about the state + * the caller needs to handle the actual pdf operators. + * + * When setting the state for pdf there are three possible ways of + * handling the situation. + * The values can be set to override previous or default values. + * A new state can be added and then the values set. + * The current state can be popped and values will return to a + * previous state then the necessary values can be overridden. + * The current transform behaves differently to other values as the + * matrix is combined with the current resolved value. + * It is impossible to optimise the result without analysing the all + * the possible combinations after completing. + */ +public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState { + + private static final long serialVersionUID = 5384726143906371279L; + + /** + * PDF State for storing graphics state. + */ + public PDFPaintingState() { + } + + /** + * Set the current paint. + * This checks if the paint will change and then sets the current paint. + * + * @param p the new paint + * @return true if the new paint changes the current paint + */ + public boolean setPaint(Paint p) { + Paint paint = ((PDFData)getData()).paint; + if (paint == null) { + if (p != null) { + ((PDFData)getData()).paint = p; + return true; + } + } else if (!paint.equals(p)) { + ((PDFData)getData()).paint = p; + return true; + } + return false; + } + + /** + * Check if the clip will change the current state. + * A clip is assumed to be used in a situation where it will add + * to any clip in the current or parent states. + * A clip cannot be cleared, this can only be achieved by going to + * a parent level with the correct clip. + * If the clip is different then it may start a new state so that + * it can return to the previous clip. + * + * @param cl the clip shape to check + * @return true if the clip will change the current clip. + */ + public boolean checkClip(Shape cl) { + Shape clip = ((PDFData)getData()).clip; + if (clip == null) { + if (cl != null) { + return true; + } + } else if (!new Area(clip).equals(new Area(cl))) { + return true; + } + //TODO check for clips that are larger than the current + return false; + } + + /** + * Set the current clip. + * This either sets a new clip or sets the clip to the intersect of + * the old clip and the new clip. + * + * @param cl the new clip in the current state + */ + public void setClip(Shape cl) { + Shape clip = ((PDFData)getData()).clip; + if (clip != null) { + Area newClip = new Area(clip); + newClip.intersect(new Area(cl)); + ((PDFData)getData()).clip = new GeneralPath(newClip); + } else { + ((PDFData)getData()).clip = cl; + } + } + + /** + * Get the current stack level. + * + * @return the current stack level + */ + public int getStackLevel() { + return getStateStack().size(); + } + + /** + * Get the graphics state. + * This gets the combination of all graphic states for + * the current context. + * This is the graphic state set with the gs operator not + * the other graphic state changes. + * + * @return the calculated ExtGState in the current context + */ + public PDFGState getGState() { + PDFGState defaultState = PDFGState.DEFAULT; + + PDFGState state; + PDFGState newState = new PDFGState(); + newState.addValues(defaultState); + for (Iterator it = getStateStack().iterator(); it.hasNext();) { + PDFData data = (PDFData)it.next(); + state = data.gstate; + if (state != null) { + newState.addValues(state); + } + } + if (((PDFData)getData()).gstate != null) { + newState.addValues(((PDFData)getData()).gstate); + } + return newState; + } + + /** {@inheritDoc} */ + protected AbstractData instantiateData() { + return new PDFData(); + } + + /** {@inheritDoc} */ + protected AbstractPaintingState instantiate() { + return new PDFPaintingState(); + } + + /** + * Push the current state onto the stack. + * This call should be used when the q operator is used + * so that the state is known when popped. + */ + public void push() { + AbstractData data = getData(); + AbstractData copy = (AbstractData)data.clone(); + data.clearTransform(); + getStateStack().add(copy); + } + + private class PDFData extends org.apache.fop.util.AbstractPaintingState.AbstractData { + + private static final long serialVersionUID = 3527950647293177764L; + + private Paint paint = null; + private Paint backPaint = null; + private int lineCap = 0; + private int lineJoin = 0; + private float miterLimit = 0; + private boolean text = false; + private int dashOffset = 0; + private Shape clip = null; + private PDFGState gstate = null; + + /** {@inheritDoc} */ + public Object clone() { + PDFData obj = (PDFData)super.clone(); + obj.paint = this.paint; + obj.backPaint = this.paint; + obj.lineCap = this.lineCap; + obj.lineJoin = this.lineJoin; + obj.miterLimit = this.miterLimit; + obj.text = this.text; + obj.dashOffset = this.dashOffset; + obj.clip = this.clip; + obj.gstate = this.gstate; + return obj; + } + + /** {@inheritDoc} */ + public String toString() { + return super.toString() + + ", paint=" + paint + + ", backPaint=" + backPaint + + ", lineCap=" + lineCap + + ", miterLimit=" + miterLimit + + ", text=" + text + + ", dashOffset=" + dashOffset + + ", clip=" + clip + + ", gstate=" + gstate; + } + + /** {@inheritDoc} */ + protected AbstractData instantiate() { + return new PDFData(); + } + } + +} + diff --git a/src/java/org/apache/fop/pdf/PDFState.java b/src/java/org/apache/fop/pdf/PDFState.java deleted file mode 100644 index 3804c189a..000000000 --- a/src/java/org/apache/fop/pdf/PDFState.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * 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.pdf; - -import java.awt.Paint; -import java.awt.Shape; -import java.awt.geom.Area; -import java.awt.geom.GeneralPath; -import java.util.Iterator; - -import org.apache.fop.AbstractData; -import org.apache.fop.AbstractState; - -/** - * This keeps information about the current state when writing to pdf. - * It allows for creating new graphics states with the q operator. - * This class is only used to store the information about the state - * the caller needs to handle the actual pdf operators. - * - * When setting the state for pdf there are three possible ways of - * handling the situation. - * The values can be set to override previous or default values. - * A new state can be added and then the values set. - * The current state can be popped and values will return to a - * previous state then the necessary values can be overridden. - * The current transform behaves differently to other values as the - * matrix is combined with the current resolved value. - * It is impossible to optimise the result without analysing the all - * the possible combinations after completing. - */ -public class PDFState extends org.apache.fop.AbstractState { - - private static final long serialVersionUID = 5384726143906371279L; - - /** - * PDF State for storing graphics state. - */ - public PDFState() { - } - - /** - * Set the current paint. - * This checks if the paint will change and then sets the current paint. - * - * @param p the new paint - * @return true if the new paint changes the current paint - */ - public boolean setPaint(Paint p) { - Paint paint = ((PDFData)getData()).paint; - if (paint == null) { - if (p != null) { - ((PDFData)getData()).paint = p; - return true; - } - } else if (!paint.equals(p)) { - ((PDFData)getData()).paint = p; - return true; - } - return false; - } - - /** - * Check if the clip will change the current state. - * A clip is assumed to be used in a situation where it will add - * to any clip in the current or parent states. - * A clip cannot be cleared, this can only be achieved by going to - * a parent level with the correct clip. - * If the clip is different then it may start a new state so that - * it can return to the previous clip. - * - * @param cl the clip shape to check - * @return true if the clip will change the current clip. - */ - public boolean checkClip(Shape cl) { - Shape clip = ((PDFData)getData()).clip; - if (clip == null) { - if (cl != null) { - return true; - } - } else if (!new Area(clip).equals(new Area(cl))) { - return true; - } - //TODO check for clips that are larger than the current - return false; - } - - /** - * Set the current clip. - * This either sets a new clip or sets the clip to the intersect of - * the old clip and the new clip. - * - * @param cl the new clip in the current state - */ - public void setClip(Shape cl) { - Shape clip = ((PDFData)getData()).clip; - if (clip != null) { - Area newClip = new Area(clip); - newClip.intersect(new Area(cl)); - ((PDFData)getData()).clip = new GeneralPath(newClip); - } else { - ((PDFData)getData()).clip = cl; - } - } - - /** - * Get the current stack level. - * - * @return the current stack level - */ - public int getStackLevel() { - return getStateStack().size(); - } - - /** - * Get the graphics state. - * This gets the combination of all graphic states for - * the current context. - * This is the graphic state set with the gs operator not - * the other graphic state changes. - * - * @return the calculated ExtGState in the current context - */ - public PDFGState getGState() { - PDFGState defaultState = PDFGState.DEFAULT; - - PDFGState state; - PDFGState newState = new PDFGState(); - newState.addValues(defaultState); - for (Iterator it = getStateStack().iterator(); it.hasNext();) { - PDFData data = (PDFData)it.next(); - state = data.gstate; - if (state != null) { - newState.addValues(state); - } - } - if (((PDFData)getData()).gstate != null) { - newState.addValues(((PDFData)getData()).gstate); - } - return newState; - } - - /** {@inheritDoc} */ - protected AbstractData instantiateData() { - return new PDFData(); - } - - /** {@inheritDoc} */ - protected AbstractState instantiateState() { - return new PDFState(); - } - - /** - * Push the current state onto the stack. - * This call should be used when the q operator is used - * so that the state is known when popped. - */ - public void push() { - AbstractData data = getData(); - AbstractData copy = (AbstractData)data.clone(); - data.clearTransform(); - getStateStack().add(copy); - } - - private class PDFData extends org.apache.fop.AbstractData { - - private static final long serialVersionUID = 3527950647293177764L; - - private Paint paint = null; - private Paint backPaint = null; - private int lineCap = 0; - private int lineJoin = 0; - private float miterLimit = 0; - private boolean text = false; - private int dashOffset = 0; - private Shape clip = null; - private PDFGState gstate = null; - - /** {@inheritDoc} */ - public Object clone() { - PDFData obj = (PDFData)super.clone(); - obj.paint = this.paint; - obj.backPaint = this.paint; - obj.lineCap = this.lineCap; - obj.lineJoin = this.lineJoin; - obj.miterLimit = this.miterLimit; - obj.text = this.text; - obj.dashOffset = this.dashOffset; - obj.clip = this.clip; - obj.gstate = this.gstate; - return obj; - } - - /** {@inheritDoc} */ - public String toString() { - return super.toString() - + ", paint=" + paint - + ", backPaint=" + backPaint - + ", lineCap=" + lineCap - + ", miterLimit=" + miterLimit - + ", text=" + text - + ", dashOffset=" + dashOffset - + ", clip=" + clip - + ", gstate=" + gstate; - } - - /** {@inheritDoc} */ - protected AbstractData instantiate() { - return new PDFData(); - } - } - -} - diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index 0d6bf9be9..18cc81400 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -21,9 +21,7 @@ package org.apache.fop.render; // Java import java.awt.Dimension; -import java.awt.Graphics2D; import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; import java.io.IOException; import org.apache.batik.bridge.BridgeContext; @@ -31,7 +29,9 @@ 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.fop.events.EventBroadcaster; import org.apache.fop.fo.extensions.ExtensionElementMapping; +import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl; import org.apache.fop.render.RendererContext.RendererContextWrapper; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; @@ -51,6 +51,9 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC protected static final QName CONVERSION_MODE = new QName( ExtensionElementMapping.URI, null, "conversion-mode"); + /** "bitmap" value for the "conversion-mode" extension attribute. */ + protected static final String BITMAP = "bitmap"; + /** {@inheritDoc} */ public void handleXML(RendererContext context, Document doc, String ns) throws Exception { @@ -61,65 +64,80 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC } /** - * Render the SVG document. + * Creates a graphics 2D image painter implementation * - * @param context the renderer context - * @param doc the SVG document - * @throws IOException In case of an I/O error while painting the image + * @param root the batik graphics node root + * @param ctx the batik bridge context + * @param imageSize the image size + * @return a new graphics 2D image painter implementation */ - protected void renderSVGDocument(final RendererContext context, - final Document doc) throws IOException { - updateRendererContext(context); + protected Graphics2DImagePainter createPainter( + GraphicsNode root, BridgeContext ctx, Dimension imageSize) { + return new Graphics2DImagePainterImpl(root, ctx, imageSize); + } - //Prepare - SVGUserAgent ua = new SVGUserAgent( - context.getUserAgent(), - new AffineTransform()); + /** + * Builds the GVT root + * + * @param rendererContext the renderer context + * @param ctx the batik bridge context + * @param doc the document + * @return a built GVT root tree + */ + protected GraphicsNode buildGraphicsNode( + RendererContext rendererContext, BridgeContext ctx, Document doc) { GVTBuilder builder = new GVTBuilder(); - final BridgeContext ctx = new BridgeContext(ua); - - //Build the GVT tree final GraphicsNode root; try { root = builder.build(ctx, doc); } catch (Exception e) { - SVGEventProducer eventProducer = SVGEventProducer.Provider.get( - context.getUserAgent().getEventBroadcaster()); + EventBroadcaster eventBroadcaster + = rendererContext.getUserAgent().getEventBroadcaster(); + SVGEventProducer eventProducer = SVGEventProducer.Provider.get(eventBroadcaster); final String uri = getDocumentURI(doc); eventProducer.svgNotBuilt(this, e, uri); - return; + return null; } + return root; + } - final RendererContextWrapper wrappedContext = RendererContext.wrapRendererContext(context); + /** + * Render the SVG document. + * + * @param rendererContext the renderer context + * @param doc the SVG document + * @throws IOException In case of an I/O error while painting the image + */ + protected void renderSVGDocument(final RendererContext rendererContext, + final Document doc) throws IOException { + updateRendererContext(rendererContext); - //Create the painter - Graphics2DImagePainter painter = new Graphics2DImagePainter() { + //Prepare + SVGUserAgent svgUserAgent = new SVGUserAgent( + rendererContext.getUserAgent(), new AffineTransform()); + final BridgeContext bridgeContext = new BridgeContext(svgUserAgent); - public void paint(Graphics2D g2d, Rectangle2D area) { - // 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(); - float ih = (float) ctx.getDocumentSize().getHeight(); - float w = (float) area.getWidth(); - float h = (float) area.getHeight(); - g2d.scale(w / iw, h / ih); + //Build the GVT tree + final GraphicsNode root = buildGraphicsNode(rendererContext, bridgeContext, doc); - root.paint(g2d); - } + final RendererContextWrapper wrappedContext = RendererContext.wrapRendererContext( + rendererContext); - public Dimension getImageSize() { - return new Dimension(wrappedContext.getWidth(), wrappedContext.getHeight()); - } + //Get Image Size + final int width = wrappedContext.getWidth(); + final int height = wrappedContext.getHeight(); + Dimension imageSize = new Dimension(width, height); - }; + //Create the painter + final Graphics2DImagePainter painter = createPainter(root, bridgeContext, imageSize); //Let the painter paint the SVG on the Graphics2D instance - Graphics2DAdapter adapter = context.getRenderer().getGraphics2DAdapter(); - adapter.paintImage(painter, context, - wrappedContext.getCurrentXPosition(), - wrappedContext.getCurrentYPosition(), - wrappedContext.getWidth(), - wrappedContext.getHeight()); + Graphics2DAdapter g2dAdapter = rendererContext.getRenderer().getGraphics2DAdapter(); + + //Paint the image + final int x = wrappedContext.getCurrentXPosition(); + final int y = wrappedContext.getCurrentYPosition(); + g2dAdapter.paintImage(painter, rendererContext, x, y, width, height); } /** diff --git a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java index e37d02b2b..5861fb042 100644 --- a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java @@ -135,6 +135,7 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } + /** {@inheritDoc} */ public void paintImage(Graphics2DImagePainter painter, RendererContext context, diff --git a/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java b/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java index 0c32204e2..3b00804fc 100644 --- a/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java @@ -24,8 +24,8 @@ import java.io.IOException; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPForeignAttributeReader; import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceInfo; -import org.apache.fop.afp.AFPState; import org.apache.fop.afp.AFPUnitConverter; @@ -37,7 +37,7 @@ public abstract class AFPAbstractImageFactory { private static final int Y = 1; /** the AFP state */ - protected final AFPState state; + protected final AFPPaintingState state; /** foreign attribute reader */ private final AFPForeignAttributeReader foreignAttributeReader @@ -46,9 +46,9 @@ public abstract class AFPAbstractImageFactory { /** * Main constructor * - * @param state the AFP state + * @param state the AFP painting state */ - public AFPAbstractImageFactory(AFPState state) { + public AFPAbstractImageFactory(AFPPaintingState state) { this.state = state; } diff --git a/src/java/org/apache/fop/render/afp/AFPBatikGraphicsObjectPainter.java b/src/java/org/apache/fop/render/afp/AFPBatikGraphicsObjectPainter.java deleted file mode 100644 index 0aa77d61b..000000000 --- a/src/java/org/apache/fop/render/afp/AFPBatikGraphicsObjectPainter.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.geom.Rectangle2D; - -import org.apache.batik.gvt.GraphicsNode; -import org.apache.fop.afp.AFPAbstractGraphicsObjectPainter; -import org.apache.fop.afp.AFPGraphics2D; - -/** - * Paints SVG as a GOCA Graphics Object using Batik - */ -public class AFPBatikGraphicsObjectPainter extends AFPAbstractGraphicsObjectPainter { - - /** the batik root node of the svg document */ - private GraphicsNode root; - - /** - * Main constructor - * - * @param graphics an AFP graphics 2D implementation - */ - public AFPBatikGraphicsObjectPainter(AFPGraphics2D graphics) { - super(graphics); - } - - /** - * Sets the graphics node - * - * @param rootNode the graphics root node - */ - public void setGraphicsNode(GraphicsNode rootNode) { - this.root = rootNode; - } - - /** {@inheritDoc} */ - public void paint(Graphics2D g2d, Rectangle2D area) { - log.debug("Painting SVG using GOCA"); - - // tell batik to paint the graphics object - root.paint(g2d); - - // dispose of the graphics 2d implementation - g2d.dispose(); - } - - /** {@inheritDoc} */ - public Dimension getImageSize() { - return null; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java index dcf074262..ba2392835 100644 --- a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java @@ -26,8 +26,8 @@ import java.io.IOException; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPForeignAttributeReader; import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceInfo; -import org.apache.fop.afp.AFPState; import org.apache.fop.afp.AFPUnitConverter; @@ -38,8 +38,8 @@ public abstract class AFPDataObjectInfoFactory { private static final int X = 0; private static final int Y = 1; - /** the AFP state */ - protected final AFPState state; + /** the AFP painting state */ + protected final AFPPaintingState state; /** foreign attribute reader */ private final AFPForeignAttributeReader foreignAttributeReader @@ -50,7 +50,7 @@ public abstract class AFPDataObjectInfoFactory { * * @param state the AFP state */ - public AFPDataObjectInfoFactory(AFPState state) { + public AFPDataObjectInfoFactory(AFPPaintingState state) { this.state = state; } diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java index 4211fe360..aac17b701 100644 --- a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java +++ b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java @@ -22,7 +22,7 @@ package org.apache.fop.render.afp; import java.util.Iterator; import java.util.Map; -import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPPaintingState; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; @@ -33,16 +33,18 @@ import org.apache.xmlgraphics.image.loader.impl.ImageRendered; * AFP data object info factory provider */ public class AFPDataObjectInfoProvider { + private final Map/**/ factoryMap = new java.util.HashMap/**/(); - private final AFPState state; + + private final AFPPaintingState state; /** * Main constructor * - * @param state the AFP state + * @param state the AFP painting state */ - public AFPDataObjectInfoProvider(AFPState state) { + public AFPDataObjectInfoProvider(AFPPaintingState state) { this.state = state; init(); } diff --git a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java index 453e16429..4f92826cf 100644 --- a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java @@ -27,8 +27,9 @@ import java.io.IOException; import org.apache.fop.afp.AFPGraphics2D; import org.apache.fop.afp.AFPGraphicsObjectInfo; +import org.apache.fop.afp.AFPPaintingState; +import org.apache.fop.afp.AFPResourceInfo; import org.apache.fop.afp.AFPResourceManager; -import org.apache.fop.afp.AFPState; import org.apache.fop.render.AbstractGraphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContext.RendererContextWrapper; @@ -69,28 +70,32 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { RendererContext context, int x, int y, int width, int height) throws IOException { - // get the 'width' and 'height' attributes of the SVG document - Dimension dim = painter.getImageSize(); + AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(context); + // set resource manager + AFPResourceManager resourceManager = afpInfo.getResourceManager(); + g2d.setResourceManager(resourceManager); - AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(context); - g2d.setResourceManager(afpInfo.getResourceManager()); - g2d.setResourceInfo(afpInfo.getResourceInfo()); - g2d.setState(afpInfo.getState()); - g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); + // set resource information + AFPResourceInfo resourceInfo = afpInfo.getResourceInfo(); + g2d.setResourceInfo(resourceInfo); + + // set painting state + AFPPaintingState paintingState = afpInfo.getPaintingState(); + g2d.setPaintingState(paintingState); -// // scale/convert to afp units -// AFPUnitConverter unitConv = state.getUnitConverter(); -// float scale = unitConv.mpt2units(1); + // set graphic context + g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); float fwidth = width / 1000f; float fheight = height / 1000f; - float imw = (float)dim.getWidth() / 1000f; - float imh = (float)dim.getHeight() / 1000f; + + // get the 'width' and 'height' attributes of the SVG document + Dimension imageSize = painter.getImageSize(); + float imw = (float)imageSize.getWidth() / 1000f; + float imh = (float)imageSize.getHeight() / 1000f; float sx = fwidth / imw; float sy = fheight / imh; -// float fx = x / 1000f; -// float fy = y / 1000f; AffineTransform at = new AffineTransform(sx, 0, 0, sy, x, y); renderer.saveGraphicsState(); @@ -99,26 +104,21 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { //Fallback solution: Paint to a BufferedImage int resolution = Math.round(context.getUserAgent().getTargetResolution()); RendererContextWrapper ctx = RendererContext.wrapRendererContext(context); - BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false); + BufferedImage bufferedImage = paintToBufferedImage(painter, ctx, resolution, false, false); - AFPState state = afpInfo.getState(); + AFPPaintingState state = afpInfo.getPaintingState(); AffineTransform trans = state.getData().getTransform(); float scale = AFPRenderer.NORMAL_AFP_RESOLUTION / context.getUserAgent().getTargetResolution(); if (scale != 1) { at.scale(scale, scale); - if (!at.isIdentity()) { - trans.concatenate(at); - } } + if (!at.isIdentity()) { + trans.concatenate(at); + } - // concatenate to transformation matrix -// state.concatenate(at); - - // draw image using current transformation matrix -// at = state.getData().getTransform(); - g2d.drawImage(bi, trans, null); + g2d.drawImage(bufferedImage, trans, null); } else { AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo(); graphicsObjectInfo.setPainter(painter); @@ -126,8 +126,6 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh); graphicsObjectInfo.setArea(area); - AFPResourceManager resourceManager = (AFPResourceManager)context.getProperty( - AFPRendererContextConstants.AFP_RESOURCE_MANAGER); resourceManager.createObject(graphicsObjectInfo); } diff --git a/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java b/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java index da9a37b76..88c0b5c26 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java @@ -19,10 +19,8 @@ package org.apache.fop.render.afp; -import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; import java.io.IOException; import org.apache.batik.bridge.BridgeContext; @@ -30,16 +28,16 @@ import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPGraphics2D; import org.apache.fop.afp.AFPGraphicsObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceInfo; import org.apache.fop.afp.AFPResourceLevel; -import org.apache.fop.afp.AFPState; import org.apache.fop.afp.AFPTextElementBridge; import org.apache.fop.afp.AFPTextHandler; import org.apache.fop.afp.AFPTextPainter; -import org.apache.fop.image.loader.batik.BatikGraphics2DImagePainter; import org.apache.fop.render.RendererContext; import org.apache.fop.svg.SVGUserAgent; import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; import org.apache.xmlgraphics.util.MimeConstants; @@ -51,9 +49,9 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { /** * Main constructor * - * @param state the afp state + * @param state the AFP painting state */ - public AFPImageGraphics2DFactory(AFPState state) { + public AFPImageGraphics2DFactory(AFPPaintingState state) { super(state); } @@ -62,8 +60,6 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { return new AFPGraphicsObjectInfo(); } - private static final AFPResourceLevel inlineResourceLevel = new AFPResourceLevel(AFPResourceLevel.INLINE); - /** {@inheritDoc} */ public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { AFPGraphicsObjectInfo graphicsObjectInfo @@ -73,7 +69,7 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { // level not explicitly set/changed so default to inline for GOCA graphic objects // (due to a bug in the IBM AFP Workbench Viewer (2.04.01.07) - hard copy works just fine) if (!resourceInfo.levelChanged()) { - resourceInfo.setLevel(inlineResourceLevel); + resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE)); } // set mime type (unsupported by MOD:CA registry) @@ -89,7 +85,7 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(rendererContext); g2d.setResourceManager(afpInfo.getResourceManager()); g2d.setResourceInfo(afpInfo.getResourceInfo()); - g2d.setState(afpInfo.getState()); + g2d.setPaintingState(afpInfo.getPaintingState()); g2d.setFontInfo(afpInfo.getFontInfo()); // set to default graphic context @@ -100,7 +96,7 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { g2d.translate(at.getTranslateX(), at.getTranslateY()); // set afp state - g2d.setState(state); + g2d.setPaintingState(state); // controls whether text painted by Batik is generated using text or path operations SVGUserAgent svgUserAgent @@ -117,49 +113,23 @@ public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { // set painter ImageGraphics2D imageG2D = (ImageGraphics2D)rendererImageInfo.getImage(); - BatikGraphics2DImagePainter painter - = (BatikGraphics2DImagePainter)imageG2D.getGraphics2DImagePainter(); - painter = new AFPGraphics2DImagePainter(painter); - imageG2D.setGraphics2DImagePainter(painter); + Graphics2DImagePainter painter = imageG2D.getGraphics2DImagePainter(); graphicsObjectInfo.setPainter(painter); // set object area AFPObjectAreaInfo objectAreaInfo = graphicsObjectInfo.getObjectAreaInfo(); - Rectangle area = new Rectangle(objectAreaInfo.getWidth(), objectAreaInfo.getHeight()); + int width = objectAreaInfo.getWidth(); + int height = objectAreaInfo.getHeight(); + Rectangle area = new Rectangle(width, height); graphicsObjectInfo.setArea(area); - return graphicsObjectInfo; - } - - private class AFPGraphics2DImagePainter extends BatikGraphics2DImagePainter { - /** - * Copy constructor - * - * @param painter a graphics 2D image painter - */ - public AFPGraphics2DImagePainter(BatikGraphics2DImagePainter painter) { - super(painter.getImageXMLDOM(), painter.getBridgeContext(), painter.getRoot()); - } - - /** {@inheritDoc} */ - protected void init(Graphics2D g2d, Rectangle2D area) { - double tx = area.getX(); - double ty = area.getHeight() - area.getY(); - if (tx != 0 || ty != 0) { - g2d.translate(tx, ty); - } - - float iw = (float) ctx.getDocumentSize().getWidth(); - float ih = (float) ctx.getDocumentSize().getHeight(); - float w = (float) area.getWidth(); - float h = (float) area.getHeight(); - float sx = w / iw; - float sy = -(h / ih); - if (sx != 1.0 || sy != 1.0) { - g2d.scale(sx, sy); - } - } + // invert y-axis for GOCA + final int sx = 1; + final int sy = -1; + g2d.translate(0, height); + g2d.scale(sx, sy); + return graphicsObjectInfo; } } diff --git a/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java b/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java index 19504f6c9..376bee7b9 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java @@ -24,7 +24,7 @@ import java.io.InputStream; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPPaintingState; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; @@ -36,9 +36,9 @@ public class AFPImageRawStreamFactory extends AFPDataObjectInfoFactory { /** * Main constructor * - * @param state the AFP state + * @param state the AFP painting state */ - public AFPImageRawStreamFactory(AFPState state) { + public AFPImageRawStreamFactory(AFPPaintingState state) { super(state); } diff --git a/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java b/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java index 9c59e8b83..59d6af9a8 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java @@ -26,7 +26,7 @@ import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPImageObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPPaintingState; import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.ps.ImageEncodingHelper; import org.apache.xmlgraphics.util.MimeConstants; @@ -39,9 +39,9 @@ public class AFPImageRenderedFactory extends AFPDataObjectInfoFactory { /** * Main constructor * - * @param state the AFP state + * @param state the AFP painting state */ - public AFPImageRenderedFactory(AFPState state) { + public AFPImageRenderedFactory(AFPPaintingState state) { super(state); } diff --git a/src/java/org/apache/fop/render/afp/AFPInfo.java b/src/java/org/apache/fop/render/afp/AFPInfo.java index 5fd59c2aa..1059014ab 100644 --- a/src/java/org/apache/fop/render/afp/AFPInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPInfo.java @@ -20,9 +20,9 @@ package org.apache.fop.render.afp; import org.apache.avalon.framework.configuration.Configuration; +import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceInfo; import org.apache.fop.afp.AFPResourceManager; -import org.apache.fop.afp.AFPState; import org.apache.fop.fonts.FontInfo; /** @@ -48,7 +48,7 @@ public final class AFPInfo { private FontInfo fontInfo; /** See AFP_STATE */ - private AFPState state; + private AFPPaintingState state; /** See AFP_RESOURCE_MANAGER */ private AFPResourceManager resourceManager; @@ -127,7 +127,7 @@ public final class AFPInfo { * * @return the current AFP state */ - public AFPState getState() { + public AFPPaintingState getPaintingState() { return this.state; } @@ -146,7 +146,7 @@ public final class AFPInfo { * @return true if supports color */ public boolean isColorSupported() { - return getState().isColorImages(); + return getPaintingState().isColorImages(); } /** @@ -173,7 +173,7 @@ public final class AFPInfo { * @return the resolution */ protected int getResolution() { - return getState().getResolution(); + return getPaintingState().getResolution(); } /** @@ -181,7 +181,7 @@ public final class AFPInfo { * @return the number of bits per pixel to use */ protected int getBitsPerPixel() { - return getState().getBitsPerPixel(); + return getPaintingState().getBitsPerPixel(); } /** @@ -216,7 +216,7 @@ public final class AFPInfo { * * @param state the AFP state */ - public void setState(AFPState state) { + public void setPaintingState(AFPPaintingState state) { this.state = state; } diff --git a/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java b/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java index 17aff9fc0..2e6eca6ae 100644 --- a/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java +++ b/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java @@ -24,7 +24,7 @@ import java.io.IOException; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPImageObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPState; +import org.apache.fop.afp.AFPPaintingState; import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; /** @@ -35,9 +35,9 @@ public class AFPRawCCITTFaxFactory extends AFPDataObjectInfoFactory { /** * Main constructor * - * @param state the afp state + * @param state the AFP painting state */ - public AFPRawCCITTFaxFactory(AFPState state) { + public AFPRawCCITTFaxFactory(AFPPaintingState state) { super(state); } diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 03945dfee..87c098a89 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -33,14 +33,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.fop.AbstractState; import org.apache.fop.afp.AFPBorderPainter; import org.apache.fop.afp.AFPConstants; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPPageFonts; +import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPRectanglePainter; import org.apache.fop.afp.AFPResourceManager; -import org.apache.fop.afp.AFPState; import org.apache.fop.afp.AFPTextDataInfo; import org.apache.fop.afp.AFPUnitConverter; import org.apache.fop.afp.BorderPaintInfo; @@ -72,6 +71,7 @@ import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.render.afp.extensions.AFPElementMapping; import org.apache.fop.render.afp.extensions.AFPPageSetup; +import org.apache.fop.util.AbstractPaintingState; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageInfo; @@ -146,8 +146,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** resource manager */ private AFPResourceManager resourceManager; - /** drawing state */ - private final AFPState state; + /** painting state */ + private final AFPPaintingState paintingState; /** unit converter */ private final AFPUnitConverter unitConv; @@ -175,9 +175,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { public AFPRenderer() { super(); this.resourceManager = new AFPResourceManager(); - this.state = new AFPState(); - this.dataObjectInfoProvider = new AFPDataObjectInfoProvider(state); - this.unitConv = state.getUnitConverter(); + this.paintingState = new AFPPaintingState(); + this.dataObjectInfoProvider = new AFPDataObjectInfoProvider(paintingState); + this.unitConv = paintingState.getUnitConverter(); } /** {@inheritDoc} */ @@ -197,13 +197,13 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public void startRenderer(OutputStream outputStream) throws IOException { - state.setColor(Color.WHITE); + paintingState.setColor(Color.WHITE); - resourceManager.createDataStream(state, outputStream); + resourceManager.createDataStream(paintingState, outputStream); this.dataStream = resourceManager.getDataStream(); - this.borderPainter = new AFPBorderPainter(state, dataStream); - this.rectanglePainter = new AFPRectanglePainter(state, dataStream); + this.borderPainter = new AFPBorderPainter(paintingState, dataStream); + this.rectanglePainter = new AFPRectanglePainter(paintingState, dataStream); dataStream.startDocument(); } @@ -231,10 +231,10 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public void preparePage(PageViewport page) { - int pageRotation = state.getPageRotation(); - int pageWidth = state.getPageWidth(); - int pageHeight = state.getPageHeight(); - int resolution = state.getResolution(); + int pageRotation = paintingState.getPageRotation(); + int pageWidth = paintingState.getPageWidth(); + int pageHeight = paintingState.getPageHeight(); + int resolution = paintingState.getResolution(); dataStream.startPage(pageWidth, pageHeight, pageRotation, resolution, resolution); @@ -278,7 +278,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ protected void concatenateTransformationMatrix(AffineTransform at) { if (!at.isIdentity()) { - state.concatenate(at); + paintingState.concatenate(at); } } @@ -296,12 +296,12 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public void renderPage(PageViewport pageViewport) throws IOException, FOPException { - state.clear(); + paintingState.clear(); Rectangle2D bounds = pageViewport.getViewArea(); AffineTransform baseTransform = getBaseTransform(); - state.concatenate(baseTransform); + paintingState.concatenate(baseTransform); if (pages.containsKey(pageViewport)) { dataStream.restorePage( @@ -309,15 +309,15 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } else { int pageWidth = Math.round(unitConv.mpt2units((float)bounds.getWidth())); - state.setPageWidth(pageWidth); + paintingState.setPageWidth(pageWidth); int pageHeight = Math.round(unitConv.mpt2units((float)bounds.getHeight())); - state.setPageHeight(pageHeight); + paintingState.setPageHeight(pageHeight); - int pageRotation = state.getPageRotation(); + int pageRotation = paintingState.getPageRotation(); - int resolution = state.getResolution(); + int resolution = paintingState.getResolution(); dataStream.startPage(pageWidth, pageHeight, pageRotation, resolution, resolution); @@ -327,7 +327,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { super.renderPage(pageViewport); - AFPPageFonts pageFonts = state.getPageFonts(); + AFPPageFonts pageFonts = paintingState.getPageFonts(); if (pageFonts != null && !pageFonts.isEmpty()) { dataStream.addFontsToCurrentPage(pageFonts); } @@ -389,24 +389,22 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { this.fontInfo); context.setProperty(AFPRendererContextConstants.AFP_RESOURCE_MANAGER, this.resourceManager); - context.setProperty(AFPRendererContextConstants.AFP_STATE, state); + context.setProperty(AFPRendererContextConstants.AFP_PAINTING_STATE, paintingState); return context; } private static final ImageFlavor[] NATIVE_FLAVORS = new ImageFlavor[] { /*ImageFlavor.RAW_PNG, */ // PNG not natively supported in AFP - ImageFlavor.RAW_JPEG, ImageFlavor.RAW_CCITTFAX, ImageFlavor.RAW_EPS, - ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE, - ImageFlavor.XML_DOM }; + ImageFlavor.XML_DOM, ImageFlavor.RAW_JPEG, ImageFlavor.RAW_CCITTFAX, ImageFlavor.RAW_EPS, + ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE }; private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { - ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE, - ImageFlavor.XML_DOM }; + ImageFlavor.XML_DOM, ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE }; /** {@inheritDoc} */ public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) { uri = URISpecification.getURL(uri); - state.setImageUri(uri); + paintingState.setImageUri(uri); Rectangle posInt = new Rectangle((int) pos.getX(), (int) pos.getY(), (int) pos.getWidth(), (int) pos.getHeight()); String name = (String)pageSegmentMap.get(uri); @@ -427,7 +425,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { // Only now fully load/prepare the image Map hints = ImageUtil.getDefaultHints(sessionContext); - ImageFlavor[] flavors = state.isNativeImages() ? NATIVE_FLAVORS : FLAVORS; + ImageFlavor[] flavors = paintingState.isNativeImages() ? NATIVE_FLAVORS : FLAVORS; org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, flavors, hints, sessionContext); @@ -501,30 +499,30 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public void updateColor(Color col, boolean fill) { if (fill) { - state.setColor(col); + paintingState.setColor(col); } } /** {@inheritDoc} */ public void restoreStateStackAfterBreakOut(List breakOutList) { log.debug("Block.FIXED --> restoring context after break-out"); - state.pushAll(breakOutList); + paintingState.pushAll(breakOutList); } /** {@inheritDoc} */ protected List breakOutOfStateStack() { log.debug("Block.FIXED --> break out"); - return state.popAll(); + return paintingState.popAll(); } /** {@inheritDoc} */ public void saveGraphicsState() { - state.push(); + paintingState.push(); } /** {@inheritDoc} */ public void restoreGraphicsState() { - state.pop(); + paintingState.pop(); } /** Indicates the beginning of a text object. */ @@ -549,7 +547,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { renderInlineAreaBackAndBorders(text); int fontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); - state.setFontSize(fontSize); + paintingState.setFontSize(fontSize); String name = getInternalFontNameForArea(text); AFPFont font = (AFPFont)fontInfo.getFonts().get(name); @@ -561,10 +559,10 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { AFPFontAttributes fontAttributes = new AFPFontAttributes(name, font, fontSize); - AFPPageFonts pageFonts = state.getPageFonts(); + AFPPageFonts pageFonts = paintingState.getPageFonts(); if (!pageFonts.containsKey(fontAttributes.getFontKey())) { // Font not found on current page, so add the new one - fontAttributes.setFontReference(state.incrementPageFontCount()); + fontAttributes.setFontReference(paintingState.incrementPageFontCount()); pageFonts.put(fontAttributes.getFontKey(), fontAttributes); } else { // Use the previously stored font attributes @@ -727,7 +725,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * The rotation in degrees. */ public void setPortraitRotation(int rotation) { - state.setPortraitRotation(rotation); + paintingState.setPortraitRotation(rotation); } /** @@ -738,7 +736,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * The rotation in degrees. */ public void setLandscapeRotation(int rotation) { - state.setLandscapeRotation(rotation); + paintingState.setLandscapeRotation(rotation); } /** @@ -748,7 +746,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * number of bits per pixel */ public void setBitsPerPixel(int bitsPerPixel) { - state.setBitsPerPixel(bitsPerPixel); + paintingState.setBitsPerPixel(bitsPerPixel); } /** @@ -758,7 +756,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * color image output */ public void setColorImages(boolean colorImages) { - state.setColorImages(colorImages); + paintingState.setColorImages(colorImages); } /** @@ -768,7 +766,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * native image support */ public void setNativeImages(boolean nativeImages) { - state.setNativeImages(nativeImages); + paintingState.setNativeImages(nativeImages); } /** @@ -778,7 +776,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * the output resolution (dpi) */ public void setResolution(int resolution) { - state.setResolution(resolution); + paintingState.setResolution(resolution); } /** @@ -787,7 +785,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * @return the resolution in dpi */ public int getResolution() { - return state.getResolution(); + return paintingState.getResolution(); } /** @@ -795,8 +793,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * * @return the current AFP state */ - public AbstractState getState() { - return this.state; + public AbstractPaintingState getState() { + return this.paintingState; } /** diff --git a/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java b/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java index 72be26483..3302b7f3c 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java @@ -38,6 +38,6 @@ public interface AFPRendererContextConstants extends RendererContextConstants { /** The afp resource manager */ String AFP_RESOURCE_MANAGER = "afpResourceManager"; - /** The afp state */ - String AFP_STATE = "afpPageState"; + /** The afp painting state */ + String AFP_PAINTING_STATE = "afpPaintingState"; } diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index de2786215..3bdab289c 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -20,6 +20,7 @@ package org.apache.fop.render.afp; // FOP +import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.awt.geom.Dimension2D; import java.io.IOException; @@ -36,14 +37,16 @@ import org.apache.fop.afp.AFPForeignAttributeReader; import org.apache.fop.afp.AFPGraphics2D; import org.apache.fop.afp.AFPGraphicsObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceLevel; import org.apache.fop.afp.AFPResourceManager; -import org.apache.fop.afp.AFPState; import org.apache.fop.afp.AFPTextElementBridge; import org.apache.fop.afp.AFPTextHandler; import org.apache.fop.afp.AFPTextPainter; import org.apache.fop.afp.AFPUnitConverter; -import org.apache.fop.fo.extensions.ExtensionElementMapping; +import org.apache.fop.afp.Graphics2DImagePainterGOCA; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; @@ -51,7 +54,7 @@ import org.apache.fop.render.RendererContextConstants; import org.apache.fop.render.RendererContext.RendererContextWrapper; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; -import org.apache.xmlgraphics.util.QName; +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; import org.w3c.dom.Document; /** @@ -61,9 +64,7 @@ import org.w3c.dom.Document; */ public class AFPSVGHandler extends AbstractGenericSVGHandler { - /** foreign attribute reader */ - private final AFPForeignAttributeReader foreignAttributeReader - = new AFPForeignAttributeReader(); + private boolean paintAsBitmap = false; /** {@inheritDoc} */ public void handleXML(RendererContext context, @@ -88,21 +89,24 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { afpi.setHandlerConfiguration((Configuration)context.getProperty(HANDLER_CONFIGURATION)); afpi.setFontInfo((org.apache.fop.fonts.FontInfo)context.getProperty( AFPRendererContextConstants.AFP_FONT_INFO)); - afpi.setState((AFPState)context.getProperty( - AFPRendererContextConstants.AFP_STATE)); + afpi.setPaintingState((AFPPaintingState)context.getProperty( + AFPRendererContextConstants.AFP_PAINTING_STATE)); afpi.setResourceManager(((AFPResourceManager)context.getProperty( AFPRendererContextConstants.AFP_RESOURCE_MANAGER))); Map foreignAttributes = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); if (foreignAttributes != null) { + String conversionMode = (String)foreignAttributes.get(CONVERSION_MODE); + boolean paintAsBitmap = BITMAP.equalsIgnoreCase(conversionMode); + afpi.setPaintAsBitmap(paintAsBitmap); + AFPForeignAttributeReader foreignAttributeReader = new AFPForeignAttributeReader(); AFPResourceInfo resourceInfo = foreignAttributeReader.getResourceInfo(foreignAttributes); - afpi.setResourceInfo(resourceInfo); - - QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); - if ("bitmap".equalsIgnoreCase((String)foreignAttributes.get(qName))) { - afpi.setPaintAsBitmap(true); + // default to inline level if painted as GOCA + if (!resourceInfo.levelChanged() && !paintAsBitmap) { + resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE)); } + afpi.setResourceInfo(resourceInfo); } return afpi; } @@ -122,8 +126,10 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { AFPInfo afpInfo = getAFPInfo(context); + this.paintAsBitmap = afpInfo.paintAsBitmap(); + // fallback paint as bitmap - if (afpInfo.paintAsBitmap()) { + if (paintAsBitmap) { try { super.renderSVGDocument(context, doc); } catch (IOException ioe) { @@ -135,8 +141,8 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { } String uri = ((AbstractDocument)doc).getDocumentURI(); - AFPState state = afpInfo.getState(); - state.setImageUri(uri); + AFPPaintingState paintingState = afpInfo.getPaintingState(); + paintingState.setImageUri(uri); // set the data object parameters AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); @@ -146,7 +152,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { int curry = rctx.getCurrentYPosition(); float[] srcPts = {currx, curry}; - AFPUnitConverter unitConv = state.getUnitConverter(); + AFPUnitConverter unitConv = paintingState.getUnitConverter(); int[] coords = unitConv.mpts2units(srcPts); objectAreaInfo.setX(coords[X]); objectAreaInfo.setY(coords[Y]); @@ -161,7 +167,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { int height = Math.round(unitConv.mpt2units(afpInfo.getHeight())); objectAreaInfo.setHeight(height); - int rotation = state.getRotation(); + int rotation = paintingState.getRotation(); objectAreaInfo.setRotation(rotation); AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo(); @@ -171,14 +177,22 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { final boolean textAsShapes = false; AFPGraphics2D g2d = new AFPGraphics2D(textAsShapes); - g2d.setResourceManager(afpInfo.getResourceManager()); - g2d.setResourceInfo(afpInfo.getResourceInfo()); - g2d.setState(afpInfo.getState()); + g2d.setPaintingState(paintingState); + + AFPResourceManager resourceManager = afpInfo.getResourceManager(); + g2d.setResourceManager(resourceManager); + + AFPResourceInfo resourceInfo = afpInfo.getResourceInfo(); + g2d.setResourceInfo(resourceInfo); + graphicsObjectInfo.setResourceInfo(resourceInfo); + g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - g2d.setFontInfo(afpInfo.getFontInfo()); + + FontInfo fontInfo = afpInfo.getFontInfo(); + g2d.setFontInfo(fontInfo); // Configure GraphicsObjectPainter with the Graphics2D implementation - AFPBatikGraphicsObjectPainter painter = new AFPBatikGraphicsObjectPainter(g2d); + GraphicsObjectPainterAFP painter = new GraphicsObjectPainterAFP(g2d); (graphicsObjectInfo).setPainter(painter); // Controls whether text painted by Batik is generated using text or path operations @@ -194,12 +208,6 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { ctx.putBridge(tBridge); } - Map/**/ foreignAttributes - = (Map/**/)context.getProperty( - RendererContextConstants.FOREIGN_ATTRIBUTES); - AFPResourceInfo resourceInfo = foreignAttributeReader.getResourceInfo(foreignAttributes); - graphicsObjectInfo.setResourceInfo(resourceInfo); - // Build the SVG DOM and provide the painter with it GraphicsNode root; GVTBuilder builder = new GVTBuilder(); @@ -221,13 +229,12 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { double hx = (afpInfo.getHeight() / h); double scaleX = unitConv.pt2units((float)wx); double scaleY = unitConv.pt2units((float)hx); - double xOffset = unitConv.mpt2units(afpInfo.getX()); double yOffset = unitConv.mpt2units(afpInfo.getHeight()); // Transformation matrix that establishes the local coordinate system // for the SVG graphic in relation to the current coordinate system // (note: y axis is inverted) - AffineTransform trans = new AffineTransform(scaleX, 0, 0, -scaleY, xOffset, yOffset); + AffineTransform trans = new AffineTransform(scaleX, 0, 0, -scaleY, 0, yOffset); g2d.setTransform(trans); // Set the afp graphics 2d implementation @@ -236,8 +243,6 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { // Set the object area info graphicsObjectInfo.setObjectAreaInfo(objectAreaInfo); - AFPResourceManager resourceManager = afpInfo.getResourceManager(); - // Create the graphics object resourceManager.createObject(graphicsObjectInfo); } @@ -253,4 +258,24 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE, Boolean.FALSE); } + /** {@inheritDoc} */ + protected Graphics2DImagePainter createPainter(BridgeContext ctx, GraphicsNode root, Dimension imageSize) { + Graphics2DImagePainter painter = null; + if (paintAsBitmap()) { + painter = super.createPainter(root, ctx, imageSize); + } else { + painter = new Graphics2DImagePainterGOCA(root, ctx, imageSize); + } + return painter; + } + + /** + * Returns true if the SVG is to be painted as a bitmap + * + * @return true if the SVG is to be painted as a bitmap + */ + private boolean paintAsBitmap() { + return paintAsBitmap; + } + } diff --git a/src/java/org/apache/fop/render/afp/GraphicsObjectPainterAFP.java b/src/java/org/apache/fop/render/afp/GraphicsObjectPainterAFP.java new file mode 100644 index 000000000..7eb2c1001 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/GraphicsObjectPainterAFP.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.render.afp; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +import org.apache.batik.gvt.GraphicsNode; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.afp.modca.GraphicsObject; +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; + +/** + * Paints SVG as a GOCA Graphics Object using Batik + */ +public class GraphicsObjectPainterAFP implements Graphics2DImagePainter { + /** Static logging instance */ + protected static Log log = LogFactory.getLog(GraphicsObjectPainterAFP.class); + + private final AFPGraphics2D graphics2D; + + /** the batik root node of the svg document */ + private GraphicsNode root; + + /** + * Main constructor + * + * @param graphics an AFP graphics 2D implementation + */ + public GraphicsObjectPainterAFP(AFPGraphics2D graphics) { + final boolean textAsShapes = false; + this.graphics2D = new AFPGraphics2D(textAsShapes); + } + + /** + * Sets the graphics node + * + * @param rootNode the graphics root node + */ + public void setGraphicsNode(GraphicsNode rootNode) { + this.root = rootNode; + } + + /** {@inheritDoc} */ + public void paint(Graphics2D g2d, Rectangle2D area) { + log.debug("Painting SVG using GOCA"); + + // tell batik to paint the graphics object + root.paint(g2d); + + // dispose of the graphics 2d implementation + g2d.dispose(); + } + + /** {@inheritDoc} */ + public Dimension getImageSize() { + return null; + } + + /** + * Sets the GOCA Graphics Object + * + * @param graphicsObject the GOCA Graphics Object + */ + public void setGraphicsObject(GraphicsObject graphicsObject) { + this.graphics2D.setGraphicsObject(graphicsObject); + } + +} diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java index 6ed45ca98..ba5c86059 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java +++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java @@ -23,22 +23,18 @@ import java.awt.geom.AffineTransform; import java.io.IOException; import java.util.Map; -import org.w3c.dom.Document; - 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.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContextConstants; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; -import org.apache.xmlgraphics.util.QName; +import org.w3c.dom.Document; /** * Java2D XML handler for SVG (uses Apache Batik). @@ -72,9 +68,8 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler pdfi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue(); pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); - QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); if (foreign != null - && "bitmap".equalsIgnoreCase((String)foreign.get(qName))) { + && BITMAP.equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))) { pdfi.paintAsBitmap = true; } return pdfi; diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java index 2aa11227a..01d863e6a 100644 --- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java @@ -95,8 +95,8 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { AffineTransform transform = new AffineTransform(); transform.translate(fx, fy); - pdfInfo.pdfState.concatenate(transform); - graphics.setPDFState(pdfInfo.pdfState); + pdfInfo.pdfPaintingState.concatenate(transform); + graphics.setPaintingState(pdfInfo.pdfPaintingState); graphics.setOutputStream(pdfInfo.outputStream); if (pdfInfo.paintAsBitmap) { diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 9f60d3c86..0eba2fe91 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -40,7 +40,6 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import org.apache.commons.io.IOUtils; -import org.apache.fop.AbstractData; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; @@ -95,9 +94,9 @@ import org.apache.fop.pdf.PDFOutline; import org.apache.fop.pdf.PDFOutputIntent; import org.apache.fop.pdf.PDFPage; import org.apache.fop.pdf.PDFPageLabels; +import org.apache.fop.pdf.PDFPaintingState; import org.apache.fop.pdf.PDFResourceContext; import org.apache.fop.pdf.PDFResources; -import org.apache.fop.pdf.PDFState; import org.apache.fop.pdf.PDFStream; import org.apache.fop.pdf.PDFTextUtil; import org.apache.fop.pdf.PDFXMode; @@ -105,9 +104,11 @@ import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.AbstractPathOrientedRenderer; import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; +import org.apache.fop.util.AbstractPaintingState; import org.apache.fop.util.CharUtilities; import org.apache.fop.util.ColorProfileUtil; import org.apache.fop.util.ColorUtil; +import org.apache.fop.util.AbstractPaintingState.AbstractData; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageManager; @@ -249,8 +250,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** Optional URI to an output profile to be used. */ protected String outputProfileURI; - /** drawing state */ - protected PDFState currentState = null; + /** Painting state */ + protected PDFPaintingState paintingState = null; /** Text generation utility holding the current font status */ protected PDFTextUtil textutil; @@ -518,7 +519,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream = null; currentContext = null; currentPage = null; - currentState = null; + paintingState = null; this.textutil = null; idPositions.clear(); @@ -639,7 +640,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ protected void saveGraphicsState() { endTextObject(); - currentState.push(); + paintingState.push(); currentStream.add("q\n"); } @@ -647,7 +648,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { endTextObject(); currentStream.add("Q\n"); if (popState) { - currentState.pop(); + paintingState.pop(); } } @@ -782,11 +783,11 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } }; - currentState = new PDFState(); + paintingState = new PDFPaintingState(); // Transform the PDF's default coordinate system (0,0 at lower left) to the PDFRenderer's AffineTransform basicPageTransform = new AffineTransform(1, 0, 0, -1, 0, pageHeight / 1000f); - currentState.concatenate(basicPageTransform); + paintingState.concatenate(basicPageTransform); currentStream.add(CTMHelper.toPDFString(basicPageTransform, false) + " cm\n"); super.renderPage(page); @@ -806,7 +807,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { protected void startVParea(CTM ctm, Rectangle2D clippingRect) { saveGraphicsState(); // Set the given CTM in the graphics state - currentState.concatenate( + paintingState.concatenate( new AffineTransform(CTMHelper.toPDFArray(ctm))); if (clippingRect != null) { @@ -827,7 +828,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ protected void concatenateTransformationMatrix(AffineTransform at) { if (!at.isIdentity()) { - currentState.concatenate(at); + paintingState.concatenate(at); currentStream.add(CTMHelper.toPDFString(at, false) + " cm\n"); } } @@ -1017,7 +1018,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * @param width line width in points */ private void updateLineWidth(float width) { - if (currentState.setLineWidth(width)) { + if (paintingState.setLineWidth(width)) { //Only write if value has changed WRT the current line width currentStream.add(format(width) + " w\n"); } @@ -1095,10 +1096,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { protected List breakOutOfStateStack() { // return currentState.popAll(); List breakOutList = new java.util.ArrayList(); - AbstractData data; + AbstractPaintingState.AbstractData data; while (true) { - data = currentState.getData(); - if (currentState.pop() == null) { + data = paintingState.getData(); + if (paintingState.pop() == null) { break; } if (breakOutList.size() == 0) { @@ -1260,7 +1261,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { */ protected void saveAbsolutePosition(String id, int relativeIPP, int relativeBPP) { saveAbsolutePosition(id, currentPageRef, - relativeIPP, relativeBPP, currentState.getTransform()); + relativeIPP, relativeBPP, paintingState.getTransform()); } /** @@ -1284,8 +1285,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { bpp += currentBPPosition; } AffineTransform tf = positioning == Block.FIXED - ? currentState.getBaseTransform() - : currentState.getTransform(); + ? paintingState.getBaseTransform() + : paintingState.getTransform(); saveAbsolutePosition(id, currentPageRef, ipp, bpp, tf); } } @@ -1348,7 +1349,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { int bpp = currentBPPosition + ip.getOffset(); ipRect = new Rectangle2D.Float(ipp / 1000f, bpp / 1000f, ip.getIPD() / 1000f, ip.getBPD() / 1000f); - AffineTransform transform = currentState.getTransform(); + AffineTransform transform = paintingState.getTransform(); ipRect = transform.createTransformedShape(ipRect).getBounds2D(); factory = pdfDoc.getFactory(); @@ -1582,9 +1583,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } boolean update = false; if (fill) { - update = currentState.setBackColor(col); + update = paintingState.setBackColor(col); } else { - update = currentState.setColor(col); + update = paintingState.setColor(col); } if (update) { @@ -1725,7 +1726,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { x, y, width, height, foreignAttributes); context.setProperty(PDFRendererContextConstants.PDF_DOCUMENT, pdfDoc); context.setProperty(PDFRendererContextConstants.OUTPUT_STREAM, ostream); - context.setProperty(PDFRendererContextConstants.PDF_STATE, currentState); + context.setProperty(PDFRendererContextConstants.PDF_PAINTING_STATE, paintingState); context.setProperty(PDFRendererContextConstants.PDF_PAGE, currentPage); context.setProperty(PDFRendererContextConstants.PDF_CONTEXT, currentContext == null ? currentPage : currentContext); @@ -1745,7 +1746,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { public void renderLeader(Leader area) { renderInlineAreaBackAndBorders(area); - currentState.push(); + paintingState.push(); saveGraphicsState(); int style = area.getRuleStyle(); float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f; @@ -1803,7 +1804,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } restoreGraphicsState(); - currentState.pop(); + paintingState.pop(); beginTextObject(); super.renderLeader(area); } diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java b/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java index de51aabc7..33888d442 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java @@ -29,8 +29,8 @@ public interface PDFRendererContextConstants extends RendererContextConstants { /** The PDF document that this image is being drawn into. */ String PDF_DOCUMENT = "pdfDoc"; - /** The current pdf state. */ - String PDF_STATE = "pdfState"; + /** The current PDF painting state. */ + String PDF_PAINTING_STATE = "pdfPaintingState"; /** The current PDF page for page renference and as a resource context. */ String PDF_PAGE = "pdfPage"; diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java index e31628160..e83579728 100644 --- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java @@ -25,8 +25,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Map; -import org.w3c.dom.Document; - import org.apache.avalon.framework.configuration.Configuration; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; @@ -35,16 +33,12 @@ import org.apache.batik.gvt.GraphicsNode; 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; import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFPage; +import org.apache.fop.pdf.PDFPaintingState; import org.apache.fop.pdf.PDFResourceContext; -import org.apache.fop.pdf.PDFState; import org.apache.fop.pdf.PDFStream; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; @@ -55,6 +49,7 @@ 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.w3c.dom.Document; /** * PDF XML handler for SVG (uses Apache Batik). @@ -78,7 +73,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler PDFInfo pdfi = new PDFInfo(); pdfi.pdfDoc = (PDFDocument)context.getProperty(PDF_DOCUMENT); pdfi.outputStream = (OutputStream)context.getProperty(OUTPUT_STREAM); - pdfi.pdfState = (PDFState)context.getProperty(PDF_STATE); + pdfi.pdfPaintingState = (PDFPaintingState)context.getProperty(PDF_PAINTING_STATE); pdfi.pdfPage = (PDFPage)context.getProperty(PDF_PAGE); pdfi.pdfContext = (PDFResourceContext)context.getProperty(PDF_CONTEXT); pdfi.currentStream = (PDFStream)context.getProperty(PDF_STREAM); @@ -91,10 +86,9 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); pdfi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION); Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); - - QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); + if (foreign != null - && "bitmap".equalsIgnoreCase((String)foreign.get(qName))) { + && BITMAP.equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))) { pdfi.paintAsBitmap = true; } return pdfi; @@ -109,7 +103,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler /** see OUTPUT_STREAM */ public OutputStream outputStream; /** see PDF_STATE */ - public PDFState pdfState; + public PDFPaintingState pdfPaintingState; /** see PDF_PAGE */ public PDFPage pdfPage; /** see PDF_CONTEXT */ @@ -199,8 +193,8 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler float w = (float)ctx.getDocumentSize().getWidth() * 1000f; float h = (float)ctx.getDocumentSize().getHeight() * 1000f; - float sx = pdfInfo.width / (float)w; - float sy = pdfInfo.height / (float)h; + float sx = pdfInfo.width / w; + float sy = pdfInfo.height / h; //Scaling and translation for the bounding box of the image AffineTransform scaling = new AffineTransform( @@ -249,16 +243,16 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler pdfInfo.currentStream.add("%SVG start\n"); //Save state and update coordinate system for the SVG image - pdfInfo.pdfState.push(); - pdfInfo.pdfState.concatenate(imageTransform); + pdfInfo.pdfPaintingState.push(); + pdfInfo.pdfPaintingState.concatenate(imageTransform); //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); - aBridge.getCurrentTransform().setTransform(pdfInfo.pdfState.getTransform()); + aBridge.getCurrentTransform().setTransform(pdfInfo.pdfPaintingState.getTransform()); - graphics.setPDFState(pdfInfo.pdfState); + graphics.setPaintingState(pdfInfo.pdfPaintingState); graphics.setOutputStream(pdfInfo.outputStream); try { root.paint(graphics); @@ -268,7 +262,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler context.getUserAgent().getEventBroadcaster()); eventProducer.svgRenderingError(this, e, getDocumentURI(doc)); } - pdfInfo.pdfState.pop(); + pdfInfo.pdfPaintingState.pop(); renderer.restoreGraphicsState(); pdfInfo.currentStream.add("%SVG end\n"); } diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java index dd13df1c4..cc6e06978 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java @@ -19,30 +19,30 @@ package org.apache.fop.svg; -import org.apache.fop.Version; -import org.apache.fop.pdf.PDFDocument; -import org.apache.fop.pdf.PDFFilterList; -import org.apache.fop.pdf.PDFPage; -import org.apache.fop.pdf.PDFStream; -import org.apache.fop.pdf.PDFState; -import org.apache.fop.pdf.PDFNumber; -import org.apache.fop.pdf.PDFResources; -import org.apache.fop.pdf.PDFColor; -import org.apache.fop.pdf.PDFAnnotList; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontSetup; - -import java.awt.Graphics; -import java.awt.Font; import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; import java.awt.Shape; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; import java.awt.geom.AffineTransform; -import java.io.OutputStream; import java.io.IOException; +import java.io.OutputStream; import java.io.StringWriter; +import org.apache.fop.Version; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontSetup; +import org.apache.fop.pdf.PDFAnnotList; +import org.apache.fop.pdf.PDFColor; +import org.apache.fop.pdf.PDFDocument; +import org.apache.fop.pdf.PDFFilterList; +import org.apache.fop.pdf.PDFNumber; +import org.apache.fop.pdf.PDFPage; +import org.apache.fop.pdf.PDFPaintingState; +import org.apache.fop.pdf.PDFResources; +import org.apache.fop.pdf.PDFStream; + /** * This class is a wrapper for the PDFGraphics2D that * is used to create a full document around the pdf rendering from @@ -52,7 +52,7 @@ import java.io.StringWriter; */ public class PDFDocumentGraphics2D extends PDFGraphics2D { - private PDFContext pdfContext; + private final PDFContext pdfContext; private int width; private int height; @@ -296,7 +296,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { throw new IllegalStateException("Close page first before starting another"); } //Start page - graphicsState = new PDFState(); + paintingState = new PDFPaintingState(); if (this.initialTransform == null) { //Save initial transformation matrix this.initialTransform = getTransform(); @@ -322,7 +322,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { pageRef = page.referencePDF(); AffineTransform at = new AffineTransform(1.0, 0.0, 0.0, -1.0, - 0.0, (double)height); + 0.0, height); currentStream.write("1 0 0 -1 0 " + height + " cm\n"); if (svgWidth != 0) { double scaleX = width / svgWidth; @@ -340,7 +340,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { scale(1 / s, 1 / s); } // Remember the transform we installed. - graphicsState.concatenate(at); + paintingState.concatenate(at); pdfContext.increasePageCount(); } diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index cd0a4133b..179ebb90a 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -59,15 +59,6 @@ import org.apache.batik.ext.awt.RadialGradientPaint; import org.apache.batik.ext.awt.RenderingHintsKeyExt; import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.gvt.PatternPaint; - -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.ImageSize; -import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; -import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; -import org.apache.xmlgraphics.image.loader.impl.ImageRendered; -import org.apache.xmlgraphics.java2d.AbstractGraphics2D; -import org.apache.xmlgraphics.java2d.GraphicContext; - import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontSetup; @@ -83,16 +74,23 @@ import org.apache.fop.pdf.PDFImage; import org.apache.fop.pdf.PDFImageXObject; import org.apache.fop.pdf.PDFLink; import org.apache.fop.pdf.PDFNumber; +import org.apache.fop.pdf.PDFPaintingState; import org.apache.fop.pdf.PDFPattern; import org.apache.fop.pdf.PDFResourceContext; import org.apache.fop.pdf.PDFResources; -import org.apache.fop.pdf.PDFState; import org.apache.fop.pdf.PDFText; import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.pdf.ImageRawCCITTFaxAdapter; import org.apache.fop.render.pdf.ImageRawJPEGAdapter; import org.apache.fop.render.pdf.ImageRenderedAdapter; import org.apache.fop.util.ColorExt; +import org.apache.xmlgraphics.image.loader.ImageInfo; +import org.apache.xmlgraphics.image.loader.ImageSize; +import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; +import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; +import org.apache.xmlgraphics.image.loader.impl.ImageRendered; +import org.apache.xmlgraphics.java2d.AbstractGraphics2D; +import org.apache.xmlgraphics.java2d.GraphicContext; /** * PDF Graphics 2D. @@ -129,9 +127,9 @@ public class PDFGraphics2D extends AbstractGraphics2D { protected String pageRef; /** - * the current state of the pdf graphics + * The PDF painting state */ - protected PDFState graphicsState; + protected PDFPaintingState paintingState; /** * The PDF graphics state level that this svg is being drawn into. @@ -200,7 +198,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { currentFontSize = size; fontInfo = fi; pageRef = pref; - graphicsState = new PDFState(); + paintingState = new PDFPaintingState(); } /** @@ -226,7 +224,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { this.currentFontSize = g.currentFontSize; this.fontInfo = g.fontInfo; this.pageRef = g.pageRef; - this.graphicsState = g.graphicsState; + this.paintingState = g.paintingState; this.currentStream = g.currentStream; this.nativeCount = g.nativeCount; this.outputStream = g.outputStream; @@ -266,9 +264,9 @@ public class PDFGraphics2D extends AbstractGraphics2D { * * @param state the PDF state */ - public void setPDFState(PDFState state) { - graphicsState = state; - baseLevel = graphicsState.getStackLevel(); + public void setPaintingState(PDFPaintingState state) { + paintingState = state; + baseLevel = paintingState.getStackLevel(); } /** @@ -369,7 +367,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { * @return the transformation matrix that established the basic user space for this document */ protected AffineTransform getBaseTransform() { - AffineTransform at = new AffineTransform(graphicsState.getTransform()); + AffineTransform at = new AffineTransform(paintingState.getTransform()); return at; } @@ -518,10 +516,13 @@ public class PDFGraphics2D extends AbstractGraphics2D { g.setBackground(new Color(1, 1, 1, 0)); g.setPaint(new Color(1, 1, 1, 0)); g.fillRect(0, 0, width, height); - g.clip(new Rectangle(0, 0, buf.getWidth(), buf.getHeight())); + + int imageWidth = buf.getWidth(); + int imageHeight = buf.getHeight(); + g.clip(new Rectangle(0, 0, imageWidth, imageHeight)); g.setComposite(gc.getComposite()); - if (!g.drawImage(img, 0, 0, buf.getWidth(), buf.getHeight(), observer)) { + if (!g.drawImage(img, 0, 0, imageWidth, imageHeight, observer)) { return false; } g.dispose(); @@ -602,13 +603,13 @@ public class PDFGraphics2D extends AbstractGraphics2D { trans.getMatrix(tranvals); Shape imclip = getClip(); - boolean newClip = graphicsState.checkClip(imclip); - boolean newTransform = graphicsState.checkTransform(trans) + boolean newClip = paintingState.checkClip(imclip); + boolean newTransform = paintingState.checkTransform(trans) && !trans.isIdentity(); if (newClip || newTransform) { currentStream.write("q\n"); - graphicsState.push(); + paintingState.push(); if (newTransform) { concatMatrix(tranvals); } @@ -625,7 +626,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { applyColor(c, true); Paint paint = getPaint(); - if (graphicsState.setPaint(paint)) { + if (paintingState.setPaint(paint)) { if (!applyPaint(paint, false)) { // Stroke the shape and use it to 'clip' // the paint contents. @@ -634,7 +635,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { if (newClip || newTransform) { currentStream.write("Q\n"); - graphicsState.pop(); + paintingState.pop(); } return; } @@ -646,7 +647,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { doDrawing(false, true, false); if (newClip || newTransform) { currentStream.write("Q\n"); - graphicsState.pop(); + paintingState.pop(); } } @@ -1380,7 +1381,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { if (!useMultiByte) { if (ch > 127) { currentStream.write("\\"); - currentStream.write(Integer.toOctalString((int)ch)); + currentStream.write(Integer.toOctalString(ch)); } else { switch (ch) { case '(': @@ -1397,8 +1398,8 @@ public class PDFGraphics2D extends AbstractGraphics2D { } if (kerningAvailable && (i + 1) < l) { - addKerning(currentStream, (new Integer((int)ch)), - (new Integer((int)fontState.mapChar(s.charAt(i + 1)))), + addKerning(currentStream, (new Integer(ch)), + (new Integer(fontState.mapChar(s.charAt(i + 1)))), kerning, startText, endText); } @@ -1426,7 +1427,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { vals.put(PDFGState.GSTATE_ALPHA_STROKE, new Float(strokeAlpha / 255f)); } PDFGState gstate = pdfDoc.getFactory().makeGState( - vals, graphicsState.getGState()); + vals, paintingState.getGState()); resourceContext.addGState(gstate); currentStream.write("/" + gstate.getName() + " gs\n"); } @@ -1438,7 +1439,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { */ protected void updateCurrentFont(Font font) { String name = font.getFontName(); - float size = (float)font.getFontSize() / 1000f; + float size = font.getFontSize() / 1000f; //Only update if necessary if ((!name.equals(this.currentFontName)) @@ -1617,13 +1618,13 @@ public class PDFGraphics2D extends AbstractGraphics2D { trans.getMatrix(tranvals); Shape imclip = getClip(); - boolean newClip = graphicsState.checkClip(imclip); - boolean newTransform = graphicsState.checkTransform(trans) + boolean newClip = paintingState.checkClip(imclip); + boolean newTransform = paintingState.checkTransform(trans) && !trans.isIdentity(); if (newClip || newTransform) { currentStream.write("q\n"); - graphicsState.push(); + paintingState.push(); if (newTransform) { concatMatrix(tranvals); } @@ -1640,14 +1641,14 @@ public class PDFGraphics2D extends AbstractGraphics2D { applyColor(c, false); Paint paint = getPaint(); - if (graphicsState.setPaint(paint)) { + if (paintingState.setPaint(paint)) { if (!applyPaint(paint, true)) { // Use the shape to 'clip' the paint contents. applyUnknownPaint(paint, s); if (newClip || newTransform) { currentStream.write("Q\n"); - graphicsState.pop(); + paintingState.pop(); } return; } @@ -1660,7 +1661,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { iter.getWindingRule() == PathIterator.WIND_EVEN_ODD); if (newClip || newTransform) { currentStream.write("Q\n"); - graphicsState.pop(); + paintingState.pop(); } } diff --git a/src/java/org/apache/fop/util/AbstractPaintingState.java b/src/java/org/apache/fop/util/AbstractPaintingState.java new file mode 100644 index 000000000..e712ce74f --- /dev/null +++ b/src/java/org/apache/fop/util/AbstractPaintingState.java @@ -0,0 +1,530 @@ +/* + * 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.awt.Color; +import java.awt.geom.AffineTransform; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + + +/** + * A base class which holds information about the current rendering state. + */ +public abstract class AbstractPaintingState implements Cloneable, Serializable { + + private static final long serialVersionUID = 5998356138437094188L; + + /** current state data */ + private AbstractData data = null; + + /** the state stack */ + private StateStack/**/ stateStack = new StateStack/**/(); + + /** + * Instantiates a new state data object + * + * @return a new state data object + */ + protected abstract AbstractData instantiateData(); + + /** + * Instantiates a new state object + * + * @return a new state object + */ + protected abstract AbstractPaintingState instantiate(); + + /** + * Returns the currently valid state + * + * @return the currently valid state + */ + public AbstractData getData() { + if (data == null) { + data = instantiateData(); + } + return data; + } + + /** + * Set the current color. + * Check if the new color is a change and then set the current color. + * + * @param col the color to set + * @return true if the color has changed + */ + public boolean setColor(Color col) { + if (!col.equals(getData().color)) { + getData().color = col; + return true; + } + return false; + } + + /** + * Get the color. + * + * @return the color + */ + public Color getColor() { + if (getData().color == null) { + getData().color = Color.black; + } + return getData().color; + } + + /** + * Get the background color. + * + * @return the background color + */ + public Color getBackColor() { + if (getData().backColor == null) { + getData().backColor = Color.white; + } + return getData().backColor; + } + + /** + * Set the current background color. + * Check if the new background color is a change and then set the current background color. + * + * @param col the background color to set + * @return true if the color has changed + */ + public boolean setBackColor(Color col) { + if (!col.equals(getData().backColor)) { + getData().backColor = col; + return true; + } + return false; + } + + /** + * Set the current font name + * + * @param internalFontName the internal font name + * @return true if the font name has changed + */ + public boolean setFontName(String internalFontName) { + if (!internalFontName.equals(getData().fontName)) { + getData().fontName = internalFontName; + return true; + } + return false; + } + + /** + * Gets the current font name + * + * @return the current font name + */ + public String getFontName() { + return getData().fontName; + } + + /** + * Gets the current font size + * + * @return the current font size + */ + public int getFontSize() { + return getData().fontSize; + } + + /** + * Set the current font size. + * Check if the font size is a change and then set the current font size. + * + * @param size the font size to set + * @return true if the font size has changed + */ + public boolean setFontSize(int size) { + if (size != getData().fontSize) { + getData().fontSize = size; + return true; + } + return false; + } + + /** + * Set the current line width. + * + * @param width the line width in points + * @return true if the line width has changed + */ + public boolean setLineWidth(float width) { + if (getData().lineWidth != width) { + getData().lineWidth = width; + return true; + } + return false; + } + + /** + * Returns the current line width + * + * @return the current line width + */ + public float getLineWidth() { + return getData().lineWidth; + } + + /** + * Sets the dash array (line type) for the current basic stroke + * + * @param dash the line dash array + * @return true if the dash array has changed + */ + public boolean setDashArray(float[] dash) { + if (!Arrays.equals(dash, getData().dashArray)) { + getData().dashArray = dash; + return true; + } + return false; + } + + /** + * Get the current transform. + * This gets the combination of all transforms in the + * current state. + * + * @return the calculate combined transform for the current state + */ + public AffineTransform getTransform() { + AffineTransform at = new AffineTransform(); + for (Iterator iter = stateStack.iterator(); iter.hasNext();) { + AbstractData data = (AbstractData)iter.next(); + AffineTransform stackTrans = data.getTransform(); + at.concatenate(stackTrans); + } + AffineTransform currentTrans = getData().getTransform(); + at.concatenate(currentTrans); + return at; + } + + /** + * Check the current transform. + * The transform for the current state is the combination of all + * transforms in the current state. The parameter is compared + * against this current transform. + * + * @param tf the transform the check against + * @return true if the new transform is different then the current transform + */ + public boolean checkTransform(AffineTransform tf) { + return !tf.equals(getData().getTransform()); + } + + /** + * Get a copy of the base transform for the page. Used to translate + * IPP/BPP values into X,Y positions when positioning is "fixed". + * + * @return the base transform, or null if the state stack is empty + */ + public AffineTransform getBaseTransform() { + if (stateStack.isEmpty()) { + return null; + } else { + AbstractData baseData = (AbstractData)stateStack.get(0); + return (AffineTransform) baseData.getTransform().clone(); + } + } + + /** + * Concatenates the given AffineTransform to the current one. + * + * @param at the transform to concatenate to the current level transform + */ + public void concatenate(AffineTransform at) { + getData().concatenate(at); + } + + /** + * Resets the current AffineTransform to the Base AffineTransform. + */ + public void resetTransform() { + getData().setTransform(getBaseTransform()); + } + + /** + * Clears the current AffineTransform to the Identity AffineTransform + */ + public void clearTransform() { + getData().clearTransform(); + } + + + /** + * Push the current painting state onto the stack. + * This call should be used when the Q operator is used + * so that the state is known when popped. + */ + public void push() { + AbstractData copy = (AbstractData)getData().clone(); + stateStack.push(copy); + } + + /** + * Pop the painting state from the stack and set current values to popped state. + * This should be called when a Q operator is used so + * the state is restored to the correct values. + * + * @return the restored state, null if the stack is empty + */ + public AbstractData pop() { + if (!stateStack.isEmpty()) { + setData((AbstractData)stateStack.pop()); + return this.data; + } else { + return null; + } + } + + /** + * Pushes all painting state data in the given list to the stack + * + * @param dataList a state data list + */ + public void pushAll(List/**/ dataList) { + Iterator it = dataList.iterator(); + while (it.hasNext()) { + // save current data on stack + push(); + setData((AbstractData)it.next()); + } + } + + /** + * Pops all painting state data from the stack + * + * @return a list of state data popped from the stack + */ + public List/**/ popAll() { + List/**/ dataList = new java.util.ArrayList/**/(); + AbstractData data; + while (true) { + data = getData(); + if (pop() == null) { + break; + } + // insert because of stack-popping + dataList.add(0, data); + } + return dataList; + } + + /** + * Sets the current state data + * + * @param currentData state data + */ + protected void setData(AbstractData data) { + this.data = data; + } + + /** + * Clears the state stack + */ + public void clear() { + stateStack.clear(); + setData(null); + } + + /** + * Return the state stack + * + * @return the state stack + */ + protected Stack/**/ getStateStack() { + return this.stateStack; + } + + /** {@inheritDoc} */ + public Object clone() { + AbstractPaintingState state = instantiate(); + state.stateStack = new StateStack(this.stateStack); + state.data = (AbstractData)this.data.clone(); + return state; + } + + /** {@inheritDoc} */ + public String toString() { + return ", stateStack=" + stateStack + + ", currentData=" + data; + } + + + /** + * A stack implementation which holds state objects + */ + public class StateStack extends java.util.Stack { + + private static final long serialVersionUID = 4897178211223823041L; + + /** + * Default constructor + */ + public StateStack() { + super(); + } + + /** + * Copy constructor + * + * @param c initial contents of stack + */ + public StateStack(Collection c) { + elementCount = c.size(); + // 10% for growth + elementData = new Object[ + (int)Math.min((elementCount * 110L) / 100, Integer.MAX_VALUE)]; + c.toArray(elementData); + } + } + + + /** + * A base painting state data holding object + */ + public abstract class AbstractData implements Cloneable, Serializable { + + private static final long serialVersionUID = 5208418041189828624L; + + /** The current color */ + protected Color color = null; + + /** The current background color */ + protected Color backColor = null; + + /** The current font name */ + protected String fontName = null; + + /** The current font size */ + protected int fontSize = 0; + + /** The current line width */ + protected float lineWidth = 0; + + /** The dash array for the current basic stroke (line type) */ + protected float[] dashArray = null; + + /** The current transform */ + protected AffineTransform transform = null; + + /** + * Returns a newly create data object + * + * @return a new data object + */ + protected abstract AbstractData instantiate(); + + /** + * Concatenate the given AffineTransform with the current thus creating + * a new viewport. Note that all concatenation operations are logged + * so they can be replayed if necessary (ex. for block-containers with + * "fixed" positioning. + * + * @param at Transformation to perform + */ + public void concatenate(AffineTransform at) { + getTransform().concatenate(at); + } + + /** + * Get the current AffineTransform. + * + * @return the current transform + */ + public AffineTransform getTransform() { + if (transform == null) { + transform = new AffineTransform(); + } + return transform; + } + + /** + * Sets the current AffineTransform. + */ + public void setTransform(AffineTransform baseTransform) { + this.transform = baseTransform; + } + + /** + * Resets the current AffineTransform. + */ + public void clearTransform() { + transform = new AffineTransform(); + } + + /** + * Returns the derived rotation from the current transform + * + * @return the derived rotation from the current transform + */ + public int getDerivedRotation() { + AffineTransform at = getTransform(); + double sx = at.getScaleX(); + double sy = at.getScaleY(); + double shx = at.getShearX(); + double shy = at.getShearY(); + int rotation = 0; + if (sx == 0 && sy == 0 && shx > 0 && shy < 0) { + rotation = 270; + } else if (sx < 0 && sy < 0 && shx == 0 && shy == 0) { + rotation = 180; + } else if (sx == 0 && sy == 0 && shx < 0 && shy > 0) { + rotation = 90; + } else { + rotation = 0; + } + return rotation; + } + + /** {@inheritDoc} */ + public Object clone() { + AbstractData data = instantiate(); + data.color = this.color; + data.backColor = this.backColor; + data.fontName = this.fontName; + data.fontSize = this.fontSize; + data.lineWidth = this.lineWidth; + data.dashArray = this.dashArray; + data.transform = new AffineTransform(this.transform); + return data; + } + + /** {@inheritDoc} */ + public String toString() { + return "color=" + color + + ", backColor=" + backColor + + ", fontName=" + fontName + + ", fontSize=" + fontSize + + ", lineWidth=" + lineWidth + + ", dashArray=" + dashArray + + ", transform=" + transform; + } + } +} -- cgit v1.2.3 From f637010908d0898b6f7f40843c4bfa2d37daabc0 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Thu, 13 Nov 2008 16:11:58 +0000 Subject: * PDFImageHandler interface split into ImageHandler and PDFImageHandler. * Deleted AFPDataObjectInfoProvider and AFPImage*Factory implementations, and abstracted AbstractImageHandlerRegistry from PDFImageHandlerRegistry, creating AFPImageHandlerRegistry and AFPImageHandler so there is a common reuse of image handling implementation between AFP and PDF now. * RendererContext instantiation is now overridable in PrintRenderer. * Created AFPRendererContext that is able to provide AFPInfo. * toString() added to RendererContext for ease of use. * Removed GraphicsObjectPainterAFP. * Added package.html for AFP (sub)packages. * Abstracted AbstractFOPBridgeContext from PDFBridgeContext and provided AFPBridgeContext implementation. * Abstracted AbstractFOPTextElementBridge from PDFTextElementBridge and provided AFPTextElementBridge implementation. * Abstracted AbstractFOPImageElementBridge from PDFImageElementBridge and provided AFPImageElementBridge implementation. * Provided inline image support/handling in AFPGraphics2D for SVG. * Created NativeImageHandler interface. * Fix for path iterator filled line drawing in AFPGraphics2D adding coordinate drawing implementations GraphicsLineRelative and GraphicsFilletRelative (Thanks for the patch Jeremias). * Improved configuration.xml documentation for images mode/native setting in AFP renderer configuration. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@713747 13f79535-47bb-0310-9956-ffa450edef68 --- .../content/xdocs/trunk/configuration.xml | 3 +- .../org.apache.fop.render.afp.AFPImageHandler | 5 + .../apache/fop/afp/AFPForeignAttributeReader.java | 126 ----- src/java/org/apache/fop/afp/AFPGraphics2D.java | 193 +++++--- .../org/apache/fop/afp/AFPGraphicsObjectInfo.java | 6 +- src/java/org/apache/fop/afp/AFPPageFonts.java | 67 --- src/java/org/apache/fop/afp/AFPPaintingState.java | 13 +- .../org/apache/fop/afp/AFPResourceManager.java | 5 - src/java/org/apache/fop/afp/AFPStreamer.java | 7 +- .../org/apache/fop/afp/AFPTextElementBridge.java | 110 ----- src/java/org/apache/fop/afp/AFPTextHandler.java | 143 ------ src/java/org/apache/fop/afp/AFPTextPainter.java | 514 -------------------- .../apache/fop/afp/Graphics2DImagePainterGOCA.java | 2 +- .../apache/fop/afp/fonts/AFPFontAttributes.java | 27 +- .../org/apache/fop/afp/fonts/AFPPageFonts.java | 63 +++ src/java/org/apache/fop/afp/fonts/package.html | 23 + .../apache/fop/afp/goca/AbstractGraphicsCoord.java | 1 - .../fop/afp/goca/GraphicsFilletRelative.java | 42 ++ src/java/org/apache/fop/afp/goca/GraphicsLine.java | 3 +- .../apache/fop/afp/goca/GraphicsLineRelative.java | 42 ++ src/java/org/apache/fop/afp/goca/package.html | 23 + src/java/org/apache/fop/afp/ioca/package.html | 23 + .../org/apache/fop/afp/modca/GraphicsObject.java | 35 +- src/java/org/apache/fop/afp/modca/package.html | 23 + .../org/apache/fop/afp/modca/triplets/package.html | 23 + src/java/org/apache/fop/afp/package.html | 23 + .../org/apache/fop/afp/svg/AFPBridgeContext.java | 105 ++++ .../apache/fop/afp/svg/AFPImageElementBridge.java | 37 ++ .../apache/fop/afp/svg/AFPTextElementBridge.java | 42 ++ .../org/apache/fop/afp/svg/AFPTextHandler.java | 136 ++++++ .../org/apache/fop/afp/svg/AFPTextPainter.java | 529 +++++++++++++++++++++ src/java/org/apache/fop/fonts/FontInfo.java | 4 +- src/java/org/apache/fop/fonts/package.html | 17 + src/java/org/apache/fop/pdf/package.html | 17 + .../fop/render/AbstractGenericSVGHandler.java | 42 +- .../fop/render/AbstractGraphics2DAdapter.java | 15 +- .../fop/render/AbstractImageHandlerRegistry.java | 211 ++++++++ src/java/org/apache/fop/render/ImageHandler.java | 46 ++ src/java/org/apache/fop/render/PrintRenderer.java | 14 +- .../org/apache/fop/render/RendererContext.java | 36 +- .../fop/render/afp/AFPAbstractImageFactory.java | 93 ---- .../fop/render/afp/AFPDataObjectInfoFactory.java | 108 ----- .../fop/render/afp/AFPDataObjectInfoProvider.java | 87 ---- .../fop/render/afp/AFPForeignAttributeReader.java | 128 +++++ .../fop/render/afp/AFPGraphics2DAdapter.java | 103 ++-- .../fop/render/afp/AFPImageGraphics2DFactory.java | 135 ------ .../org/apache/fop/render/afp/AFPImageHandler.java | 101 ++++ .../fop/render/afp/AFPImageHandlerGraphics2D.java | 128 +++++ .../fop/render/afp/AFPImageHandlerRawCCITTFax.java | 86 ++++ .../fop/render/afp/AFPImageHandlerRawStream.java | 103 ++++ .../fop/render/afp/AFPImageHandlerRegistry.java | 42 ++ .../render/afp/AFPImageHandlerRenderedImage.java | 118 +++++ .../apache/fop/render/afp/AFPImageHandlerXML.java | 82 ++++ .../fop/render/afp/AFPImageRawStreamFactory.java | 75 --- .../fop/render/afp/AFPImageRenderedFactory.java | 94 ---- src/java/org/apache/fop/render/afp/AFPInfo.java | 30 +- .../fop/render/afp/AFPRawCCITTFaxFactory.java | 67 --- .../org/apache/fop/render/afp/AFPRenderer.java | 128 +++-- .../fop/render/afp/AFPRendererConfigurator.java | 34 +- .../apache/fop/render/afp/AFPRendererContext.java | 83 ++++ .../fop/render/afp/AFPRendererImageInfo.java | 25 +- .../org/apache/fop/render/afp/AFPSVGHandler.java | 230 ++++----- .../fop/render/afp/GraphicsObjectPainterAFP.java | 89 ---- src/java/org/apache/fop/render/afp/package.html | 23 + .../org/apache/fop/render/pdf/PDFImageHandler.java | 27 +- .../fop/render/pdf/PDFImageHandlerGraphics2D.java | 13 +- .../fop/render/pdf/PDFImageHandlerRawCCITTFax.java | 15 +- .../fop/render/pdf/PDFImageHandlerRawJPEG.java | 15 +- .../fop/render/pdf/PDFImageHandlerRegistry.java | 163 +------ .../render/pdf/PDFImageHandlerRenderedImage.java | 16 +- .../apache/fop/render/pdf/PDFImageHandlerXML.java | 16 +- .../org/apache/fop/render/pdf/PDFRenderer.java | 3 +- .../org/apache/fop/render/ps/PSTextPainter.java | 44 +- .../apache/fop/svg/AbstractFOPBridgeContext.java | 139 ++++++ .../fop/svg/AbstractFOPImageElementBridge.java | 284 +++++++++++ .../fop/svg/AbstractFOPTextElementBridge.java | 113 +++++ .../org/apache/fop/svg/NativeImageHandler.java | 40 ++ src/java/org/apache/fop/svg/PDFBridgeContext.java | 104 ++-- src/java/org/apache/fop/svg/PDFGraphics2D.java | 7 +- .../org/apache/fop/svg/PDFImageElementBridge.java | 233 +-------- .../org/apache/fop/svg/PDFTextElementBridge.java | 42 +- src/java/org/apache/fop/svg/PDFTextPainter.java | 7 +- 82 files changed, 3521 insertions(+), 2748 deletions(-) create mode 100644 src/java/META-INF/services/org.apache.fop.render.afp.AFPImageHandler delete mode 100644 src/java/org/apache/fop/afp/AFPForeignAttributeReader.java delete mode 100644 src/java/org/apache/fop/afp/AFPPageFonts.java delete mode 100644 src/java/org/apache/fop/afp/AFPTextElementBridge.java delete mode 100644 src/java/org/apache/fop/afp/AFPTextHandler.java delete mode 100644 src/java/org/apache/fop/afp/AFPTextPainter.java create mode 100644 src/java/org/apache/fop/afp/fonts/AFPPageFonts.java create mode 100644 src/java/org/apache/fop/afp/fonts/package.html create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java create mode 100644 src/java/org/apache/fop/afp/goca/package.html create mode 100644 src/java/org/apache/fop/afp/ioca/package.html create mode 100644 src/java/org/apache/fop/afp/modca/package.html create mode 100644 src/java/org/apache/fop/afp/modca/triplets/package.html create mode 100644 src/java/org/apache/fop/afp/package.html create mode 100644 src/java/org/apache/fop/afp/svg/AFPBridgeContext.java create mode 100644 src/java/org/apache/fop/afp/svg/AFPImageElementBridge.java create mode 100644 src/java/org/apache/fop/afp/svg/AFPTextElementBridge.java create mode 100644 src/java/org/apache/fop/afp/svg/AFPTextHandler.java create mode 100644 src/java/org/apache/fop/afp/svg/AFPTextPainter.java create mode 100644 src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java create mode 100644 src/java/org/apache/fop/render/ImageHandler.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java create mode 100644 src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java create mode 100644 src/java/org/apache/fop/render/afp/AFPImageHandler.java create mode 100644 src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java create mode 100644 src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java create mode 100644 src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java create mode 100644 src/java/org/apache/fop/render/afp/AFPImageHandlerRegistry.java create mode 100644 src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java create mode 100644 src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java delete mode 100644 src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java create mode 100644 src/java/org/apache/fop/render/afp/AFPRendererContext.java delete mode 100644 src/java/org/apache/fop/render/afp/GraphicsObjectPainterAFP.java create mode 100644 src/java/org/apache/fop/render/afp/package.html create mode 100644 src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java create mode 100644 src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java create mode 100644 src/java/org/apache/fop/svg/AbstractFOPTextElementBridge.java create mode 100644 src/java/org/apache/fop/svg/NativeImageHandler.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/documentation/content/xdocs/trunk/configuration.xml b/src/documentation/content/xdocs/trunk/configuration.xml index 131b89a37..08463b9b9 100644 --- a/src/documentation/content/xdocs/trunk/configuration.xml +++ b/src/documentation/content/xdocs/trunk/configuration.xml @@ -383,7 +383,8 @@ resources.afp ]]>

      - The default value for the "images mode" setting is "b+w" (black and white). When the setting is "color" a "bits-per-pixel" setting can be provided. When the setting "native" is set to true, images (TIFF, JPEG and Encapsulated Postscript) will be placed in the datastream in their native form using a MO:DCA Object Container. + The default value for the images "mode" setting is "b+w" (black and white). When the images "mode" setting is "b+w" a "bits-per-pixel" setting can be provided to aid the grayscale conversion process. With this setting all images referenced in your source document are converted to an IOCA FS45 grayscale bitmap image form. + When the setting is "color" all images are converted to an IOCA FS45 color bitmap image form. When "native" setting is "true", all images encountered (TIFF, GIF, JPEG and Encapsulated Postscript etc.) will be embedded directly in the datastream in their native form using a MO:DCA Object Container.

      The default value for the "renderer-resolution" is 240 dpi. diff --git a/src/java/META-INF/services/org.apache.fop.render.afp.AFPImageHandler b/src/java/META-INF/services/org.apache.fop.render.afp.AFPImageHandler new file mode 100644 index 000000000..deab7d259 --- /dev/null +++ b/src/java/META-INF/services/org.apache.fop.render.afp.AFPImageHandler @@ -0,0 +1,5 @@ +org.apache.fop.render.afp.AFPImageHandlerRenderedImage +org.apache.fop.render.afp.AFPImageHandlerRawCCITTFax +org.apache.fop.render.afp.AFPImageHandlerRawStream +org.apache.fop.render.afp.AFPImageHandlerGraphics2D +org.apache.fop.render.afp.AFPImageHandlerXML diff --git a/src/java/org/apache/fop/afp/AFPForeignAttributeReader.java b/src/java/org/apache/fop/afp/AFPForeignAttributeReader.java deleted file mode 100644 index 710c24533..000000000 --- a/src/java/org/apache/fop/afp/AFPForeignAttributeReader.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.afp; - -import java.io.File; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.render.afp.extensions.AFPElementMapping; -import org.apache.xmlgraphics.util.QName; - -/** - * Parses any AFP foreign attributes - */ -public class AFPForeignAttributeReader { - private static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); - - /** the resource-name attribute */ - public static final String RESOURCE_NAME = "afp:resource-name"; - - /** the resource-level attribute */ - public static final String RESOURCE_LEVEL = "afp:resource-level"; - - /** the resource-group-file attribute */ - public static final String RESOURCE_GROUP_FILE = "afp:resource-group-file"; - - /** - * Main constructor - */ - public AFPForeignAttributeReader() { - } - - /** - * Returns the resource information - * - * @param foreignAttributes the foreign attributes - * @return the resource information - */ - public AFPResourceInfo getResourceInfo(Map/**/ foreignAttributes) { - AFPResourceInfo resourceInfo = new AFPResourceInfo(); - if (foreignAttributes != null && !foreignAttributes.isEmpty()) { - QName resourceNameKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_NAME); - String resourceName = (String)foreignAttributes.get(resourceNameKey); - if (resourceName != null) { - resourceInfo.setName(resourceName); - } - AFPResourceLevel level = getResourceLevel(foreignAttributes); - if (level != null) { - resourceInfo.setLevel(level); - } - } - return resourceInfo; - } - - /** - * Returns the resource level - * - * @param foreignAttributes the foreign attributes - * @return the resource level - */ - public AFPResourceLevel getResourceLevel(Map/**/ foreignAttributes) { - AFPResourceLevel resourceLevel = null; - if (foreignAttributes != null && !foreignAttributes.isEmpty()) { - QName resourceLevelKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_LEVEL); - if (foreignAttributes.containsKey(resourceLevelKey)) { - String levelString = (String)foreignAttributes.get(resourceLevelKey); - resourceLevel = AFPResourceLevel.valueOf(levelString); - // if external get resource group file attributes - if (resourceLevel != null && resourceLevel.isExternal()) { - QName resourceGroupFileKey = new QName(AFPElementMapping.NAMESPACE, - RESOURCE_GROUP_FILE); - String resourceGroupFile - = (String)foreignAttributes.get(resourceGroupFileKey); - if (resourceGroupFile == null) { - String msg = RESOURCE_GROUP_FILE + " not specified"; - log.error(msg); - throw new UnsupportedOperationException(msg); - } - File resourceExternalGroupFile = new File(resourceGroupFile); - SecurityManager security = System.getSecurityManager(); - try { - if (security != null) { - security.checkWrite(resourceExternalGroupFile.getPath()); - } - } catch (SecurityException ex) { - String msg = "unable to gain write access to external resource file: " - + resourceGroupFile; - log.error(msg); - } - - try { - boolean exists = resourceExternalGroupFile.exists(); - if (exists) { - log.warn("overwriting external resource file: " - + resourceGroupFile); - } - resourceLevel.setExternalFilePath(resourceGroupFile); - } catch (SecurityException ex) { - String msg = "unable to gain read access to external resource file: " - + resourceGroupFile; - log.error(msg); - } - } - } - } - return resourceLevel; - } -} diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java index dd9a0dc03..df233dafa 100644 --- a/src/java/org/apache/fop/afp/AFPGraphics2D.java +++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java @@ -48,6 +48,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.fop.afp.goca.GraphicsSetLineType; import org.apache.fop.afp.modca.GraphicsObject; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.svg.NativeImageHandler; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageSize; import org.apache.xmlgraphics.image.loader.impl.ImageRendered; @@ -65,7 +66,7 @@ import org.apache.xmlgraphics.util.MimeConstants; * * @see org.apache.xmlgraphics.java2d.AbstractGraphics2D */ -public class AFPGraphics2D extends AbstractGraphics2D { +public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHandler { private static final Log log = LogFactory.getLog(AFPGraphics2D.class); @@ -109,10 +110,19 @@ public class AFPGraphics2D extends AbstractGraphics2D { * @param textAsShapes * if true, all text is turned into shapes in the convertion. No * text is output. - * + * @param paintingState painting state + * @param resourceManager resource manager + * @param resourceInfo resource info + * @param fontInfo font info */ - public AFPGraphics2D(boolean textAsShapes) { + public AFPGraphics2D(boolean textAsShapes, AFPPaintingState paintingState, + AFPResourceManager resourceManager, AFPResourceInfo resourceInfo, + FontInfo fontInfo) { super(textAsShapes); + this.paintingState = paintingState; + this.resourceManager = resourceManager; + this.resourceInfo = resourceInfo; + this.fontInfo = fontInfo; } /** @@ -123,12 +133,14 @@ public class AFPGraphics2D extends AbstractGraphics2D { */ public AFPGraphics2D(AFPGraphics2D g2d) { super(g2d); + this.paintingState = g2d.paintingState; + this.resourceManager = g2d.resourceManager; + this.resourceInfo = g2d.resourceInfo; + this.fontInfo = g2d.fontInfo; + this.graphicsObj = g2d.graphicsObj; this.fallbackTextHandler = g2d.fallbackTextHandler; this.customTextHandler = g2d.customTextHandler; - this.resourceManager = g2d.resourceManager; - this.resourceInfo = g2d.resourceInfo; - this.paintingState = g2d.paintingState; } /** @@ -282,16 +294,13 @@ public class AFPGraphics2D extends AbstractGraphics2D { mhr ); } else { - // graphics segment opening coordinates (x,y) - // current position coordinates (x,y) for (int[] openingCoords = new int[2], currCoords = new int[2]; !iter.isDone(); iter.next()) { - // round the coordinate values and combine with current position - // coordinates int type = iter.currentSegment(dstPts); if (type == PathIterator.SEG_MOVETO) { openingCoords[X] = currCoords[X] = (int)Math.round(dstPts[X]); openingCoords[Y] = currCoords[Y] = (int)Math.round(dstPts[Y]); + graphicsObj.setCurrentPosition(openingCoords); } else { int numCoords; if (type == PathIterator.SEG_LINETO) { @@ -303,32 +312,22 @@ public class AFPGraphics2D extends AbstractGraphics2D { } else { // close of the graphics segment if (type == PathIterator.SEG_CLOSE) { - coords = new int[] { - coords[coords.length - 2], //prev X - coords[coords.length - 1], //prev Y - openingCoords[X], - openingCoords[Y] - }; - graphicsObj.addLine(coords); + graphicsObj.addLine(openingCoords, true); } else { log.debug("Unrecognised path iterator type: " + type); } continue; } - // combine current position coordinates with new graphics - // segment coordinates - coords = new int[numCoords + 2]; - coords[X] = currCoords[X]; - coords[Y] = currCoords[Y]; + coords = new int[numCoords]; for (int i = 0; i < numCoords; i++) { - coords[i + 2] = (int) Math.round(dstPts[i]); + coords[i] = (int) Math.round(dstPts[i]); } if (type == PathIterator.SEG_LINETO) { - graphicsObj.addLine(coords); + graphicsObj.addLine(coords, true); } else if (type == PathIterator.SEG_QUADTO || type == PathIterator.SEG_CUBICTO) { - graphicsObj.addFillet(coords); + graphicsObj.addFillet(coords, true); } // update current position coordinates currCoords[X] = coords[coords.length - 2]; @@ -408,7 +407,7 @@ public class AFPGraphics2D extends AbstractGraphics2D { BufferedImage.TYPE_INT_ARGB); } - private AFPImageObjectInfo getImageObjectInfo( + private AFPImageObjectInfo createImageObjectInfo( RenderedImage img, int x, int y, int width, int height) throws IOException { ImageInfo imageInfo = new ImageInfo(null, "image/unknown"); ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), 72); @@ -422,7 +421,8 @@ public class AFPGraphics2D extends AbstractGraphics2D { imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); - imageObjectInfo.setBitsPerPixel(paintingState.getBitsPerPixel()); + int bitsPerPixel = paintingState.getBitsPerPixel(); + imageObjectInfo.setBitsPerPixel(bitsPerPixel); imageObjectInfo.setResourceInfo(resourceInfo); @@ -442,7 +442,6 @@ public class AFPGraphics2D extends AbstractGraphics2D { // convert to grayscale if (!colorImages) { boas.reset(); - int bitsPerPixel = paintingState.getBitsPerPixel(); imageObjectInfo.setBitsPerPixel(bitsPerPixel); ImageEncodingHelper.encodeRGBAsGrayScale( imageData, dataWidth, dataHeight, bitsPerPixel, boas); @@ -456,21 +455,10 @@ public class AFPGraphics2D extends AbstractGraphics2D { // create object area info AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); - - AffineTransform at = gc.getTransform(); - float[] srcPts = new float[] {x, y}; - float[] dstPts = new float[srcPts.length]; - at.transform(srcPts, 0, dstPts, 0, 1); - objectAreaInfo.setX(Math.round(dstPts[X])); - objectAreaInfo.setY(Math.round(dstPts[Y])); - - AFPUnitConverter unitConv = paintingState.getUnitConverter(); - - int w = Math.round(unitConv.pt2units(width)); - objectAreaInfo.setWidth(w); - - int h = Math.round(unitConv.pt2units(height)); - objectAreaInfo.setHeight(h); + objectAreaInfo.setX(x); + objectAreaInfo.setY(y); + objectAreaInfo.setWidth(width); + objectAreaInfo.setHeight(height); int resolution = paintingState.getResolution(); objectAreaInfo.setWidthRes(resolution); @@ -481,37 +469,62 @@ public class AFPGraphics2D extends AbstractGraphics2D { return imageObjectInfo; } - /** {@inheritDoc} */ - public boolean drawImage(Image img, int x, int y, int width, int height, - ImageObserver observer) { - - // draw with AWT Graphics2D - Dimension size = new Dimension(width, height); - BufferedImage bufferedImage = buildBufferedImage(size); + /** + * Draws an AWT image into a BufferedImage using an AWT Graphics2D implementation + * + * @param img the AWT image + * @param bufferedImage the AWT buffered image + * @param width the image width + * @param height the image height + * @param observer the image observer + * @return true if the image was drawn + */ + private boolean drawBufferedImage(Image img, BufferedImage bufferedImage, + int width, int height, ImageObserver observer) { java.awt.Graphics2D g2d = bufferedImage.createGraphics(); - g2d.setComposite(AlphaComposite.SrcOver); + try { + g2d.setComposite(AlphaComposite.SrcOver); + + Color color = new Color(1, 1, 1, 0); + g2d.setBackground(color); + g2d.setPaint(color); + + g2d.fillRect(0, 0, width, height); - Color color = new Color(1, 1, 1, 0); - g2d.setBackground(color); - g2d.setPaint(color); + int imageWidth = bufferedImage.getWidth(); + int imageHeight = bufferedImage.getHeight(); + Rectangle clipRect = new Rectangle(0, 0, imageWidth, imageHeight); + g2d.clip(clipRect); - g2d.fillRect(0, 0, width, height); + g2d.setComposite(gc.getComposite()); - int imageWidth = bufferedImage.getWidth(); - int imageHeight = bufferedImage.getHeight(); - Rectangle clipRect = new Rectangle(0, 0, imageWidth, imageHeight); - g2d.clip(clipRect); + return g2d.drawImage(img, 0, 0, imageWidth, imageHeight, observer); + } finally { + g2d.dispose(); //drawn so dispose immediately to free system resource + } + } - g2d.setComposite(gc.getComposite()); + /** {@inheritDoc} */ + public boolean drawImage(Image img, int x, int y, int width, int height, + ImageObserver observer) { - boolean drawn = g2d.drawImage(img, 0, 0, imageWidth, imageHeight, observer); - g2d.dispose(); //drawn so dispose immediately to free system resource + // draw with AWT Graphics2D + Dimension imageSize = new Dimension(width, height); + BufferedImage bufferedImage = buildBufferedImage(imageSize); + boolean drawn = drawBufferedImage(img, bufferedImage, width, height, observer); if (drawn) { + AffineTransform at = gc.getTransform(); + float[] srcPts = new float[] {x, y}; + float[] dstPts = new float[srcPts.length]; + at.transform(srcPts, 0, dstPts, 0, 1); + x = Math.round(dstPts[X]); + y = Math.round(dstPts[Y]); try { // get image object info - AFPImageObjectInfo imageObjectInfo = getImageObjectInfo(bufferedImage, x, y, width, height); + AFPImageObjectInfo imageObjectInfo + = createImageObjectInfo(bufferedImage, x, y, width, height); // create image resource resourceManager.createObject(imageObjectInfo); @@ -523,25 +536,24 @@ public class AFPGraphics2D extends AbstractGraphics2D { return false; } - /** {@inheritDoc} */ - public void drawRenderableImage(RenderableImage img, AffineTransform xform) { - log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform); - } - /** {@inheritDoc} */ public void drawRenderedImage(RenderedImage img, AffineTransform xform) { - log.debug("drawRenderedImage() NYI: img=" + img + ", xform=" + xform); - } - - /** {@inheritDoc} */ - public FontMetrics getFontMetrics(Font f) { - log.debug("getFontMetrics() NYI: f=" + f); - return null; - } + int width = img.getWidth(); + int height = img.getHeight(); - /** {@inheritDoc} */ - public void setXORMode(Color col) { - log.debug("setXORMode() NYI: col=" + col); + AffineTransform at = paintingState.getData().getTransform(); + AffineTransform gat = gc.getTransform(); + int x = (int)Math.round(at.getTranslateX() + gat.getTranslateX()); + int y = (int)Math.round(at.getTranslateY()); + try { + // get image object info + AFPImageObjectInfo imageObjectInfo + = createImageObjectInfo(img, x, y, width, height); + // create image resource + resourceManager.createObject(imageObjectInfo); + } catch (IOException ioe) { + handleIOException(ioe); + } } /** @@ -609,4 +621,27 @@ public class AFPGraphics2D extends AbstractGraphics2D { public FontInfo getFontInfo() { return this.fontInfo; } + + /** {@inheritDoc} */ + public void drawRenderableImage(RenderableImage img, AffineTransform xform) { + log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform); + } + + /** {@inheritDoc} */ + public FontMetrics getFontMetrics(Font f) { + log.debug("getFontMetrics() NYI: f=" + f); + return null; + } + + /** {@inheritDoc} */ + public void setXORMode(Color col) { + log.debug("setXORMode() NYI: col=" + col); + } + + /** {@inheritDoc} */ + public void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, + float x, float y, float width, float height) { + log.debug("NYI: addNativeImage() "+ "image=" + image + + ",x=" + x + ",y=" + y + ",width=" + width + ",height=" + height); + } } diff --git a/src/java/org/apache/fop/afp/AFPGraphicsObjectInfo.java b/src/java/org/apache/fop/afp/AFPGraphicsObjectInfo.java index df0ef55c5..cd8c7c303 100644 --- a/src/java/org/apache/fop/afp/AFPGraphicsObjectInfo.java +++ b/src/java/org/apache/fop/afp/AFPGraphicsObjectInfo.java @@ -19,6 +19,7 @@ package org.apache.fop.afp; +import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; @@ -62,7 +63,10 @@ public class AFPGraphicsObjectInfo extends AFPDataObjectInfo { * @return the graphics area */ public Rectangle2D getArea() { - return this.area; + AFPObjectAreaInfo objectAreaInfo = getObjectAreaInfo(); + int width = objectAreaInfo.getWidth(); + int height = objectAreaInfo.getHeight(); + return new Rectangle(width, height); } /** diff --git a/src/java/org/apache/fop/afp/AFPPageFonts.java b/src/java/org/apache/fop/afp/AFPPageFonts.java deleted file mode 100644 index 41fce731d..000000000 --- a/src/java/org/apache/fop/afp/AFPPageFonts.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.afp; - -import org.apache.fop.afp.fonts.AFPFont; -import org.apache.fop.afp.fonts.AFPFontAttributes; - - -/** - * Holds the current page fonts - */ -public class AFPPageFonts extends java.util.HashMap { - private static final long serialVersionUID = -4991896259427109041L; - - /** - * Default constructor - */ - public AFPPageFonts() { - super(); - } - - /** - * Parameterized constructor - * - * @param fonts an existing set of afp page fonts - */ - public AFPPageFonts(AFPPageFonts fonts) { - super(fonts); - } - - /** - * Registers a font on the current page and returns font attributes - * - * @param fontName the internal font name - * @param font the AFPFont - * @param fontSize the font point size - * @return newly registered AFPFontAttributes - */ - public AFPFontAttributes registerFont(String fontName, AFPFont font, int fontSize) { - String pageFontKey = fontName + "_" + fontSize; - AFPFontAttributes afpFontAttributes = (AFPFontAttributes)super.get(pageFontKey); - // Add to page font mapping if not already present - if (afpFontAttributes == null) { - afpFontAttributes = new AFPFontAttributes(fontName, font, fontSize); - super.put(pageFontKey, afpFontAttributes); - afpFontAttributes.setFontReference(super.size()); - } - return afpFontAttributes; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPPaintingState.java b/src/java/org/apache/fop/afp/AFPPaintingState.java index 60e4812b9..cb78fb36e 100644 --- a/src/java/org/apache/fop/afp/AFPPaintingState.java +++ b/src/java/org/apache/fop/afp/AFPPaintingState.java @@ -21,6 +21,7 @@ package org.apache.fop.afp; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.fonts.AFPPageFonts; import org.apache.fop.util.AbstractPaintingState; /** @@ -42,7 +43,7 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState private boolean colorImages = false; /** images are supported in this AFP environment */ - private boolean nativeImages = false; + private boolean nativeImagesSupported = false; /** default value for image depth */ private int bitsPerPixel = 8; @@ -165,10 +166,10 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState /** * Sets whether images are natively supported or not in the AFP environment * - * @param nativeImages true if images are natively supported in this AFP environment + * @param nativeImagesSupported true if images are natively supported in this AFP environment */ - public void setNativeImages(boolean nativeImages) { - this.nativeImages = nativeImages; + public void setNativeImagesSupported(boolean nativeImagesSupported) { + this.nativeImagesSupported = nativeImagesSupported; } /** @@ -176,8 +177,8 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState * * @return true if images are supported natively in this AFP environment */ - public boolean isNativeImages() { - return this.nativeImages; + public boolean isNativeImagesSupported() { + return this.nativeImagesSupported; } /** diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java index c912b8b17..21de78250 100644 --- a/src/java/org/apache/fop/afp/AFPResourceManager.java +++ b/src/java/org/apache/fop/afp/AFPResourceManager.java @@ -23,8 +23,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.fop.afp.modca.AbstractDataObject; import org.apache.fop.afp.modca.AbstractNamedAFPObject; import org.apache.fop.afp.modca.DataStream; @@ -36,9 +34,6 @@ import org.apache.fop.afp.modca.ResourceGroup; * Manages the creation and storage of document resources */ public class AFPResourceManager { - /** Static logging instance */ - private static final Log log = LogFactory.getLog(AFPResourceManager.class); - /** The AFP datastream (document tree) */ private DataStream dataStream; diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java index 1d9367ef6..269e6ae08 100644 --- a/src/java/org/apache/fop/afp/AFPStreamer.java +++ b/src/java/org/apache/fop/afp/AFPStreamer.java @@ -44,7 +44,7 @@ public class AFPStreamer implements Streamable { private static final String AFPDATASTREAM_TEMP_FILE_PREFIX = "AFPDataStream_"; - private static final int BUFFER_SIZE = 4096; + private static final int BUFFER_SIZE = 4096; // 4k writing buffer private static final String DEFAULT_EXTERNAL_RESOURCE_FILENAME = "resources.afp"; @@ -159,8 +159,8 @@ public class AFPStreamer implements Streamable { * * @throws IOException if an an I/O exception of some sort has occurred */ - public void close() throws IOException { // write out any external resource groups + public void close() throws IOException { Iterator it = pathResourceGroupMap.entrySet().iterator(); while (it.hasNext()) { StreamedResourceGroup resourceGroup = (StreamedResourceGroup)it.next(); @@ -192,6 +192,7 @@ public class AFPStreamer implements Streamable { /** {@inheritDoc} */ public void writeToStream(OutputStream os) throws IOException { +// long start = System.currentTimeMillis(); int len = (int)documentFile.length(); int numChunks = len / BUFFER_SIZE; int remainingChunkSize = len % BUFFER_SIZE; @@ -212,5 +213,7 @@ public class AFPStreamer implements Streamable { os.write(buffer, 0, remainingChunkSize); } os.flush(); +// long end = System.currentTimeMillis(); +// log.debug("writing time " + (end - start) + "ms"); } } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/AFPTextElementBridge.java b/src/java/org/apache/fop/afp/AFPTextElementBridge.java deleted file mode 100644 index 2bfccf47d..000000000 --- a/src/java/org/apache/fop/afp/AFPTextElementBridge.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.afp; - -import org.apache.batik.bridge.SVGTextElementBridge; -import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.gvt.GraphicsNode; -import org.apache.batik.gvt.TextNode; -import org.apache.batik.gvt.TextPainter; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * Bridge class for the <text> element. - * This bridge will use the direct text painter if the text - * for the element is simple. - */ -public class AFPTextElementBridge extends SVGTextElementBridge { - - private AFPTextPainter textPainter; - - /** - * Constructs a new bridge for the <text> element. - * @param textPainter the text painter to use - */ - public AFPTextElementBridge(AFPTextPainter textPainter) { - this.textPainter = textPainter; - } - - /** - * Create a text element bridge. - * This set the text painter on the node if the text is simple. - * @param ctx the bridge context - * @param e the svg element - * @return the text graphics node created by the super class - */ - public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { - GraphicsNode node = super.createGraphicsNode(ctx, e); - if (node != null && isSimple(ctx, e, node)) { - ((TextNode)node).setTextPainter(getTextPainter()); - } - return node; - } - - private TextPainter getTextPainter() { - return this.textPainter; - } - - /** - * Check if text element contains simple text. - * This checks the children of the text element to determine - * if the text is simple. The text is simple if it can be rendered - * with basic text drawing algorithms. This means there are no - * alternate characters, the font is known and there are no effects - * applied to the text. - * - * @param ctx the bridge context - * @param element the svg text element - * @param node the graphics node - * @return true if this text is simple of false if it cannot be - * easily rendered using normal drawString on the PDFGraphics2D - */ - private boolean isSimple(BridgeContext ctx, Element element, GraphicsNode node) { - for (Node n = element.getFirstChild(); - n != null; - n = n.getNextSibling()) { - - switch (n.getNodeType()) { - case Node.ELEMENT_NODE: - - if (n.getLocalName().equals(SVG_TSPAN_TAG) - || n.getLocalName().equals(SVG_ALT_GLYPH_TAG)) { - return false; - } else if (n.getLocalName().equals(SVG_TEXT_PATH_TAG)) { - return false; - } else if (n.getLocalName().equals(SVG_TREF_TAG)) { - return false; - } - break; - case Node.TEXT_NODE: - case Node.CDATA_SECTION_NODE: - default: - } - } - - /*if (CSSUtilities.convertFilter(element, node, ctx) != null) { - return false; - }*/ - - return true; - } -} - diff --git a/src/java/org/apache/fop/afp/AFPTextHandler.java b/src/java/org/apache/fop/afp/AFPTextHandler.java deleted file mode 100644 index 77dc641b9..000000000 --- a/src/java/org/apache/fop/afp/AFPTextHandler.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.afp; - -import java.awt.Color; -import java.awt.geom.AffineTransform; -import java.io.IOException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.afp.fonts.AFPFont; -import org.apache.fop.afp.fonts.AFPFontAttributes; -import org.apache.fop.afp.modca.GraphicsObject; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontInfo; -import org.apache.xmlgraphics.java2d.TextHandler; - -/** - * Specialized TextHandler implementation that the AFPGraphics2D class delegates to to paint text - * using AFP GOCA text operations. - */ -public class AFPTextHandler implements TextHandler { - - /** logging instance */ - private static Log log = LogFactory.getLog(AFPTextHandler.class); - - private static final int X = 0; - private static final int Y = 1; - - private AFPGraphics2D g2d = null; - - /** Overriding FontState */ - protected Font overrideFont = null; - - /** - * Main constructor. - * - * @param g2d the AFPGraphics2D instance - */ - public AFPTextHandler(AFPGraphics2D g2d) { - this.g2d = g2d; - } - - /** - * Return the font information associated with this object - * - * @return the FontInfo object - */ - public FontInfo getFontInfo() { - return g2d.getFontInfo(); - } - - /** - * Registers a page font - * - * @param internalFontName the internal font name - * @param fontSize the font size - * @return a font reference - */ - private int registerPageFont(String internalFontName, int fontSize) { - FontInfo fontInfo = getFontInfo(); - AFPFont afpFont = (AFPFont)fontInfo.getFonts().get(internalFontName); - AFPPaintingState paintingState = g2d.getPaintingState(); - AFPPageFonts pageFonts = paintingState.getPageFonts(); - // register if necessary - AFPFontAttributes afpFontAttributes = pageFonts.registerFont( - internalFontName, - afpFont, - fontSize - ); - return afpFontAttributes.getFontReference(); - } - - /** - * Add a text string to the current data object of the AFP datastream. - * The text is painted using text operations. - * - * {@inheritDoc} - */ - public void drawString(String str, float x, float y) throws IOException { - log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y); - GraphicsObject graphicsObj = g2d.getGraphicsObject(); - Color color = g2d.getColor(); - - // set the color - AFPPaintingState paintingState = g2d.getPaintingState(); - if (paintingState.setColor(color)) { - graphicsObj.setColor(color); - } - - // set the character set - int fontReference = 0; - if (overrideFont != null) { - String internalFontName = overrideFont.getFontName(); - int fontSize = overrideFont.getFontSize(); - fontReference = registerPageFont(internalFontName, fontSize); - } else { - java.awt.Font awtFont = g2d.getFont(); - AffineTransform fontTransform = awtFont.getTransform(); - FontInfo fontInfo = getFontInfo(); - Font fopFont = fontInfo.getFontInstanceForAWTFont(awtFont); - String internalFontName = fopFont.getFontName(); - int fontSize = fopFont.getFontSize(); - fontReference = registerPageFont(internalFontName, fontSize); - } - graphicsObj.setCharacterSet(fontReference); - - // calculate x, y plotting coordinates from graphics context - AffineTransform at = g2d.getTransform(); - float[] srcPts = new float[] { x, y }; - float[] dstPts = new float[srcPts.length]; - at.transform(srcPts, 0, dstPts, 0, 1); - - // add the character string - graphicsObj.addString(str, Math.round(dstPts[X]), Math.round(dstPts[Y])); - } - - /** - * Sets the overriding font. - * - * @param overrideFont Overriding Font to set - */ - public void setOverrideFont(Font overrideFont) { - this.overrideFont = overrideFont; - } -} diff --git a/src/java/org/apache/fop/afp/AFPTextPainter.java b/src/java/org/apache/fop/afp/AFPTextPainter.java deleted file mode 100644 index 7e3f3405f..000000000 --- a/src/java/org/apache/fop/afp/AFPTextPainter.java +++ /dev/null @@ -1,514 +0,0 @@ -/* - * 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.afp; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Paint; -import java.awt.Shape; -import java.awt.font.TextAttribute; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.io.IOException; -import java.text.AttributedCharacterIterator; -import java.text.CharacterIterator; -import java.util.Iterator; -import java.util.List; - -import org.apache.batik.dom.svg.SVGOMTextElement; -import org.apache.batik.gvt.TextNode; -import org.apache.batik.gvt.TextPainter; -import org.apache.batik.gvt.font.GVTFontFamily; -import org.apache.batik.gvt.renderer.StrokingTextPainter; -import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; -import org.apache.batik.gvt.text.Mark; -import org.apache.batik.gvt.text.TextPaintInfo; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.fonts.Font; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontTriplet; - - -/** - * Renders the attributed character iterator of a TextNode. - * This class draws the text directly into the AFPGraphics2D so that - * the text is not drawn using shapes. - * If the text is simple enough to draw then it sets the font and calls - * drawString. If the text is complex or the cannot be translated - * into a simple drawString the StrokingTextPainter is used instead. - */ -public class AFPTextPainter implements TextPainter { - - /** the logger for this class */ - protected Log log = LogFactory.getLog(AFPTextPainter.class); - - private final AFPTextHandler nativeTextHandler; - - /** - * 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 - PROXY_PAINTER = StrokingTextPainter.getInstance(); - - /** - * Create a new PS text painter with the given font information. - * @param nativeTextHandler the NativeTextHandler instance used for text painting - */ - public AFPTextPainter(AFPTextHandler nativeTextHandler) { - this.nativeTextHandler = nativeTextHandler; - } - - /** - * Paints the specified attributed character iterator using the - * specified Graphics2D and context and font context. - * @param node the TextNode to paint - * @param g2d the Graphics2D to use - */ - public void paint(TextNode node, Graphics2D g2d) { - Point2D loc = node.getLocation(); - log.debug("painting text node " + node); - if (hasUnsupportedAttributes(node)) { - log.debug("hasunsuportedattributes"); - PROXY_PAINTER.paint(node, g2d); - } else { - log.debug("allattributessupported"); - paintTextRuns(node.getTextRuns(), g2d, loc); - } - } - - private boolean hasUnsupportedAttributes(TextNode node) { - Iterator iter = node.getTextRuns().iterator(); - while (iter.hasNext()) { - StrokingTextPainter.TextRun - run = (StrokingTextPainter.TextRun)iter.next(); - AttributedCharacterIterator aci = run.getACI(); - boolean hasUnsupported = hasUnsupportedAttributes(aci); - if (hasUnsupported) { - return true; - } - } - return false; - } - - 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) - && ((tpi.strokeStroke != null && tpi.strokePaint != null) - || (tpi.strikethroughStroke != null) - || (tpi.underlineStroke != null) - || (tpi.overlineStroke != null))) { - log.trace("-> under/overlines etc. found"); - hasUnsupported = true; - } - - //Alpha is not supported - Paint foreground = (Paint) aci.getAttribute(TextAttribute.FOREGROUND); - if (foreground instanceof Color) { - Color col = (Color)foreground; - if (col.getAlpha() != 255) { - log.trace("-> transparency found"); - hasUnsupported = true; - } - } - - Object letSpace = aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.LETTER_SPACING); - if (letSpace != null) { - log.trace("-> letter spacing found"); - hasUnsupported = true; - } - - Object wordSpace = aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.WORD_SPACING); - if (wordSpace != null) { - log.trace("-> word spacing found"); - hasUnsupported = true; - } - - Object lengthAdjust = aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.LENGTH_ADJUST); - if (lengthAdjust != null) { - log.trace("-> length adjustments found"); - hasUnsupported = true; - } - - Object writeMod = aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE); - if (writeMod != null - && !GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE_LTR.equals( - writeMod)) { - log.trace("-> Unsupported writing modes found"); - hasUnsupported = true; - } - - Object vertOr = aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.VERTICAL_ORIENTATION); - if (GVTAttributedCharacterIterator.TextAttribute.ORIENTATION_ANGLE.equals( - vertOr)) { - 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 - //be painted or not, i.e. fall back to stroking. :-( - if (rcDel != null && !(rcDel instanceof SVGOMTextElement)) { - log.trace("-> spans found"); - hasUnsupported = true; //Filter spans - } - - if (hasUnsupported) { - log.trace("Unsupported attributes found in ACI, using StrokingTextPainter"); - } - return hasUnsupported; - } - - /** - * Paint a list of text runs on the Graphics2D at a given location. - * @param textRuns the list of text runs - * @param g2d the Graphics2D to paint to - * @param loc the current location of the "cursor" - */ - protected void paintTextRuns(List textRuns, Graphics2D g2d, Point2D loc) { - Point2D currentloc = loc; - Iterator i = textRuns.iterator(); - while (i.hasNext()) { - StrokingTextPainter.TextRun - run = (StrokingTextPainter.TextRun)i.next(); - currentloc = paintTextRun(run, g2d, currentloc); - } - } - - /** - * Paint a single text run on the Graphics2D at a given location. - * @param run the text run to paint - * @param g2d the Graphics2D to paint to - * @param loc the current location of the "cursor" - * @return the new location of the "cursor" after painting the text run - */ - protected Point2D paintTextRun(StrokingTextPainter.TextRun run, Graphics2D g2d, Point2D loc) { - AttributedCharacterIterator aci = run.getACI(); - aci.first(); - - updateLocationFromACI(aci, loc); - loc = g2d.getTransform().transform(loc, null); - - // font - Font font = makeFont(aci); - nativeTextHandler.setOverrideFont(font); - - // color - TextPaintInfo tpi = (TextPaintInfo) aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO); - if (tpi == null) { - return loc; - } - Paint foreground = tpi.fillPaint; - if (foreground instanceof Color) { - Color col = (Color)foreground; - g2d.setColor(col); - } - g2d.setPaint(foreground); - - String txt = getText(aci); - float advance = getStringWidth(txt, font); - float tx = 0; - TextNode.Anchor anchor = (TextNode.Anchor)aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE); - if (anchor != null) { - switch (anchor.getType()) { - case TextNode.Anchor.ANCHOR_MIDDLE: - tx = -advance / 2; - break; - case TextNode.Anchor.ANCHOR_END: - tx = -advance; - break; - default: //nop - } - } - - // draw string - try { - try { - nativeTextHandler.drawString(txt, (float)(loc.getX() + tx), (float)(loc.getY())); - } catch (IOException ioe) { - if (g2d instanceof AFPGraphics2D) { - ((AFPGraphics2D)g2d).handleIOException(ioe); - } - } - } finally { - nativeTextHandler.setOverrideFont(null); - } - loc.setLocation(loc.getX() + advance, loc.getY()); - return loc; - } - - /** - * Extract the raw text from an ACI. - * @param aci ACI to inspect - * @return the extracted text - */ - protected String getText(AttributedCharacterIterator aci) { - StringBuffer sb = new StringBuffer(aci.getEndIndex() - aci.getBeginIndex()); - for (char c = aci.first(); c != CharacterIterator.DONE; c = aci.next()) { - sb.append(c); - } - return sb.toString(); - } - - private void updateLocationFromACI( - AttributedCharacterIterator aci, - Point2D loc) { - //Adjust position of span - Float xpos = (Float)aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.X); - Float ypos = (Float)aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.Y); - Float dxpos = (Float)aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.DX); - Float dypos = (Float)aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.DY); - if (xpos != null) { - loc.setLocation(xpos.doubleValue(), loc.getY()); - } - 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)) - ? Font.STYLE_ITALIC - : Font.STYLE_NORMAL; - } - - private int getWeight(AttributedCharacterIterator aci) { - Float taWeight = (Float)aci.getAttribute(TextAttribute.WEIGHT); - return ((taWeight != null) && (taWeight.floatValue() > 1.0)) - ? Font.WEIGHT_BOLD - : Font.WEIGHT_NORMAL; - } - - private Font makeFont(AttributedCharacterIterator aci) { - Float fontSize = (Float)aci.getAttribute(TextAttribute.SIZE); - if (fontSize == null) { - fontSize = new Float(10.0f); - } - String style = getStyle(aci); - int weight = getWeight(aci); - - FontInfo fontInfo = nativeTextHandler.getFontInfo(); - String fontFamily = null; - List gvtFonts = (List) aci.getAttribute( - GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES); - if (gvtFonts != null) { - Iterator i = gvtFonts.iterator(); - while (i.hasNext()) { - GVTFontFamily fam = (GVTFontFamily) i.next(); - /* (todo) Enable SVG Font painting - if (fam instanceof SVGFontFamily) { - PROXY_PAINTER.paint(node, g2d); - return; - }*/ - fontFamily = fam.getFamilyName(); - if (fontInfo.hasFont(fontFamily, style, weight)) { - FontTriplet triplet = fontInfo.fontLookup( - fontFamily, style, weight); - int fsize = (int)(fontSize.floatValue() * 1000); - return fontInfo.getFontInstance(triplet, fsize); - } - } - } - FontTriplet triplet = fontInfo.fontLookup("any", style, Font.WEIGHT_NORMAL); - int fsize = (int)(fontSize.floatValue() * 1000); - return fontInfo.getFontInstance(triplet, fsize); - } - - private float getStringWidth(String str, Font font) { - float wordWidth = 0; - float whitespaceWidth = font.getWidth(font.mapChar(' ')); - - for (int i = 0; i < str.length(); i++) { - float charWidth; - char c = str.charAt(i); - if (!((c == ' ') || (c == '\n') || (c == '\r') || (c == '\t'))) { - charWidth = font.getWidth(font.mapChar(c)); - if (charWidth <= 0) { - charWidth = whitespaceWidth; - } - } else { - charWidth = whitespaceWidth; - } - wordWidth += charWidth; - } - return wordWidth / 1000f; - } - - private boolean hasUnsupportedGlyphs(String str, Font font) { - for (int i = 0; i < str.length(); i++) { - char c = str.charAt(i); - if (!((c == ' ') || (c == '\n') || (c == '\r') || (c == '\t'))) { - if (!font.hasChar(c)) { - return true; - } - } - } - return false; - } - - /** - * Get the outline shape of the text characters. - * This uses the StrokingTextPainter to get the outline - * shape since in theory it should be the same. - * - * @param node the text node - * @return the outline shape of the text characters - */ - public Shape getOutline(TextNode node) { - return PROXY_PAINTER.getOutline(node); - } - - /** - * Get the bounds. - * This uses the StrokingTextPainter to get the bounds - * since in theory it should be the same. - * - * @param node the text node - * @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 - * method ourselves. */ - return PROXY_PAINTER.getBounds2D(node); - } - - /** - * Get the geometry bounds. - * This uses the StrokingTextPainter to get the bounds - * since in theory it should be the same. - * @param node the text node - * @return the bounds of the text - */ - public Rectangle2D getGeometryBounds(TextNode node) { - return PROXY_PAINTER.getGeometryBounds(node); - } - - // Methods that have no purpose for PS - - /** - * Get the mark. - * This does nothing since the output is AFP and not interactive. - * @param node the text node - * @param pos the position - * @param all select all - * @return null - */ - public Mark getMark(TextNode node, int pos, boolean all) { - return null; - } - - /** - * Select at. - * This does nothing since the output is AFP and not interactive. - * @param x the x position - * @param y the y position - * @param node the text node - * @return null - */ - public Mark selectAt(double x, double y, TextNode node) { - return null; - } - - /** - * Select to. - * This does nothing since the output is AFP and not interactive. - * @param x the x position - * @param y the y position - * @param beginMark the start mark - * @return null - */ - public Mark selectTo(double x, double y, Mark beginMark) { - return null; - } - - /** - * Selec first. - * This does nothing since the output is AFP and not interactive. - * @param node the text node - * @return null - */ - public Mark selectFirst(TextNode node) { - return null; - } - - /** - * Select last. - * This does nothing since the output is AFP and not interactive. - * @param node the text node - * @return null - */ - public Mark selectLast(TextNode node) { - return null; - } - - /** - * Get selected. - * This does nothing since the output is AFP and not interactive. - * @param start the start mark - * @param finish the finish mark - * @return null - */ - public int[] getSelected(Mark start, Mark finish) { - return null; - } - - /** - * Get the highlighted shape. - * This does nothing since the output is AFP and not interactive. - * @param beginMark the start mark - * @param endMark the end mark - * @return null - */ - public Shape getHighlightShape(Mark beginMark, Mark endMark) { - return null; - } - -} diff --git a/src/java/org/apache/fop/afp/Graphics2DImagePainterGOCA.java b/src/java/org/apache/fop/afp/Graphics2DImagePainterGOCA.java index 1a2883e72..6a7538550 100644 --- a/src/java/org/apache/fop/afp/Graphics2DImagePainterGOCA.java +++ b/src/java/org/apache/fop/afp/Graphics2DImagePainterGOCA.java @@ -51,7 +51,7 @@ public class Graphics2DImagePainterGOCA extends Graphics2DImagePainterImpl { /** {@inheritdoc} */ public void prepare(Graphics2D g2d, Rectangle2D area) { double tx = area.getX(); - double ty = area.getHeight() - area.getY(); + double ty = area.getHeight() + area.getY(); if (tx != 0 || ty != 0) { g2d.translate(tx, ty); } diff --git a/src/java/org/apache/fop/afp/fonts/AFPFontAttributes.java b/src/java/org/apache/fop/afp/fonts/AFPFontAttributes.java index 1dd22c66a..de7f7f5be 100644 --- a/src/java/org/apache/fop/afp/fonts/AFPFontAttributes.java +++ b/src/java/org/apache/fop/afp/fonts/AFPFontAttributes.java @@ -23,32 +23,24 @@ package org.apache.fop.afp.fonts; * This class encapsulates the font attributes that need to be included * in the AFP data stream. This class does not assist in converting the * font attributes to AFP code pages and character set values. - * */ public class AFPFontAttributes { - /** - * The font reference - */ + /** the font reference */ private int fontReference; - /** - * The font key - */ + /** the font key */ private final String fontKey; - /** - * The font - */ + /** the font */ private final AFPFont font; - /** - * The point size - */ + /** the point size */ private final int pointSize; /** * Constructor for the AFPFontAttributes + * * @param fontKey the font key * @param font the font * @param pointSize the point size @@ -60,6 +52,8 @@ public class AFPFontAttributes { } /** + * Return the font + * * @return the font */ public AFPFont getFont() { @@ -67,6 +61,8 @@ public class AFPFontAttributes { } /** + * Return the FontKey attribute + * * @return the FontKey attribute */ public String getFontKey() { @@ -74,6 +70,8 @@ public class AFPFontAttributes { } /** + * Return the point size attribute + * * @return the point size attribute */ public int getPointSize() { @@ -81,6 +79,8 @@ public class AFPFontAttributes { } /** + * Return the FontReference attribute + * * @return the FontReference attribute */ public int getFontReference() { @@ -89,6 +89,7 @@ public class AFPFontAttributes { /** * Sets the FontReference attribute + * * @param fontReference the FontReference to set */ public void setFontReference(int fontReference) { diff --git a/src/java/org/apache/fop/afp/fonts/AFPPageFonts.java b/src/java/org/apache/fop/afp/fonts/AFPPageFonts.java new file mode 100644 index 000000000..146c6f14b --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/AFPPageFonts.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.afp.fonts; + +/** + * Holds the current page fonts + */ +public class AFPPageFonts extends java.util.HashMap { + private static final long serialVersionUID = -4991896259427109041L; + + /** + * Default constructor + */ + public AFPPageFonts() { + super(); + } + + /** + * Parameterized constructor + * + * @param fonts an existing set of afp page fonts + */ + public AFPPageFonts(AFPPageFonts fonts) { + super(fonts); + } + + /** + * Registers a font on the current page and returns font attributes + * + * @param fontName the internal font name + * @param font the AFPFont + * @param fontSize the font point size + * @return newly registered AFPFontAttributes + */ + public AFPFontAttributes registerFont(String fontName, AFPFont font, int fontSize) { + String pageFontKey = fontName + "_" + fontSize; + AFPFontAttributes afpFontAttributes = (AFPFontAttributes)super.get(pageFontKey); + // Add to page font mapping if not already present + if (afpFontAttributes == null) { + afpFontAttributes = new AFPFontAttributes(fontName, font, fontSize); + super.put(pageFontKey, afpFontAttributes); + afpFontAttributes.setFontReference(super.size()); + } + return afpFontAttributes; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/fonts/package.html b/src/java/org/apache/fop/afp/fonts/package.html new file mode 100644 index 000000000..74f8bf450 --- /dev/null +++ b/src/java/org/apache/fop/afp/fonts/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.afp.goca Package + +

      Contains a collection of AFP Graphics Object Content Architecture (GOCA) structured objects.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java index 6f993b840..3adcd9466 100644 --- a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java +++ b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java @@ -73,7 +73,6 @@ public abstract class AbstractGraphicsCoord extends AbstractPreparedAFPObject { * Returns the length of this order code (typically this is the same as the coordinate length) * * @return the length of this order code - * */ protected int getLength() { return this.coords.length * 2; diff --git a/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java b/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java new file mode 100644 index 000000000..b0e408405 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.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.afp.goca; + +/** + * A GOCA graphics curved tangential line to a specified set of + * straight lines drawn from the given position or current position + */ +public final class GraphicsFilletRelative extends AbstractGraphicsCoord { + + /** + * Constructor + * + * @param coords the x/y coordinates for this object + */ + public GraphicsFilletRelative(int[] coords) { + super(coords); + } + + /** {@inheritDoc} */ + protected byte getOrderCode() { + return (byte)0x85; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsLine.java b/src/java/org/apache/fop/afp/goca/GraphicsLine.java index 319a9a122..99f54b2d1 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsLine.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsLine.java @@ -19,10 +19,9 @@ package org.apache.fop.afp.goca; - /** * A GOCA graphics straight line drawn from the - * given position or current position. + * given position */ public class GraphicsLine extends AbstractGraphicsCoord { diff --git a/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java b/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java new file mode 100644 index 000000000..1eddc5129 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.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.afp.goca; + +/** + * A GOCA graphics straight line drawn from the + * relative from the current position. + */ +public class GraphicsLineRelative extends AbstractGraphicsCoord { + + /** + * Constructor + * + * @param coords the x/y coordinates for this object + */ + public GraphicsLineRelative(int[] coords) { + super(coords); + } + + /** {@inheritDoc} */ + protected byte getOrderCode() { + return (byte)0x81; + } + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/package.html b/src/java/org/apache/fop/afp/goca/package.html new file mode 100644 index 000000000..539be8d13 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.afp.fonts Package + +

      Contains a collection of AFP font related classes.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/package.html b/src/java/org/apache/fop/afp/ioca/package.html new file mode 100644 index 000000000..34e0bc19d --- /dev/null +++ b/src/java/org/apache/fop/afp/ioca/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.afp.ioca Package + +

      Contains a collection of AFP Image Object Content Architecture (IOCA) structured objects.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/afp/modca/GraphicsObject.java index 8b76dde15..3848ca4c3 100644 --- a/src/java/org/apache/fop/afp/modca/GraphicsObject.java +++ b/src/java/org/apache/fop/afp/modca/GraphicsObject.java @@ -30,8 +30,10 @@ import org.apache.fop.afp.Factory; import org.apache.fop.afp.goca.GraphicsBox; import org.apache.fop.afp.goca.GraphicsData; import org.apache.fop.afp.goca.GraphicsFillet; +import org.apache.fop.afp.goca.GraphicsFilletRelative; import org.apache.fop.afp.goca.GraphicsFullArc; import org.apache.fop.afp.goca.GraphicsLine; +import org.apache.fop.afp.goca.GraphicsLineRelative; import org.apache.fop.afp.goca.GraphicsSetArcParameters; import org.apache.fop.afp.goca.GraphicsSetCharacterSet; import org.apache.fop.afp.goca.GraphicsSetCurrentPosition; @@ -181,7 +183,21 @@ public class GraphicsObject extends AbstractDataObject { * @param coords the x/y coordinates (can be a series) */ public void addLine(int[] coords) { - addObject(new GraphicsLine(coords)); + addLine(coords, false); + } + + /** + * Adds a line at the given x/y coordinates + * + * @param coords the x/y coordinates (can be a series) + * @param relative relative true for a line at current position (relative to) + */ + public void addLine(int[] coords, boolean relative) { + if (relative) { + addObject(new GraphicsLineRelative(coords)); + } else { + addObject(new GraphicsLine(coords)); + } } /** @@ -199,7 +215,21 @@ public class GraphicsObject extends AbstractDataObject { * @param coords the x/y coordinates */ public void addFillet(int[] coords) { - addObject(new GraphicsFillet(coords)); + addFillet(coords, false); + } + + /** + * Adds a fillet (curve) at the given coordinates + * + * @param coords the x/y coordinates + * @param relative relative true for a fillet at current position (relative to) + */ + public void addFillet(int[] coords, boolean relative) { + if (relative) { + addObject(new GraphicsFilletRelative(coords)); + } else { + addObject(new GraphicsFillet(coords)); + } } /** @@ -300,4 +330,5 @@ public class GraphicsObject extends AbstractDataObject { copySF(data, Type.END, Category.GRAPHICS); os.write(data); } + } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/package.html b/src/java/org/apache/fop/afp/modca/package.html new file mode 100644 index 000000000..572743558 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.afp.modca Package + +

      Contains a collection of AFP Mixed Object Document Content Architecture (MO:DCA) structured objects.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/triplets/package.html b/src/java/org/apache/fop/afp/modca/triplets/package.html new file mode 100644 index 000000000..99ae55a45 --- /dev/null +++ b/src/java/org/apache/fop/afp/modca/triplets/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.afp.modca.triplets Package + +

      Contains a collection of AFP Mixed Object Document Content Architecture (MO:DCA) triplet classes.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/package.html b/src/java/org/apache/fop/afp/package.html new file mode 100644 index 000000000..d67498159 --- /dev/null +++ b/src/java/org/apache/fop/afp/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.afp Package + +

      Contains an AFP library.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java b/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java new file mode 100644 index 000000000..5434b5b9d --- /dev/null +++ b/src/java/org/apache/fop/afp/svg/AFPBridgeContext.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.afp.svg; + +import java.awt.geom.AffineTransform; + +import org.apache.batik.bridge.BridgeContext; +import org.apache.batik.bridge.DocumentLoader; +import org.apache.batik.bridge.UserAgent; +import org.apache.batik.gvt.TextPainter; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.svg.AbstractFOPBridgeContext; +import org.apache.xmlgraphics.image.loader.ImageManager; +import org.apache.xmlgraphics.image.loader.ImageSessionContext; + +public class AFPBridgeContext extends AbstractFOPBridgeContext { + + private final AFPGraphics2D g2d; + + /** + * Constructs a new bridge context. + * + * @param userAgent the user agent + * @param fontInfo the font list for the text painter, may be null + * in which case text is painted as shapes + * @param imageManager an image manager + * @param imageSessionContext an image session context + * @param linkTransform AffineTransform to properly place links, + * may be null + * @param g2d an AFPGraphics 2D implementation + */ + public AFPBridgeContext(UserAgent userAgent, FontInfo fontInfo, + ImageManager imageManager, ImageSessionContext imageSessionContext, + AffineTransform linkTransform, AFPGraphics2D g2d) { + super(userAgent, fontInfo, imageManager, imageSessionContext, linkTransform); + this.g2d = g2d; + } + + /** + * Constructs a new bridge context. + * @param userAgent the user agent + * @param loader the Document Loader to use for referenced documents. + * @param fontInfo the font list for the text painter, may be null + * in which case text is painted as shapes + * @param linkTransform AffineTransform to properly place links, + * may be null + * @param imageManager an image manager + * @param imageSessionContext an image session context + * @param linkTransform AffineTransform to properly place links, + * may be null + * @param an AFPGraphics 2D implementation + */ + public AFPBridgeContext(UserAgent userAgent, DocumentLoader documentLoader, + FontInfo fontInfo, ImageManager imageManager, + ImageSessionContext imageSessionContext, + AffineTransform linkTransform, AFPGraphics2D g2d) { + super(userAgent, documentLoader, fontInfo, imageManager, imageSessionContext, linkTransform); + this.g2d = g2d; + } + + /** {@inheritDoc} */ + public void registerSVGBridges() { + super.registerSVGBridges(); + + if (fontInfo != null) { + AFPTextHandler textHandler = new AFPTextHandler(g2d); + g2d.setCustomTextHandler(textHandler); + + TextPainter textPainter = new AFPTextPainter(textHandler); + setTextPainter(textPainter); + + putBridge(new AFPTextElementBridge(textPainter)); + } + + putBridge(new AFPImageElementBridge()); + } + + /** {@inheritDoc} */ + public BridgeContext createBridgeContext() { + return new AFPBridgeContext(getUserAgent(), getDocumentLoader(), + fontInfo, + getImageManager(), + getImageSessionContext(), + linkTransform, g2d); + } + +} diff --git a/src/java/org/apache/fop/afp/svg/AFPImageElementBridge.java b/src/java/org/apache/fop/afp/svg/AFPImageElementBridge.java new file mode 100644 index 000000000..de677e7ab --- /dev/null +++ b/src/java/org/apache/fop/afp/svg/AFPImageElementBridge.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.afp.svg; + +import org.apache.fop.svg.AbstractFOPImageElementBridge; +import org.apache.xmlgraphics.image.loader.ImageFlavor; + +public class AFPImageElementBridge extends AbstractFOPImageElementBridge { + + private final ImageFlavor[] supportedFlavors = new ImageFlavor[] + {ImageFlavor.RAW_JPEG, + ImageFlavor.RAW_CCITTFAX, + ImageFlavor.GRAPHICS2D, + ImageFlavor.XML_DOM}; + + /** {@inheritDoc} */ + protected ImageFlavor[] getSupportedFlavours() { + return supportedFlavors; + } +} diff --git a/src/java/org/apache/fop/afp/svg/AFPTextElementBridge.java b/src/java/org/apache/fop/afp/svg/AFPTextElementBridge.java new file mode 100644 index 000000000..31aa3fe60 --- /dev/null +++ b/src/java/org/apache/fop/afp/svg/AFPTextElementBridge.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.afp.svg; + +import org.apache.batik.gvt.TextPainter; +import org.apache.fop.svg.AbstractFOPTextElementBridge; + +/** + * Bridge class for the <text> element. + * This bridge will use the direct text painter if the text + * for the element is simple. + */ +public class AFPTextElementBridge extends AbstractFOPTextElementBridge { + + /** + * Constructs a new bridge for the <text> element. + * + * @param textPainter the text painter to use + */ + public AFPTextElementBridge(TextPainter textPainter) { + super(textPainter); + } + +} + diff --git a/src/java/org/apache/fop/afp/svg/AFPTextHandler.java b/src/java/org/apache/fop/afp/svg/AFPTextHandler.java new file mode 100644 index 000000000..d78e5c16e --- /dev/null +++ b/src/java/org/apache/fop/afp/svg/AFPTextHandler.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.afp.svg; + +import java.awt.Color; +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.afp.AFPPaintingState; +import org.apache.fop.afp.fonts.AFPFont; +import org.apache.fop.afp.fonts.AFPFontAttributes; +import org.apache.fop.afp.fonts.AFPPageFonts; +import org.apache.fop.afp.modca.GraphicsObject; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontInfo; +import org.apache.xmlgraphics.java2d.TextHandler; + +/** + * Specialized TextHandler implementation that the AFPGraphics2D class delegates to to paint text + * using AFP GOCA text operations. + */ +public class AFPTextHandler implements TextHandler { + + /** logging instance */ + private static Log log = LogFactory.getLog(AFPTextHandler.class); + + private AFPGraphics2D g2d = null; + + /** Overriding FontState */ + protected Font overrideFont = null; + + /** + * Main constructor. + * + * @param g2d the AFPGraphics2D instance + */ + public AFPTextHandler(AFPGraphics2D g2d) { + this.g2d = g2d; + } + + /** + * Return the font information associated with this object + * + * @return the FontInfo object + */ + public FontInfo getFontInfo() { + return g2d.getFontInfo(); + } + + /** + * Registers a page font + * + * @param internalFontName the internal font name + * @param fontSize the font size + * @return a font reference + */ + private int registerPageFont(String internalFontName, int fontSize) { + FontInfo fontInfo = getFontInfo(); + AFPFont afpFont = (AFPFont)fontInfo.getFonts().get(internalFontName); + AFPPaintingState paintingState = g2d.getPaintingState(); + AFPPageFonts pageFonts = paintingState.getPageFonts(); + // register if necessary + AFPFontAttributes afpFontAttributes = pageFonts.registerFont( + internalFontName, + afpFont, + fontSize + ); + return afpFontAttributes.getFontReference(); + } + + /** + * Add a text string to the current data object of the AFP datastream. + * The text is painted using text operations. + * + * {@inheritDoc} + */ + public void drawString(String str, float x, float y) throws IOException { + log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y); + GraphicsObject graphicsObj = g2d.getGraphicsObject(); + Color color = g2d.getColor(); + + // set the color + AFPPaintingState paintingState = g2d.getPaintingState(); + if (paintingState.setColor(color)) { + graphicsObj.setColor(color); + } + + // set the character set + int fontReference = 0; + if (overrideFont != null) { + String internalFontName = overrideFont.getFontName(); + int fontSize = overrideFont.getFontSize(); + fontReference = registerPageFont(internalFontName, fontSize); + } else { + java.awt.Font awtFont = g2d.getFont(); +// AffineTransform fontTransform = awtFont.getTransform(); + FontInfo fontInfo = getFontInfo(); + Font fopFont = fontInfo.getFontInstanceForAWTFont(awtFont); + String internalFontName = fopFont.getFontName(); + int fontSize = fopFont.getFontSize(); + fontReference = registerPageFont(internalFontName, fontSize); + } + graphicsObj.setCharacterSet(fontReference); + + // add the character string + graphicsObj.addString(str, Math.round(x), Math.round(y)); + } + + /** + * Sets the overriding font. + * + * @param overrideFont Overriding Font to set + */ + public void setOverrideFont(Font overrideFont) { + this.overrideFont = overrideFont; + } +} diff --git a/src/java/org/apache/fop/afp/svg/AFPTextPainter.java b/src/java/org/apache/fop/afp/svg/AFPTextPainter.java new file mode 100644 index 000000000..2d68616a3 --- /dev/null +++ b/src/java/org/apache/fop/afp/svg/AFPTextPainter.java @@ -0,0 +1,529 @@ +/* + * 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.afp.svg; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.font.TextAttribute; +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.text.AttributedCharacterIterator; +import java.text.CharacterIterator; +import java.util.Iterator; +import java.util.List; + +import org.apache.batik.dom.svg.SVGOMTextElement; +import org.apache.batik.gvt.TextNode; +import org.apache.batik.gvt.TextPainter; +import org.apache.batik.gvt.font.GVTFontFamily; +import org.apache.batik.gvt.renderer.StrokingTextPainter; +import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; +import org.apache.batik.gvt.text.Mark; +import org.apache.batik.gvt.text.TextPaintInfo; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.FontInfo; +import org.apache.fop.fonts.FontTriplet; + + +/** + * Renders the attributed character iterator of a TextNode. + * This class draws the text directly into the AFPGraphics2D so that + * the text is not drawn using shapes. + * If the text is simple enough to draw then it sets the font and calls + * drawString. If the text is complex or the cannot be translated + * into a simple drawString the StrokingTextPainter is used instead. + */ +public class AFPTextPainter implements TextPainter { + + /** the logger for this class */ + protected Log log = LogFactory.getLog(AFPTextPainter.class); + + private final AFPTextHandler nativeTextHandler; + + /** + * 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 + PROXY_PAINTER = StrokingTextPainter.getInstance(); + + /** + * Create a new PS text painter with the given font information. + * @param nativeTextHandler the NativeTextHandler instance used for text painting + */ + public AFPTextPainter(AFPTextHandler nativeTextHandler) { + this.nativeTextHandler = nativeTextHandler; + } + + /** + * Paints the specified attributed character iterator using the + * specified Graphics2D and context and font context. + * + * @param node the TextNode to paint + * @param g2d the Graphics2D to use + */ + public void paint(TextNode node, Graphics2D g2d) { + Point2D loc = node.getLocation(); + log.debug("painting text node " + node); + if (hasUnsupportedAttributes(node)) { + log.debug("hasUnsuportedAttributes"); + PROXY_PAINTER.paint(node, g2d); + } else { + log.debug("allAttributesSupported"); + paintTextRuns(node.getTextRuns(), g2d, loc); + } + } + + private boolean hasUnsupportedAttributes(TextNode node) { + Iterator iter = node.getTextRuns().iterator(); + while (iter.hasNext()) { + StrokingTextPainter.TextRun + run = (StrokingTextPainter.TextRun)iter.next(); + AttributedCharacterIterator aci = run.getACI(); + boolean hasUnsupported = hasUnsupportedAttributes(aci); + if (hasUnsupported) { + return true; + } + } + return false; + } + + 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) + && ((tpi.strokeStroke != null && tpi.strokePaint != null) + || (tpi.strikethroughStroke != null) + || (tpi.underlineStroke != null) + || (tpi.overlineStroke != null))) { + log.trace("-> under/overlines etc. found"); + hasUnsupported = true; + } + + //Alpha is not supported + Paint foreground = (Paint) aci.getAttribute(TextAttribute.FOREGROUND); + if (foreground instanceof Color) { + Color col = (Color)foreground; + if (col.getAlpha() != 255) { + log.trace("-> transparency found"); + hasUnsupported = true; + } + } + + Object letSpace = aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.LETTER_SPACING); + if (letSpace != null) { + log.trace("-> letter spacing found"); + hasUnsupported = true; + } + + Object wordSpace = aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.WORD_SPACING); + if (wordSpace != null) { + log.trace("-> word spacing found"); + hasUnsupported = true; + } + + Object lengthAdjust = aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.LENGTH_ADJUST); + if (lengthAdjust != null) { + log.trace("-> length adjustments found"); + hasUnsupported = true; + } + + Object writeMod = aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE); + if (writeMod != null + && !GVTAttributedCharacterIterator.TextAttribute.WRITING_MODE_LTR.equals( + writeMod)) { + log.trace("-> Unsupported writing modes found"); + hasUnsupported = true; + } + + Object vertOr = aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.VERTICAL_ORIENTATION); + if (GVTAttributedCharacterIterator.TextAttribute.ORIENTATION_ANGLE.equals( + vertOr)) { + 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 + //be painted or not, i.e. fall back to stroking. :-( + if (rcDel != null && !(rcDel instanceof SVGOMTextElement)) { + log.trace("-> spans found"); + hasUnsupported = true; //Filter spans + } + + if (hasUnsupported) { + log.trace("Unsupported attributes found in ACI, using StrokingTextPainter"); + } + return hasUnsupported; + } + + /** + * Paint a list of text runs on the Graphics2D at a given location. + * @param textRuns the list of text runs + * @param g2d the Graphics2D to paint to + * @param loc the current location of the "cursor" + */ + protected void paintTextRuns(List textRuns, Graphics2D g2d, Point2D loc) { + Point2D currentloc = loc; + Iterator i = textRuns.iterator(); + while (i.hasNext()) { + StrokingTextPainter.TextRun + run = (StrokingTextPainter.TextRun)i.next(); + currentloc = paintTextRun(run, g2d, currentloc); + } + } + + /** + * Paint a single text run on the Graphics2D at a given location. + * @param run the text run to paint + * @param g2d the Graphics2D to paint to + * @param loc the current location of the "cursor" + * @return the new location of the "cursor" after painting the text run + */ + protected Point2D paintTextRun(StrokingTextPainter.TextRun run, Graphics2D g2d, Point2D loc) { + AttributedCharacterIterator aci = run.getACI(); + aci.first(); + + updateLocationFromACI(aci, loc); + AffineTransform at = g2d.getTransform(); + loc = at.transform(loc, null); + + // font + Font font = makeFont(aci); + nativeTextHandler.setOverrideFont(font); + + // color + TextPaintInfo tpi = (TextPaintInfo) aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.PAINT_INFO); + if (tpi == null) { + return loc; + } + Paint foreground = tpi.fillPaint; + if (foreground instanceof Color) { + Color col = (Color)foreground; + g2d.setColor(col); + } + g2d.setPaint(foreground); + + // text + String txt = getText(aci); + float advance = getStringWidth(txt, font); + float tx = 0; + TextNode.Anchor anchor = (TextNode.Anchor)aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.ANCHOR_TYPE); + if (anchor != null) { + switch (anchor.getType()) { + case TextNode.Anchor.ANCHOR_MIDDLE: + tx = -advance / 2; + break; + case TextNode.Anchor.ANCHOR_END: + tx = -advance; + break; + default: //nop + } + } + + // draw string + double x = loc.getX(); + double y = loc.getY(); + try { + try { + nativeTextHandler.drawString(txt, (float)x + tx, (float)y); + } catch (IOException ioe) { + if (g2d instanceof AFPGraphics2D) { + ((AFPGraphics2D)g2d).handleIOException(ioe); + } + } + } finally { + nativeTextHandler.setOverrideFont(null); + } + loc.setLocation(loc.getX() + advance, loc.getY()); + return loc; + } + + /** + * Extract the raw text from an ACI. + * @param aci ACI to inspect + * @return the extracted text + */ + protected String getText(AttributedCharacterIterator aci) { + StringBuffer sb = new StringBuffer(aci.getEndIndex() - aci.getBeginIndex()); + for (char c = aci.first(); c != CharacterIterator.DONE; c = aci.next()) { + sb.append(c); + } + return sb.toString(); + } + + private void updateLocationFromACI( + AttributedCharacterIterator aci, + Point2D loc) { + //Adjust position of span + Float xpos = (Float)aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.X); + Float ypos = (Float)aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.Y); + Float dxpos = (Float)aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.DX); + Float dypos = (Float)aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.DY); + if (xpos != null) { + loc.setLocation(xpos.doubleValue(), loc.getY()); + } + 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)) + ? Font.STYLE_ITALIC + : Font.STYLE_NORMAL; + } + + private int getWeight(AttributedCharacterIterator aci) { + Float taWeight = (Float)aci.getAttribute(TextAttribute.WEIGHT); + return ((taWeight != null) && (taWeight.floatValue() > 1.0)) + ? Font.WEIGHT_BOLD + : Font.WEIGHT_NORMAL; + } + + private Font makeFont(AttributedCharacterIterator aci) { + Float fontSize = (Float)aci.getAttribute(TextAttribute.SIZE); + if (fontSize == null) { + fontSize = new Float(10.0f); + } + String style = getStyle(aci); + int weight = getWeight(aci); + + FontInfo fontInfo = nativeTextHandler.getFontInfo(); + String fontFamily = null; + List gvtFonts = (List) aci.getAttribute( + GVTAttributedCharacterIterator.TextAttribute.GVT_FONT_FAMILIES); + if (gvtFonts != null) { + Iterator i = gvtFonts.iterator(); + while (i.hasNext()) { + GVTFontFamily fam = (GVTFontFamily) i.next(); + /* (todo) Enable SVG Font painting + if (fam instanceof SVGFontFamily) { + PROXY_PAINTER.paint(node, g2d); + return; + }*/ + fontFamily = fam.getFamilyName(); + if (fontInfo.hasFont(fontFamily, style, weight)) { + FontTriplet triplet = fontInfo.fontLookup( + fontFamily, style, weight); + int fsize = (int)(fontSize.floatValue() * 1000); + return fontInfo.getFontInstance(triplet, fsize); + } + } + } + FontTriplet triplet = fontInfo.fontLookup("any", style, Font.WEIGHT_NORMAL); + int fsize = (int)(fontSize.floatValue() * 1000); + return fontInfo.getFontInstance(triplet, fsize); + } + + private float getStringWidth(String str, Font font) { + float wordWidth = 0; + float whitespaceWidth = font.getWidth(font.mapChar(' ')); + + for (int i = 0; i < str.length(); i++) { + float charWidth; + char c = str.charAt(i); + if (!((c == ' ') || (c == '\n') || (c == '\r') || (c == '\t'))) { + charWidth = font.getWidth(font.mapChar(c)); + if (charWidth <= 0) { + charWidth = whitespaceWidth; + } + } else { + charWidth = whitespaceWidth; + } + wordWidth += charWidth; + } + return wordWidth / 1000f; + } + + private boolean hasUnsupportedGlyphs(String str, Font font) { + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if (!((c == ' ') || (c == '\n') || (c == '\r') || (c == '\t'))) { + if (!font.hasChar(c)) { + return true; + } + } + } + return false; + } + + /** + * Get the outline shape of the text characters. + * This uses the StrokingTextPainter to get the outline + * shape since in theory it should be the same. + * + * @param node the text node + * @return the outline shape of the text characters + */ + public Shape getOutline(TextNode node) { + return PROXY_PAINTER.getOutline(node); + } + + /** + * Get the bounds. + * This uses the StrokingTextPainter to get the bounds + * since in theory it should be the same. + * + * @param node the text node + * @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 + * method ourselves. */ + return PROXY_PAINTER.getBounds2D(node); + } + + /** + * Get the geometry bounds. + * This uses the StrokingTextPainter to get the bounds + * since in theory it should be the same. + * + * @param node the text node + * @return the bounds of the text + */ + public Rectangle2D getGeometryBounds(TextNode node) { + return PROXY_PAINTER.getGeometryBounds(node); + } + + // Methods that have no purpose for PS + + /** + * Get the mark. + * This does nothing since the output is AFP and not interactive. + * + * @param node the text node + * @param pos the position + * @param all select all + * @return null + */ + public Mark getMark(TextNode node, int pos, boolean all) { + return null; + } + + /** + * Select at. + * This does nothing since the output is AFP and not interactive. + * + * @param x the x position + * @param y the y position + * @param node the text node + * @return null + */ + public Mark selectAt(double x, double y, TextNode node) { + return null; + } + + /** + * Select to. + * This does nothing since the output is AFP and not interactive. + * + * @param x the x position + * @param y the y position + * @param beginMark the start mark + * @return null + */ + public Mark selectTo(double x, double y, Mark beginMark) { + return null; + } + + /** + * Selec first. + * This does nothing since the output is AFP and not interactive. + * + * @param node the text node + * @return null + */ + public Mark selectFirst(TextNode node) { + return null; + } + + /** + * Select last. + * This does nothing since the output is AFP and not interactive. + * + * @param node the text node + * @return null + */ + public Mark selectLast(TextNode node) { + return null; + } + + /** + * Get selected. + * This does nothing since the output is AFP and not interactive. + * + * @param start the start mark + * @param finish the finish mark + * @return null + */ + public int[] getSelected(Mark start, Mark finish) { + return null; + } + + /** + * Get the highlighted shape. + * This does nothing since the output is AFP and not interactive. + * + * @param beginMark the start mark + * @param endMark the end mark + * @return null + */ + public Shape getHighlightShape(Mark beginMark, Mark endMark) { + return null; + } + +} diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index 1a04d129a..8f8032767 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -389,8 +389,8 @@ public class FontInfo { } matchedTriplet = fontLookup(awtFontFamily, awtFontStyle, awtFontWeight); } - float awtFontSize = awtFont.getSize2D(); - return getFontInstance(matchedTriplet, (int)(awtFontSize * 1000 + 0.5)); + int fontSize = Math.round(awtFont.getSize2D() * 1000); + return getFontInstance(matchedTriplet, fontSize); } /** diff --git a/src/java/org/apache/fop/fonts/package.html b/src/java/org/apache/fop/fonts/package.html index 33e1e2cb3..fee0bf827 100644 --- a/src/java/org/apache/fop/fonts/package.html +++ b/src/java/org/apache/fop/fonts/package.html @@ -1,3 +1,20 @@ + + org.apache.fop.fonts Package diff --git a/src/java/org/apache/fop/pdf/package.html b/src/java/org/apache/fop/pdf/package.html index e86318adc..383f78da1 100644 --- a/src/java/org/apache/fop/pdf/package.html +++ b/src/java/org/apache/fop/pdf/package.html @@ -1,3 +1,20 @@ + + org.apache.fop.pdf Package diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index 18cc81400..5c253fe94 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -29,10 +29,12 @@ 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.fop.apps.FOUserAgent; import org.apache.fop.events.EventBroadcaster; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl; import org.apache.fop.render.RendererContext.RendererContextWrapper; +import org.apache.fop.render.afp.AFPGraphics2DAdapter; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; @@ -71,7 +73,7 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC * @param imageSize the image size * @return a new graphics 2D image painter implementation */ - protected Graphics2DImagePainter createPainter( + protected Graphics2DImagePainter createGraphics2DImagePainter( GraphicsNode root, BridgeContext ctx, Dimension imageSize) { return new Graphics2DImagePainterImpl(root, ctx, imageSize); } @@ -85,14 +87,14 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC * @return a built GVT root tree */ protected GraphicsNode buildGraphicsNode( - RendererContext rendererContext, BridgeContext ctx, Document doc) { + FOUserAgent userAgent, BridgeContext ctx, Document doc) { GVTBuilder builder = new GVTBuilder(); final GraphicsNode root; try { root = builder.build(ctx, doc); } catch (Exception e) { EventBroadcaster eventBroadcaster - = rendererContext.getUserAgent().getEventBroadcaster(); + = userAgent.getEventBroadcaster(); SVGEventProducer eventProducer = SVGEventProducer.Provider.get(eventBroadcaster); final String uri = getDocumentURI(doc); eventProducer.svgNotBuilt(this, e, uri); @@ -101,6 +103,18 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC return root; } + /** + * Returns the image size + * @param wrappedContext renderer context wrapper + * + * @return the image size + */ + protected Dimension getImageSize(RendererContextWrapper wrappedContext) { + final int width = wrappedContext.getWidth(); + final int height = wrappedContext.getHeight(); + return new Dimension(width, height); + } + /** * Render the SVG document. * @@ -113,23 +127,21 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC updateRendererContext(rendererContext); //Prepare - SVGUserAgent svgUserAgent = new SVGUserAgent( - rendererContext.getUserAgent(), new AffineTransform()); + FOUserAgent userAgent = rendererContext.getUserAgent(); + SVGUserAgent svgUserAgent = new SVGUserAgent(userAgent, new AffineTransform()); + + //Create Batik BridgeContext final BridgeContext bridgeContext = new BridgeContext(svgUserAgent); //Build the GVT tree - final GraphicsNode root = buildGraphicsNode(rendererContext, bridgeContext, doc); + final GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, doc); + + // Create Graphics2DImagePainter final RendererContextWrapper wrappedContext = RendererContext.wrapRendererContext( rendererContext); - - //Get Image Size - final int width = wrappedContext.getWidth(); - final int height = wrappedContext.getHeight(); - Dimension imageSize = new Dimension(width, height); - - //Create the painter - final Graphics2DImagePainter painter = createPainter(root, bridgeContext, imageSize); + Dimension imageSize = getImageSize(wrappedContext); + final Graphics2DImagePainter painter = createGraphics2DImagePainter(root, bridgeContext, imageSize); //Let the painter paint the SVG on the Graphics2D instance Graphics2DAdapter g2dAdapter = rendererContext.getRenderer().getGraphics2DAdapter(); @@ -137,6 +149,8 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC //Paint the image final int x = wrappedContext.getCurrentXPosition(); final int y = wrappedContext.getCurrentYPosition(); + final int width = wrappedContext.getWidth(); + final int height = wrappedContext.getHeight(); g2dAdapter.paintImage(painter, rendererContext, x, y, width, height); } diff --git a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java index 5861fb042..ee18dff0d 100644 --- a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java @@ -54,8 +54,8 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { protected BufferedImage paintToBufferedImage( 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)); + int bmw = mpt2px(context.getWidth(), resolution); + int bmh = mpt2px(context.getHeight(), resolution); BufferedImage bi; if (gray) { if (withAlpha) { @@ -102,6 +102,17 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { return bi; } + /** + * Converts millipoints to pixels + * + * @param unit the unit to convert in mpts + * @param resolution the target resolution + * @return the converted unit in pixels + */ + protected int mpt2px(int unit, int resolution) { + return (int)Math.ceil(UnitConv.mpt2px(unit, resolution)); + } + private static BufferedImage createGrayBufferedImageWithAlpha(int width, int height) { BufferedImage bi; boolean alphaPremultiplied = true; diff --git a/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java b/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java new file mode 100644 index 000000000..e305e0a55 --- /dev/null +++ b/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java @@ -0,0 +1,211 @@ +/* + * 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.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; + +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.ImageFlavor; +import org.apache.xmlgraphics.util.Service; + +/** + * This class holds references to various image handlers used by the renderers. It also + * supports automatic discovery of additional handlers available through + * the class path. + */ +public abstract class AbstractImageHandlerRegistry { + + /** the logger */ + private static Log log = LogFactory.getLog(AbstractImageHandlerRegistry.class); + + private static final Comparator HANDLER_COMPARATOR = new Comparator() { + public int compare(Object o1, Object o2) { + ImageHandler h1 = (ImageHandler)o1; + ImageHandler h2 = (ImageHandler)o2; + return h1.getPriority() - h2.getPriority(); + } + }; + + /** Map containing image handlers for various MIME types */ + private final Map/**/ handlers + = new java.util.HashMap/**/(); + + /** List containing the same handlers as above but ordered by priority */ + private final 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 AbstractImageHandlerRegistry() { + discoverHandlers(); + } + + /** + * Add an ImageHandler. The handler itself is inspected to find out what it supports. + * @param classname the fully qualified class name + */ + public void addHandler(String classname) { + try { + ImageHandler handlerInstance + = (ImageHandler)Class.forName(classname).newInstance(); + addHandler(handlerInstance); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException("Could not find " + + classname); + } catch (InstantiationException e) { + throw new IllegalArgumentException("Could not instantiate " + + classname); + } catch (IllegalAccessException e) { + throw new IllegalArgumentException("Could not access " + + classname); + } catch (ClassCastException e) { + throw new IllegalArgumentException(classname + + " is not an " + + getHandlerClass().getName()); + } + } + + /** + * Add an image handler. The handler itself is inspected to find out what it supports. + * @param handler the ImageHandler instance + */ + public synchronized void addHandler(ImageHandler handler) { + Class[] imageClasses = handler.getSupportedImageClasses(); + for (int i = 0; i < imageClasses.length; i++) { + this.handlers.put(imageClasses[i], handler); + } + + //Sorted insert + ListIterator iter = this.handlerList.listIterator(); + while (iter.hasNext()) { + ImageHandler h = (ImageHandler)iter.next(); + if (getHandlerComparator().compare(handler, h) < 0) { + iter.previous(); + break; + } + } + iter.add(handler); + this.handlerRegistrations++; + } + + /** + * Returns an ImageHandler which handles an specific image type given the MIME type + * of the image. + * @param img the Image to be handled + * @return the ImageHandler responsible for handling the image or null if none is available + */ + public ImageHandler getHandler(Image img) { + return getHandler(img.getClass()); + } + + /** + * Returns an ImageHandler which handles an specific image type given the MIME type + * of the image. + * @param imageClass the Image subclass for which to get a handler + * @return the ImageHandler responsible for handling the image or null if none is available + */ + public synchronized ImageHandler getHandler(Class imageClass) { + ImageHandler handler = null; + Class cl = imageClass; + while (cl != null) { + handler = (ImageHandler)handlers.get(cl); + if (handler != null) { + break; + } + cl = cl.getSuperclass(); + } + return handler; + } + + /** + * Returns the ordered array of supported image flavors. + * @return the array of image flavors + */ + public synchronized ImageFlavor[] getSupportedFlavors() { + if (this.lastSync != this.handlerRegistrations) { + //Extract all ImageFlavors into a single array + List flavors = new java.util.ArrayList(); + Iterator iter = this.handlerList.iterator(); + while (iter.hasNext()) { + ImageFlavor[] f = ((ImageHandler)iter.next()).getSupportedImageFlavors(); + for (int i = 0; i < f.length; i++) { + flavors.add(f[i]); + } + } + this.supportedFlavors = (ImageFlavor[])flavors.toArray(new ImageFlavor[flavors.size()]); + this.lastSync = this.handlerRegistrations; + } + return this.supportedFlavors; + } + + /** + * Discovers ImageHandler implementations through the classpath and dynamically + * registers them. + */ + private void discoverHandlers() { + // add mappings from available services + Class imageHandlerClass = getHandlerClass(); + Iterator providers = Service.providers(imageHandlerClass); + if (providers != null) { + while (providers.hasNext()) { + ImageHandler handler = (ImageHandler)providers.next(); + try { + if (log.isDebugEnabled()) { + log.debug("Dynamically adding ImageHandler: " + + handler.getClass().getName()); + } + addHandler(handler); + } catch (IllegalArgumentException e) { + log.error("Error while adding ImageHandler", e); + } + + } + } + } + + /** + * Returns the ImageHandler comparator + * + * @return the ImageHandler comparator + */ + public Comparator getHandlerComparator() { + return HANDLER_COMPARATOR; + } + + /** + * Returns the ImageHandler implementing class + * + * @return the ImageHandler implementing class + */ + public abstract Class getHandlerClass(); +} diff --git a/src/java/org/apache/fop/render/ImageHandler.java b/src/java/org/apache/fop/render/ImageHandler.java new file mode 100644 index 000000000..05d1e2e79 --- /dev/null +++ b/src/java/org/apache/fop/render/ImageHandler.java @@ -0,0 +1,46 @@ +/* + * 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 org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.image.loader.ImageFlavor; + +public interface ImageHandler { + + /** + * Returns the priority for this image handler. A lower value means higher priority. This + * information is used to build the ordered/prioritized list of supported ImageFlavors for + * the PDF renderer. The built-in handlers use priorities between 100 and 999. + * @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} subclasses supported by this instance. + * @return the Image types + */ + Class[] getSupportedImageClasses(); +} diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java index 56504ff53..e4ec41e0b 100644 --- a/src/java/org/apache/fop/render/PrintRenderer.java +++ b/src/java/org/apache/fop/render/PrintRenderer.java @@ -24,8 +24,6 @@ import java.awt.geom.Rectangle2D; import java.util.List; import java.util.Map; -import org.w3c.dom.Document; - import org.apache.fop.area.Area; import org.apache.fop.area.Trait; import org.apache.fop.fonts.CustomFontCollection; @@ -36,6 +34,7 @@ import org.apache.fop.fonts.FontManager; import org.apache.fop.fonts.FontResolver; import org.apache.fop.fonts.FontTriplet; import org.apache.fop.fonts.base14.Base14FontCollection; +import org.w3c.dom.Document; /** Abstract base class of "Print" type renderers. */ public abstract class PrintRenderer extends AbstractRenderer { @@ -111,6 +110,14 @@ public abstract class PrintRenderer extends AbstractRenderer { return fontInfo.getFontInstance(triplet, size); } + /** + * Instantiates a RendererContext for an image + * @return a newly created RendererContext. + */ + protected RendererContext instantiateRendererContext() { + return new RendererContext(this, getMimeType()); + } + /** * Creates a RendererContext for an image. * @param x the x coordinate (in millipoints) @@ -122,8 +129,7 @@ public abstract class PrintRenderer extends AbstractRenderer { */ protected RendererContext createRendererContext(int x, int y, int width, int height, Map foreignAttributes) { - RendererContext context; - context = new RendererContext(this, getMimeType()); + RendererContext context = instantiateRendererContext(); context.setUserAgent(userAgent); context.setProperty(RendererContextConstants.WIDTH, diff --git a/src/java/org/apache/fop/render/RendererContext.java b/src/java/org/apache/fop/render/RendererContext.java index e4e234cd2..ac885a44b 100644 --- a/src/java/org/apache/fop/render/RendererContext.java +++ b/src/java/org/apache/fop/render/RendererContext.java @@ -20,10 +20,12 @@ package org.apache.fop.render; //Java +import java.util.Iterator; import java.util.Map; -//FOP import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.fo.extensions.ExtensionElementMapping; +import org.apache.xmlgraphics.util.QName; /** * The Render Context for external handlers. This provides a rendering context @@ -31,21 +33,28 @@ import org.apache.fop.apps.FOUserAgent; * render target. */ public class RendererContext { + /** conversion-mode extension attribute */ + protected static final QName CONVERSION_MODE = new QName( + ExtensionElementMapping.URI, null, "conversion-mode"); + + /** "bitmap" value for the "conversion-mode" extension attribute. */ + protected static final String BITMAP = "bitmap"; private final String mime; private final AbstractRenderer renderer; private FOUserAgent userAgent; - private final Map props = new java.util.HashMap(); + + private final Map/**/ props = new java.util.HashMap/**/(); /** - * Contructor for this class. It takes a MIME type as parameter. + * Constructor for this class. It takes a MIME type as parameter. * - * @param renderer The current renderer - * @param m The MIME type of the output that's generated. + * @param renderer the current renderer + * @param mime the MIME type of the output that's generated. */ - public RendererContext(AbstractRenderer renderer, String m) { + public RendererContext(AbstractRenderer renderer, String mime) { this.renderer = renderer; - this.mime = m; + this.mime = mime; } /** @@ -113,6 +122,19 @@ public class RendererContext { return wrapper; } + /** {@inheritDoc} **/ + public String toString() { + StringBuffer stringBuffer = new StringBuffer("RendererContext{\n"); + Iterator it = props.keySet().iterator(); + while (it.hasNext()) { + String key = (String)it.next(); + Object value = props.get(key); + stringBuffer.append("\t" + key + "=" + value + "\n"); + } + stringBuffer.append("}"); + return stringBuffer.toString(); + } + /** * Base class for a wrapper around RendererContext to access its properties in a type-safe, * renderer-specific way. diff --git a/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java b/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java deleted file mode 100644 index 3b00804fc..000000000 --- a/src/java/org/apache/fop/render/afp/AFPAbstractImageFactory.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 java.io.IOException; - -import org.apache.fop.afp.AFPDataObjectInfo; -import org.apache.fop.afp.AFPForeignAttributeReader; -import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPPaintingState; -import org.apache.fop.afp.AFPResourceInfo; -import org.apache.fop.afp.AFPUnitConverter; - - -/** - * Abstract image configurator - */ -public abstract class AFPAbstractImageFactory { - private static final int X = 0; - private static final int Y = 1; - - /** the AFP state */ - protected final AFPPaintingState state; - - /** foreign attribute reader */ - private final AFPForeignAttributeReader foreignAttributeReader - = new AFPForeignAttributeReader(); - - /** - * Main constructor - * - * @param state the AFP painting state - */ - public AFPAbstractImageFactory(AFPPaintingState state) { - this.state = state; - } - - /** - * Configures the data object info - * - * @param afpImageInfo the afp image info - * @return the data object info - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public AFPDataObjectInfo create(AFPRendererImageInfo afpImageInfo) throws IOException { - AFPDataObjectInfo dataObjectInfo = createDataObjectInfo(); - - // set resource information - AFPResourceInfo resourceInfo - = foreignAttributeReader.getResourceInfo(afpImageInfo.foreignAttributes); - resourceInfo.setUri(afpImageInfo.uri); - dataObjectInfo.setResourceInfo(resourceInfo); - - // set object area - AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); - float srcX = afpImageInfo.origin.x + (float)afpImageInfo.pos.getX(); - float srcY = afpImageInfo.origin.y + (float)afpImageInfo.pos.getY(); - AFPUnitConverter unitConv = state.getUnitConverter(); - int[] coords = unitConv.mpts2units(new float[] {srcX, srcY}); - objectAreaInfo.setX(coords[X]); - objectAreaInfo.setY(coords[Y]); - int width = Math.round(unitConv.mpt2units((float)afpImageInfo.pos.getWidth())); - objectAreaInfo.setWidth(width); - int height = Math.round(unitConv.mpt2units((float)afpImageInfo.pos.getHeight())); - objectAreaInfo.setHeight(height); - dataObjectInfo.setObjectAreaInfo(objectAreaInfo); - return dataObjectInfo; - } - - /** - * Creates the data object information object - * - * @return the data object information object - */ - protected abstract AFPDataObjectInfo createDataObjectInfo(); -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java deleted file mode 100644 index ba2392835..000000000 --- a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 java.awt.Point; -import java.awt.geom.Rectangle2D; -import java.io.IOException; - -import org.apache.fop.afp.AFPDataObjectInfo; -import org.apache.fop.afp.AFPForeignAttributeReader; -import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPPaintingState; -import org.apache.fop.afp.AFPResourceInfo; -import org.apache.fop.afp.AFPUnitConverter; - - -/** - * Abstract image configurator - */ -public abstract class AFPDataObjectInfoFactory { - private static final int X = 0; - private static final int Y = 1; - - /** the AFP painting state */ - protected final AFPPaintingState state; - - /** foreign attribute reader */ - private final AFPForeignAttributeReader foreignAttributeReader - = new AFPForeignAttributeReader(); - - /** - * Main constructor - * - * @param state the AFP state - */ - public AFPDataObjectInfoFactory(AFPPaintingState state) { - this.state = state; - } - - /** - * Configures the data object info - * - * @param rendererImageInfo the afp image info - * @return the data object info - * @throws IOException thrown if an I/O exception of some sort has occurred. - */ - public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { - AFPDataObjectInfo dataObjectInfo = createDataObjectInfo(); - - // set resource information - AFPResourceInfo resourceInfo - = foreignAttributeReader.getResourceInfo(rendererImageInfo.getForeignAttributes()); - resourceInfo.setUri(rendererImageInfo.getURI()); - dataObjectInfo.setResourceInfo(resourceInfo); - - // set object area - AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); - - Point origin = rendererImageInfo.getOrigin(); - Rectangle2D position = rendererImageInfo.getPosition(); - float srcX = origin.x + (float)position.getX(); - float srcY = origin.y + (float)position.getY(); - AFPUnitConverter unitConv = state.getUnitConverter(); - int[] coords = unitConv.mpts2units(new float[] {srcX, srcY}); - objectAreaInfo.setX(coords[X]); - objectAreaInfo.setY(coords[Y]); - - int width = Math.round(unitConv.mpt2units((float)position.getWidth())); - objectAreaInfo.setWidth(width); - - int height = Math.round(unitConv.mpt2units((float)position.getHeight())); - objectAreaInfo.setHeight(height); - - int resolution = state.getResolution(); - objectAreaInfo.setHeightRes(resolution); - objectAreaInfo.setWidthRes(resolution); - - objectAreaInfo.setRotation(state.getRotation()); - - dataObjectInfo.setObjectAreaInfo(objectAreaInfo); - - return dataObjectInfo; - } - - /** - * Creates the data object information object - * - * @return the data object information object - */ - protected abstract AFPDataObjectInfo createDataObjectInfo(); -} diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java deleted file mode 100644 index aac17b701..000000000 --- a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 java.util.Iterator; -import java.util.Map; - -import org.apache.fop.afp.AFPPaintingState; -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; -import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; -import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; -import org.apache.xmlgraphics.image.loader.impl.ImageRendered; - -/** - * AFP data object info factory provider - */ -public class AFPDataObjectInfoProvider { - - private final Map/**/ factoryMap - = new java.util.HashMap/**/(); - - private final AFPPaintingState state; - - /** - * Main constructor - * - * @param state the AFP painting state - */ - public AFPDataObjectInfoProvider(AFPPaintingState state) { - this.state = state; - init(); - } - - /** - * Initialises the configurators - */ - private void init() { - factoryMap.put( - ImageRendered.class, new AFPImageRenderedFactory(state)); - factoryMap.put( - ImageRawCCITTFax.class, new AFPRawCCITTFaxFactory(state)); - factoryMap.put( - ImageRawStream.class, new AFPImageRawStreamFactory(state)); - factoryMap.put( - ImageGraphics2D.class, new AFPImageGraphics2DFactory(state)); - }; - - /** - * Returns the configurator for a given image - * - * @param img the image - * @return the image configurator for the image - */ - public AFPDataObjectInfoFactory getFactory(Image img) { - Class clazz = img.getClass(); - AFPDataObjectInfoFactory configurator = (AFPDataObjectInfoFactory)factoryMap.get(clazz); - // not directly matched so try to map ancestor - if (configurator == null) { - Iterator it = factoryMap.keySet().iterator(); - while (it.hasNext()) { - Class imageClass = (Class)it.next(); - if (imageClass.isInstance(img)) { - return (AFPDataObjectInfoFactory)factoryMap.get(imageClass); - } - } - } - return configurator; - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java b/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java new file mode 100644 index 000000000..2b5077fe9 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java @@ -0,0 +1,128 @@ +/* + * 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 java.io.File; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceLevel; +import org.apache.fop.render.afp.extensions.AFPElementMapping; +import org.apache.xmlgraphics.util.QName; + +/** + * Parses any AFP foreign attributes + */ +public class AFPForeignAttributeReader { + private static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); + + /** the resource-name attribute */ + public static final String RESOURCE_NAME = "afp:resource-name"; + + /** the resource-level attribute */ + public static final String RESOURCE_LEVEL = "afp:resource-level"; + + /** the resource-group-file attribute */ + public static final String RESOURCE_GROUP_FILE = "afp:resource-group-file"; + + /** + * Main constructor + */ + public AFPForeignAttributeReader() { + } + + /** + * Returns the resource information + * + * @param foreignAttributes the foreign attributes + * @return the resource information + */ + public AFPResourceInfo getResourceInfo(Map/**/ foreignAttributes) { + AFPResourceInfo resourceInfo = new AFPResourceInfo(); + if (foreignAttributes != null && !foreignAttributes.isEmpty()) { + QName resourceNameKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_NAME); + String resourceName = (String)foreignAttributes.get(resourceNameKey); + if (resourceName != null) { + resourceInfo.setName(resourceName); + } + AFPResourceLevel level = getResourceLevel(foreignAttributes); + if (level != null) { + resourceInfo.setLevel(level); + } + } + return resourceInfo; + } + + /** + * Returns the resource level + * + * @param foreignAttributes the foreign attributes + * @return the resource level + */ + public AFPResourceLevel getResourceLevel(Map/**/ foreignAttributes) { + AFPResourceLevel resourceLevel = null; + if (foreignAttributes != null && !foreignAttributes.isEmpty()) { + QName resourceLevelKey = new QName(AFPElementMapping.NAMESPACE, RESOURCE_LEVEL); + if (foreignAttributes.containsKey(resourceLevelKey)) { + String levelString = (String)foreignAttributes.get(resourceLevelKey); + resourceLevel = AFPResourceLevel.valueOf(levelString); + // if external get resource group file attributes + if (resourceLevel != null && resourceLevel.isExternal()) { + QName resourceGroupFileKey = new QName(AFPElementMapping.NAMESPACE, + RESOURCE_GROUP_FILE); + String resourceGroupFile + = (String)foreignAttributes.get(resourceGroupFileKey); + if (resourceGroupFile == null) { + String msg = RESOURCE_GROUP_FILE + " not specified"; + log.error(msg); + throw new UnsupportedOperationException(msg); + } + File resourceExternalGroupFile = new File(resourceGroupFile); + SecurityManager security = System.getSecurityManager(); + try { + if (security != null) { + security.checkWrite(resourceExternalGroupFile.getPath()); + } + } catch (SecurityException ex) { + String msg = "unable to gain write access to external resource file: " + + resourceGroupFile; + log.error(msg); + } + + try { + boolean exists = resourceExternalGroupFile.exists(); + if (exists) { + log.warn("overwriting external resource file: " + + resourceGroupFile); + } + resourceLevel.setExternalFilePath(resourceGroupFile); + } catch (SecurityException ex) { + String msg = "unable to gain read access to external resource file: " + + resourceGroupFile; + log.error(msg); + } + } + } + } + return resourceLevel; + } +} diff --git a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java index 4f92826cf..8e43d1c28 100644 --- a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java @@ -28,7 +28,6 @@ import java.io.IOException; import org.apache.fop.afp.AFPGraphics2D; import org.apache.fop.afp.AFPGraphicsObjectInfo; import org.apache.fop.afp.AFPPaintingState; -import org.apache.fop.afp.AFPResourceInfo; import org.apache.fop.afp.AFPResourceManager; import org.apache.fop.render.AbstractGraphics2DAdapter; import org.apache.fop.render.RendererContext; @@ -40,95 +39,67 @@ import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; */ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { - private final AFPRenderer renderer; - - private final AFPGraphics2D g2d; + private final AFPPaintingState paintingState; /** * Main constructor * - * @param renderer the afp renderer - */ - public AFPGraphics2DAdapter(AFPRenderer renderer) { - this.renderer = renderer; - - final boolean textAsShapes = false; - this.g2d = new AFPGraphics2D(textAsShapes); - } - - /** - * Returns the AFP graphics 2D implementation - * - * @return the AFP graphics 2D implementation + * @param paintingState the AFP painting state */ - public AFPGraphics2D getGraphics2D() { - return g2d; + public AFPGraphics2DAdapter(AFPPaintingState paintingState) { + this.paintingState = paintingState; } /** {@inheritDoc} */ public void paintImage(Graphics2DImagePainter painter, - RendererContext context, + RendererContext rendererContext, int x, int y, int width, int height) throws IOException { - AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(context); - - // set resource manager - AFPResourceManager resourceManager = afpInfo.getResourceManager(); - g2d.setResourceManager(resourceManager); - - // set resource information - AFPResourceInfo resourceInfo = afpInfo.getResourceInfo(); - g2d.setResourceInfo(resourceInfo); + AFPRendererContext afpRendererContext = (AFPRendererContext)rendererContext; + AFPInfo afpInfo = afpRendererContext.getInfo(); - // set painting state - AFPPaintingState paintingState = afpInfo.getPaintingState(); - g2d.setPaintingState(paintingState); - - // set graphic context - g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - - float fwidth = width / 1000f; - float fheight = height / 1000f; - - // get the 'width' and 'height' attributes of the SVG document - Dimension imageSize = painter.getImageSize(); - float imw = (float)imageSize.getWidth() / 1000f; - float imh = (float)imageSize.getHeight() / 1000f; - float sx = fwidth / imw; - float sy = fheight / imh; - AffineTransform at = new AffineTransform(sx, 0, 0, sy, x, y); + final boolean textAsShapes = false; + AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes); - renderer.saveGraphicsState(); + paintingState.push(); + //Fallback solution: Paint to a BufferedImage if (afpInfo.paintAsBitmap()) { - //Fallback solution: Paint to a BufferedImage - int resolution = Math.round(context.getUserAgent().getTargetResolution()); - RendererContextWrapper ctx = RendererContext.wrapRendererContext(context); - BufferedImage bufferedImage = paintToBufferedImage(painter, ctx, resolution, false, false); - - AFPPaintingState state = afpInfo.getPaintingState(); - AffineTransform trans = state.getData().getTransform(); - float scale = AFPRenderer.NORMAL_AFP_RESOLUTION - / context.getUserAgent().getTargetResolution(); - if (scale != 1) { - at.scale(scale, scale); - } - - if (!at.isIdentity()) { - trans.concatenate(at); - } - - g2d.drawImage(bufferedImage, trans, null); + + // paint image + RendererContextWrapper rendererContextWrapper + = RendererContext.wrapRendererContext(rendererContext); + float targetResolution = rendererContext.getUserAgent().getTargetResolution(); + int resolution = Math.round(targetResolution); + boolean colorImages = afpInfo.isColorSupported(); + BufferedImage bufferedImage = paintToBufferedImage( + painter, rendererContextWrapper, resolution, !colorImages, false); + + // draw image + AffineTransform at = paintingState.getData().getTransform(); + at.translate(x, y); + g2d.drawImage(bufferedImage, at, null); } else { AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo(); graphicsObjectInfo.setPainter(painter); graphicsObjectInfo.setGraphics2D(g2d); + // get the 'width' and 'height' attributes of the SVG document + Dimension imageSize = painter.getImageSize(); + float imw = (float)imageSize.getWidth() / 1000f; + float imh = (float)imageSize.getHeight() / 1000f; + Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh); graphicsObjectInfo.setArea(area); + AFPResourceManager resourceManager = afpInfo.getResourceManager(); resourceManager.createObject(graphicsObjectInfo); } - renderer.restoreGraphicsState(); + paintingState.pop(); + } + + /** {@inheritDoc} */ + protected int mpt2px(int unit, int resolution) { + return Math.round(paintingState.getUnitConverter().mpt2units(unit)); } } diff --git a/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java b/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java deleted file mode 100644 index 88c0b5c26..000000000 --- a/src/java/org/apache/fop/render/afp/AFPImageGraphics2DFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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 java.awt.Rectangle; -import java.awt.geom.AffineTransform; -import java.io.IOException; - -import org.apache.batik.bridge.BridgeContext; -import org.apache.fop.afp.AFPDataObjectInfo; -import org.apache.fop.afp.AFPGraphics2D; -import org.apache.fop.afp.AFPGraphicsObjectInfo; -import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPPaintingState; -import org.apache.fop.afp.AFPResourceInfo; -import org.apache.fop.afp.AFPResourceLevel; -import org.apache.fop.afp.AFPTextElementBridge; -import org.apache.fop.afp.AFPTextHandler; -import org.apache.fop.afp.AFPTextPainter; -import org.apache.fop.render.RendererContext; -import org.apache.fop.svg.SVGUserAgent; -import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; -import org.apache.xmlgraphics.util.MimeConstants; - - -/** - * An AFP image graphics 2d factory - */ -public class AFPImageGraphics2DFactory extends AFPDataObjectInfoFactory { - - /** - * Main constructor - * - * @param state the AFP painting state - */ - public AFPImageGraphics2DFactory(AFPPaintingState state) { - super(state); - } - - /** {@inheritDoc} */ - protected AFPDataObjectInfo createDataObjectInfo() { - return new AFPGraphicsObjectInfo(); - } - - /** {@inheritDoc} */ - public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { - AFPGraphicsObjectInfo graphicsObjectInfo - = (AFPGraphicsObjectInfo)super.create(rendererImageInfo); - - AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo(); - // level not explicitly set/changed so default to inline for GOCA graphic objects - // (due to a bug in the IBM AFP Workbench Viewer (2.04.01.07) - hard copy works just fine) - if (!resourceInfo.levelChanged()) { - resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE)); - } - - // set mime type (unsupported by MOD:CA registry) - graphicsObjectInfo.setMimeType(MimeConstants.MIME_AFP_GOCA); - - // set graphics 2d - AFPGraphics2DAdapter g2dAdapter = rendererImageInfo.getGraphics2DAdapter(); - AFPGraphics2D g2d = g2dAdapter.getGraphics2D(); - graphicsObjectInfo.setGraphics2D(g2d); - - // set resource, state and font info - RendererContext rendererContext = rendererImageInfo.getRendererContext(); - AFPInfo afpInfo = AFPSVGHandler.getAFPInfo(rendererContext); - g2d.setResourceManager(afpInfo.getResourceManager()); - g2d.setResourceInfo(afpInfo.getResourceInfo()); - g2d.setPaintingState(afpInfo.getPaintingState()); - g2d.setFontInfo(afpInfo.getFontInfo()); - - // set to default graphic context - g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - - // translate to current location - AffineTransform at = state.getData().getTransform(); - g2d.translate(at.getTranslateX(), at.getTranslateY()); - - // set afp state - g2d.setPaintingState(state); - - // controls whether text painted by Batik is generated using text or path operations - SVGUserAgent svgUserAgent - = new SVGUserAgent(rendererContext.getUserAgent(), new AffineTransform()); - BridgeContext ctx = new BridgeContext(svgUserAgent); - if (!afpInfo.strokeText()) { - AFPTextHandler textHandler = new AFPTextHandler(g2d); - g2d.setCustomTextHandler(textHandler); - AFPTextPainter textPainter = new AFPTextPainter(textHandler); - ctx.setTextPainter(textPainter); - AFPTextElementBridge textElementBridge = new AFPTextElementBridge(textPainter); - ctx.putBridge(textElementBridge); - } - - // set painter - ImageGraphics2D imageG2D = (ImageGraphics2D)rendererImageInfo.getImage(); - Graphics2DImagePainter painter = imageG2D.getGraphics2DImagePainter(); - graphicsObjectInfo.setPainter(painter); - - // set object area - AFPObjectAreaInfo objectAreaInfo = graphicsObjectInfo.getObjectAreaInfo(); - int width = objectAreaInfo.getWidth(); - int height = objectAreaInfo.getHeight(); - Rectangle area = new Rectangle(width, height); - graphicsObjectInfo.setArea(area); - - // invert y-axis for GOCA - final int sx = 1; - final int sy = -1; - g2d.translate(0, height); - g2d.scale(sx, sy); - - return graphicsObjectInfo; - } - -} diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandler.java b/src/java/org/apache/fop/render/afp/AFPImageHandler.java new file mode 100644 index 000000000..8e925d460 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPImageHandler.java @@ -0,0 +1,101 @@ +/* + * 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 java.awt.Point; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.util.Map; + +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPUnitConverter; +import org.apache.fop.render.ImageHandler; + +public abstract class AFPImageHandler implements ImageHandler { + private static final int X = 0; + private static final int Y = 1; + + /** foreign attribute reader */ + private final AFPForeignAttributeReader foreignAttributeReader + = new AFPForeignAttributeReader(); + + /** + * Generates an intermediate AFPDataObjectInfo that is later used to construct + * the appropriate data object in the AFP DataStream. + * + * @param rendererImageInfo the renderer image info + * @return a data object info object + * @throws IOException thrown if an I/O exception of some sort has occurred. + */ + public AFPDataObjectInfo generateDataObjectInfo( + AFPRendererImageInfo rendererImageInfo) throws IOException { + AFPDataObjectInfo dataObjectInfo = createDataObjectInfo(); + + // set resource information + Map foreignAttributes = rendererImageInfo.getForeignAttributes(); + AFPResourceInfo resourceInfo + = foreignAttributeReader.getResourceInfo(foreignAttributes); + resourceInfo.setUri(rendererImageInfo.getURI()); + dataObjectInfo.setResourceInfo(resourceInfo); + + // set object area + AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); + + Point origin = rendererImageInfo.getOrigin(); + Rectangle2D position = rendererImageInfo.getPosition(); + float srcX = origin.x + (float)position.getX(); + float srcY = origin.y + (float)position.getY(); + + AFPRendererContext rendererContext + = (AFPRendererContext)rendererImageInfo.getRendererContext(); + AFPInfo afpInfo = rendererContext.getInfo(); + AFPPaintingState paintingState = afpInfo.getPaintingState(); + AFPUnitConverter unitConv = paintingState.getUnitConverter(); + int[] coords = unitConv.mpts2units(new float[] {srcX, srcY}); + objectAreaInfo.setX(coords[X]); + objectAreaInfo.setY(coords[Y]); + + int width = Math.round(unitConv.mpt2units((float)position.getWidth())); + objectAreaInfo.setWidth(width); + + int height = Math.round(unitConv.mpt2units((float)position.getHeight())); + objectAreaInfo.setHeight(height); + + int resolution = paintingState.getResolution(); + objectAreaInfo.setHeightRes(resolution); + objectAreaInfo.setWidthRes(resolution); + + objectAreaInfo.setRotation(paintingState.getRotation()); + + dataObjectInfo.setObjectAreaInfo(objectAreaInfo); + + return dataObjectInfo; + } + + /** + * Creates the data object information object + * + * @return the data object information object + */ + protected abstract AFPDataObjectInfo createDataObjectInfo(); +} diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java new file mode 100644 index 000000000..e8fe1f4f1 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java @@ -0,0 +1,128 @@ +/* + * 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 java.awt.geom.AffineTransform; +import java.io.IOException; + +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPGraphics2D; +import org.apache.fop.afp.AFPGraphicsObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceLevel; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; +import org.apache.xmlgraphics.util.MimeConstants; + +/** + * PDFImageHandler implementation which handles Graphics2D images. + */ +public class AFPImageHandlerGraphics2D extends AFPImageHandler { + + private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { + ImageFlavor.GRAPHICS2D + }; + + private static final Class[] CLASSES = new Class[] { + ImageGraphics2D.class + }; + + /** {@inheritDoc} */ + public AFPDataObjectInfo generateDataObjectInfo( + AFPRendererImageInfo rendererImageInfo) throws IOException { + + AFPRendererContext rendererContext = (AFPRendererContext)rendererImageInfo.getRendererContext(); + AFPInfo afpInfo = rendererContext.getInfo(); + ImageGraphics2D imageG2D = (ImageGraphics2D)rendererImageInfo.getImage(); + Graphics2DImagePainter painter = imageG2D.getGraphics2DImagePainter(); + + if (afpInfo.paintAsBitmap()) { + int x = afpInfo.getX(); + int y = afpInfo.getY(); + int width = afpInfo.getWidth(); + int height = afpInfo.getHeight(); + AFPPaintingState paintingState = afpInfo.getPaintingState(); + AFPGraphics2DAdapter g2dAdapter = new AFPGraphics2DAdapter(paintingState); + g2dAdapter.paintImage(painter, rendererContext, x, y, width, height); + return null; + } else { + AFPGraphicsObjectInfo graphicsObjectInfo + = (AFPGraphicsObjectInfo)super.generateDataObjectInfo(rendererImageInfo); + + AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo(); + //level not explicitly set/changed so default to inline for GOCA graphic objects + // (due to a bug in the IBM AFP Workbench Viewer (2.04.01.07) - hard copy works just fine) + if (!resourceInfo.levelChanged()) { + resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE)); + } + + // set mime type (unsupported by MOD:CA registry) + graphicsObjectInfo.setMimeType(MimeConstants.MIME_AFP_GOCA); + + // set g2d + boolean textAsShapes = false; + + AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes); + + graphicsObjectInfo.setGraphics2D(g2d); + + // translate to current location + AFPPaintingState paintingState = afpInfo.getPaintingState(); + AffineTransform at = paintingState.getData().getTransform(); + g2d.translate(at.getTranslateX(), at.getTranslateY()); + + // set painter + graphicsObjectInfo.setPainter(painter); + + // invert y-axis for GOCA + final int sx = 1; + final int sy = -1; + AFPObjectAreaInfo objectAreaInfo = graphicsObjectInfo.getObjectAreaInfo(); + int height = objectAreaInfo.getHeight(); + g2d.translate(0, height); + g2d.scale(sx, sy); + + return graphicsObjectInfo; + } + } + + /** {@inheritDoc} */ + public int getPriority() { + return 200; + } + + /** {@inheritDoc} */ + public Class[] getSupportedImageClasses() { + return CLASSES; + } + + /** {@inheritDoc} */ + public ImageFlavor[] getSupportedImageFlavors() { + return FLAVORS; + } + + /** {@inheritDoc} */ + protected AFPDataObjectInfo createDataObjectInfo() { + return new AFPGraphicsObjectInfo(); + } +} diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java new file mode 100644 index 000000000..aa91bb660 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java @@ -0,0 +1,86 @@ +/* + * 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 java.io.IOException; + +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPImageObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.ImageSize; +import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; + +/** + * PDFImageHandler implementation which handles CCITT encoded images (CCITT fax group 3/4). + */ +public class AFPImageHandlerRawCCITTFax extends AFPImageHandler { + + private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { + ImageFlavor.RAW_CCITTFAX, + }; + + private static final Class[] CLASSES = new Class[] { + ImageRawCCITTFax.class, + }; + + /** {@inheritDoc} */ + public AFPDataObjectInfo generateDataObjectInfo( + AFPRendererImageInfo rendererImageInfo) throws IOException { + AFPImageObjectInfo imageObjectInfo + = (AFPImageObjectInfo)super.generateDataObjectInfo(rendererImageInfo); + + ImageRawCCITTFax ccitt = (ImageRawCCITTFax) rendererImageInfo.getImage(); + imageObjectInfo.setCompression(ccitt.getCompression()); + + AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); + ImageSize imageSize = ccitt.getSize(); + int widthRes = (int) (imageSize.getDpiHorizontal() * 10); + objectAreaInfo.setWidthRes(widthRes); + + int heightRes = (int) (imageSize.getDpiVertical() * 10); + objectAreaInfo.setHeightRes(heightRes); + + imageObjectInfo.setInputStream(ccitt.createInputStream()); + + return imageObjectInfo; + } + + /** {@inheritDoc} */ + protected AFPDataObjectInfo createDataObjectInfo() { + return new AFPImageObjectInfo(); + } + + /** {@inheritDoc} */ + public int getPriority() { + return 400; + } + + /** {@inheritDoc} */ + public Class[] getSupportedImageClasses() { + return CLASSES; + } + + /** {@inheritDoc} */ + public ImageFlavor[] getSupportedImageFlavors() { + return FLAVORS; + } + +} diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java new file mode 100644 index 000000000..47344b200 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java @@ -0,0 +1,103 @@ +/* + * 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 java.io.IOException; +import java.io.InputStream; + +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.ImageInfo; +import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; +import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS; +import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; +import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; + +/** + * AFPImageHandler implementation which handles raw stream images. + */ +public class AFPImageHandlerRawStream extends AFPImageHandler { + + private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { + ImageFlavor.RAW_JPEG, + ImageFlavor.RAW_CCITTFAX, + ImageFlavor.RAW_EPS, + }; + + private static final Class[] CLASSES = new Class[] { + ImageRawJPEG.class, + ImageRawCCITTFax.class, + ImageRawEPS.class + }; + + /** {@inheritDoc} */ + public AFPDataObjectInfo generateDataObjectInfo( + AFPRendererImageInfo rendererImageInfo) throws IOException { + AFPDataObjectInfo dataObjectInfo = super.generateDataObjectInfo(rendererImageInfo); + ImageInfo imageInfo = rendererImageInfo.getImageInfo(); + String mimeType = imageInfo.getMimeType(); + if (mimeType != null) { + dataObjectInfo.setMimeType(mimeType); + } + ImageRawStream rawStream = (ImageRawStream) rendererImageInfo.getImage(); + + AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + + AFPRendererContext rendererContext + = (AFPRendererContext)rendererImageInfo.getRendererContext(); + AFPInfo afpInfo = rendererContext.getInfo(); + AFPPaintingState paintingState = afpInfo.getPaintingState(); + int resolution = paintingState.getResolution(); + objectAreaInfo.setWidthRes(resolution); + objectAreaInfo.setHeightRes(resolution); + + InputStream inputStream = rawStream.createInputStream(); + dataObjectInfo.setInputStream(inputStream); + + int dataHeight = rawStream.getSize().getHeightPx(); + dataObjectInfo.setDataHeight(dataHeight); + + int dataWidth = rawStream.getSize().getWidthPx(); + dataObjectInfo.setDataWidth(dataWidth); + return dataObjectInfo; + } + + /** {@inheritDoc} */ + public int getPriority() { + return 100; + } + + /** {@inheritDoc} */ + public Class[] getSupportedImageClasses() { + return CLASSES; + } + + /** {@inheritDoc} */ + public ImageFlavor[] getSupportedImageFlavors() { + return FLAVORS; + } + + /** {@inheritDoc} */ + protected AFPDataObjectInfo createDataObjectInfo() { + return new AFPDataObjectInfo(); + } +} diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRegistry.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRegistry.java new file mode 100644 index 000000000..59ca6cf38 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRegistry.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.render.afp; + +import org.apache.fop.render.AbstractImageHandlerRegistry; + +/** + * This class holds references to various image handlers used by the AFP renderer. It also + * supports automatic discovery of additional handlers available through + * the class path. + */ +public class AFPImageHandlerRegistry extends AbstractImageHandlerRegistry { + + /** + * Main constructor + */ + public AFPImageHandlerRegistry() { + } + + /** {@inheritDoc} */ + public Class getHandlerClass() { + return AFPImageHandler.class; + } + +} diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java new file mode 100644 index 000000000..ef6a6bb65 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java @@ -0,0 +1,118 @@ +/* + * 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 java.awt.image.RenderedImage; +import java.io.IOException; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPImageObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.impl.ImageBuffered; +import org.apache.xmlgraphics.image.loader.impl.ImageRendered; +import org.apache.xmlgraphics.ps.ImageEncodingHelper; +import org.apache.xmlgraphics.util.MimeConstants; + +/** + * PDFImageHandler implementation which handles RenderedImage instances. + */ +public class AFPImageHandlerRenderedImage extends AFPImageHandler { + + private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { + ImageFlavor.BUFFERED_IMAGE, + ImageFlavor.RENDERED_IMAGE + }; + + private static final Class[] CLASSES = new Class[] { + ImageBuffered.class, + ImageRendered.class + }; + + /** {@inheritDoc} */ + public AFPDataObjectInfo generateDataObjectInfo( + AFPRendererImageInfo rendererImageInfo) throws IOException { + AFPImageObjectInfo imageObjectInfo + = (AFPImageObjectInfo)super.generateDataObjectInfo(rendererImageInfo); + + imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); + + AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); + AFPRendererContext rendererContext + = (AFPRendererContext)rendererImageInfo.getRendererContext(); + AFPInfo afpInfo = rendererContext.getInfo(); + AFPPaintingState paintingState = afpInfo.getPaintingState(); + int resolution = paintingState.getResolution(); + objectAreaInfo.setWidthRes(resolution); + objectAreaInfo.setHeightRes(resolution); + + ImageRendered imageRendered = (ImageRendered) rendererImageInfo.img; + RenderedImage renderedImage = imageRendered.getRenderedImage(); + + int dataHeight = renderedImage.getHeight(); + imageObjectInfo.setDataHeight(dataHeight); + + int dataWidth = renderedImage.getWidth(); + imageObjectInfo.setDataWidth(dataWidth); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ImageEncodingHelper.encodeRenderedImageAsRGB(renderedImage, baos); + byte[] imageData = baos.toByteArray(); + + boolean colorImages = paintingState.isColorImages(); + imageObjectInfo.setColor(colorImages); + + // convert to grayscale + if (!colorImages) { + baos.reset(); + int bitsPerPixel = paintingState.getBitsPerPixel(); + imageObjectInfo.setBitsPerPixel(bitsPerPixel); + ImageEncodingHelper.encodeRGBAsGrayScale( + imageData, dataWidth, dataHeight, bitsPerPixel, baos); + imageData = baos.toByteArray(); + } + imageObjectInfo.setData(imageData); + + return imageObjectInfo; + } + + /** {@inheritDoc} */ + protected AFPDataObjectInfo createDataObjectInfo() { + return new AFPImageObjectInfo(); + } + + /** {@inheritDoc} */ + public int getPriority() { + return 300; + } + + /** {@inheritDoc} */ + public Class[] getSupportedImageClasses() { + return CLASSES; + } + + /** {@inheritDoc} */ + public ImageFlavor[] getSupportedImageFlavors() { + return FLAVORS; + } + +} diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java new file mode 100644 index 000000000..fee355da7 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.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.render.afp; + +import java.awt.Point; +import java.awt.Rectangle; +import java.io.IOException; +import java.util.Map; + +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.render.RendererContext; +import org.apache.fop.render.RendererContextConstants; +import org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; +import org.w3c.dom.Document; + +/** + * PDFImageHandler implementation which handles XML-based images. + */ +public class AFPImageHandlerXML extends AFPImageHandler { + + private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { + ImageFlavor.XML_DOM, + }; + + private static final Class[] CLASSES = new Class[] { + ImageXMLDOM.class, + }; + + /** {@inheritDoc} */ + public AFPDataObjectInfo generateDataObjectInfo(RendererContext context, Image image, + Point origin, Rectangle pos) + throws IOException { + AFPRenderer renderer = (AFPRenderer)context.getRenderer(); + ImageXMLDOM imgXML = (ImageXMLDOM)image; + Document doc = imgXML.getDocument(); + String ns = imgXML.getRootNamespace(); + Map foreignAttributes = (Map)context.getProperty( + RendererContextConstants.FOREIGN_ATTRIBUTES); + renderer.renderDocument(doc, ns, pos, foreignAttributes); + return null; + } + + /** {@inheritDoc} */ + public int getPriority() { + return 400; + } + + /** {@inheritDoc} */ + public Class[] getSupportedImageClasses() { + return CLASSES; + } + + /** {@inheritDoc} */ + public ImageFlavor[] getSupportedImageFlavors() { + return FLAVORS; + } + + /** {@inheritDoc} */ + protected AFPDataObjectInfo createDataObjectInfo() { + return null; + } + +} diff --git a/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java b/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java deleted file mode 100644 index 376bee7b9..000000000 --- a/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 java.io.IOException; -import java.io.InputStream; - -import org.apache.fop.afp.AFPDataObjectInfo; -import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPPaintingState; -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; - -/** - * A raw stream image data object info factory - */ -public class AFPImageRawStreamFactory extends AFPDataObjectInfoFactory { - - /** - * Main constructor - * - * @param state the AFP painting state - */ - public AFPImageRawStreamFactory(AFPPaintingState state) { - super(state); - } - - /** {@inheritDoc} */ - public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { - AFPDataObjectInfo dataObjectInfo = super.create(rendererImageInfo); - ImageInfo imageInfo = rendererImageInfo.getImageInfo(); - String mimeType = imageInfo.getMimeType(); - if (mimeType != null) { - dataObjectInfo.setMimeType(mimeType); - } - ImageRawStream rawStream = (ImageRawStream) rendererImageInfo.getImage(); - int resolution = state.getResolution(); - - AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - objectAreaInfo.setWidthRes(resolution); - objectAreaInfo.setHeightRes(resolution); - - InputStream inputStream = rawStream.createInputStream(); - dataObjectInfo.setInputStream(inputStream); - - int dataHeight = rawStream.getSize().getHeightPx(); - dataObjectInfo.setDataHeight(dataHeight); - - int dataWidth = rawStream.getSize().getWidthPx(); - dataObjectInfo.setDataWidth(dataWidth); - return dataObjectInfo; - } - - /** {@inheritDoc} */ - protected AFPDataObjectInfo createDataObjectInfo() { - return new AFPDataObjectInfo(); - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java b/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java deleted file mode 100644 index 59d6af9a8..000000000 --- a/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 java.awt.image.RenderedImage; -import java.io.IOException; - -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.apache.fop.afp.AFPDataObjectInfo; -import org.apache.fop.afp.AFPImageObjectInfo; -import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPPaintingState; -import org.apache.xmlgraphics.image.loader.impl.ImageRendered; -import org.apache.xmlgraphics.ps.ImageEncodingHelper; -import org.apache.xmlgraphics.util.MimeConstants; - -/** - * A buffered image data object info factory - */ -public class AFPImageRenderedFactory extends AFPDataObjectInfoFactory { - - /** - * Main constructor - * - * @param state the AFP painting state - */ - public AFPImageRenderedFactory(AFPPaintingState state) { - super(state); - } - - /** {@inheritDoc} */ - public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { - AFPImageObjectInfo imageObjectInfo - = (AFPImageObjectInfo)super.create(rendererImageInfo); - - imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); - - AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); - int resolution = state.getResolution(); - objectAreaInfo.setWidthRes(resolution); - objectAreaInfo.setHeightRes(resolution); - - ImageRendered imageRendered = (ImageRendered) rendererImageInfo.img; - RenderedImage renderedImage = imageRendered.getRenderedImage(); - - int dataHeight = renderedImage.getHeight(); - imageObjectInfo.setDataHeight(dataHeight); - - int dataWidth = renderedImage.getWidth(); - imageObjectInfo.setDataWidth(dataWidth); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ImageEncodingHelper.encodeRenderedImageAsRGB(renderedImage, baos); - byte[] imageData = baos.toByteArray(); - - boolean colorImages = state.isColorImages(); - imageObjectInfo.setColor(colorImages); - - // convert to grayscale - if (!colorImages) { - baos.reset(); - int bitsPerPixel = state.getBitsPerPixel(); - imageObjectInfo.setBitsPerPixel(bitsPerPixel); - ImageEncodingHelper.encodeRGBAsGrayScale( - imageData, dataWidth, dataHeight, bitsPerPixel, baos); - imageData = baos.toByteArray(); - } - imageObjectInfo.setData(imageData); - - return imageObjectInfo; - } - - /** {@inheritDoc} */ - protected AFPDataObjectInfo createDataObjectInfo() { - return new AFPImageObjectInfo(); - } -} diff --git a/src/java/org/apache/fop/render/afp/AFPInfo.java b/src/java/org/apache/fop/render/afp/AFPInfo.java index 1059014ab..59050b66d 100644 --- a/src/java/org/apache/fop/render/afp/AFPInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPInfo.java @@ -20,6 +20,7 @@ package org.apache.fop.render.afp; import org.apache.avalon.framework.configuration.Configuration; +import org.apache.fop.afp.AFPGraphics2D; import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceInfo; import org.apache.fop.afp.AFPResourceManager; @@ -47,18 +48,18 @@ public final class AFPInfo { /** see AFP_FONT_INFO */ private FontInfo fontInfo; - /** See AFP_STATE */ - private AFPPaintingState state; + /** See AFP_PAINTING_STATE */ + private AFPPaintingState paintingState; /** See AFP_RESOURCE_MANAGER */ private AFPResourceManager resourceManager; + /** See AFP_RESOURCE_INFO */ + private AFPResourceInfo resourceInfo; + /** true if SVG should be rendered as a bitmap instead of natively */ private boolean paintAsBitmap; - /** the resource information */ - private AFPResourceInfo resourceInfo; - /** * Returns the width. * @@ -128,7 +129,7 @@ public final class AFPInfo { * @return the current AFP state */ public AFPPaintingState getPaintingState() { - return this.state; + return this.paintingState; } /** @@ -217,7 +218,7 @@ public final class AFPInfo { * @param state the AFP state */ public void setPaintingState(AFPPaintingState state) { - this.state = state; + this.paintingState = state; } /** @@ -278,6 +279,19 @@ public final class AFPInfo { return resourceInfo; } + /** + * Creates an AFPGraphics2D implementation + * + * @param textAsShapes true when text is painted as shapes + * @return a newly created AFPGraphics2D + */ + public AFPGraphics2D createGraphics2D(boolean textAsShapes) { + AFPGraphics2D g2d = new AFPGraphics2D( + textAsShapes, paintingState, resourceManager, resourceInfo, fontInfo); + g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); + return g2d; + } + /** {@inheritDoc} */ public String toString() { return "AFPInfo{width=" + width @@ -287,7 +301,7 @@ public final class AFPInfo { + ", cfg=" + handlerConfiguration + ", fontInfo=" + fontInfo + ", resourceManager=" + resourceManager - + ", state=" + state + + ", paintingState=" + paintingState + ", paintAsBitmap=" + paintAsBitmap + ", resourceInfo=" + resourceInfo + "}"; diff --git a/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java b/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java deleted file mode 100644 index 2e6eca6ae..000000000 --- a/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 java.io.IOException; - -import org.apache.fop.afp.AFPDataObjectInfo; -import org.apache.fop.afp.AFPImageObjectInfo; -import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPPaintingState; -import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; - -/** - * An CITT fax image data object info factory - */ -public class AFPRawCCITTFaxFactory extends AFPDataObjectInfoFactory { - - /** - * Main constructor - * - * @param state the AFP painting state - */ - public AFPRawCCITTFaxFactory(AFPPaintingState state) { - super(state); - } - - /** {@inheritDoc} */ - public AFPDataObjectInfo create(AFPRendererImageInfo rendererImageInfo) throws IOException { - AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)super.create(rendererImageInfo); - - ImageRawCCITTFax ccitt = (ImageRawCCITTFax) rendererImageInfo.img; - imageObjectInfo.setCompression(ccitt.getCompression()); - - AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); - int xresol = (int) (ccitt.getSize().getDpiHorizontal() * 10); - objectAreaInfo.setWidthRes(xresol); - - int yresol = (int) (ccitt.getSize().getDpiVertical() * 10); - objectAreaInfo.setHeightRes(yresol); - - imageObjectInfo.setInputStream(ccitt.createInputStream()); - - return imageObjectInfo; - } - - /** {@inheritDoc} */ - protected AFPDataObjectInfo createDataObjectInfo() { - return new AFPImageObjectInfo(); - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 87c098a89..ede556ecb 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -36,7 +36,6 @@ import java.util.Map; import org.apache.fop.afp.AFPBorderPainter; import org.apache.fop.afp.AFPConstants; import org.apache.fop.afp.AFPDataObjectInfo; -import org.apache.fop.afp.AFPPageFonts; import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPRectanglePainter; import org.apache.fop.afp.AFPResourceManager; @@ -47,6 +46,7 @@ import org.apache.fop.afp.RectanglePaintInfo; import org.apache.fop.afp.fonts.AFPFont; import org.apache.fop.afp.fonts.AFPFontAttributes; import org.apache.fop.afp.fonts.AFPFontCollection; +import org.apache.fop.afp.fonts.AFPPageFonts; import org.apache.fop.afp.modca.DataStream; import org.apache.fop.afp.modca.PageObject; import org.apache.fop.apps.FOPException; @@ -77,7 +77,6 @@ import org.apache.xmlgraphics.image.loader.ImageFlavor; 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.image.loader.impl.ImageXMLDOM; import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.xmlgraphics.ps.ImageEncodingHelper; @@ -137,35 +136,33 @@ import org.apache.xmlgraphics.ps.ImageEncodingHelper; */ public class AFPRenderer extends AbstractPathOrientedRenderer { - /** Normal PDF resolution (72dpi) */ - public static final int NORMAL_AFP_RESOLUTION = 72; - private static final int X = 0; private static final int Y = 1; - /** resource manager */ + /** the resource manager */ private AFPResourceManager resourceManager; - /** painting state */ + /** the painting state */ private final AFPPaintingState paintingState; /** unit converter */ private final AFPUnitConverter unitConv; - /** line painter */ + /** the line painter */ private AFPBorderPainter borderPainter; - /** The map of page segments */ - private final Map/**/pageSegmentMap = new java.util.HashMap/**/(); + /** the map of page segments */ + private final Map/**/pageSegmentMap + = new java.util.HashMap/**/(); - /** The map of saved incomplete pages */ + /** the map of saved incomplete pages */ private final Map pages = new java.util.HashMap/**/(); - /** the afp datastream */ + /** the AFP datastream */ private DataStream dataStream; - /** data object information factory */ - private final AFPDataObjectInfoProvider dataObjectInfoProvider; + /** the image handler registry */ + private final AFPImageHandlerRegistry imageHandlerRegistry; private AFPRectanglePainter rectanglePainter; @@ -176,7 +173,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { super(); this.resourceManager = new AFPResourceManager(); this.paintingState = new AFPPaintingState(); - this.dataObjectInfoProvider = new AFPDataObjectInfoProvider(paintingState); + this.imageHandlerRegistry = new AFPImageHandlerRegistry(); this.unitConv = paintingState.getUnitConverter(); } @@ -252,7 +249,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public Graphics2DAdapter getGraphics2DAdapter() { - return new AFPGraphics2DAdapter(this); + return new AFPGraphics2DAdapter(paintingState); } /** {@inheritDoc} */ @@ -379,6 +376,11 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { rectanglePainter.paint(rectanglePaintInfo); } + /** {@inheritDoc} */ + protected RendererContext instantiateRendererContext() { + return new AFPRendererContext(this, getMimeType()); + } + /** {@inheritDoc} */ protected RendererContext createRendererContext(int x, int y, int width, int height, Map foreignAttributes) { @@ -394,25 +396,34 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } private static final ImageFlavor[] NATIVE_FLAVORS = new ImageFlavor[] { + ImageFlavor.XML_DOM, /*ImageFlavor.RAW_PNG, */ // PNG not natively supported in AFP - ImageFlavor.XML_DOM, ImageFlavor.RAW_JPEG, ImageFlavor.RAW_CCITTFAX, ImageFlavor.RAW_EPS, + ImageFlavor.RAW_JPEG, ImageFlavor.RAW_CCITTFAX, ImageFlavor.RAW_EPS, ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE }; private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { - ImageFlavor.XML_DOM, ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE }; + ImageFlavor.XML_DOM, + ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE }; /** {@inheritDoc} */ public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) { uri = URISpecification.getURL(uri); paintingState.setImageUri(uri); - Rectangle posInt = new Rectangle((int) pos.getX(), (int) pos.getY(), - (int) pos.getWidth(), (int) pos.getHeight()); + + Point origin = new Point(currentIPPosition, currentBPPosition); + Rectangle posInt = new Rectangle( + (int)Math.round(pos.getX()), + (int)Math.round(pos.getY()), + (int)Math.round(pos.getWidth()), + (int)Math.round(pos.getHeight()) + ); + int x = origin.x + posInt.x; + int y = origin.y + posInt.y; + String name = (String)pageSegmentMap.get(uri); - int x = currentIPPosition + posInt.x; - int y = currentBPPosition + posInt.y; - float[] srcPts = {x, y}; - int[] coords = unitConv.mpts2units(srcPts); if (name != null) { + float[] srcPts = {x, y}; + int[] coords = unitConv.mpts2units(srcPts); dataStream.createIncludePageSegment(name, coords[X], coords[Y]); } else { ImageManager manager = userAgent.getFactory().getImageManager(); @@ -425,41 +436,40 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { // Only now fully load/prepare the image Map hints = ImageUtil.getDefaultHints(sessionContext); - ImageFlavor[] flavors = paintingState.isNativeImages() ? NATIVE_FLAVORS : FLAVORS; + boolean nativeImagesSupported = paintingState.isNativeImagesSupported(); + ImageFlavor[] flavors = nativeImagesSupported ? NATIVE_FLAVORS : FLAVORS; + + // Load image org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, flavors, hints, sessionContext); - Point origin = new Point(currentIPPosition, currentBPPosition); - AFPDataObjectInfoFactory factory = dataObjectInfoProvider.getFactory(img); - if (factory != null) { - AFPRendererImageInfo afpImageInfo - = new AFPRendererImageInfo(uri, pos, origin, info, img, foreignAttributes); - if (factory instanceof AFPImageGraphics2DFactory) { - RendererContext rendererContext = createRendererContext( - x, y, posInt.width, posInt.height, foreignAttributes); - afpImageInfo.setRendererContext(rendererContext); - AFPGraphics2DAdapter g2dAdapter - = (AFPGraphics2DAdapter)getGraphics2DAdapter(); - afpImageInfo.setGraphics2DAdapter(g2dAdapter); - } + // Handle image + AFPImageHandler imageHandler + = (AFPImageHandler)imageHandlerRegistry.getHandler(img); + if (imageHandler != null) { + RendererContext rendererContext = createRendererContext( + x, y, posInt.width, posInt.height, foreignAttributes); + AFPRendererImageInfo rendererImageInfo = new AFPRendererImageInfo( + uri, pos, origin, info, img, rendererContext, foreignAttributes); AFPDataObjectInfo dataObjectInfo = null; try { - dataObjectInfo = factory.create(afpImageInfo); + dataObjectInfo = imageHandler.generateDataObjectInfo(rendererImageInfo); + // Create image + if (dataObjectInfo != null) { + resourceManager.createObject(dataObjectInfo); + } } catch (IOException ioe) { ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(userAgent.getEventBroadcaster()); eventProducer.imageWritingError(this, ioe); throw ioe; } - resourceManager.createObject(dataObjectInfo); - } else if (img instanceof ImageXMLDOM) { - ImageXMLDOM imgXML = (ImageXMLDOM) img; - renderDocument(imgXML.getDocument(), imgXML.getRootNamespace(), - posInt, foreignAttributes); } else { throw new UnsupportedOperationException( - "Unsupported image type: " + img); + "No AFPImageHandler available for image: " + + info + " (" + img.getClass().getName() + ")"); } + } catch (ImageException ie) { ResourceEventProducer eventProducer = ResourceEventProducer.Provider .get(userAgent.getEventBroadcaster()); @@ -546,29 +556,17 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { public void renderText(TextArea text) { renderInlineAreaBackAndBorders(text); + // set font size int fontSize = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); paintingState.setFontSize(fontSize); - String name = getInternalFontNameForArea(text); - AFPFont font = (AFPFont)fontInfo.getFonts().get(name); - - // Set letterSpacing - // float ls = fs.getLetterSpacing() / this.currentFontSize; - - // Create an AFPFontAttributes object from the current font details - AFPFontAttributes fontAttributes - = new AFPFontAttributes(name, font, fontSize); - + // register font as necessary + String internalFontName = getInternalFontNameForArea(text); + AFPFont font = (AFPFont)fontInfo.getFonts().get(internalFontName); AFPPageFonts pageFonts = paintingState.getPageFonts(); - if (!pageFonts.containsKey(fontAttributes.getFontKey())) { - // Font not found on current page, so add the new one - fontAttributes.setFontReference(paintingState.incrementPageFontCount()); - pageFonts.put(fontAttributes.getFontKey(), fontAttributes); - } else { - // Use the previously stored font attributes - fontAttributes = (AFPFontAttributes)pageFonts.get(fontAttributes.getFontKey()); - } + AFPFontAttributes fontAttributes = pageFonts.registerFont(internalFontName, font, fontSize); + // create text data info AFPTextDataInfo textDataInfo = new AFPTextDataInfo(); int fontReference = fontAttributes.getFontReference(); @@ -765,8 +763,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { * @param nativeImages * native image support */ - public void setNativeImages(boolean nativeImages) { - paintingState.setNativeImages(nativeImages); + public void setNativeImagesSupported(boolean nativeImages) { + paintingState.setNativeImagesSupported(nativeImages); } /** diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index 6a59d27e3..532d45967 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java @@ -213,6 +213,12 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator { return fontList; } + /** images are converted to grayscale bitmapped IOCA */ + private static final String IMAGES_MODE_GRAYSCALE = "b+w"; + + /** images are converted to color bitmapped IOCA */ + private static final String IMAGES_MODE_COLOR = "color"; + /** * Configure the AFP renderer. * @@ -234,15 +240,21 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator { // image information Configuration imagesCfg = cfg.getChild("images"); - if (!"color".equalsIgnoreCase(imagesCfg.getAttribute("mode", "b+w"))) { - afpRenderer.setColorImages(false); - afpRenderer.setBitsPerPixel(imagesCfg.getAttributeAsInteger("bits-per-pixel", 8)); - } else { + + // default to grayscale images + String imagesMode = imagesCfg.getAttribute("mode", IMAGES_MODE_GRAYSCALE); + if (IMAGES_MODE_COLOR.equals(imagesMode)) { afpRenderer.setColorImages(true); + } else { + afpRenderer.setColorImages(false); + // default to 8 bits per pixel + int bitsPerPixel = imagesCfg.getAttributeAsInteger("bits-per-pixel", 8); + afpRenderer.setBitsPerPixel(bitsPerPixel); } - // images are embedded directly without conversion to bitmapped IOCA - afpRenderer.setNativeImages(imagesCfg.getAttributeAsBoolean("native", false)); + // native image support + boolean nativeImageSupport = imagesCfg.getAttributeAsBoolean("native", false); + afpRenderer.setNativeImagesSupported(nativeImageSupport); // renderer resolution Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false); @@ -269,16 +281,6 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator { + resourceGroupDest + "'"); } } - - // TODO: provide support for different MO:DCA interchange sets - // the MO:DCA interchange set in use (defaults to MO:DCA-L) -// Configuration modcaCfg = cfg.getChild("modca", false); -// if (modcaCfg != null) { -// String interchangeSetString = cfg.getAttribute( -// "interchange-set", InterchangeSet.MODCA_PRESENTATION_INTERCHANGE_SET_2); -// InterchangeSet interchangeSet = InterchangeSet.valueOf(interchangeSetString); -// afpRenderer.getAFPDataStream().setInterchangeSet(interchangeSet); -// } } } } diff --git a/src/java/org/apache/fop/render/afp/AFPRendererContext.java b/src/java/org/apache/fop/render/afp/AFPRendererContext.java new file mode 100644 index 000000000..8d544a7c4 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AFPRendererContext.java @@ -0,0 +1,83 @@ +/* + * 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 java.util.Map; + +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.fop.afp.AFPPaintingState; +import org.apache.fop.afp.AFPResourceInfo; +import org.apache.fop.afp.AFPResourceLevel; +import org.apache.fop.afp.AFPResourceManager; +import org.apache.fop.render.AbstractRenderer; +import org.apache.fop.render.RendererContext; +import org.apache.fop.render.RendererContextConstants; + +public class AFPRendererContext extends RendererContext { + + /** + * Main constructor + * + * @param renderer the current renderer + * @param mime the MIME type of the output that's generated. + */ + public AFPRendererContext(AbstractRenderer renderer, String mime) { + super(renderer, mime); + } + + /** + * Returns a new AFPInfo for this renderer context + * + * @return an AFPInfo for this renderer context + */ + public AFPInfo getInfo() { + AFPInfo info = new AFPInfo(); + info.setWidth(((Integer)getProperty(RendererContextConstants.WIDTH)).intValue()); + info.setHeight(((Integer)getProperty(RendererContextConstants.HEIGHT)).intValue()); + info.setX(((Integer)getProperty(RendererContextConstants.XPOS)).intValue()); + info.setY(((Integer)getProperty(RendererContextConstants.YPOS)).intValue()); + info.setHandlerConfiguration((Configuration)getProperty( + RendererContextConstants.HANDLER_CONFIGURATION)); + info.setFontInfo((org.apache.fop.fonts.FontInfo)getProperty( + AFPRendererContextConstants.AFP_FONT_INFO)); + info.setPaintingState((AFPPaintingState)getProperty( + AFPRendererContextConstants.AFP_PAINTING_STATE)); + info.setResourceManager(((AFPResourceManager)getProperty( + AFPRendererContextConstants.AFP_RESOURCE_MANAGER))); + + Map foreignAttributes = (Map)getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); + if (foreignAttributes != null) { + String conversionMode = (String)foreignAttributes.get(CONVERSION_MODE); + boolean paintAsBitmap = BITMAP.equalsIgnoreCase(conversionMode); + info.setPaintAsBitmap(paintAsBitmap); + + AFPForeignAttributeReader foreignAttributeReader + = new AFPForeignAttributeReader(); + AFPResourceInfo resourceInfo + = foreignAttributeReader.getResourceInfo(foreignAttributes); + // default to inline level if painted as GOCA + if (!resourceInfo.levelChanged() && !paintAsBitmap) { + resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE)); + } + info.setResourceInfo(resourceInfo); + } + return info; + } +} diff --git a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java index d4a14d3c2..0aa3eb6ab 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java @@ -50,9 +50,6 @@ public class AFPRendererImageInfo { /** the image */ protected final Image img; - /** the AFP graphics 2d adapter */ - protected AFPGraphics2DAdapter g2dAdapter; - /** the renderer context */ protected RendererContext rendererContext; @@ -64,15 +61,17 @@ public class AFPRendererImageInfo { * @param origin the current position * @param info the image info * @param img the image + * @param rendererContext the renderer context * @param foreignAttributes the foreign attributes */ public AFPRendererImageInfo(String uri, Rectangle2D pos, Point origin, - ImageInfo info, Image img, Map foreignAttributes) { + ImageInfo info, Image img, RendererContext rendererContext, Map foreignAttributes) { this.uri = uri; this.pos = pos; this.origin = origin; this.info = info; this.img = img; + this.rendererContext = rendererContext; this.foreignAttributes = foreignAttributes; } @@ -85,15 +84,6 @@ public class AFPRendererImageInfo { this.rendererContext = rendererContext; } - /** - * Sets the graphics 2d adapter - * - * @param adapter the graphics 2d adapter - */ - public void setGraphics2DAdapter(AFPGraphics2DAdapter adapter) { - this.g2dAdapter = adapter; - } - /** * Returns the image info * @@ -112,15 +102,6 @@ public class AFPRendererImageInfo { return this.img; } - /** - * Returns the graphics 2D adapter - * - * @return the graphics 2D adapter - */ - public AFPGraphics2DAdapter getGraphics2DAdapter() { - return this.g2dAdapter; - } - /** * Returns the renderer context * diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index 3bdab289c..2800686d9 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -22,39 +22,32 @@ package org.apache.fop.render.afp; // FOP import java.awt.Dimension; import java.awt.geom.AffineTransform; -import java.awt.geom.Dimension2D; import java.io.IOException; -import java.util.Map; -import org.apache.avalon.framework.configuration.Configuration; import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.bridge.BridgeException; -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.fop.afp.AFPForeignAttributeReader; import org.apache.fop.afp.AFPGraphics2D; import org.apache.fop.afp.AFPGraphicsObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceInfo; -import org.apache.fop.afp.AFPResourceLevel; import org.apache.fop.afp.AFPResourceManager; -import org.apache.fop.afp.AFPTextElementBridge; -import org.apache.fop.afp.AFPTextHandler; -import org.apache.fop.afp.AFPTextPainter; import org.apache.fop.afp.AFPUnitConverter; import org.apache.fop.afp.Graphics2DImagePainterGOCA; +import org.apache.fop.afp.svg.AFPBridgeContext; +import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontInfo; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; -import org.apache.fop.render.RendererContextConstants; import org.apache.fop.render.RendererContext.RendererContextWrapper; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; +import org.apache.xmlgraphics.image.loader.ImageManager; +import org.apache.xmlgraphics.image.loader.ImageSessionContext; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; +import org.apache.xmlgraphics.util.MimeConstants; import org.w3c.dom.Document; /** @@ -74,177 +67,138 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { } } - /** - * Get the AFP information from the render context. - * - * @param context the renderer context - * @return the AFP information retrieved from the context - */ - public static AFPInfo getAFPInfo(RendererContext context) { - AFPInfo afpi = new AFPInfo(); - afpi.setWidth(((Integer)context.getProperty(WIDTH)).intValue()); - afpi.setHeight(((Integer)context.getProperty(HEIGHT)).intValue()); - afpi.setX(((Integer)context.getProperty(XPOS)).intValue()); - afpi.setY(((Integer)context.getProperty(YPOS)).intValue()); - afpi.setHandlerConfiguration((Configuration)context.getProperty(HANDLER_CONFIGURATION)); - afpi.setFontInfo((org.apache.fop.fonts.FontInfo)context.getProperty( - AFPRendererContextConstants.AFP_FONT_INFO)); - afpi.setPaintingState((AFPPaintingState)context.getProperty( - AFPRendererContextConstants.AFP_PAINTING_STATE)); - afpi.setResourceManager(((AFPResourceManager)context.getProperty( - AFPRendererContextConstants.AFP_RESOURCE_MANAGER))); - - Map foreignAttributes = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); - if (foreignAttributes != null) { - String conversionMode = (String)foreignAttributes.get(CONVERSION_MODE); - boolean paintAsBitmap = BITMAP.equalsIgnoreCase(conversionMode); - afpi.setPaintAsBitmap(paintAsBitmap); - - AFPForeignAttributeReader foreignAttributeReader = new AFPForeignAttributeReader(); - AFPResourceInfo resourceInfo = foreignAttributeReader.getResourceInfo(foreignAttributes); - // default to inline level if painted as GOCA - if (!resourceInfo.levelChanged() && !paintAsBitmap) { - resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE)); - } - afpi.setResourceInfo(resourceInfo); - } - return afpi; - } - private static final int X = 0; private static final int Y = 1; /** * Render the SVG document. * - * @param context the renderer context + * @param rendererContext the renderer context * @param doc the SVG document * @throws IOException In case of an I/O error while painting the image */ - protected void renderSVGDocument(final RendererContext context, + protected void renderSVGDocument(final RendererContext rendererContext, final Document doc) throws IOException { - AFPInfo afpInfo = getAFPInfo(context); + AFPRendererContext afpRendererContext = (AFPRendererContext)rendererContext; + AFPInfo afpInfo = afpRendererContext.getInfo(); this.paintAsBitmap = afpInfo.paintAsBitmap(); + FOUserAgent userAgent = rendererContext.getUserAgent(); + // fallback paint as bitmap + String uri = getDocumentURI(doc); if (paintAsBitmap) { try { - super.renderSVGDocument(context, doc); + super.renderSVGDocument(rendererContext, doc); } catch (IOException ioe) { SVGEventProducer eventProducer = SVGEventProducer.Provider.get( - context.getUserAgent().getEventBroadcaster()); - eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc)); + userAgent.getEventBroadcaster()); + eventProducer.svgRenderingError(this, ioe, uri); } return; } - String uri = ((AbstractDocument)doc).getDocumentURI(); - AFPPaintingState paintingState = afpInfo.getPaintingState(); + // Create a new AFPGraphics2D + final boolean textAsShapes = false; + AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes); + + AFPPaintingState paintingState = g2d.getPaintingState(); paintingState.setImageUri(uri); + // Create an AFPBridgeContext + BridgeContext bridgeContext = createBridgeContext(userAgent, g2d); + + // Build the SVG DOM and provide the painter with it + GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, doc); + + // Create Graphics2DImagePainter + final RendererContextWrapper wrappedContext + = RendererContext.wrapRendererContext(rendererContext); + Dimension imageSize = getImageSize(wrappedContext); + Graphics2DImagePainter painter + = createGrapics2DImagePainter(bridgeContext, root, imageSize); + + // Create AFPObjectAreaInfo + RendererContextWrapper rctx = RendererContext.wrapRendererContext(rendererContext); + int x = rctx.getCurrentXPosition(); + int y = rctx.getCurrentYPosition(); + int width = afpInfo.getWidth(); + int height = afpInfo.getHeight(); + int resolution = afpInfo.getResolution(); + + paintingState.push(); // save + + AFPObjectAreaInfo objectAreaInfo + = createObjectAreaInfo(paintingState, x, y, width, height, resolution); + + // Create AFPGraphicsObjectInfo + AFPResourceInfo resourceInfo = afpInfo.getResourceInfo(); + AFPGraphicsObjectInfo graphicsObjectInfo = createGraphicsObjectInfo( + paintingState, painter, userAgent, resourceInfo, g2d); + graphicsObjectInfo.setObjectAreaInfo(objectAreaInfo); + + // Create the GOCA GraphicsObject in the DataStream + AFPResourceManager resourceManager = afpInfo.getResourceManager(); + resourceManager.createObject(graphicsObjectInfo); + + paintingState.pop(); // resume + } + + private AFPObjectAreaInfo createObjectAreaInfo(AFPPaintingState paintingState, + int x, int y, int width, int height, int resolution) { // set the data object parameters AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(); - RendererContextWrapper rctx = RendererContext.wrapRendererContext(context); - int currx = rctx.getCurrentXPosition(); - int curry = rctx.getCurrentYPosition(); - float[] srcPts = {currx, curry}; - - AFPUnitConverter unitConv = paintingState.getUnitConverter(); - int[] coords = unitConv.mpts2units(srcPts); - objectAreaInfo.setX(coords[X]); - objectAreaInfo.setY(coords[Y]); + AffineTransform at = paintingState.getData().getTransform(); + at.translate(x, y); + objectAreaInfo.setX((int)Math.round(at.getTranslateX())); + objectAreaInfo.setY((int)Math.round(at.getTranslateY())); - int resolution = afpInfo.getResolution(); objectAreaInfo.setWidthRes(resolution); objectAreaInfo.setHeightRes(resolution); - int width = Math.round(unitConv.mpt2units(afpInfo.getWidth())); - objectAreaInfo.setWidth(width); - - int height = Math.round(unitConv.mpt2units(afpInfo.getHeight())); - objectAreaInfo.setHeight(height); + AFPUnitConverter unitConv = paintingState.getUnitConverter(); + objectAreaInfo.setWidth(Math.round(unitConv.mpt2units(width))); + objectAreaInfo.setHeight(Math.round(unitConv.mpt2units(height))); int rotation = paintingState.getRotation(); objectAreaInfo.setRotation(rotation); - AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo(); - graphicsObjectInfo.setUri(uri); + return objectAreaInfo; + } - // Configure Graphics2D implementation - final boolean textAsShapes = false; - AFPGraphics2D g2d = new AFPGraphics2D(textAsShapes); + private AFPGraphicsObjectInfo createGraphicsObjectInfo(AFPPaintingState paintingState, Graphics2DImagePainter painter, + FOUserAgent userAgent, AFPResourceInfo resourceInfo, AFPGraphics2D g2d) { + AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo(); - g2d.setPaintingState(paintingState); + String uri = paintingState.getImageUri(); + graphicsObjectInfo.setUri(uri); - AFPResourceManager resourceManager = afpInfo.getResourceManager(); - g2d.setResourceManager(resourceManager); + graphicsObjectInfo.setMimeType(MimeConstants.MIME_AFP_GOCA); - AFPResourceInfo resourceInfo = afpInfo.getResourceInfo(); - g2d.setResourceInfo(resourceInfo); graphicsObjectInfo.setResourceInfo(resourceInfo); - g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - - FontInfo fontInfo = afpInfo.getFontInfo(); - g2d.setFontInfo(fontInfo); - - // Configure GraphicsObjectPainter with the Graphics2D implementation - GraphicsObjectPainterAFP painter = new GraphicsObjectPainterAFP(g2d); - (graphicsObjectInfo).setPainter(painter); + graphicsObjectInfo.setPainter(painter); - // Controls whether text painted by Batik is generated using text or path operations - SVGUserAgent svgUserAgent - = new SVGUserAgent(context.getUserAgent(), new AffineTransform()); - BridgeContext ctx = new BridgeContext(svgUserAgent); - if (!afpInfo.strokeText()) { - AFPTextHandler textHandler = new AFPTextHandler(g2d); - g2d.setCustomTextHandler(textHandler); - AFPTextPainter textPainter = new AFPTextPainter(textHandler); - ctx.setTextPainter(textPainter); - AFPTextElementBridge tBridge = new AFPTextElementBridge(textPainter); - ctx.putBridge(tBridge); - } + // Set the afp graphics 2d implementation + graphicsObjectInfo.setGraphics2D(g2d); - // Build the SVG DOM and provide the painter with it - GraphicsNode root; - GVTBuilder builder = new GVTBuilder(); - try { - root = builder.build(ctx, doc); - painter.setGraphicsNode(root); - } catch (BridgeException e) { - SVGEventProducer eventProducer = SVGEventProducer.Provider.get( - context.getUserAgent().getEventBroadcaster()); - eventProducer.svgNotBuilt(this, e, uri); - return; - } + return graphicsObjectInfo; + } - // convert to afp inches - Dimension2D dim = ctx.getDocumentSize(); - double w = dim.getWidth() * 1000f; - double h = dim.getHeight() * 1000f; - double wx = (afpInfo.getWidth() / w); - double hx = (afpInfo.getHeight() / h); - double scaleX = unitConv.pt2units((float)wx); - double scaleY = unitConv.pt2units((float)hx); - double yOffset = unitConv.mpt2units(afpInfo.getHeight()); - - // Transformation matrix that establishes the local coordinate system - // for the SVG graphic in relation to the current coordinate system - // (note: y axis is inverted) - AffineTransform trans = new AffineTransform(scaleX, 0, 0, -scaleY, 0, yOffset); - g2d.setTransform(trans); + public static BridgeContext createBridgeContext(FOUserAgent userAgent, AFPGraphics2D g2d) { + ImageManager imageManager = userAgent.getFactory().getImageManager(); - // Set the afp graphics 2d implementation - graphicsObjectInfo.setGraphics2D(g2d); + SVGUserAgent svgUserAgent + = new SVGUserAgent(userAgent, new AffineTransform()); - // Set the object area info - graphicsObjectInfo.setObjectAreaInfo(objectAreaInfo); + ImageSessionContext imageSessionContext = userAgent.getImageSessionContext(); - // Create the graphics object - resourceManager.createObject(graphicsObjectInfo); + FontInfo fontInfo = g2d.getFontInfo(); + return new AFPBridgeContext(svgUserAgent, fontInfo, imageManager, imageSessionContext, + new AffineTransform(), g2d); } /** {@inheritDoc} */ @@ -259,11 +213,13 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { } /** {@inheritDoc} */ - protected Graphics2DImagePainter createPainter(BridgeContext ctx, GraphicsNode root, Dimension imageSize) { + protected Graphics2DImagePainter createGrapics2DImagePainter(BridgeContext ctx, GraphicsNode root, Dimension imageSize) { Graphics2DImagePainter painter = null; if (paintAsBitmap()) { - painter = super.createPainter(root, ctx, imageSize); + // paint as IOCA Image + painter = super.createGraphics2DImagePainter(root, ctx, imageSize); } else { + // paint as GOCA Graphics painter = new Graphics2DImagePainterGOCA(root, ctx, imageSize); } return painter; diff --git a/src/java/org/apache/fop/render/afp/GraphicsObjectPainterAFP.java b/src/java/org/apache/fop/render/afp/GraphicsObjectPainterAFP.java deleted file mode 100644 index 7eb2c1001..000000000 --- a/src/java/org/apache/fop/render/afp/GraphicsObjectPainterAFP.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.geom.Rectangle2D; - -import org.apache.batik.gvt.GraphicsNode; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.afp.AFPGraphics2D; -import org.apache.fop.afp.modca.GraphicsObject; -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; - -/** - * Paints SVG as a GOCA Graphics Object using Batik - */ -public class GraphicsObjectPainterAFP implements Graphics2DImagePainter { - /** Static logging instance */ - protected static Log log = LogFactory.getLog(GraphicsObjectPainterAFP.class); - - private final AFPGraphics2D graphics2D; - - /** the batik root node of the svg document */ - private GraphicsNode root; - - /** - * Main constructor - * - * @param graphics an AFP graphics 2D implementation - */ - public GraphicsObjectPainterAFP(AFPGraphics2D graphics) { - final boolean textAsShapes = false; - this.graphics2D = new AFPGraphics2D(textAsShapes); - } - - /** - * Sets the graphics node - * - * @param rootNode the graphics root node - */ - public void setGraphicsNode(GraphicsNode rootNode) { - this.root = rootNode; - } - - /** {@inheritDoc} */ - public void paint(Graphics2D g2d, Rectangle2D area) { - log.debug("Painting SVG using GOCA"); - - // tell batik to paint the graphics object - root.paint(g2d); - - // dispose of the graphics 2d implementation - g2d.dispose(); - } - - /** {@inheritDoc} */ - public Dimension getImageSize() { - return null; - } - - /** - * Sets the GOCA Graphics Object - * - * @param graphicsObject the GOCA Graphics Object - */ - public void setGraphicsObject(GraphicsObject graphicsObject) { - this.graphics2D.setGraphicsObject(graphicsObject); - } - -} diff --git a/src/java/org/apache/fop/render/afp/package.html b/src/java/org/apache/fop/render/afp/package.html new file mode 100644 index 000000000..3e611d964 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.render.afp Package + +

      An AFP Renderer implementation and supporting classes.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandler.java b/src/java/org/apache/fop/render/pdf/PDFImageHandler.java index f93ee5a97..6343d0c50 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandler.java @@ -23,36 +23,15 @@ import java.awt.Point; import java.awt.Rectangle; import java.io.IOException; -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageFlavor; - import org.apache.fop.pdf.PDFXObject; +import org.apache.fop.render.ImageHandler; import org.apache.fop.render.RendererContext; +import org.apache.xmlgraphics.image.loader.Image; /** * This interface is used for handling all sorts of image type for PDF output. */ -public interface PDFImageHandler { - - /** - * Returns the priority for this image handler. A lower value means higher priority. This - * information is used to build the ordered/prioritized list of supported ImageFlavors for - * the PDF renderer. The built-in handlers use priorities between 100 and 999. - * @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(); +public interface PDFImageHandler extends ImageHandler { /** * Generates the PDF objects for the given {@link Image} instance. If the handler generates diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java index a58fe5922..9f44e58b5 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java @@ -23,13 +23,12 @@ import java.awt.Point; import java.awt.Rectangle; import java.io.IOException; +import org.apache.fop.pdf.PDFXObject; +import org.apache.fop.render.RendererContext; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D; -import org.apache.fop.pdf.PDFXObject; -import org.apache.fop.render.RendererContext; - /** * PDFImageHandler implementation which handles Graphics2D images. */ @@ -39,6 +38,10 @@ public class PDFImageHandlerGraphics2D implements PDFImageHandler { ImageFlavor.GRAPHICS2D, }; + private static final Class[] CLASSES = new Class[] { + ImageGraphics2D.class, + }; + /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -56,8 +59,8 @@ public class PDFImageHandlerGraphics2D implements PDFImageHandler { } /** {@inheritDoc} */ - public Class getSupportedImageClass() { - return ImageGraphics2D.class; + public Class[] getSupportedImageClasses() { + return CLASSES; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java index 9f56ebfea..158e93c86 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java @@ -23,15 +23,14 @@ import java.awt.Point; import java.awt.Rectangle; import java.io.IOException; -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; - import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFImage; import org.apache.fop.pdf.PDFResourceContext; import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.RendererContext; +import org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; /** * PDFImageHandler implementation which handles CCITT encoded images (CCITT fax group 3/4). @@ -42,6 +41,10 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler { ImageFlavor.RAW_CCITTFAX, }; + private static final Class[] CLASSES = new Class[] { + ImageRawCCITTFax.class, + }; + /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -71,8 +74,8 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler { } /** {@inheritDoc} */ - public Class getSupportedImageClass() { - return ImageRawCCITTFax.class; + public Class[] getSupportedImageClasses() { + return CLASSES; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java index f971a49ae..1432547da 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java @@ -23,15 +23,14 @@ import java.awt.Point; import java.awt.Rectangle; import java.io.IOException; -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; - import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFImage; import org.apache.fop.pdf.PDFResourceContext; import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.RendererContext; +import org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; /** * PDFImageHandler implementation which handles raw JPEG images. @@ -42,6 +41,10 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler { ImageFlavor.RAW_JPEG, }; + private static final Class[] CLASSES = new Class[] { + ImageRawJPEG.class, + }; + /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -71,8 +74,8 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler { } /** {@inheritDoc} */ - public Class getSupportedImageClass() { - return ImageRawJPEG.class; + public Class[] getSupportedImageClasses() { + return CLASSES; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java index b664a0a24..1d4c733a3 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java @@ -19,171 +19,18 @@ package org.apache.fop.render.pdf; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; - -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.ImageFlavor; -import org.apache.xmlgraphics.util.Service; +import org.apache.fop.render.AbstractImageHandlerRegistry; /** * This class holds references to various image handlers used by the PDF renderer. It also * supports automatic discovery of additional handlers available through * the class path. */ -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; - PDFImageHandler h2 = (PDFImageHandler)o2; - return h1.getPriority() - h2.getPriority(); - } - }; - - /** Map containing PDF image handlers for various MIME types */ - 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(); +public class PDFImageHandlerRegistry extends AbstractImageHandlerRegistry { - /** 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 - */ - public void addHandler(String classname) { - try { - PDFImageHandler handlerInstance - = (PDFImageHandler)Class.forName(classname).newInstance(); - addHandler(handlerInstance); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException("Could not find " - + classname); - } catch (InstantiationException e) { - throw new IllegalArgumentException("Could not instantiate " - + classname); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException("Could not access " - + classname); - } catch (ClassCastException e) { - throw new IllegalArgumentException(classname - + " is not an " - + PDFImageHandler.class.getName()); - } + /** {@inheritDoc} */ + public Class getHandlerClass() { + return PDFImageHandler.class; } - /** - * Add an image handler. The handler itself is inspected to find out what it supports. - * @param handler the PDFImageHandler instance - */ - 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()) { - PDFImageHandler h = (PDFImageHandler)iter.next(); - if (HANDLER_COMPARATOR.compare(handler, h) < 0) { - iter.previous(); - break; - } - } - iter.add(handler); - this.handlerRegistrations++; - } - - /** - * Returns an PDFImageHandler which handles an specific image type given the MIME type - * of the image. - * @param img the Image to be handled - * @return the PDFImageHandler responsible for handling the image or null if none is available - */ - public PDFImageHandler getHandler(Image img) { - return getHandler(img.getClass()); - } - - /** - * Returns an PDFImageHandler which handles an specific image type given the MIME type - * of the image. - * @param imageClass the Image subclass for which to get a handler - * @return the PDFImageHandler responsible for handling the image or null if none is available - */ - protected synchronized PDFImageHandler getHandler(Class imageClass) { - PDFImageHandler handler = null; - Class cl = imageClass; - while (cl != null) { - handler = (PDFImageHandler)handlers.get(cl); - if (handler != null) { - break; - } - cl = cl.getSuperclass(); - } - return handler; - } - - /** - * Returns the ordered array of supported image flavors. - * @return the array of image flavors - */ - public synchronized ImageFlavor[] getSupportedFlavors() { - if (this.lastSync != this.handlerRegistrations) { - //Extract all ImageFlavors into a single array - List flavors = new java.util.ArrayList(); - Iterator iter = this.handlerList.iterator(); - while (iter.hasNext()) { - ImageFlavor[] f = ((PDFImageHandler)iter.next()).getSupportedImageFlavors(); - for (int i = 0; i < f.length; i++) { - flavors.add(f[i]); - } - } - this.supportedFlavors = (ImageFlavor[])flavors.toArray(new ImageFlavor[flavors.size()]); - this.lastSync = this.handlerRegistrations; - } - return this.supportedFlavors; - } - - /** - * Discovers PDFImageHandler implementations through the classpath and dynamically - * registers them. - */ - private void discoverHandlers() { - // add mappings from available services - Iterator providers = Service.providers(PDFImageHandler.class); - if (providers != null) { - while (providers.hasNext()) { - PDFImageHandler handler = (PDFImageHandler)providers.next(); - try { - if (log.isDebugEnabled()) { - log.debug("Dynamically adding PDFImageHandler: " - + handler.getClass().getName()); - } - addHandler(handler); - } catch (IllegalArgumentException e) { - log.error("Error while adding PDFImageHandler", e); - } - - } - } - } } diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java index 783cb225c..edbe9005d 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java @@ -23,15 +23,14 @@ import java.awt.Point; import java.awt.Rectangle; import java.io.IOException; -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.impl.ImageRendered; - import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFImage; import org.apache.fop.pdf.PDFResourceContext; import org.apache.fop.pdf.PDFXObject; import org.apache.fop.render.RendererContext; +import org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +import org.apache.xmlgraphics.image.loader.impl.ImageRendered; /** * PDFImageHandler implementation which handles RenderedImage instances. @@ -43,6 +42,11 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler { ImageFlavor.RENDERED_IMAGE }; + private static final Class[] CLASSES = new Class[] { + ImageRendered.class, + }; + + /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -72,8 +76,8 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler { } /** {@inheritDoc} */ - public Class getSupportedImageClass() { - return ImageRendered.class; + public Class[] getSupportedImageClasses() { + return CLASSES; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java index d111e733f..069fef172 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java @@ -24,14 +24,12 @@ import java.awt.Rectangle; import java.io.IOException; import java.util.Map; -import org.w3c.dom.Document; - +import org.apache.fop.pdf.PDFXObject; +import org.apache.fop.render.RendererContext; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; - -import org.apache.fop.pdf.PDFXObject; -import org.apache.fop.render.RendererContext; +import org.w3c.dom.Document; /** * PDFImageHandler implementation which handles XML-based images. @@ -42,6 +40,10 @@ public class PDFImageHandlerXML implements PDFImageHandler { ImageFlavor.XML_DOM, }; + private static final Class[] CLASSES = new Class[] { + ImageXMLDOM.class, + }; + /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -62,8 +64,8 @@ public class PDFImageHandlerXML implements PDFImageHandler { } /** {@inheritDoc} */ - public Class getSupportedImageClass() { - return ImageXMLDOM.class; + public Class[] getSupportedImageClasses() { + return CLASSES; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 0eba2fe91..ba3d89195 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -1658,7 +1658,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { info, imageHandlerRegistry.getSupportedFlavors(), hints, sessionContext); //First check for a dynamically registered handler - PDFImageHandler handler = imageHandlerRegistry.getHandler(img.getClass()); + PDFImageHandler handler + = (PDFImageHandler)imageHandlerRegistry.getHandler(img.getClass()); if (handler != null) { if (log.isDebugEnabled()) { log.debug("Using PDFImageHandler: " + handler.getClass().getName()); diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java index 7c525dbf7..a318c6465 100644 --- a/src/java/org/apache/fop/render/ps/PSTextPainter.java +++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java @@ -19,40 +19,34 @@ package org.apache.fop.render.ps; +import java.awt.Color; import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.font.TextAttribute; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; -/* java.awt.Font is not imported to avoid confusion with - org.apache.fop.fonts.Font */ - +import java.io.IOException; import java.text.AttributedCharacterIterator; import java.text.CharacterIterator; -import java.awt.font.TextAttribute; -import java.awt.Shape; -import java.awt.Paint; -import java.awt.Stroke; -import java.awt.Color; -import java.io.IOException; -import java.util.List; import java.util.Iterator; +import java.util.List; +import org.apache.batik.dom.svg.SVGOMTextElement; +import org.apache.batik.gvt.TextNode; +import org.apache.batik.gvt.TextPainter; +import org.apache.batik.gvt.font.GVTFontFamily; +import org.apache.batik.gvt.renderer.StrokingTextPainter; +import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; +import org.apache.batik.gvt.text.Mark; +import org.apache.batik.gvt.text.TextPaintInfo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; - import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; -import org.apache.xmlgraphics.java2d.TextHandler; - -import org.apache.batik.dom.svg.SVGOMTextElement; -import org.apache.batik.gvt.text.Mark; -import org.apache.batik.gvt.TextPainter; -import org.apache.batik.gvt.TextNode; -import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; -import org.apache.batik.gvt.text.TextPaintInfo; -import org.apache.batik.gvt.font.GVTFontFamily; -import org.apache.batik.gvt.renderer.StrokingTextPainter; /** @@ -74,8 +68,8 @@ public class PSTextPainter implements TextPainter { /** the logger for this class */ protected Log log = LogFactory.getLog(PSTextPainter.class); - private NativeTextHandler nativeTextHandler; - private FontInfo fontInfo; + private final NativeTextHandler nativeTextHandler; + private final FontInfo fontInfo; /** * Use the stroking text painter to get the bounds and shape. @@ -317,7 +311,7 @@ public class PSTextPainter implements TextPainter { } drawPrimitiveString(g2d, loc, font, txt, tx); - loc.setLocation(loc.getX() + (double)advance, loc.getY()); + loc.setLocation(loc.getX() + advance, loc.getY()); return loc; } @@ -422,7 +416,7 @@ public class PSTextPainter implements TextPainter { fStyle |= java.awt.Font.ITALIC; } return new java.awt.Font(font.getFontName(), fStyle, - (int)(font.getFontSize() / 1000)); + (font.getFontSize() / 1000)); } private float getStringWidth(String str, Font font) { diff --git a/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java b/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java new file mode 100644 index 000000000..be1c3c122 --- /dev/null +++ b/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java @@ -0,0 +1,139 @@ +/* + * 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.geom.AffineTransform; +import java.lang.reflect.Constructor; + +import org.apache.batik.bridge.Bridge; +import org.apache.batik.bridge.BridgeContext; +import org.apache.batik.bridge.DocumentLoader; +import org.apache.batik.bridge.UserAgent; +import org.apache.fop.fonts.FontInfo; +import org.apache.xmlgraphics.image.loader.ImageManager; +import org.apache.xmlgraphics.image.loader.ImageSessionContext; + +public abstract class AbstractFOPBridgeContext extends BridgeContext { + + /** The font list. */ + protected final FontInfo fontInfo; + + protected final ImageManager imageManager; + protected final ImageSessionContext imageSessionContext; + + protected final AffineTransform linkTransform; + + /** + * Constructs a new bridge context. + * @param userAgent the user agent + * @param loader the Document Loader to use for referenced documents. + * @param fontInfo the font list for the text painter, may be null + * in which case text is painted as shapes + * @param linkTransform AffineTransform to properly place links, + * may be null + * @param imageManager an image manager + * @param imageSessionContext an image session context + * @param linkTransform AffineTransform to properly place links, + * may be null + */ + public AbstractFOPBridgeContext(UserAgent userAgent, + DocumentLoader loader, + FontInfo fontInfo, + ImageManager imageManager, + ImageSessionContext imageSessionContext, + AffineTransform linkTransform) { + super(userAgent, loader); + this.fontInfo = fontInfo; + this.imageManager = imageManager; + this.imageSessionContext = imageSessionContext; + this.linkTransform = linkTransform; + } + + /** + * Constructs a new bridge context. + * @param userAgent the user agent + * @param fontInfo the font list for the text painter, may be null + * in which case text is painted as shapes + * @param imageManager an image manager + * @param imageSessionContext an image session context + * @param linkTransform AffineTransform to properly place links, + * may be null + */ + public AbstractFOPBridgeContext(UserAgent userAgent, + FontInfo fontInfo, + ImageManager imageManager, + ImageSessionContext imageSessionContext, + AffineTransform linkTransform) { + super(userAgent); + this.fontInfo = fontInfo; + this.imageManager = imageManager; + this.imageSessionContext = imageSessionContext; + this.linkTransform = linkTransform; + } + + /** + * Constructs a new bridge context. + * @param userAgent the user agent + * @param fontInfo the font list for the text painter, may be null + * in which case text is painted as shapes + * @param imageManager an image manager + * @param imageSessionContext an image session context + */ + public AbstractFOPBridgeContext(UserAgent userAgent, + FontInfo fontInfo, + ImageManager imageManager, + ImageSessionContext imageSessionContext) { + this(userAgent, fontInfo, imageManager, imageSessionContext, null); + } + + /** + * Returns the ImageManager to be used by the ImageElementBridge. + * @return the image manager + */ + public ImageManager getImageManager() { + return this.imageManager; + } + + /** + * Returns the ImageSessionContext to be used by the ImageElementBridge. + * @return the image session context + */ + public ImageSessionContext getImageSessionContext() { + return this.imageSessionContext; + } + + protected void putElementBridgeConditional(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})); + } catch (Throwable t) { + //simply ignore (bridges instantiated over this method are optional) + } + } + + // Make sure any 'sub bridge contexts' also have our bridges. + //TODO There's no matching method in the super-class here + public abstract BridgeContext createBridgeContext(); + +} diff --git a/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java b/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java new file mode 100644 index 000000000..31895cebe --- /dev/null +++ b/src/java/org/apache/fop/svg/AbstractFOPImageElementBridge.java @@ -0,0 +1,284 @@ +/* + * 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.Graphics2D; +import java.awt.Shape; +import java.awt.geom.Rectangle2D; + +import org.apache.batik.bridge.BridgeContext; +import org.apache.batik.bridge.SVGImageElementBridge; +import org.apache.batik.gvt.AbstractGraphicsNode; +import org.apache.batik.gvt.GraphicsNode; +import org.apache.batik.util.ParsedURL; +import org.apache.xmlgraphics.image.loader.Image; +import org.apache.xmlgraphics.image.loader.ImageException; +import org.apache.xmlgraphics.image.loader.ImageFlavor; +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.image.loader.impl.ImageGraphics2D; +import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; +import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; +import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; +import org.w3c.dom.Element; +import org.w3c.dom.svg.SVGDocument; + +/** + * Bridge class for the <image> element when jpeg images. + * + * @author Keiron Liddle + */ +public abstract class AbstractFOPImageElementBridge extends SVGImageElementBridge { + + /** + * Constructs a new bridge for the <image> element. + */ + public AbstractFOPImageElementBridge() { } + + /** + * Create the raster image node. + * THis checks if it is a jpeg file and creates a jpeg node + * so the jpeg can be inserted directly into the pdf document. + * @param ctx the bridge context + * @param imageElement the svg element for the image + * @param purl the parsed url for the image resource + * @return a new graphics node + */ + protected GraphicsNode createImageGraphicsNode + (BridgeContext ctx, Element imageElement, ParsedURL purl) { + AbstractFOPBridgeContext bridgeCtx = (AbstractFOPBridgeContext)ctx; + + ImageManager manager = bridgeCtx.getImageManager(); + ImageSessionContext sessionContext = bridgeCtx.getImageSessionContext(); + try { + ImageInfo info = manager.getImageInfo(purl.toString(), sessionContext); + ImageFlavor[] supportedFlavors = getSupportedFlavours(); + Image image = manager.getImage(info, supportedFlavors, sessionContext); + + //TODO color profile overrides aren't handled, yet! + //ICCColorSpaceExt colorspaceOverride = extractColorSpace(e, ctx); + AbstractGraphicsNode specializedNode = null; + if (image instanceof ImageXMLDOM) { + ImageXMLDOM xmlImage = (ImageXMLDOM)image; + if (xmlImage.getDocument() instanceof SVGDocument) { + return createSVGImageNode(ctx, imageElement, + (SVGDocument)xmlImage.getDocument()); + } else { + //Convert image to Graphics2D + image = manager.convertImage(xmlImage, + new ImageFlavor[] {ImageFlavor.GRAPHICS2D}); + } + } + if (image instanceof ImageRawJPEG) { + specializedNode = createLoaderImageNode(image, ctx, imageElement, purl); + } else if (image instanceof ImageRawCCITTFax) { + specializedNode = createLoaderImageNode(image, ctx, imageElement, purl); + } else if (image instanceof ImageGraphics2D) { + ImageGraphics2D g2dImage = (ImageGraphics2D)image; + specializedNode = new Graphics2DNode(g2dImage); + } else { + 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]; + vb[0] = 0; // x + vb[1] = 0; // y + vb[2] = (float) bounds.getWidth(); // width + vb[3] = (float) bounds.getHeight(); // height + + // 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); + } + + /** + * Calls the superclass' createImageGraphicNode() method to create the normal GraphicsNode. + * @param ctx the bridge context + * @param imageElement the image element + * @param purl the parsed URL + * @return the newly created graphics node + * @see org.apache.batik.bridge.SVGImageElementBridge#createGraphicsNode(BridgeContext, Element) + */ + protected GraphicsNode superCreateGraphicsNode + (BridgeContext ctx, Element imageElement, ParsedURL purl) { + return super.createImageGraphicsNode(ctx, imageElement, purl); + } + + /** + * Returns an array of supported image flavours + * + * @return an array of supported image flavours + */ + protected abstract ImageFlavor[] getSupportedFlavours(); + + /** + * Creates a loader image node implementation + * @param purl the parsed url + * @param imageElement the image element + * @param ctx the batik bridge context + * @param image the image + * + * @return a loader image node implementation + */ + protected LoaderImageNode createLoaderImageNode( + Image image, BridgeContext ctx, Element imageElement, ParsedURL purl) { + return new LoaderImageNode(image, ctx, imageElement, purl); + } + + /** + * An image node for natively handled Image instance. + * This holds a natively handled image so that it can be drawn into + * the PDFGraphics2D. + */ + public class LoaderImageNode extends AbstractGraphicsNode { + + protected final Image image; + protected final BridgeContext ctx; + protected final Element imageElement; + protected final ParsedURL purl; + protected GraphicsNode origGraphicsNode = null; + + /** + * Create a new image node for drawing natively handled images + * into PDF graphics. + * @param image the JPEG image + * @param ctx the bridge context + * @param imageElement the SVG image element + * @param purl the URL to the image + */ + public LoaderImageNode(Image image, BridgeContext ctx, + Element imageElement, ParsedURL purl) { + this.image = image; + this.ctx = ctx; + this.imageElement = imageElement; + this.purl = purl; + } + + /** {@inheritDoc} */ + public Shape getOutline() { + return getPrimitiveBounds(); + } + + /** {@inheritDoc} */ + public void primitivePaint(Graphics2D g2d) { + if (g2d instanceof NativeImageHandler) { + NativeImageHandler nativeImageHandler = (NativeImageHandler) g2d; + float x = 0; + float y = 0; + try { + float width = image.getSize().getWidthPx(); + float height = image.getSize().getHeightPx(); + nativeImageHandler.addNativeImage(image, x, y, width, height); + } catch (Exception e) { + ctx.getUserAgent().displayError(e); + } + } else { + // Not going directly into PDF so use + // original implementation so filters etc work. + if (origGraphicsNode == null) { + // Haven't constructed base class Graphics Node, + // so do so now. + origGraphicsNode + = superCreateGraphicsNode(ctx, imageElement, purl); + } + origGraphicsNode.primitivePaint(g2d); + } + } + + /** {@inheritDoc} */ + public Rectangle2D getGeometryBounds() { + return getPrimitiveBounds(); + } + + /** {@inheritDoc} */ + public Rectangle2D getPrimitiveBounds() { + return new Rectangle2D.Double(0, 0, + image.getSize().getWidthPx(), + image.getSize().getHeightPx()); + } + + /** {@inheritDoc} */ + public Rectangle2D getSensitiveBounds() { + //No interactive features, just return primitive bounds + return getPrimitiveBounds(); + } + + } + + /** + * A node that holds a Graphics2D image. + */ + public class Graphics2DNode extends AbstractGraphicsNode { + + private final ImageGraphics2D image; + + /** + * Create a new Graphics2D node. + * @param g2d the Graphics2D image + */ + public Graphics2DNode(ImageGraphics2D g2d) { + this.image = g2d; + } + + /** {@inheritDoc} */ + public Shape getOutline() { + return getPrimitiveBounds(); + } + + /** {@inheritDoc} */ + public void primitivePaint(Graphics2D g2d) { + int width = image.getSize().getWidthPx(); + int height = image.getSize().getHeightPx(); + Rectangle2D area = new Rectangle2D.Double(0, 0, width, height); + Graphics2DImagePainter painter = image.getGraphics2DImagePainter(); + painter.paint(g2d, area); + } + + /** {@inheritDoc} */ + public Rectangle2D getGeometryBounds() { + return getPrimitiveBounds(); + } + + /** {@inheritDoc} */ + public Rectangle2D getPrimitiveBounds() { + return new Rectangle2D.Double(0, 0, + image.getSize().getWidthPx(), + image.getSize().getHeightPx()); + } + + /** {@inheritDoc} */ + public Rectangle2D getSensitiveBounds() { + //No interactive features, just return primitive bounds + return getPrimitiveBounds(); + } + + } +} diff --git a/src/java/org/apache/fop/svg/AbstractFOPTextElementBridge.java b/src/java/org/apache/fop/svg/AbstractFOPTextElementBridge.java new file mode 100644 index 000000000..53b8e2ad5 --- /dev/null +++ b/src/java/org/apache/fop/svg/AbstractFOPTextElementBridge.java @@ -0,0 +1,113 @@ +/* + * 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.batik.bridge.BridgeContext; +import org.apache.batik.bridge.SVGTextElementBridge; +import org.apache.batik.gvt.GraphicsNode; +import org.apache.batik.gvt.TextNode; +import org.apache.batik.gvt.TextPainter; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * Bridge class for the <text> element. + * This bridge will use the direct text painter if the text + * for the element is simple. + * + * @author Keiron Liddle + */ +public abstract class AbstractFOPTextElementBridge extends SVGTextElementBridge { + + /** text painter */ + protected TextPainter textPainter; + + /** + * Main constructor + * + * @param textPainter the text painter + */ + public AbstractFOPTextElementBridge(TextPainter textPainter) { + this.textPainter = textPainter; + } + + /** + * Create a text element bridge. + * + * This set the text painter on the node if the text is simple. + * @param ctx the bridge context + * @param e the svg element + * @return the text graphics node created by the super class + */ + public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { + GraphicsNode node = super.createGraphicsNode(ctx, e); + if (node != null) { + //Set our own text painter + ((TextNode)node).setTextPainter(textPainter); + } + return node; + } + + /** + * Check if text element contains simple text. + * This checks the children of the text element to determine + * if the text is simple. The text is simple if it can be rendered + * with basic text drawing algorithms. This means there are no + * alternate characters, the font is known and there are no effects + * applied to the text. + * + * @param ctx the bridge context + * @param element the svg text element + * @param node the graphics node + * @return true if this text is simple of false if it cannot be + * easily rendered using normal drawString on the Graphics2D + */ + protected boolean isSimple(BridgeContext ctx, Element element, GraphicsNode node) { + for (Node n = element.getFirstChild(); + n != null; + n = n.getNextSibling()) { + + switch (n.getNodeType()) { + case Node.ELEMENT_NODE: + + if (n.getLocalName().equals(SVG_TSPAN_TAG) + || n.getLocalName().equals(SVG_ALT_GLYPH_TAG)) { + return false; + } else if (n.getLocalName().equals(SVG_TEXT_PATH_TAG)) { + return false; + } else if (n.getLocalName().equals(SVG_TREF_TAG)) { + return false; + } + break; + case Node.TEXT_NODE: + case Node.CDATA_SECTION_NODE: + default: + } + } + + /*if (CSSUtilities.convertFilter(element, node, ctx) != null) { + return false; + }*/ + + return true; + } + +} + diff --git a/src/java/org/apache/fop/svg/NativeImageHandler.java b/src/java/org/apache/fop/svg/NativeImageHandler.java new file mode 100644 index 000000000..8e74cba1d --- /dev/null +++ b/src/java/org/apache/fop/svg/NativeImageHandler.java @@ -0,0 +1,40 @@ +/* + * 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; + +public interface NativeImageHandler { + + /** + * Add a natively handled image directly to the document. + * This is used by the ImageElementBridge to draw a natively handled image + * (like JPEG or CCITT images) + * directly into the document rather than converting the image into + * a bitmap and increasing the size. + * + * @param image the image to draw + * @param x the x position + * @param y the y position + * @param width the width to draw the image + * @param height the height to draw the image + */ + void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y, + float width, float height); + +} diff --git a/src/java/org/apache/fop/svg/PDFBridgeContext.java b/src/java/org/apache/fop/svg/PDFBridgeContext.java index 6aa29cfa1..364c7a6f3 100644 --- a/src/java/org/apache/fop/svg/PDFBridgeContext.java +++ b/src/java/org/apache/fop/svg/PDFBridgeContext.java @@ -20,30 +20,20 @@ package org.apache.fop.svg; import java.awt.geom.AffineTransform; -import java.lang.reflect.Constructor; -import org.apache.batik.bridge.Bridge; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.DocumentLoader; +import org.apache.batik.bridge.SVGTextElementBridge; import org.apache.batik.bridge.UserAgent; +import org.apache.batik.gvt.TextPainter; import org.apache.fop.fonts.FontInfo; - import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; - /** * BridgeContext which registers the custom bridges for PDF output. */ -public class PDFBridgeContext extends BridgeContext { - - /** The font list. */ - private final FontInfo fontInfo; - - private final ImageManager imageManager; - private final ImageSessionContext imageSessionContext; - - private AffineTransform linkTransform; +public class PDFBridgeContext extends AbstractFOPBridgeContext { /** * Constructs a new bridge context. @@ -53,18 +43,16 @@ public class PDFBridgeContext extends BridgeContext { * in which case text is painted as shapes * @param linkTransform AffineTransform to properly place links, * may be null + * @param imageManager an image manager + * @param imageSessionContext an image session context + * @param linkTransform AffineTransform to properly place links, + * may be null */ - public PDFBridgeContext(UserAgent userAgent, - DocumentLoader loader, - FontInfo fontInfo, - ImageManager imageManager, - ImageSessionContext imageSessionContext, - AffineTransform linkTransform) { - super(userAgent, loader); - this.fontInfo = fontInfo; - this.imageManager = imageManager; - this.imageSessionContext = imageSessionContext; - this.linkTransform = linkTransform; + public PDFBridgeContext(UserAgent userAgent, DocumentLoader documentLoader, + FontInfo fontInfo, ImageManager imageManager, + ImageSessionContext imageSessionContext, + AffineTransform linkTransform) { + super(userAgent, documentLoader, fontInfo, imageManager, imageSessionContext, linkTransform); } /** @@ -72,19 +60,12 @@ public class PDFBridgeContext extends BridgeContext { * @param userAgent the user agent * @param fontInfo the font list for the text painter, may be null * in which case text is painted as shapes - * @param linkTransform AffineTransform to properly place links, - * may be null + * @param imageManager an image manager + * @param imageSessionContext an image session context */ - public PDFBridgeContext(UserAgent userAgent, - FontInfo fontInfo, - ImageManager imageManager, - ImageSessionContext imageSessionContext, - AffineTransform linkTransform) { - super(userAgent); - this.fontInfo = fontInfo; - this.imageManager = imageManager; - this.imageSessionContext = imageSessionContext; - this.linkTransform = linkTransform; + public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo, + ImageManager imageManager, ImageSessionContext imageSessionContext) { + super(userAgent, fontInfo, imageManager, imageSessionContext); } /** @@ -92,41 +73,15 @@ public class PDFBridgeContext extends BridgeContext { * @param userAgent the user agent * @param fontInfo the font list for the text painter, may be null * in which case text is painted as shapes + * @param imageManager an image manager + * @param imageSessionContext an image session context + * @param linkTransform AffineTransform to properly place links, + * may be null */ - public PDFBridgeContext(UserAgent userAgent, - FontInfo fontInfo, - ImageManager imageManager, - ImageSessionContext imageSessionContext) { - this(userAgent, fontInfo, imageManager, imageSessionContext, null); - } - - /** - * Returns the ImageManager to be used by the ImageElementBridge. - * @return the image manager - */ - public ImageManager getImageManager() { - return this.imageManager; - } - - /** - * Returns the ImageSessionContext to be used by the ImageElementBridge. - * @return the image session context - */ - 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})); - } catch (Throwable t) { - //simply ignore (bridges instantiated over this method are optional) - } + public PDFBridgeContext(SVGUserAgent userAgent, FontInfo fontInfo, + ImageManager imageManager, ImageSessionContext imageSessionContext, + AffineTransform linkTransform) { + super(userAgent, fontInfo, imageManager, imageSessionContext, linkTransform); } /** {@inheritDoc} */ @@ -134,23 +89,24 @@ public class PDFBridgeContext extends BridgeContext { super.registerSVGBridges(); if (fontInfo != null) { - PDFTextElementBridge textElementBridge = new PDFTextElementBridge(fontInfo); + TextPainter textPainter = new PDFTextPainter(fontInfo); + SVGTextElementBridge textElementBridge = new PDFTextElementBridge(textPainter); putBridge(textElementBridge); //Batik flow text extension (may not always be available) //putBridge(new PDFBatikFlowTextElementBridge(fontInfo); - putPDFElementBridgeConditional( + putElementBridgeConditional( "org.apache.fop.svg.PDFBatikFlowTextElementBridge", "org.apache.batik.extension.svg.BatikFlowTextElementBridge"); //SVG 1.2 flow text support //putBridge(new PDFSVG12TextElementBridge(fontInfo)); //-->Batik 1.7 - putPDFElementBridgeConditional( + putElementBridgeConditional( "org.apache.fop.svg.PDFSVG12TextElementBridge", "org.apache.batik.bridge.svg12.SVG12TextElementBridge"); //putBridge(new PDFSVGFlowRootElementBridge(fontInfo)); - putPDFElementBridgeConditional( + putElementBridgeConditional( "org.apache.fop.svg.PDFSVGFlowRootElementBridge", "org.apache.batik.bridge.svg12.SVGFlowRootElementBridge"); } diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index cafb5f4d3..f8a0bd415 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -100,7 +100,7 @@ import org.apache.xmlgraphics.java2d.GraphicContext; * @version $Id$ * @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D */ -public class PDFGraphics2D extends AbstractGraphics2D { +public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHandler { private static final AffineTransform IDENTITY_TRANSFORM = new AffineTransform(); @@ -414,7 +414,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { * @param width the width to draw the image * @param height the height to draw the image */ - void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y, + public void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y, float width, float height) { preparePainting(); String key = image.getInfo().getOriginalURI(); @@ -521,7 +521,8 @@ public class PDFGraphics2D extends AbstractGraphics2D { g.clip(new Rectangle(0, 0, imageWidth, imageHeight)); g.setComposite(gc.getComposite()); - if (!g.drawImage(img, 0, 0, imageWidth, imageHeight, observer)) { + boolean drawn = g.drawImage(img, 0, 0, imageWidth, imageHeight, observer); + if (!drawn) { return false; } g.dispose(); diff --git a/src/java/org/apache/fop/svg/PDFImageElementBridge.java b/src/java/org/apache/fop/svg/PDFImageElementBridge.java index 7eb89d2b1..1a17aa410 100644 --- a/src/java/org/apache/fop/svg/PDFImageElementBridge.java +++ b/src/java/org/apache/fop/svg/PDFImageElementBridge.java @@ -19,36 +19,14 @@ package org.apache.fop.svg; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.geom.Rectangle2D; - -import org.w3c.dom.Element; -import org.w3c.dom.svg.SVGDocument; - -import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.bridge.SVGImageElementBridge; -import org.apache.batik.gvt.AbstractGraphicsNode; -import org.apache.batik.gvt.GraphicsNode; -import org.apache.batik.util.ParsedURL; - -import org.apache.xmlgraphics.image.loader.Image; -import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; -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.image.loader.impl.ImageGraphics2D; -import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; -import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; -import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; /** - * Bridge class for the <image> element when jpeg images. + * PDF Image Element Bridge class for the <image> element when jpeg images. * * @author Keiron Liddle */ -public class PDFImageElementBridge extends SVGImageElementBridge { +public class PDFImageElementBridge extends AbstractFOPImageElementBridge { /** * Constructs a new bridge for the <image> element. @@ -60,210 +38,9 @@ public class PDFImageElementBridge extends SVGImageElementBridge { ImageFlavor.RAW_CCITTFAX, ImageFlavor.GRAPHICS2D, ImageFlavor.XML_DOM}; - /** - * Create the raster image node. - * THis checks if it is a jpeg file and creates a jpeg node - * so the jpeg can be inserted directly into the pdf document. - * @param ctx the bridge context - * @param imageElement the svg element for the image - * @param purl the parsed url for the image resource - * @return a new graphics node - */ - 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; - if (image instanceof ImageXMLDOM) { - ImageXMLDOM xmlImage = (ImageXMLDOM)image; - if (xmlImage.getDocument() instanceof SVGDocument) { - return createSVGImageNode(ctx, imageElement, - (SVGDocument)xmlImage.getDocument()); - } else { - //Convert image to Graphics2D - image = manager.convertImage(xmlImage, - new ImageFlavor[] {ImageFlavor.GRAPHICS2D}); - } - } - if (image instanceof ImageRawJPEG) { - specializedNode = new LoaderImageNode(image, ctx, imageElement, purl); - } else if (image instanceof ImageRawCCITTFax) { - specializedNode = new LoaderImageNode(image, ctx, imageElement, purl); - } else if (image instanceof ImageGraphics2D) { - ImageGraphics2D g2dImage = (ImageGraphics2D)image; - specializedNode = new Graphics2DNode(g2dImage); - } else { - 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]; - vb[0] = 0; // x - vb[1] = 0; // y - vb[2] = (float) bounds.getWidth(); // width - vb[3] = (float) bounds.getHeight(); // height - - // 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); - } - - /** - * Calls the superclass' createImageGraphicNode() method to create the normal GraphicsNode. - * @param ctx the bridge context - * @param imageElement the image element - * @param purl the parsed URL - * @return the newly created graphics node - * @see org.apache.batik.bridge.SVGImageElementBridge#createGraphicsNode(BridgeContext, Element) - */ - protected GraphicsNode superCreateGraphicsNode - (BridgeContext ctx, Element imageElement, ParsedURL purl) { - return super.createImageGraphicsNode(ctx, imageElement, purl); - } - - - /** - * An image node for natively handled Image instance. - * This holds a natively handled image so that it can be drawn into - * 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. - * @param image the JPEG image - * @param ctx the bridge context - * @param imageElement the SVG image element - * @param purl the URL to the image - */ - public LoaderImageNode(Image image, BridgeContext ctx, - Element imageElement, ParsedURL purl) { - this.image = image; - this.ctx = ctx; - this.imageElement = imageElement; - this.purl = purl; - } - - /** {@inheritDoc} */ - public Shape getOutline() { - return getPrimitiveBounds(); - } - - /** {@inheritDoc} */ - public void primitivePaint(Graphics2D g2d) { - if (g2d instanceof PDFGraphics2D) { - PDFGraphics2D pdfg = (PDFGraphics2D) g2d; - float x = 0; - float y = 0; - try { - float width = image.getSize().getWidthPx(); - float height = image.getSize().getHeightPx(); - pdfg.addNativeImage(image, x, y, width, height); - } catch (Exception e) { - ctx.getUserAgent().displayError(e); - } - } else { - // Not going directly into PDF so use - // original implementation so filters etc work. - if (origGraphicsNode == null) { - // Haven't constructed baseclass Graphics Node, - // so do so now. - origGraphicsNode - = PDFImageElementBridge.this.superCreateGraphicsNode - (ctx, imageElement, purl); - } - origGraphicsNode.primitivePaint(g2d); - } - } - - /** {@inheritDoc} */ - public Rectangle2D getGeometryBounds() { - return getPrimitiveBounds(); - } - - /** {@inheritDoc} */ - public Rectangle2D getPrimitiveBounds() { - return new Rectangle2D.Double(0, 0, - image.getSize().getWidthPx(), - image.getSize().getHeightPx()); - } - - /** {@inheritDoc} */ - public Rectangle2D getSensitiveBounds() { - //No interactive features, just return primitive bounds - return getPrimitiveBounds(); - } - - } - - /** - * 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 - */ - public Graphics2DNode(ImageGraphics2D g2d) { - this.image = g2d; - } - - /** {@inheritDoc} */ - public Shape getOutline() { - return getPrimitiveBounds(); - } - - /** {@inheritDoc} */ - public void primitivePaint(Graphics2D g2d) { - int width = image.getSize().getWidthPx(); - int height = image.getSize().getHeightPx(); - Rectangle2D area = new Rectangle2D.Double(0, 0, width, height); - image.getGraphics2DImagePainter().paint(g2d, area); - } - - /** {@inheritDoc} */ - public Rectangle2D getGeometryBounds() { - return getPrimitiveBounds(); - } - - /** {@inheritDoc} */ - public Rectangle2D getPrimitiveBounds() { - return new Rectangle2D.Double(0, 0, - image.getSize().getWidthPx(), - image.getSize().getHeightPx()); - } - - /** {@inheritDoc} */ - public Rectangle2D getSensitiveBounds() { - //No interactive features, just return primitive bounds - return getPrimitiveBounds(); - } + /** {@inheritDoc} */ + protected ImageFlavor[] getSupportedFlavours() { + return supportedFlavors; } } diff --git a/src/java/org/apache/fop/svg/PDFTextElementBridge.java b/src/java/org/apache/fop/svg/PDFTextElementBridge.java index 4c11aa97e..c983d2b45 100644 --- a/src/java/org/apache/fop/svg/PDFTextElementBridge.java +++ b/src/java/org/apache/fop/svg/PDFTextElementBridge.java @@ -19,13 +19,7 @@ package org.apache.fop.svg; -import org.apache.batik.bridge.BridgeContext; -import org.apache.batik.bridge.SVGTextElementBridge; -import org.apache.batik.gvt.GraphicsNode; -import org.apache.batik.gvt.TextNode; import org.apache.batik.gvt.TextPainter; -import org.apache.fop.fonts.FontInfo; -import org.w3c.dom.Element; /** * Bridge class for the <text> element. @@ -34,41 +28,15 @@ import org.w3c.dom.Element; * * @author Keiron Liddle */ -public class PDFTextElementBridge extends SVGTextElementBridge { - - private PDFTextPainter pdfTextPainter; +public class PDFTextElementBridge extends AbstractFOPTextElementBridge { /** * Constructs a new bridge for the <text> element. - * @param fi the font information - */ - public PDFTextElementBridge(FontInfo fi) { - pdfTextPainter = new PDFTextPainter(fi); - } - - /** - * Create a text element bridge. - * This set the text painter on the node if the text is simple. - * @param ctx the bridge context - * @param e the svg element - * @return the text graphics node created by the super class + * + * @param textPainter the text painter to use */ - public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { - GraphicsNode node = super.createGraphicsNode(ctx, e); - if (node != null) { - //Set our own text painter - ((TextNode)node).setTextPainter(getTextPainter()); - } - return node; + public PDFTextElementBridge(TextPainter textPainter) { + super(textPainter); } - - /** - * Returns the TextPainter instance used by this bridge. - * @return the text painter - */ - public TextPainter getTextPainter() { - return pdfTextPainter; - } - } diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java index 06fea54cc..8a0feb3a2 100644 --- a/src/java/org/apache/fop/svg/PDFTextPainter.java +++ b/src/java/org/apache/fop/svg/PDFTextPainter.java @@ -43,7 +43,6 @@ import org.apache.batik.gvt.renderer.StrokingTextPainter; import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; import org.apache.batik.gvt.text.TextPaintInfo; import org.apache.batik.gvt.text.TextSpanLayout; - import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; @@ -63,8 +62,8 @@ public class PDFTextPainter extends StrokingTextPainter { private static final boolean DEBUG = false; - private boolean strokeText = false; - private FontInfo fontInfo; + private final boolean strokeText = false; + private final FontInfo fontInfo; /** * Create a new PDF text painter with the given font information. @@ -280,7 +279,7 @@ public class PDFTextPainter extends StrokingTextPainter { Float fontSize = (Float) aci.getAttribute(TextAttribute.SIZE); String style = ((posture != null) && (posture.floatValue() > 0.0)) - ? "italic" : "normal"; + ? Font.STYLE_ITALIC : Font.STYLE_NORMAL; int weight = ((taWeight != null) && (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL; -- cgit v1.2.3 From 8a08b69ee6049677c1578a9c0791140caf6a1d6a Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Thu, 20 Nov 2008 16:38:44 +0000 Subject: SetCurrentPosition fix for line drawing. AbstractPaintingState push(), pushAll(), pop(), popAll() renamed to save(), saveAll() and restore(), restoreAll(). Some Javadoc improvements/updates. Added Completable, Startable object writing interfaces. StructuredDataObject interface renamed to StructuredData. High level DataStream class moved from afp.modca to afp package. Graphics*Relative objects removed and feature provided by absolute implementation. GraphicsArea broken into GraphicsAreaBegin and GraphicsAreaEnd since areas are able to span more than one segment. Improvement in SetLineWidth thickness precision. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@719274 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/afp/AFPBorderPainter.java | 19 +- .../org/apache/fop/afp/AFPDataObjectFactory.java | 3 + src/java/org/apache/fop/afp/AFPGraphics2D.java | 156 ++++-- src/java/org/apache/fop/afp/AFPPaintingState.java | 19 +- .../org/apache/fop/afp/AFPRectanglePainter.java | 24 +- .../org/apache/fop/afp/AFPResourceManager.java | 1 - src/java/org/apache/fop/afp/AFPStreamer.java | 1 - src/java/org/apache/fop/afp/AFPUnitConverter.java | 14 +- .../org/apache/fop/afp/AbstractAFPPainter.java | 16 +- src/java/org/apache/fop/afp/BorderPaintInfo.java | 121 ----- .../org/apache/fop/afp/BorderPaintingInfo.java | 121 +++++ src/java/org/apache/fop/afp/Completable.java | 40 ++ src/java/org/apache/fop/afp/DataStream.java | 600 +++++++++++++++++++++ src/java/org/apache/fop/afp/Factory.java | 9 +- src/java/org/apache/fop/afp/PaintInfo.java | 27 - src/java/org/apache/fop/afp/PaintingInfo.java | 27 + .../org/apache/fop/afp/RectanglePaintInfo.java | 84 --- .../org/apache/fop/afp/RectanglePaintingInfo.java | 84 +++ src/java/org/apache/fop/afp/Startable.java | 40 ++ src/java/org/apache/fop/afp/StructuredData.java | 33 ++ .../apache/fop/afp/goca/AbstractGraphicsCoord.java | 59 +- .../fop/afp/goca/AbstractGraphicsDrawingOrder.java | 60 +++ .../AbstractGraphicsDrawingOrderContainer.java | 158 ++++++ .../afp/goca/AbstractGraphicsObjectContainer.java | 83 --- .../fop/afp/goca/AbstractGraphicsString.java | 74 --- src/java/org/apache/fop/afp/goca/GraphicsArea.java | 74 --- .../org/apache/fop/afp/goca/GraphicsAreaBegin.java | 69 +++ .../org/apache/fop/afp/goca/GraphicsAreaEnd.java | 53 ++ .../fop/afp/goca/GraphicsChainedSegment.java | 60 +-- .../fop/afp/goca/GraphicsCharacterString.java | 114 ++++ src/java/org/apache/fop/afp/goca/GraphicsData.java | 89 ++- .../org/apache/fop/afp/goca/GraphicsFillet.java | 11 +- .../fop/afp/goca/GraphicsFilletRelative.java | 42 -- .../org/apache/fop/afp/goca/GraphicsImage.java | 37 +- src/java/org/apache/fop/afp/goca/GraphicsLine.java | 20 +- .../apache/fop/afp/goca/GraphicsLineRelative.java | 42 -- .../fop/afp/goca/GraphicsSetCharacterSet.java | 12 +- .../apache/fop/afp/goca/GraphicsSetLineType.java | 13 +- .../apache/fop/afp/goca/GraphicsSetLineWidth.java | 12 +- .../org/apache/fop/afp/goca/GraphicsSetMix.java | 17 +- .../fop/afp/goca/GraphicsSetPatternSymbol.java | 23 +- .../fop/afp/goca/GraphicsSetProcessColor.java | 6 +- .../org/apache/fop/afp/goca/GraphicsString.java | 64 --- .../fop/afp/goca/GraphicsStringRelative.java | 57 -- .../org/apache/fop/afp/ioca/ImageCellPosition.java | 27 +- src/java/org/apache/fop/afp/ioca/ImageContent.java | 28 +- .../apache/fop/afp/ioca/ImageInputDescriptor.java | 5 +- .../apache/fop/afp/ioca/ImageOutputControl.java | 8 +- .../org/apache/fop/afp/ioca/ImageRasterData.java | 7 +- .../apache/fop/afp/modca/AbstractAFPObject.java | 12 +- .../apache/fop/afp/modca/AbstractDataObject.java | 35 +- .../fop/afp/modca/AbstractNamedAFPObject.java | 13 +- .../apache/fop/afp/modca/AbstractPageObject.java | 24 +- .../afp/modca/AbstractResourceGroupContainer.java | 5 +- .../afp/modca/AbstractTripletStructuredObject.java | 3 + src/java/org/apache/fop/afp/modca/DataStream.java | 593 -------------------- src/java/org/apache/fop/afp/modca/Document.java | 6 +- .../org/apache/fop/afp/modca/GraphicsObject.java | 178 +++--- .../org/apache/fop/afp/modca/MapCodedFont.java | 6 +- .../fop/afp/modca/ObjectEnvironmentGroup.java | 8 +- src/java/org/apache/fop/afp/modca/PageGroup.java | 2 +- .../fop/afp/modca/ResourceEnvironmentGroup.java | 54 +- .../fop/afp/modca/StreamedResourceGroup.java | 24 +- .../apache/fop/afp/modca/StructuredDataObject.java | 33 -- .../fop/afp/modca/triplets/AbstractTriplet.java | 4 +- .../modca/triplets/DescriptorPositionTriplet.java | 3 + .../modca/triplets/ResourceObjectTypeTriplet.java | 2 +- .../org/apache/fop/afp/svg/AFPBridgeContext.java | 3 + .../apache/fop/afp/svg/AFPImageElementBridge.java | 3 + src/java/org/apache/fop/afp/svg/package.html | 23 + src/java/org/apache/fop/afp/util/package.html | 23 + src/java/org/apache/fop/pdf/PDFPaintingState.java | 2 +- .../fop/render/afp/AFPGraphics2DAdapter.java | 4 +- src/java/org/apache/fop/render/afp/AFPInfo.java | 6 +- .../org/apache/fop/render/afp/AFPRenderer.java | 20 +- .../org/apache/fop/render/afp/AFPSVGHandler.java | 4 +- .../org/apache/fop/render/pdf/PDFRenderer.java | 10 +- .../org/apache/fop/render/pdf/PDFSVGHandler.java | 4 +- .../apache/fop/svg/AbstractFOPBridgeContext.java | 3 + src/java/org/apache/fop/svg/PDFGraphics2D.java | 12 +- .../org/apache/fop/util/AbstractPaintingState.java | 29 +- 81 files changed, 2089 insertions(+), 1825 deletions(-) delete mode 100644 src/java/org/apache/fop/afp/BorderPaintInfo.java create mode 100644 src/java/org/apache/fop/afp/BorderPaintingInfo.java create mode 100644 src/java/org/apache/fop/afp/Completable.java create mode 100644 src/java/org/apache/fop/afp/DataStream.java delete mode 100644 src/java/org/apache/fop/afp/PaintInfo.java create mode 100644 src/java/org/apache/fop/afp/PaintingInfo.java delete mode 100644 src/java/org/apache/fop/afp/RectanglePaintInfo.java create mode 100644 src/java/org/apache/fop/afp/RectanglePaintingInfo.java create mode 100644 src/java/org/apache/fop/afp/Startable.java create mode 100644 src/java/org/apache/fop/afp/StructuredData.java create mode 100644 src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java create mode 100644 src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java delete mode 100644 src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java delete mode 100644 src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java delete mode 100644 src/java/org/apache/fop/afp/goca/GraphicsArea.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.java create mode 100644 src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java delete mode 100644 src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java delete mode 100644 src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java delete mode 100644 src/java/org/apache/fop/afp/goca/GraphicsString.java delete mode 100644 src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java delete mode 100644 src/java/org/apache/fop/afp/modca/DataStream.java delete mode 100644 src/java/org/apache/fop/afp/modca/StructuredDataObject.java create mode 100644 src/java/org/apache/fop/afp/svg/package.html create mode 100644 src/java/org/apache/fop/afp/util/package.html (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/afp/AFPBorderPainter.java b/src/java/org/apache/fop/afp/AFPBorderPainter.java index 86960b7ff..4c56c0def 100644 --- a/src/java/org/apache/fop/afp/AFPBorderPainter.java +++ b/src/java/org/apache/fop/afp/AFPBorderPainter.java @@ -21,7 +21,6 @@ package org.apache.fop.afp; import java.awt.geom.AffineTransform; -import org.apache.fop.afp.modca.DataStream; import org.apache.fop.fo.Constants; import org.apache.fop.util.ColorUtil; @@ -33,16 +32,16 @@ public class AFPBorderPainter extends AbstractAFPPainter { /** * Main constructor * - * @param state the AFP painting state converter + * @param paintingState the AFP painting state converter * @param dataStream the AFP datastream */ - public AFPBorderPainter(AFPPaintingState state, DataStream dataStream) { - super(state, dataStream); + public AFPBorderPainter(AFPPaintingState paintingState, DataStream dataStream) { + super(paintingState, dataStream); } /** {@inheritDoc} */ - public void paint(PaintInfo paintInfo) { - BorderPaintInfo borderPaintInfo = (BorderPaintInfo)paintInfo; + public void paint(PaintingInfo paintInfo) { + BorderPaintingInfo borderPaintInfo = (BorderPaintingInfo)paintInfo; float w = borderPaintInfo.getX2() - borderPaintInfo.getX1(); float h = borderPaintInfo.getY2() - borderPaintInfo.getY1(); if ((w < 0) || (h < 0)) { @@ -52,15 +51,15 @@ public class AFPBorderPainter extends AbstractAFPPainter { int pageWidth = dataStream.getCurrentPage().getWidth(); int pageHeight = dataStream.getCurrentPage().getHeight(); - AFPUnitConverter unitConv = state.getUnitConverter(); - AffineTransform at = state.getData().getTransform(); + AFPUnitConverter unitConv = paintingState.getUnitConverter(); + AffineTransform at = paintingState.getData().getTransform(); float x1 = unitConv.pt2units(borderPaintInfo.getX1()); float y1 = unitConv.pt2units(borderPaintInfo.getY1()); float x2 = unitConv.pt2units(borderPaintInfo.getX2()); float y2 = unitConv.pt2units(borderPaintInfo.getY2()); - switch (state.getRotation()) { + switch (paintingState.getRotation()) { case 0: x1 += at.getTranslateX(); y1 += at.getTranslateY(); @@ -89,7 +88,7 @@ public class AFPBorderPainter extends AbstractAFPPainter { AFPLineDataInfo lineDataInfo = new AFPLineDataInfo(); lineDataInfo.setColor(borderPaintInfo.getColor()); - lineDataInfo.setRotation(state.getRotation()); + lineDataInfo.setRotation(paintingState.getRotation()); lineDataInfo.x1 = Math.round(x1); lineDataInfo.y1 = Math.round(y1); if (borderPaintInfo.isHorizontal()) { diff --git a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java index c333f5987..5463a336b 100644 --- a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java +++ b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java @@ -132,8 +132,11 @@ public class AFPDataObjectFactory { Rectangle2D area = graphicsObjectInfo.getArea(); g2d.scale(1, -1); g2d.translate(0, -area.getHeight()); + painter.paint(g2d, area); + graphicsObj.setComplete(true); + // return painted graphics object return graphicsObj; } diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java index 0a8161a3b..e8eebce43 100644 --- a/src/java/org/apache/fop/afp/AFPGraphics2D.java +++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java @@ -28,9 +28,11 @@ import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.Image; +import java.awt.Paint; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; +import java.awt.TexturePaint; import java.awt.geom.AffineTransform; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; @@ -83,6 +85,9 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand private static final int Y2 = 3; + private static final int X3 = 4; + + private static final int Y3 = 5; /** graphics object */ private GraphicsObject graphicsObj = null; @@ -188,7 +193,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand // set line width float lineWidth = basicStroke.getLineWidth(); - getGraphicsObject().setLineWidth(Math.round(lineWidth * 2)); + graphicsObj.setLineWidth(Math.round(lineWidth / 2)); // set line type/style (note: this is an approximation at best!) float[] dashArray = basicStroke.getDashArray(); @@ -219,13 +224,40 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand } } } - getGraphicsObject().setLineType(type); + graphicsObj.setLineType(type); } } else { log.warn("Unsupported Stroke: " + stroke.getClass().getName()); } } + /** + * Apply the java paint to the AFP. + * This takes the java paint sets up the appropriate AFP commands + * for the drawing with that paint. + * Currently this supports the gradients and patterns from batik. + * + * @param paint the paint to convert to AFP + * @param fill true if the paint should be set for filling + * @return true if the paint is handled natively, false if the paint should be rasterized + */ + private boolean applyPaint(Paint paint, boolean fill) { + if (paint instanceof Color) { + return true; + } + log.debug("NYI: applyPaint() " + paint + " fill=" + fill); + if (paint instanceof TexturePaint) { +// TexturePaint texturePaint = (TexturePaint)paint; +// BufferedImage bufferedImage = texturePaint.getImage(); +// AffineTransform at = paintingState.getTransform(); +// int x = (int)Math.round(at.getTranslateX()); +// int y = (int)Math.round(at.getTranslateY()); +// drawImage(bufferedImage, x, y, null); + } + return false; + } + + /** * Handle the Batik drawing event * @@ -239,25 +271,22 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand graphicsObj.newSegment(); } - Color color = getColor(); - if (paintingState.setColor(color)) { - graphicsObj.setColor(color); - } + graphicsObj.setColor(gc.getColor()); - Stroke stroke = getStroke(); - applyStroke(stroke); + applyPaint(gc.getPaint(), fill); if (fill) { graphicsObj.beginArea(); + } else { + applyStroke(gc.getStroke()); } AffineTransform trans = gc.getTransform(); PathIterator iter = shape.getPathIterator(trans); - double[] dstPts = new double[6]; - int[] coords = null; if (shape instanceof Line2D) { + double[] dstPts = new double[6]; iter.currentSegment(dstPts); - coords = new int[4]; + int[] coords = new int[4]; coords[X1] = (int) Math.round(dstPts[X]); coords[Y1] = (int) Math.round(dstPts[Y]); iter.next(); @@ -266,8 +295,9 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand coords[Y2] = (int) Math.round(dstPts[Y]); graphicsObj.addLine(coords); } else if (shape instanceof Rectangle2D) { + double[] dstPts = new double[6]; iter.currentSegment(dstPts); - coords = new int[4]; + int[] coords = new int[4]; coords[X2] = (int) Math.round(dstPts[X]); coords[Y2] = (int) Math.round(dstPts[Y]); iter.next(); @@ -277,6 +307,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand coords[Y1] = (int) Math.round(dstPts[Y]); graphicsObj.addBox(coords); } else if (shape instanceof Ellipse2D) { + double[] dstPts = new double[6]; Ellipse2D elip = (Ellipse2D) shape; double scale = trans.getScaleX(); double radiusWidth = elip.getWidth() / 2; @@ -298,56 +329,73 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand mhr ); } else { - for (int[] openingCoords = new int[2]; !iter.isDone(); iter.next()) { - int type = iter.currentSegment(dstPts); - int numCoords; - if (type == PathIterator.SEG_MOVETO || type == PathIterator.SEG_LINETO) { - numCoords = 2; - } else if (type == PathIterator.SEG_QUADTO) { - numCoords = 4; - } else if (type == PathIterator.SEG_CUBICTO) { - numCoords = 6; - } else { - // close of the graphics segment - if (type == PathIterator.SEG_CLOSE) { - // close segment by drawing to opening position - graphicsObj.addLine(openingCoords, true); - } else { - log.debug("Unrecognised path iterator type: " - + type); - } - continue; - } - coords = new int[numCoords]; - for (int i = 0; i < numCoords; i++) { - coords[i] = (int) Math.round(dstPts[i]); - } - if (type == PathIterator.SEG_MOVETO) { - graphicsObj.setCurrentPosition(coords); - openingCoords[X] = coords[X]; - openingCoords[Y] = coords[Y]; - } else if (type == PathIterator.SEG_LINETO) { - graphicsObj.addLine(coords, true); - } else if (type == PathIterator.SEG_QUADTO - || type == PathIterator.SEG_CUBICTO) { - graphicsObj.addFillet(coords, true); - } - } + processPathIterator(iter); } + if (fill) { graphicsObj.endArea(); } } + /** + * Processes a path iterator generating the necessary painting operations. + * + * @param iter PathIterator to process + */ + private void processPathIterator(PathIterator iter) { + double[] dstPts = new double[6]; + for (int[] openingCoords = new int[2]; !iter.isDone(); iter.next()) { + switch (iter.currentSegment(dstPts)) { + case PathIterator.SEG_LINETO: + graphicsObj.addLine(new int[] { + (int)Math.round(dstPts[X]), + (int)Math.round(dstPts[Y]) + }, true); + break; + case PathIterator.SEG_QUADTO: + graphicsObj.addFillet(new int[] { + (int)Math.round(dstPts[X1]), + (int)Math.round(dstPts[Y1]), + (int)Math.round(dstPts[X2]), + (int)Math.round(dstPts[Y2]) + }, true); + break; + case PathIterator.SEG_CUBICTO: + graphicsObj.addFillet(new int[] { + (int)Math.round(dstPts[X1]), + (int)Math.round(dstPts[Y1]), + (int)Math.round(dstPts[X2]), + (int)Math.round(dstPts[Y2]), + (int)Math.round(dstPts[X3]), + (int)Math.round(dstPts[Y3]) + }, true); + break; + case PathIterator.SEG_MOVETO: + openingCoords = new int[] { + (int)Math.round(dstPts[X]), + (int)Math.round(dstPts[Y]) + }; + graphicsObj.setCurrentPosition(openingCoords); + break; + case PathIterator.SEG_CLOSE: + graphicsObj.addLine(openingCoords, true); + break; + default: + log.debug("Unrecognised path iterator type"); + break; + } + } + } + /** {@inheritDoc} */ public void draw(Shape shape) { -// log.debug("draw() shape=" + shape); + log.debug("draw() shape=" + shape); doDrawing(shape, false); } /** {@inheritDoc} */ public void fill(Shape shape) { -// log.debug("fill() shape=" + shape); + log.debug("fill() shape=" + shape); doDrawing(shape, true); } @@ -381,11 +429,6 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand return graphicsConfig; } - /** {@inheritDoc} */ - public void copyArea(int x, int y, int width, int height, int dx, int dy) { - log.debug("copyArea() NYI: "); - } - /** {@inheritDoc} */ public Graphics create() { return new AFPGraphics2D(this); @@ -643,4 +686,9 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand log.debug("NYI: addNativeImage() "+ "image=" + image + ",x=" + x + ",y=" + y + ",width=" + width + ",height=" + height); } + + /** {@inheritDoc} */ + public void copyArea(int x, int y, int width, int height, int dx, int dy) { + log.debug("copyArea() NYI: "); + } } diff --git a/src/java/org/apache/fop/afp/AFPPaintingState.java b/src/java/org/apache/fop/afp/AFPPaintingState.java index cb78fb36e..bf710b18d 100644 --- a/src/java/org/apache/fop/afp/AFPPaintingState.java +++ b/src/java/org/apache/fop/afp/AFPPaintingState.java @@ -27,7 +27,8 @@ import org.apache.fop.util.AbstractPaintingState; /** * This keeps information about the current painting state when writing to an AFP datastream. */ -public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState implements Cloneable { +public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState +implements Cloneable { private static final long serialVersionUID = 8206711712452344473L; @@ -337,14 +338,14 @@ public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState /** {@inheritDoc} */ public Object clone() { - AFPPaintingState state = (AFPPaintingState)super.clone(); - state.pagePaintingState = (AFPPagePaintingState)this.pagePaintingState.clone(); - state.portraitRotation = this.portraitRotation; - state.landscapeRotation = this.landscapeRotation; - state.bitsPerPixel = this.bitsPerPixel; - state.colorImages = this.colorImages; - state.resolution = this.resolution; - return state; + AFPPaintingState paintingState = (AFPPaintingState)super.clone(); + paintingState.pagePaintingState = (AFPPagePaintingState)this.pagePaintingState.clone(); + paintingState.portraitRotation = this.portraitRotation; + paintingState.landscapeRotation = this.landscapeRotation; + paintingState.bitsPerPixel = this.bitsPerPixel; + paintingState.colorImages = this.colorImages; + paintingState.resolution = this.resolution; + return paintingState; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/afp/AFPRectanglePainter.java b/src/java/org/apache/fop/afp/AFPRectanglePainter.java index 81915a190..e2bad6159 100644 --- a/src/java/org/apache/fop/afp/AFPRectanglePainter.java +++ b/src/java/org/apache/fop/afp/AFPRectanglePainter.java @@ -21,37 +21,39 @@ package org.apache.fop.afp; import java.awt.geom.AffineTransform; -import org.apache.fop.afp.modca.DataStream; +/** + * A painter of rectangles in AFP + */ public class AFPRectanglePainter extends AbstractAFPPainter { /** * Main constructor * - * @param state the AFP painting state - * @param dataStream the afp datastream + * @param paintingState the AFP painting state + * @param dataStream the AFP datastream */ - public AFPRectanglePainter(AFPPaintingState state, DataStream dataStream) { - super(state, dataStream); + public AFPRectanglePainter(AFPPaintingState paintingState, DataStream dataStream) { + super(paintingState, dataStream); } /** {@inheritDoc} */ - public void paint(PaintInfo paintInfo) { - RectanglePaintInfo rectanglePaintInfo = (RectanglePaintInfo)paintInfo; + public void paint(PaintingInfo paintInfo) { + RectanglePaintingInfo rectanglePaintInfo = (RectanglePaintingInfo)paintInfo; int pageWidth = dataStream.getCurrentPage().getWidth(); int pageHeight = dataStream.getCurrentPage().getHeight(); - AFPUnitConverter unitConv = state.getUnitConverter(); + AFPUnitConverter unitConv = paintingState.getUnitConverter(); float width = unitConv.pt2units(rectanglePaintInfo.getWidth()); float height = unitConv.pt2units(rectanglePaintInfo.getHeight()); float x = unitConv.pt2units(rectanglePaintInfo.getX()); float y = unitConv.pt2units(rectanglePaintInfo.getY()); - AffineTransform at = state.getData().getTransform(); + AffineTransform at = paintingState.getData().getTransform(); AFPLineDataInfo lineDataInfo = new AFPLineDataInfo(); - lineDataInfo.color = state.getColor(); - lineDataInfo.rotation = state.getRotation(); + lineDataInfo.color = paintingState.getColor(); + lineDataInfo.rotation = paintingState.getRotation(); lineDataInfo.thickness = Math.round(height); switch (lineDataInfo.rotation) { diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java index 21de78250..ec5890e39 100644 --- a/src/java/org/apache/fop/afp/AFPResourceManager.java +++ b/src/java/org/apache/fop/afp/AFPResourceManager.java @@ -25,7 +25,6 @@ import java.util.Map; import org.apache.fop.afp.modca.AbstractDataObject; import org.apache.fop.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.afp.modca.DataStream; import org.apache.fop.afp.modca.IncludeObject; import org.apache.fop.afp.modca.Registry; import org.apache.fop.afp.modca.ResourceGroup; diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java index 269e6ae08..007259cd4 100644 --- a/src/java/org/apache/fop/afp/AFPStreamer.java +++ b/src/java/org/apache/fop/afp/AFPStreamer.java @@ -31,7 +31,6 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.afp.modca.DataStream; import org.apache.fop.afp.modca.ResourceGroup; import org.apache.fop.afp.modca.StreamedResourceGroup; diff --git a/src/java/org/apache/fop/afp/AFPUnitConverter.java b/src/java/org/apache/fop/afp/AFPUnitConverter.java index c5f37d25f..3195ba70f 100644 --- a/src/java/org/apache/fop/afp/AFPUnitConverter.java +++ b/src/java/org/apache/fop/afp/AFPUnitConverter.java @@ -29,15 +29,15 @@ import java.awt.geom.AffineTransform; public class AFPUnitConverter { /** the AFP state */ - private final AFPPaintingState state; + private final AFPPaintingState paintingState; /** * Unit converter * - * @param state the AFP painting state + * @param paintingState the AFP painting state */ - public AFPUnitConverter(AFPPaintingState state) { - this.state = state; + public AFPUnitConverter(AFPPaintingState paintingState) { + this.paintingState = paintingState; } /** @@ -89,7 +89,7 @@ public class AFPUnitConverter { * @return transformed point */ public float pt2units(float pt) { - return pt / ((float)AFPConstants.DPI_72 / state.getResolution()); + return pt / ((float)AFPConstants.DPI_72 / paintingState.getResolution()); } /** @@ -99,14 +99,14 @@ public class AFPUnitConverter { * @return transformed point */ public float mpt2units(float mpt) { - return mpt / ((float)AFPConstants.DPI_72_MPTS / state.getResolution()); + return mpt / ((float)AFPConstants.DPI_72_MPTS / paintingState.getResolution()); } private int[] transformPoints(float[] srcPts, float[] dstPts, boolean milli) { if (dstPts == null) { dstPts = new float[srcPts.length]; } - AffineTransform at = state.getData().getTransform(); + AffineTransform at = paintingState.getData().getTransform(); at.transform(srcPts, 0, dstPts, 0, srcPts.length / 2); int[] coords = new int[srcPts.length]; for (int i = 0; i < srcPts.length; i++) { diff --git a/src/java/org/apache/fop/afp/AbstractAFPPainter.java b/src/java/org/apache/fop/afp/AbstractAFPPainter.java index 72c6c56e1..576b8bb11 100644 --- a/src/java/org/apache/fop/afp/AbstractAFPPainter.java +++ b/src/java/org/apache/fop/afp/AbstractAFPPainter.java @@ -21,24 +21,26 @@ package org.apache.fop.afp; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.afp.modca.DataStream; +/** + * A base AFP painter + */ public abstract class AbstractAFPPainter { /** Static logging instance */ protected static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); protected final DataStream dataStream; - protected final AFPPaintingState state; + protected final AFPPaintingState paintingState; /** * Main constructor * - * @param state the afp state - * @param dataStream the afp datastream + * @param paintingState the AFP painting state + * @param dataStream the AFP Datastream */ - public AbstractAFPPainter(AFPPaintingState state, DataStream dataStream) { - this.state = state; + public AbstractAFPPainter(AFPPaintingState paintingState, DataStream dataStream) { + this.paintingState = paintingState; this.dataStream = dataStream; } @@ -47,5 +49,5 @@ public abstract class AbstractAFPPainter { * * @param paintInfo the painting information */ - public abstract void paint(PaintInfo paintInfo); + public abstract void paint(PaintingInfo paintInfo); } diff --git a/src/java/org/apache/fop/afp/BorderPaintInfo.java b/src/java/org/apache/fop/afp/BorderPaintInfo.java deleted file mode 100644 index 74252b7b9..000000000 --- a/src/java/org/apache/fop/afp/BorderPaintInfo.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.afp; - -import java.awt.Color; - - -/** - * Border painting information - */ -public class BorderPaintInfo implements PaintInfo { - private final float x1; - private final float y1; - private final float x2; - private final float y2; - private final boolean isHorizontal; - private final int style; - private final Color color; - - /** - * Main constructor - * - * @param x1 the x1 coordinate - * @param y1 the y1 coordinate - * @param x2 the x2 coordinate - * @param y2 the y2 coordinate - * @param isHorizontal true when the border line is horizontal - * @param style the border style - * @param color the border color - */ - public BorderPaintInfo(float x1, float y1, float x2, float y2, - boolean isHorizontal, int style, Color color) { - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - this.isHorizontal = isHorizontal; - this.style = style; - this.color = color; - } - - /** - * Returns the x1 coordinate - * - * @return the x1 coordinate - */ - public float getX1() { - return x1; - } - - /** - * Returns the y1 coordinate - * - * @return the y1 coordinate - */ - public float getY1() { - return y1; - } - - /** - * Returns the x2 coordinate - * - * @return the x2 coordinate - */ - public float getX2() { - return x2; - } - - /** - * Returns the y2 coordinate - * - * @return the y2 coordinate - */ - public float getY2() { - return y2; - } - - /** - * Returns true when this is a horizontal line - * - * @return true when this is a horizontal line - */ - public boolean isHorizontal() { - return isHorizontal; - } - - /** - * Returns the style - * - * @return the style - */ - public int getStyle() { - return style; - } - - /** - * Returns the color - * - * @return the color - */ - public Color getColor() { - return color; - } -} diff --git a/src/java/org/apache/fop/afp/BorderPaintingInfo.java b/src/java/org/apache/fop/afp/BorderPaintingInfo.java new file mode 100644 index 000000000..4917c7bc0 --- /dev/null +++ b/src/java/org/apache/fop/afp/BorderPaintingInfo.java @@ -0,0 +1,121 @@ +/* + * 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.afp; + +import java.awt.Color; + +/** + * Border painting information + */ +public class BorderPaintingInfo implements PaintingInfo { + + private final float x1; + private final float y1; + private final float x2; + private final float y2; + private final boolean isHorizontal; + private final int style; + private final Color color; + + /** + * Main constructor + * + * @param x1 the x1 coordinate + * @param y1 the y1 coordinate + * @param x2 the x2 coordinate + * @param y2 the y2 coordinate + * @param isHorizontal true when the border line is horizontal + * @param style the border style + * @param color the border color + */ + public BorderPaintingInfo(float x1, float y1, float x2, float y2, + boolean isHorizontal, int style, Color color) { + this.x1 = x1; + this.y1 = y1; + this.x2 = x2; + this.y2 = y2; + this.isHorizontal = isHorizontal; + this.style = style; + this.color = color; + } + + /** + * Returns the x1 coordinate + * + * @return the x1 coordinate + */ + public float getX1() { + return x1; + } + + /** + * Returns the y1 coordinate + * + * @return the y1 coordinate + */ + public float getY1() { + return y1; + } + + /** + * Returns the x2 coordinate + * + * @return the x2 coordinate + */ + public float getX2() { + return x2; + } + + /** + * Returns the y2 coordinate + * + * @return the y2 coordinate + */ + public float getY2() { + return y2; + } + + /** + * Returns true when this is a horizontal line + * + * @return true when this is a horizontal line + */ + public boolean isHorizontal() { + return isHorizontal; + } + + /** + * Returns the style + * + * @return the style + */ + public int getStyle() { + return style; + } + + /** + * Returns the color + * + * @return the color + */ + public Color getColor() { + return color; + } +} diff --git a/src/java/org/apache/fop/afp/Completable.java b/src/java/org/apache/fop/afp/Completable.java new file mode 100644 index 000000000..e1fc764dd --- /dev/null +++ b/src/java/org/apache/fop/afp/Completable.java @@ -0,0 +1,40 @@ +/* + * 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.afp; + +/** + * Set and expose the internal completeness of an object. + */ +public interface Completable { + + /** + * Sets whether or not this object is complete or not + * + * @param complete true if this object is complete + */ + void setComplete(boolean complete); + + /** + * Returns true if this object is complete + * + * @return true if this object is complete + */ + boolean isComplete(); +} diff --git a/src/java/org/apache/fop/afp/DataStream.java b/src/java/org/apache/fop/afp/DataStream.java new file mode 100644 index 000000000..34a7f0f9d --- /dev/null +++ b/src/java/org/apache/fop/afp/DataStream.java @@ -0,0 +1,600 @@ +/* + * 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.afp; + +import java.awt.Color; +import java.awt.Point; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.afp.fonts.AFPFont; +import org.apache.fop.afp.fonts.AFPFontAttributes; +import org.apache.fop.afp.modca.AbstractPageObject; +import org.apache.fop.afp.modca.Document; +import org.apache.fop.afp.modca.InterchangeSet; +import org.apache.fop.afp.modca.Overlay; +import org.apache.fop.afp.modca.PageGroup; +import org.apache.fop.afp.modca.PageObject; +import org.apache.fop.afp.modca.ResourceGroup; +import org.apache.fop.afp.modca.TagLogicalElementBean; +import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; + +/** + * A data stream is a continuous ordered stream of data elements and objects + * conforming to a given format. Application programs can generate data streams + * destined for a presentation service, archive library, presentation device or + * another application program. The strategic presentation data stream + * architectures used is Mixed Object Document Content Architecture (MO:DCA). + * + * The MO:DCA architecture defines the data stream used by applications to + * describe documents and object envelopes for interchange with other + * applications and application services. Documents defined in the MO:DCA format + * may be archived in a database, then later retrieved, viewed, annotated and + * printed in local or distributed systems environments. Presentation fidelity + * is accommodated by including resource objects in the documents that reference + * them. + */ +public class DataStream { + + /** Static logging instance */ + protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp"); + + /** Boolean completion indicator */ + private boolean complete = false; + + /** The AFP document object */ + private Document document = null; + + /** The current page group object */ + private PageGroup currentPageGroup = null; + + /** The current page object */ + private PageObject currentPageObject = null; + + /** The current overlay object */ + private Overlay currentOverlay = null; + + /** The current page */ + private AbstractPageObject currentPage = null; + + /** The MO:DCA interchange set in use (default to MO:DCA-P IS/2 set) */ + private InterchangeSet interchangeSet + = InterchangeSet.valueOf(InterchangeSet.MODCA_PRESENTATION_INTERCHANGE_SET_2); + + private final Factory factory; + + private OutputStream outputStream; + + /** the afp painting state */ + private final AFPPaintingState paintingState; + + /** + * Default constructor for the AFPDocumentStream. + * + * @param factory the resource factory + * @param paintingState the AFP painting state + * @param outputStream the outputstream to write to + */ + public DataStream(Factory factory, AFPPaintingState paintingState, OutputStream outputStream) { + this.paintingState = paintingState; + this.factory = factory; + this.outputStream = outputStream; + } + + /** + * Returns the outputstream + * + * @return the outputstream + */ + public OutputStream getOutputStream() { + return this.outputStream; + } + + /** + * Returns the document object + * + * @return the document object + */ + private Document getDocument() { + return this.document; + } + + /** + * Returns the current page + * + * @return the current page + */ + public AbstractPageObject getCurrentPage() { + return this.currentPage; + } + + /** + * The document is started by invoking this method which creates an instance + * of the AFP Document object. + * + * @param name + * the name of this document. + */ + public void setDocumentName(String name) { + if (name != null) { + getDocument().setFullyQualifiedName( + FullyQualifiedNameTriplet.TYPE_BEGIN_DOCUMENT_REF, + FullyQualifiedNameTriplet.FORMAT_CHARSTR, name); + } + } + + /** + * Helper method to mark the end of the current document. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void endDocument() throws IOException { + if (complete) { + String msg = "Invalid state - document already ended."; + log.warn("endDocument():: " + msg); + throw new IllegalStateException(msg); + } + + if (currentPageObject != null) { + // End the current page if necessary + endPage(); + } + + if (currentPageGroup != null) { + // End the current page group if necessary + endPageGroup(); + } + + // Write out document + if (document != null) { + document.endDocument(); + document.writeToStream(this.outputStream); + } + + this.outputStream.flush(); + + this.complete = true; + + this.document = null; + + this.outputStream = null; + } + + /** + * Start a new page. When processing has finished on the current page, the + * {@link #endPage()}method must be invoked to mark the page ending. + * + * @param pageWidth + * the width of the page + * @param pageHeight + * the height of the page + * @param pageRotation + * the rotation of the page + * @param pageWidthRes + * the width resolution of the page + * @param pageHeightRes + * the height resolution of the page + */ + public void startPage(int pageWidth, int pageHeight, int pageRotation, + int pageWidthRes, int pageHeightRes) { + currentPageObject = factory.createPage(pageWidth, pageHeight, + pageRotation, pageWidthRes, pageHeightRes); + currentPage = currentPageObject; + currentOverlay = null; + } + + /** + * Start a new overlay. When processing has finished on the current overlay, + * the {@link #endOverlay()}method must be invoked to mark the overlay + * ending. + * + * @param x + * the x position of the overlay on the page + * @param y + * the y position of the overlay on the page + * @param width + * the width of the overlay + * @param height + * the height of the overlay + * @param widthRes + * the width resolution of the overlay + * @param heightRes + * the height resolution of the overlay + * @param overlayRotation + * the rotation of the overlay + */ + public void startOverlay(int x, int y, int width, int height, int widthRes, + int heightRes, int overlayRotation) { + this.currentOverlay = factory.createOverlay( + width, height, widthRes, heightRes, overlayRotation); + + String overlayName = currentOverlay.getName(); + currentPageObject.createIncludePageOverlay(overlayName, x, y, 0); + currentPage = currentOverlay; + } + + /** + * Helper method to mark the end of the current overlay. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void endOverlay() throws IOException { + if (currentOverlay != null) { + currentOverlay.endPage(); + currentOverlay = null; + currentPage = currentPageObject; + } + } + + /** + * Helper method to save the current page. + * + * @return current page object that was saved + */ + public PageObject savePage() { + PageObject pageObject = currentPageObject; + if (currentPageGroup != null) { + currentPageGroup.addPage(currentPageObject); + } else { + document.addPage(currentPageObject); + } + currentPageObject = null; + currentPage = null; + return pageObject; + } + + /** + * Helper method to restore the current page. + * + * @param pageObject + * page object + */ + public void restorePage(PageObject pageObject) { + currentPageObject = pageObject; + currentPage = pageObject; + } + + /** + * Helper method to mark the end of the current page. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void endPage() throws IOException { + if (currentPageObject != null) { + currentPageObject.endPage(); + if (currentPageGroup != null) { + currentPageGroup.addPage(currentPageObject); + currentPageGroup.writeToStream(this.outputStream); + } else { + document.addPage(currentPageObject); + document.writeToStream(this.outputStream); + } + currentPageObject = null; + currentPage = null; + } + } + + /** + * Creates the given page fonts in the current page + * + * @param pageFonts + * a collection of AFP font attributes + */ + public void addFontsToCurrentPage(Map pageFonts) { + Iterator iter = pageFonts.values().iterator(); + while (iter.hasNext()) { + AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter + .next(); + createFont(afpFontAttributes.getFontReference(), afpFontAttributes + .getFont(), afpFontAttributes.getPointSize()); + } + } + + /** + * Helper method to create a map coded font object on the current page, this + * method delegates the construction of the map coded font object to the + * active environment group on the current page. + * + * @param fontReference + * the font number used as the resource identifier + * @param font + * the font + * @param size + * the point size of the font + */ + public void createFont(int fontReference, AFPFont font, int size) { + currentPage.createFont(fontReference, font, size); + } + + /** + * Returns a point on the current page + * + * @param x the X-coordinate + * @param y the Y-coordinate + * @return a point on the current page + */ + private Point getPoint(int x, int y) { + Point p = new Point(); + int rotation = paintingState.getRotation(); + switch (rotation) { + case 90: + p.x = y; + p.y = currentPage.getWidth() - x; + break; + case 180: + p.x = currentPage.getWidth() - x; + p.y = currentPage.getHeight() - y; + break; + case 270: + p.x = currentPage.getHeight() - y; + p.y = x; + break; + default: + p.x = x; + p.y = y; + break; + } + return p; + } + + /** + * Helper method to create text on the current page, this method delegates + * to the current presentation text object in order to construct the text. + * + * @param textDataInfo + * the afp text data + */ + public void createText(AFPTextDataInfo textDataInfo) { + int rotation = paintingState.getRotation(); + if (rotation != 0) { + textDataInfo.setRotation(rotation); + Point p = getPoint(textDataInfo.getX(), textDataInfo.getY()); + textDataInfo.setX(p.x); + textDataInfo.setY(p.y); + } + currentPage.createText(textDataInfo); + } + + /** + * Method to create a line on the current page. + * + * @param lineDataInfo the line data information. + */ + public void createLine(AFPLineDataInfo lineDataInfo) { + currentPage.createLine(lineDataInfo); + } + + /** + * This method will create shading on the page using the specified + * coordinates (the shading contrast is controlled via the red, green, blue + * parameters, by converting this to grey scale). + * + * @param x + * the x coordinate of the shading + * @param y + * the y coordinate of the shading + * @param w + * the width of the shaded area + * @param h + * the height of the shaded area + * @param col + * the shading color + */ + public void createShading(int x, int y, int w, int h, Color col) { + currentPageObject.createShading(x, y, w, h, col.getRed(), col.getGreen(), col.getBlue()); + } + + /** + * Helper method which allows creation of the MPO object, via the AEG. And + * the IPO via the Page. (See actual object for descriptions.) + * + * @param name + * the name of the static overlay + */ + public void createIncludePageOverlay(String name) { + currentPageObject.createIncludePageOverlay(name, 0, 0, paintingState.getRotation()); + currentPageObject.getActiveEnvironmentGroup().createOverlay(name); + } + + /** + * Helper method which allows creation of the IMM object. + * + * @param name + * the name of the medium map + */ + public void createInvokeMediumMap(String name) { + currentPageGroup.createInvokeMediumMap(name); + } + + /** + * Creates an IncludePageSegment on the current page. + * + * @param name + * the name of the include page segment + * @param x + * the x coordinate for the overlay + * @param y + * the y coordinate for the overlay + */ + public void createIncludePageSegment(String name, int x, int y) { + int xOrigin; + int yOrigin; + int orientation = paintingState.getRotation(); + switch (orientation) { + case 90: + xOrigin = currentPage.getWidth() - y; + yOrigin = x; + break; + case 180: + xOrigin = currentPage.getWidth() - x; + yOrigin = currentPage.getHeight() - y; + break; + case 270: + xOrigin = y; + yOrigin = currentPage.getHeight() - x; + break; + default: + xOrigin = x; + yOrigin = y; + break; + } + currentPage.createIncludePageSegment(name, xOrigin, yOrigin); + } + + /** + * Creates a TagLogicalElement on the current page. + * + * @param attributes + * the array of key value pairs. + */ + public void createPageTagLogicalElement(TagLogicalElementBean[] attributes) { + for (int i = 0; i < attributes.length; i++) { + String name = attributes[i].getKey(); + String value = attributes[i].getValue(); + currentPage.createTagLogicalElement(name, value); + } + } + + /** + * Creates a TagLogicalElement on the current page group. + * + * @param attributes + * the array of key value pairs. + */ + public void createPageGroupTagLogicalElement(TagLogicalElementBean[] attributes) { + for (int i = 0; i < attributes.length; i++) { + String name = attributes[i].getKey(); + String value = attributes[i].getValue(); + currentPageGroup.createTagLogicalElement(name, value); + } + } + + /** + * Creates a TagLogicalElement on the current page or page group + * + * @param name + * The tag name + * @param value + * The tag value + */ + public void createTagLogicalElement(String name, String value) { + if (currentPageGroup != null) { + currentPageGroup.createTagLogicalElement(name, value); + } else { + currentPage.createTagLogicalElement(name, value); + } + } + + /** + * Creates a NoOperation item + * + * @param content + * byte data + */ + public void createNoOperation(String content) { + currentPage.createNoOperation(content); + } + + /** + * Returns the current page group + * + * @return the current page group + */ + public PageGroup getCurrentPageGroup() { + return this.currentPageGroup; + } + + /** + * Start a new document. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void startDocument() throws IOException { + this.document = factory.createDocument(); + document.writeToStream(this.outputStream); + } + + /** + * Start a new page group. When processing has finished on the current page + * group the {@link #endPageGroup()}method must be invoked to mark the page + * group ending. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void startPageGroup() throws IOException { + endPageGroup(); + this.currentPageGroup = factory.createPageGroup(); + } + + /** + * Helper method to mark the end of the page group. + * + * @throws IOException thrown if an I/O exception of some sort has occurred + */ + public void endPageGroup() throws IOException { + if (currentPageGroup != null) { + currentPageGroup.endPageGroup(); + document.addPageGroup(currentPageGroup); + document.writeToStream(outputStream); + currentPageGroup = null; + } + } + + /** + * Sets the MO:DCA interchange set to use + * + * @param interchangeSet the MO:DCA interchange set + */ + public void setInterchangeSet(InterchangeSet interchangeSet) { + this.interchangeSet = interchangeSet; + } + + /** + * Returns the MO:DCA interchange set in use + * + * @return the MO:DCA interchange set in use + */ + public InterchangeSet getInterchangeSet() { + return this.interchangeSet; + } + + /** + * Returns the resource group for a given resource info + * + * @param level a resource level + * @return a resource group for the given resource info + */ + public ResourceGroup getResourceGroup(AFPResourceLevel level) { + ResourceGroup resourceGroup = null; + if (level.isDocument()) { + resourceGroup = document.getResourceGroup(); + } else if (level.isPageGroup()) { + resourceGroup = currentPageGroup.getResourceGroup(); + } else if (level.isPage()) { + resourceGroup = currentPageObject.getResourceGroup(); + } + return resourceGroup; + } + +} diff --git a/src/java/org/apache/fop/afp/Factory.java b/src/java/org/apache/fop/afp/Factory.java index ef7426330..a278a5761 100644 --- a/src/java/org/apache/fop/afp/Factory.java +++ b/src/java/org/apache/fop/afp/Factory.java @@ -30,7 +30,6 @@ import org.apache.fop.afp.ioca.ImageSegment; import org.apache.fop.afp.ioca.ImageSizeParameter; import org.apache.fop.afp.modca.ActiveEnvironmentGroup; import org.apache.fop.afp.modca.ContainerDataDescriptor; -import org.apache.fop.afp.modca.DataStream; import org.apache.fop.afp.modca.Document; import org.apache.fop.afp.modca.GraphicsDataDescriptor; import org.apache.fop.afp.modca.GraphicsObject; @@ -62,7 +61,7 @@ import org.apache.fop.afp.modca.TagLogicalElement; import org.apache.fop.afp.util.StringUtils; /** - * Creator of MO:DCA data objects (mostly) + * Creator of MO:DCA structured field objects */ public class Factory { @@ -392,12 +391,12 @@ public class Factory { /** * Creates a new {@link DataStream} * - * @param state the AFP painting state + * @param paintingState the AFP painting state * @param outputStream an outputstream to write to * @return a new {@link DataStream} */ - public DataStream createDataStream(AFPPaintingState state, OutputStream outputStream) { - DataStream dataStream = new DataStream(this, state, outputStream); + public DataStream createDataStream(AFPPaintingState paintingState, OutputStream outputStream) { + DataStream dataStream = new DataStream(this, paintingState, outputStream); return dataStream; } diff --git a/src/java/org/apache/fop/afp/PaintInfo.java b/src/java/org/apache/fop/afp/PaintInfo.java deleted file mode 100644 index 2b11d0e3e..000000000 --- a/src/java/org/apache/fop/afp/PaintInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.afp; - -/** - * Generic painting information interface - */ -public interface PaintInfo { - -} diff --git a/src/java/org/apache/fop/afp/PaintingInfo.java b/src/java/org/apache/fop/afp/PaintingInfo.java new file mode 100644 index 000000000..e53f28306 --- /dev/null +++ b/src/java/org/apache/fop/afp/PaintingInfo.java @@ -0,0 +1,27 @@ +/* + * 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.afp; + +/** + * Generic painting information interface + */ +public interface PaintingInfo { + +} diff --git a/src/java/org/apache/fop/afp/RectanglePaintInfo.java b/src/java/org/apache/fop/afp/RectanglePaintInfo.java deleted file mode 100644 index f0fae0317..000000000 --- a/src/java/org/apache/fop/afp/RectanglePaintInfo.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.afp; - - -/** - * Filled rectangle painting information - */ -public class RectanglePaintInfo implements PaintInfo { - - private final float x; - private final float y; - private final float width; - private final float height; - - /** - * Main constructor - * - * @param x the x coordinate - * @param y the y coordinate - * @param width the width - * @param height the height - */ - public RectanglePaintInfo(float x, float y, float width, float height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - /** - * Returns the x coordinate - * - * @return the x coordinate - */ - protected float getX() { - return x; - } - - /** - * Returns the y coordinate - * - * @return the y coordinate - */ - protected float getY() { - return y; - } - - /** - * Returns the width - * - * @return the width - */ - protected float getWidth() { - return width; - } - - /** - * Returns the height - * - * @return the height - */ - protected float getHeight() { - return height; - } - -} diff --git a/src/java/org/apache/fop/afp/RectanglePaintingInfo.java b/src/java/org/apache/fop/afp/RectanglePaintingInfo.java new file mode 100644 index 000000000..64503d0b8 --- /dev/null +++ b/src/java/org/apache/fop/afp/RectanglePaintingInfo.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.afp; + + +/** + * Filled rectangle painting information + */ +public class RectanglePaintingInfo implements PaintingInfo { + + private final float x; + private final float y; + private final float width; + private final float height; + + /** + * Main constructor + * + * @param x the x coordinate + * @param y the y coordinate + * @param width the width + * @param height the height + */ + public RectanglePaintingInfo(float x, float y, float width, float height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + /** + * Returns the x coordinate + * + * @return the x coordinate + */ + protected float getX() { + return x; + } + + /** + * Returns the y coordinate + * + * @return the y coordinate + */ + protected float getY() { + return y; + } + + /** + * Returns the width + * + * @return the width + */ + protected float getWidth() { + return width; + } + + /** + * Returns the height + * + * @return the height + */ + protected float getHeight() { + return height; + } + +} diff --git a/src/java/org/apache/fop/afp/Startable.java b/src/java/org/apache/fop/afp/Startable.java new file mode 100644 index 000000000..fd05b8455 --- /dev/null +++ b/src/java/org/apache/fop/afp/Startable.java @@ -0,0 +1,40 @@ +/* + * 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.afp; + +/** + * Set and expose whether an object has started or not. + */ +public interface Startable { + + /** + * Sets whether or not this object has started or not + * + * @param complete true if this object has started + */ + void setStarted(boolean started); + + /** + * Returns true if this object has started + * + * @return true if this object has started + */ + boolean isStarted(); +} diff --git a/src/java/org/apache/fop/afp/StructuredData.java b/src/java/org/apache/fop/afp/StructuredData.java new file mode 100644 index 000000000..99555b39b --- /dev/null +++ b/src/java/org/apache/fop/afp/StructuredData.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.afp; + +/** + * An AFP object which is able to know its own data length prior to writeToStream() + */ +public interface StructuredData { + + /** + * Returns the data length of this structured field + * + * @return the data length of this structured field + */ + int getDataLength(); +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java index 066940874..3d8495667 100644 --- a/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java +++ b/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java @@ -22,26 +22,40 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.afp.modca.StructuredDataObject; import org.apache.fop.afp.util.BinaryUtils; /** * A base class encapsulating the structure of coordinate based GOCA objects */ -public abstract class AbstractGraphicsCoord extends AbstractNamedAFPObject - implements StructuredDataObject { +public abstract class AbstractGraphicsCoord extends AbstractGraphicsDrawingOrder { /** array of x/y coordinates */ protected int[] coords = null; + protected boolean relative = false; + /** * Constructor * * @param coords the x/y coordinates for this object */ public AbstractGraphicsCoord(int[] coords) { - this.coords = coords; + if (coords == null) { + relative = true; + } else { + this.coords = coords; + } + } + + /** + * Constructor + * + * @param coords the x/y coordinates for this object + * @param relative + */ + public AbstractGraphicsCoord(int[] coords, boolean relative) { + this(coords); + this.relative = relative; } /** @@ -68,16 +82,9 @@ public abstract class AbstractGraphicsCoord extends AbstractNamedAFPObject /** {@inheritDoc} */ public int getDataLength() { - return 2 + (coords.length * 2); + return 2 + (coords != null ? coords.length * 2 : 0); } - /** - * Returns the order code of this structured field - * - * @return the order code of this structured field - */ - abstract byte getOrderCode(); - /** * Returns the coordinate data start index * @@ -93,15 +100,10 @@ public abstract class AbstractGraphicsCoord extends AbstractNamedAFPObject * @return the coordinate data */ byte[] getData() { - int len = getDataLength(); - byte[] data = new byte[len]; - data[0] = getOrderCode(); - data[1] = (byte)(len - 2); - + byte[] data = super.getData(); if (coords != null) { addCoords(data, getCoordinateDataStartIndex()); } - return data; } @@ -125,16 +127,6 @@ public abstract class AbstractGraphicsCoord extends AbstractNamedAFPObject } } - /** - * Returns the short name of this GOCA object - * - * @return the short name of this GOCA object - */ - public String getName() { - String className = getClass().getName(); - return className.substring(className.lastIndexOf(".") + 1); - } - /** {@inheritDoc} */ public String toString() { String coordsStr = ""; @@ -145,4 +137,13 @@ public abstract class AbstractGraphicsCoord extends AbstractNamedAFPObject coordsStr = coordsStr.substring(0, coordsStr.length() - 1); return getName() + "{" + coordsStr + "}"; } + + /** + * Returns true if this is a relative drawing order + * + * @return true if this is a relative drawing order + */ + protected boolean isRelative() { + return this.relative; + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java new file mode 100644 index 000000000..0d8f793c0 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java @@ -0,0 +1,60 @@ +/* + * 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.afp.goca; + +import org.apache.fop.afp.StructuredData; +import org.apache.fop.afp.modca.AbstractAFPObject; + +/** + * A base GOCA drawing order + */ +public abstract class AbstractGraphicsDrawingOrder extends AbstractAFPObject + implements StructuredData { + + /** + * Returns the order code of this structured field + * + * @return the order code of this structured field + */ + abstract byte getOrderCode(); + + /** + * Returns the coordinate data + * + * @return the coordinate data + */ + byte[] getData() { + int len = getDataLength(); + byte[] data = new byte[len]; + data[0] = getOrderCode(); + data[1] = (byte)(len - 2); + return data; + } + + /** + * Returns the short name of this GOCA object + * + * @return the short name of this GOCA object + */ + public String getName() { + String className = getClass().getName(); + return className.substring(className.lastIndexOf(".") + 1); + } +} diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java new file mode 100644 index 000000000..34398b094 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java @@ -0,0 +1,158 @@ +/* + * 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.afp.goca; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.apache.fop.afp.Completable; +import org.apache.fop.afp.Startable; +import org.apache.fop.afp.StructuredData; +import org.apache.fop.afp.modca.AbstractNamedAFPObject; + +/** + * A base container of prepared structured AFP objects + */ +public abstract class AbstractGraphicsDrawingOrderContainer extends AbstractNamedAFPObject +implements StructuredData, Completable, Startable { + + /** list of objects contained within this container */ + protected List/**/ objects + = new java.util.ArrayList/**/(); + + /** object is complete */ + private boolean complete = false; + + /** object has started */ + private boolean started = false; + + /** + * Default constructor + */ + protected AbstractGraphicsDrawingOrderContainer() { + } + + /** + * Named constructor + * + * @param name the name of the container + */ + protected AbstractGraphicsDrawingOrderContainer(String name) { + super(name); + } + + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + setStarted(true); + } + + /** {@inheritDoc} */ + protected void writeContent(OutputStream os) throws IOException { + writeObjects(objects, os); + } + + /** + * Adds a given graphics object to this container + * + * @param object the structured data object + */ + public void addObject(StructuredData object) { + objects.add(object); + } + + /** + * Adds all the contents of a given graphics container to this container + * + * @param graphicsContainer a graphics container + */ + public void addAll(AbstractGraphicsDrawingOrderContainer graphicsContainer) { + Collection/**/ objects = graphicsContainer.getObjects(); + objects.addAll(objects); + } + + /** + * Returns all the objects in this container + * + * @return all the objects in this container + */ + private Collection getObjects() { + return this.objects; + } + + /** + * Removes the last drawing order from this container and returns it + * + * @return the last drawing order from this container or null if empty + */ + public StructuredData removeLast() { + int lastIndex = objects.size() - 1; + StructuredData object = null; + if (lastIndex > -1) { + object = (StructuredData)objects.get(lastIndex); + objects.remove(lastIndex); + } + return object; + } + + /** + * Returns the current data length + * + * @return the current data length of this container including + * all enclosed objects (and their containers) + */ + public int getDataLength() { + int dataLen = 0; + Iterator it = objects.iterator(); + while (it.hasNext()) { + dataLen += ((StructuredData)it.next()).getDataLength(); + } + return dataLen; + } + + /** {@inheritDoc} */ + public void setComplete(boolean complete) { + Iterator it = objects.iterator(); + while (it.hasNext()) { + Object object = it.next(); + if (object instanceof Completable) { + ((Completable)object).setComplete(true); + } + } + this.complete = true; + } + + /** {@inheritDoc} */ + public boolean isComplete() { + return this.complete; + } + + /** {@inheritDoc} */ + public boolean isStarted() { + return this.started; + } + + /** {@inheritDoc} */ + public void setStarted(boolean started) { + this.started = started; + } +} diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java deleted file mode 100644 index 672193042..000000000 --- a/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.afp.goca; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Iterator; -import java.util.List; - -import org.apache.fop.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.afp.modca.StructuredDataObject; - -/** - * A base container of prepared structured AFP objects - */ -public abstract class AbstractGraphicsObjectContainer extends AbstractNamedAFPObject -implements StructuredDataObject { - - /** list of objects contained within this container */ - protected List/**/ objects - = new java.util.ArrayList/**/(); - - /** - * Default constructor - */ - protected AbstractGraphicsObjectContainer() { - } - - /** - * Named constructor - * - * @param name the name of the container - */ - protected AbstractGraphicsObjectContainer(String name) { - super(name); - } - - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { - writeObjects(objects, os); - } - - /** - * Adds a given graphics object to this container - * - * @param drawingOrder the graphics object - */ - public void addObject(StructuredDataObject drawingOrder) { - objects.add(drawingOrder); - } - - /** - * Returns the current data length - * - * @return the current data length of this container including - * all enclosed objects (and their containers) - */ - public int getDataLength() { - int dataLen = 0; - Iterator it = objects.iterator(); - while (it.hasNext()) { - dataLen += ((StructuredDataObject)it.next()).getDataLength(); - } - return dataLen; - } -} diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java deleted file mode 100644 index 80882db8a..000000000 --- a/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.afp.goca; - -import java.io.UnsupportedEncodingException; - -import org.apache.fop.afp.AFPConstants; - -public abstract class AbstractGraphicsString extends AbstractGraphicsCoord { - - /** Up to 255 bytes of character data */ - protected static final int MAX_STR_LEN = 255; - - /** the string to draw */ - protected final String str; - - /** - * Constructor (relative) - * - * @param str the text string - */ - public AbstractGraphicsString(String str) { - super(null); - if (str.length() > MAX_STR_LEN) { - str = str.substring(0, MAX_STR_LEN); - log.warn("truncated character string, longer than " + MAX_STR_LEN + " chars"); - } - this.str = str; - } - - /** - * Constructor (absolute) - * - * @param str the text string - * @param x the x coordinate - * @param y the y coordinate - */ - public AbstractGraphicsString(String str, int x, int y) { - super(x, y); - this.str = str; - } - - /** {@inheritDoc} */ - public int getDataLength() { - return 2 + str.length(); - } - - /** - * Returns the text string as an encoded byte array - * - * @return the text string as an encoded byte array - */ - protected byte[] getStringAsBytes() throws UnsupportedEncodingException { - return str.getBytes(AFPConstants.EBCIDIC_ENCODING); - } - -} diff --git a/src/java/org/apache/fop/afp/goca/GraphicsArea.java b/src/java/org/apache/fop/afp/goca/GraphicsArea.java deleted file mode 100644 index 3d3bafb45..000000000 --- a/src/java/org/apache/fop/afp/goca/GraphicsArea.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.afp.goca; - -import java.io.IOException; -import java.io.OutputStream; - - -/** - * A GOCA graphics area (container for filled shapes/objects) - */ -public final class GraphicsArea extends AbstractGraphicsObjectContainer { - - private static final int RES1 = 1; - private static final int BOUNDARY = 2; - private static final int NO_BOUNDARY = 0; - - /** draw boundary lines around this area */ - private boolean drawBoundary = false; - - /** - * Sets whether boundary lines are drawn - * - * @param drawBoundaryLines whether boundary lines are drawn - */ - public void setDrawBoundaryLines(boolean drawBoundaryLines) { - this.drawBoundary = drawBoundaryLines; - } - - /** {@inheritDoc} */ - public int getDataLength() { - return 4 + super.getDataLength(); - } - - /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - byte[] data = new byte[] { - (byte)0x68, // GBAR order code - (byte)(RES1 + (drawBoundary ? BOUNDARY : NO_BOUNDARY)) - }; - os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - (byte)0x60, // GEAR order code - 0x00, // LENGTH - }; - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsArea{drawBoundary=" + drawBoundary + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.java b/src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.java new file mode 100644 index 000000000..fc66fa8cd --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.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.afp.goca; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * The beginning of a filled region (graphics area). + */ +public class GraphicsAreaBegin extends AbstractGraphicsDrawingOrder { + + private static final int RES1 = 1; + private static final int BOUNDARY = 2; + private static final int NO_BOUNDARY = 0; + + /** draw boundary lines around this area */ + private boolean drawBoundary = false; + + /** + * Sets whether boundary lines are drawn + * + * @param drawBoundaryLines whether boundary lines are drawn + */ + public void setDrawBoundaryLines(boolean drawBoundaryLines) { + this.drawBoundary = drawBoundaryLines; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[] { + getOrderCode(), // GBAR order code + (byte)(RES1 + (drawBoundary ? BOUNDARY : NO_BOUNDARY)) + }; + os.write(data); + } + + /** {@inheritDoc} */ + public int getDataLength() { + return 2; + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsAreaBegin{drawBoundary=" + drawBoundary + "}"; + } + + /** {@inheritDoc} */ + byte getOrderCode() { + return 0x68; + } +} diff --git a/src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.java b/src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.java new file mode 100644 index 000000000..12f14bfa4 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.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.afp.goca; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * The end of a filled region (graphics area). + */ +public class GraphicsAreaEnd extends AbstractGraphicsDrawingOrder { + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = new byte[] { + getOrderCode(), // GEAR order code + 0x00, // LENGTH + }; + os.write(data); + } + + /** {@inheritDoc} */ + public int getDataLength() { + return 2; + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsAreaEnd"; + } + + /** {@inheritDoc} */ + byte getOrderCode() { + return 0x60; + } +} diff --git a/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java b/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java index 697d4f841..8a92db296 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java @@ -22,25 +22,17 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.StructuredDataObject; import org.apache.fop.afp.util.BinaryUtils; /** * A GOCA graphics segment */ -public final class GraphicsChainedSegment extends AbstractGraphicsObjectContainer { +public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderContainer { /** The maximum segment data length */ protected static final int MAX_DATA_LEN = 8192; - /** the current area */ - private GraphicsArea currentArea = null; - - /** the previous segment in the chain */ - private GraphicsChainedSegment previous = null; - - /** the next segment in the chain */ - private GraphicsChainedSegment next = null; + private byte[] predecessorNameBytes; /** * Main constructor @@ -57,13 +49,12 @@ public final class GraphicsChainedSegment extends AbstractGraphicsObjectContaine * * @param name * the name of this graphics segment - * @param previous - * the previous graphics segment in this chain + * @param predecessorNameBytes + * the name of the predecessor in this chain */ - public GraphicsChainedSegment(String name, GraphicsChainedSegment previous) { + public GraphicsChainedSegment(String name, byte[] predecessorNameBytes) { super(name); - previous.next = this; - this.previous = previous; + this.predecessorNameBytes = predecessorNameBytes; } /** {@inheritDoc} */ @@ -88,9 +79,7 @@ public final class GraphicsChainedSegment extends AbstractGraphicsObjectContaine } /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - + public void writeToStream(OutputStream os) throws IOException { byte[] data = new byte[14]; data[0] = getOrderCode(); // BEGIN_SEGMENT data[1] = 0x0C; // Length of following parameters @@ -108,41 +97,12 @@ public final class GraphicsChainedSegment extends AbstractGraphicsObjectContaine data[9] = len[1]; // P/S NAME (predecessor name) - if (previous != null) { - nameBytes = previous.getNameBytes(); - System.arraycopy(nameBytes, 0, data, 10, NAME_LENGTH); + if (predecessorNameBytes != null) { + System.arraycopy(predecessorNameBytes, 0, data, 10, NAME_LENGTH); } os.write(data); - } - - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - // I am the first segment in the chain so write out the rest - if (previous == null) { - for (GraphicsChainedSegment segment = next; segment != null; segment = segment.next) { - segment.writeToStream(os); - } - } // else nothing todo - } - /** Begins a graphics area (start of fill) */ - protected void beginArea() { - this.currentArea = new GraphicsArea(); - super.addObject(currentArea); - } - - /** Ends a graphics area (end of fill) */ - protected void endArea() { - this.currentArea = null; - } - - /** {@inheritDoc} */ - public void addObject(StructuredDataObject drawingOrder) { - if (currentArea != null) { - currentArea.addObject(drawingOrder); - } else { - super.addObject(drawingOrder); - } + writeObjects(objects, os); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java b/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java new file mode 100644 index 000000000..70039d167 --- /dev/null +++ b/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java @@ -0,0 +1,114 @@ +/* + * 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.afp.goca; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; + +import org.apache.fop.afp.AFPConstants; + +/** + * A GOCA graphics string + */ +public class GraphicsCharacterString extends AbstractGraphicsCoord { + + /** Up to 255 bytes of character data */ + protected static final int MAX_STR_LEN = 255; + + /** the string to draw */ + protected final String str; + + /** + * Constructor (absolute positioning) + * + * @param str the character string + * @param x the x coordinate + * @param y the y coordinate + */ + public GraphicsCharacterString(String str, int x, int y) { + super(x, y); + this.str = truncate(str); + } + + /** + * Constructor (relative positioning) + * + * @param str the character string + * @param x the x coordinate + * @param y the y coordinate + */ + public GraphicsCharacterString(String str) { + super(null); + this.str = truncate(str); + } + + /** {@inheritDoc} */ + byte getOrderCode() { + if (isRelative()) { + return (byte)0x83; + } else { + return (byte)0xC3; + } + } + + /** {@inheritDoc} */ + public int getDataLength() { + return super.getDataLength() + str.length(); + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = getData(); + byte[] strData = getStringAsBytes(); + System.arraycopy(strData, 0, data, 6, strData.length); + os.write(data); + } + + /** + * Truncates the string as necessary + * + * @param str a character string + * @return a possibly truncated string + */ + private String truncate(String str) { + if (str.length() > MAX_STR_LEN) { + str = str.substring(0, MAX_STR_LEN); + log.warn("truncated character string, longer than " + MAX_STR_LEN + " chars"); + } + return str; + } + + /** + * Returns the text string as an encoded byte array + * + * @return the text string as an encoded byte array + */ + private byte[] getStringAsBytes() throws UnsupportedEncodingException { + return str.getBytes(AFPConstants.EBCIDIC_ENCODING); + } + + /** {@inheritDoc} */ + public String toString() { + return "GraphicsCharacterString{" + + (coords != null ? "x=" + coords[0] + ", y=" + coords[1] : "") + + "str='" + str + "'" + "}"; + } +} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsData.java b/src/java/org/apache/fop/afp/goca/GraphicsData.java index 8b59436fc..89be8dd94 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsData.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsData.java @@ -22,38 +22,30 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.StructuredDataObject; +import org.apache.fop.afp.StructuredData; import org.apache.fop.afp.util.BinaryUtils; import org.apache.fop.afp.util.StringUtils; /** * A GOCA graphics data */ -public final class GraphicsData extends AbstractGraphicsObjectContainer { +public final class GraphicsData extends AbstractGraphicsDrawingOrderContainer { - /** The maximum graphics data length */ + /** the maximum graphics data length */ public static final int MAX_DATA_LEN = 32767; - /** The graphics segment */ - private GraphicsChainedSegment segment = null; - - /** {@inheritDoc} */ - public int getDataLength() { - return 8 + super.getDataLength(); - } + /** the graphics segment */ + private GraphicsChainedSegment currentSegment = null; /** - * Begins a graphics area (start of fill) + * Main constructor */ - public void beginArea() { - getSegment().beginArea(); + public GraphicsData() { } - /** - * Ends a graphics area (end of fill) - */ - public void endArea() { - getSegment().endArea(); + /** {@inheritDoc} */ + public int getDataLength() { + return 8 + super.getDataLength(); } /** @@ -61,48 +53,47 @@ public final class GraphicsData extends AbstractGraphicsObjectContainer { * * @return a new segment name */ - private String createSegmentName() { + public String createSegmentName() { return StringUtils.lpad(String.valueOf( (super.objects != null ? super.objects.size() : 0) + 1), '0', 4); } - /** - * Returns the current graphics segment, creating one if one does not exist - * - * @return the current graphics chained segment - */ - private GraphicsChainedSegment getSegment() { - if (segment == null) { - newSegment(); - } - return this.segment; - } - /** * Creates a new graphics segment * * @return a newly created graphics segment */ public GraphicsChainedSegment newSegment() { - String name = createSegmentName(); - if (segment == null) { - this.segment = new GraphicsChainedSegment(name); + String segmentName = createSegmentName(); + if (currentSegment == null) { + currentSegment = new GraphicsChainedSegment(segmentName); } else { - this.segment = new GraphicsChainedSegment(name, segment); + currentSegment.setComplete(true); + currentSegment = new GraphicsChainedSegment(segmentName, currentSegment.getNameBytes()); } - super.addObject(segment); - return segment; + super.addObject(currentSegment); + return currentSegment; } /** {@inheritDoc} */ - public void addObject(StructuredDataObject drawingOrder) { - if (segment == null - || (segment.getDataLength() + drawingOrder.getDataLength()) - >= GraphicsChainedSegment.MAX_DATA_LEN) { + public void addObject(StructuredData object) { + if (currentSegment == null + || (currentSegment.getDataLength() + object.getDataLength()) + >= GraphicsChainedSegment.MAX_DATA_LEN) { newSegment(); } - segment.addObject(drawingOrder); + currentSegment.addObject(object); + } + + /** + * Removes the current segment from this graphics data + * + * @return the current segment from this graphics data + */ + public StructuredData removeCurrentSegment() { + this.currentSegment = null; + return super.removeLast(); } /** {@inheritDoc} */ @@ -115,13 +106,21 @@ public final class GraphicsData extends AbstractGraphicsObjectContainer { data[2] = len[1]; // Length byte 2 os.write(data); - // get first segment in chain and write (including all its connected segments) - GraphicsChainedSegment firstSegment = (GraphicsChainedSegment)objects.get(0); - firstSegment.writeToStream(os); + writeObjects(objects, os); } /** {@inheritDoc} */ public String toString() { return "GraphicsData"; } + + /** + * Adds the given segment to this graphics data + * + * @param segment a graphics chained segment + */ + public void addSegment(GraphicsChainedSegment segment) { + currentSegment = segment; + super.addObject(currentSegment); + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsFillet.java b/src/java/org/apache/fop/afp/goca/GraphicsFillet.java index b4fa17d65..294be6d9b 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsFillet.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsFillet.java @@ -30,12 +30,17 @@ public final class GraphicsFillet extends AbstractGraphicsCoord { * * @param coords the x/y coordinates for this object */ - public GraphicsFillet(int[] coords) { - super(coords); + public GraphicsFillet(int[] coords, boolean relative) { + super(coords, relative); } + /** {@inheritDoc} */ byte getOrderCode() { - return (byte)0xC5; + if (isRelative()) { + return (byte)0x85; + } else { + return (byte)0xC5; + } } } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java b/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java deleted file mode 100644 index 21a1c17d6..000000000 --- a/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.afp.goca; - - -/** - * A GOCA graphics curved tangential line to a specified set of - * straight lines drawn from the given position or current position - */ -public final class GraphicsFilletRelative extends AbstractGraphicsCoord { - - /** - * Constructor - * - * @param coords the x/y coordinates for this object - */ - public GraphicsFilletRelative(int[] coords) { - super(coords); - } - - /** {@inheritDoc} */ - byte getOrderCode() { - return (byte)0x85; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsImage.java b/src/java/org/apache/fop/afp/goca/GraphicsImage.java index 94e9e9ab2..3b1dafeea 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsImage.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsImage.java @@ -22,13 +22,15 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.AbstractStructuredObject; import org.apache.fop.afp.util.BinaryUtils; /** * A GOCA Image */ -public class GraphicsImage extends AbstractStructuredObject { +public class GraphicsImage extends AbstractGraphicsDrawingOrder { + + /** the maximum image data length */ + public static final short MAX_DATA_LEN = 255; /** x coordinate */ private final int x; @@ -63,13 +65,23 @@ public class GraphicsImage extends AbstractStructuredObject { } /** {@inheritDoc} */ - protected void writeStart(OutputStream os) throws IOException { + public int getDataLength() { + //TODO: + return 0; + } + + byte getOrderCode() { + return (byte)0xD1; + } + + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { byte[] xcoord = BinaryUtils.convert(x, 2); byte[] ycoord = BinaryUtils.convert(y, 2); byte[] w = BinaryUtils.convert(width, 2); byte[] h = BinaryUtils.convert(height, 2); - byte[] data = new byte[] { - (byte) 0xD1, // GBIMG order code + byte[] startData = new byte[] { + getOrderCode(), // GBIMG order code (byte) 0x0A, // LENGTH xcoord[0], xcoord[1], @@ -82,28 +94,19 @@ public class GraphicsImage extends AbstractStructuredObject { h[0], // HEIGHT h[1] // }; - os.write(data); - } - - /** the maximum image data length */ - public static final short MAX_DATA_LEN = 255; + os.write(startData); - /** {@inheritDoc} */ - protected void writeContent(OutputStream os) throws IOException { byte[] dataHeader = new byte[] { (byte) 0x92 // GIMD }; final int lengthOffset = 1; writeChunksToStream(imageData, dataHeader, lengthOffset, MAX_DATA_LEN, os); - } - /** {@inheritDoc} */ - protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { + byte[] endData = new byte[] { (byte) 0x93, // GEIMG order code 0x00 // LENGTH }; - os.write(data); + os.write(endData); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/afp/goca/GraphicsLine.java b/src/java/org/apache/fop/afp/goca/GraphicsLine.java index d8ff1afaa..17bd43ce0 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsLine.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsLine.java @@ -19,6 +19,9 @@ package org.apache.fop.afp.goca; +import java.io.IOException; +import java.io.OutputStream; + /** * A GOCA graphics straight line drawn from the * given absolute position @@ -29,14 +32,25 @@ public class GraphicsLine extends AbstractGraphicsCoord { * Constructor * * @param coords the x/y coordinates for this object + * + * @param relative is this a relative drawing order */ - public GraphicsLine(int[] coords) { - super(coords); + public GraphicsLine(int[] coords, boolean relative) { + super(coords, relative); } /** {@inheritDoc} */ byte getOrderCode() { - return (byte)0xC1; + if (isRelative()) { + return (byte)0x81; + } else { + return (byte)0xC1; + } } + /** {@inheritDoc} */ + public void writeToStream(OutputStream os) throws IOException { + byte[] data = getData(); + os.write(data); + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java b/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java deleted file mode 100644 index 43ffebf08..000000000 --- a/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.afp.goca; - -/** - * A GOCA graphics straight line drawn from the - * relative from the current position. - */ -public class GraphicsLineRelative extends AbstractGraphicsCoord { - - /** - * Constructor - * - * @param coords the x/y coordinates for this object - */ - public GraphicsLineRelative(int[] coords) { - super(coords); - } - - /** {@inheritDoc} */ - byte getOrderCode() { - return (byte)0x81; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java b/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java index 1561ecf83..b3d1158fe 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java @@ -22,15 +22,12 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.afp.modca.StructuredDataObject; import org.apache.fop.afp.util.BinaryUtils; /** * Sets the current character set (font) to be used for following graphics strings */ -public class GraphicsSetCharacterSet extends AbstractNamedAFPObject - implements StructuredDataObject { +public class GraphicsSetCharacterSet extends AbstractGraphicsDrawingOrder { /** font character set reference */ private final int fontReference; @@ -45,7 +42,7 @@ public class GraphicsSetCharacterSet extends AbstractNamedAFPObject /** {@inheritDoc} */ public void writeToStream(OutputStream os) throws IOException { byte[] data = new byte[] { - 0x38, // GSCS order code + getOrderCode(), // GSCS order code BinaryUtils.convert(fontReference)[0] }; os.write(data); @@ -61,4 +58,9 @@ public class GraphicsSetCharacterSet extends AbstractNamedAFPObject return "GraphicsSetCharacterSet(" + fontReference + ")"; } + /** {@inheritDoc} */ + byte getOrderCode() { + return 0x38; + } + } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java b/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java index 3479bf4e5..b6512f57c 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java @@ -22,14 +22,10 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.afp.modca.StructuredDataObject; - /** * Sets the value of the current line type attribute when stroking GOCA shapes (structured fields) */ -public class GraphicsSetLineType extends AbstractNamedAFPObject -implements StructuredDataObject { +public class GraphicsSetLineType extends AbstractGraphicsDrawingOrder { /** the default line type */ public static final byte DEFAULT = 0x00; // normally SOLID @@ -78,7 +74,7 @@ implements StructuredDataObject { /** {@inheritDoc} */ public void writeToStream(OutputStream os) throws IOException { byte[] data = new byte[] { - 0x18, // GSLW order code + getOrderCode(), // GSLW order code type // line type }; os.write(data); @@ -93,4 +89,9 @@ implements StructuredDataObject { public String toString() { return "GraphicsSetLineType{type=" + TYPES[type] + "}"; } + + /** {@inheritDoc} */ + byte getOrderCode() { + return 0x18; + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java b/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java index 09ed0d7dc..96eac0677 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java @@ -22,13 +22,10 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.afp.modca.StructuredDataObject; - /** * Sets the line width to use when stroking GOCA shapes (structured fields) */ -public class GraphicsSetLineWidth extends AbstractNamedAFPObject implements StructuredDataObject { +public class GraphicsSetLineWidth extends AbstractGraphicsDrawingOrder { /** line width multiplier */ private int multiplier = 1; @@ -50,7 +47,7 @@ public class GraphicsSetLineWidth extends AbstractNamedAFPObject implements Stru /** {@inheritDoc} */ public void writeToStream(OutputStream os) throws IOException { byte[] data = new byte[] { - 0x19, // GSLW order code + getOrderCode(), // GSLW order code (byte)multiplier // MH (line-width) }; os.write(data); @@ -60,4 +57,9 @@ public class GraphicsSetLineWidth extends AbstractNamedAFPObject implements Stru public String toString() { return "GraphicsSetLineWidth{multiplier=" + multiplier + "}"; } + + /** {@inheritDoc} */ + byte getOrderCode() { + return 0x19; + } } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java b/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java index 0058a5013..dfb5ae0d2 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java @@ -22,9 +22,10 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.AbstractNamedAFPObject; - -public class GraphicsSetMix extends AbstractNamedAFPObject { +/** + * Sets the foreground mix mode. + */ +public class GraphicsSetMix extends AbstractGraphicsDrawingOrder { public static final byte MODE_DEFAULT = 0x00; public static final byte MODE_OVERPAINT = 0x02; @@ -55,4 +56,14 @@ public class GraphicsSetMix extends AbstractNamedAFPObject { return "GraphicsSetMix{mode=" + mode + "}"; } + /** {@inheritDoc} */ + byte getOrderCode() { + return 0x0C; + } + + /** {@inheritDoc} */ + public int getDataLength() { + return 2; + } + } diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java b/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java index 0d74aa9d3..3d6cf7cd6 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java @@ -22,14 +22,10 @@ package org.apache.fop.afp.goca; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.afp.modca.StructuredDataObject; - /** * Sets the pattern symbol to use when filling following GOCA structured fields */ -public class GraphicsSetPatternSymbol extends AbstractNamedAFPObject -implements StructuredDataObject { +public class GraphicsSetPatternSymbol extends AbstractGraphicsDrawingOrder { /** dotted density 1 */ public static final byte DOTTED_DENSITY_1 = 0x01; @@ -83,15 +79,15 @@ implements StructuredDataObject { public static final byte BLANK = 0x40; // processed same as NO_FILL /** the graphics pattern symbol to use */ - private final byte symbol; + private final byte pattern; /** * Main constructor * * @param symb the pattern symbol to use */ - public GraphicsSetPatternSymbol(byte symb) { - this.symbol = symb; + public GraphicsSetPatternSymbol(byte pattern) { + this.pattern = pattern; } /** {@inheritDoc} */ @@ -102,8 +98,8 @@ implements StructuredDataObject { /** {@inheritDoc} */ public void writeToStream(OutputStream os) throws IOException { byte[] data = new byte[] { - 0x28, // GSPT order code - symbol + getOrderCode(), // GSPT order code + pattern }; os.write(data); } @@ -111,6 +107,11 @@ implements StructuredDataObject { /** {@inheritDoc} */ public String toString() { return "GraphicsSetPatternSymbol(fill=" - + (symbol == SOLID_FILL ? true : false) + ")"; + + (pattern == SOLID_FILL ? true : false) + ")"; + } + + /** {@inheritDoc} */ + byte getOrderCode() { + return 0x28; } } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java index 41ddeaa96..05a6ee5d1 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java @@ -24,14 +24,10 @@ import java.awt.color.ColorSpace; import java.io.IOException; import java.io.OutputStream; -import org.apache.fop.afp.modca.AbstractNamedAFPObject; -import org.apache.fop.afp.modca.StructuredDataObject; - /** * Sets the current processing color for the following GOCA structured fields */ -public class GraphicsSetProcessColor extends AbstractNamedAFPObject -implements StructuredDataObject { +public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder { private final Color color; diff --git a/src/java/org/apache/fop/afp/goca/GraphicsString.java b/src/java/org/apache/fop/afp/goca/GraphicsString.java deleted file mode 100644 index c08da64ec..000000000 --- a/src/java/org/apache/fop/afp/goca/GraphicsString.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.afp.goca; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * A GOCA graphics string - */ -public class GraphicsString extends AbstractGraphicsString { - - /** - * Constructor - * - * @param str the character string - * @param x the x coordinate - * @param y the y coordinate - */ - public GraphicsString(String str, int x, int y) { - super(str, x, y); - } - - /** {@inheritDoc} */ - byte getOrderCode() { - return (byte)0xC3; - } - - /** {@inheritDoc} */ - public int getDataLength() { - return super.getDataLength() + (coords.length * 2); - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = getData(); - byte[] strData = getStringAsBytes(); - System.arraycopy(strData, 0, data, 6, strData.length); - - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsString{x=" + coords[0] + ", y=" + coords[1] + "str='" + str + "'" + "}"; - } -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java b/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java deleted file mode 100644 index af0c05b5d..000000000 --- a/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.afp.goca; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * A GOCA graphics string - */ -public class GraphicsStringRelative extends AbstractGraphicsString { - - /** - * Constructor - * - * @param str the character string - */ - public GraphicsStringRelative(String str) { - super(str); - } - - /** {@inheritDoc} */ - byte getOrderCode() { - return (byte)0x83; - } - - /** {@inheritDoc} */ - public void writeToStream(OutputStream os) throws IOException { - byte[] data = getData(); - byte[] strData = getStringAsBytes(); - System.arraycopy(strData, 0, data, 2, strData.length); - os.write(data); - } - - /** {@inheritDoc} */ - public String toString() { - return "GraphicsStringRelative{str='" + str + "'" + "}"; - } - -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/ImageCellPosition.java b/src/java/org/apache/fop/afp/ioca/ImageCellPosition.java index 0728ad98f..97489a9b1 100644 --- a/src/java/org/apache/fop/afp/ioca/ImageCellPosition.java +++ b/src/java/org/apache/fop/afp/ioca/ImageCellPosition.java @@ -31,38 +31,27 @@ import org.apache.fop.afp.util.BinaryUtils; */ public class ImageCellPosition extends AbstractAFPObject { - /** - * Offset of image cell in X direction - */ + /** offset of image cell in X direction */ private int xOffset = 0; - /** - * Offset of image cell in Y direction - */ + /** offset of image cell in Y direction */ private int yOffset = 0; - /** - * Size of image cell in X direction - */ + /** size of image cell in X direction */ private final byte[] xSize = new byte[] {(byte)0xFF, (byte)0xFF}; - /** - * Size of image cell in Y direction - */ + /** size of image cell in Y direction */ private final byte[] ySize = new byte[] {(byte)0xFF, (byte)0xFF}; - /** - * Size of fill rectangle in X direction - */ + /** size of fill rectangle in X direction */ private final byte[] xFillSize = new byte[] {(byte)0xFF, (byte)0xFF}; - /** - * Size of fill rectangle in Y direction - */ + /** size of fill rectangle in Y direction */ private final byte[] yFillSize = new byte[] {(byte)0xFF, (byte)0xFF}; /** - * Constructor for the ImageCellPosition + * Main Constructor + * * @param x The offset of image cell in X direction * @param y The offset of image cell in Y direction */ diff --git a/src/java/org/apache/fop/afp/ioca/ImageContent.java b/src/java/org/apache/fop/afp/ioca/ImageContent.java index 6cfddab94..028d08475 100644 --- a/src/java/org/apache/fop/afp/ioca/ImageContent.java +++ b/src/java/org/apache/fop/afp/ioca/ImageContent.java @@ -53,38 +53,26 @@ public class ImageContent extends AbstractStructuredObject { */ public static final byte COMPID_G3_MMR = (byte)0x82; - /** - * The image size parameter - */ + /** the image size parameter */ private ImageSizeParameter imageSizeParameter = null; - /** - * The image encoding - */ + /** the image encoding */ private byte encoding = (byte)0x03; - /** - * The image ide size - */ + /** the image ide size */ private byte size = 1; - /** - * The image compression - */ + /** the image compression */ private byte compression = (byte)0xC0; - /** - * The image color model - */ + /** the image color model */ private byte colorModel = (byte)0x01; - /** - * The image data - */ + /** the image data */ private byte[] data; /** - * Constructor for the image content + * Main Constructor */ public ImageContent() { } @@ -169,7 +157,7 @@ public class ImageContent extends AbstractStructuredObject { 0x00 // length }; final int lengthOffset = 2; - writeChunksToStream(this.data, dataHeader, lengthOffset, MAX_DATA_LEN, os); + writeChunksToStream(data, dataHeader, lengthOffset, MAX_DATA_LEN, os); } } diff --git a/src/java/org/apache/fop/afp/ioca/ImageInputDescriptor.java b/src/java/org/apache/fop/afp/ioca/ImageInputDescriptor.java index f3351933c..af237a467 100644 --- a/src/java/org/apache/fop/afp/ioca/ImageInputDescriptor.java +++ b/src/java/org/apache/fop/afp/ioca/ImageInputDescriptor.java @@ -32,12 +32,9 @@ import org.apache.fop.afp.util.BinaryUtils; */ public class ImageInputDescriptor extends AbstractAFPObject { - /** - * The resolution of the raster image (default 240) - */ + /** the resolution of the raster image (default 240) */ private int resolution = 240; - /** {@inheritDoc} */ public void writeToStream(OutputStream os) throws IOException { diff --git a/src/java/org/apache/fop/afp/ioca/ImageOutputControl.java b/src/java/org/apache/fop/afp/ioca/ImageOutputControl.java index 8574f445b..3d500b3fd 100644 --- a/src/java/org/apache/fop/afp/ioca/ImageOutputControl.java +++ b/src/java/org/apache/fop/afp/ioca/ImageOutputControl.java @@ -33,9 +33,7 @@ import org.apache.fop.afp.util.BinaryUtils; */ public class ImageOutputControl extends AbstractAFPObject { - /** - * The orientation of the image - */ + /** the orientation of the image */ private int orientation = 0; /** @@ -50,9 +48,7 @@ public class ImageOutputControl extends AbstractAFPObject { */ private int yCoord = 0; - /** - * Map an image point to a single presentation device - */ + /** map an image point to a single presentation device */ private boolean singlePoint = true; /** diff --git a/src/java/org/apache/fop/afp/ioca/ImageRasterData.java b/src/java/org/apache/fop/afp/ioca/ImageRasterData.java index 115472bd8..50f44d39d 100644 --- a/src/java/org/apache/fop/afp/ioca/ImageRasterData.java +++ b/src/java/org/apache/fop/afp/ioca/ImageRasterData.java @@ -23,8 +23,6 @@ import java.io.IOException; import java.io.OutputStream; import org.apache.fop.afp.modca.AbstractAFPObject; -import org.apache.fop.afp.modca.AbstractAFPObject.Category; -import org.apache.fop.afp.modca.AbstractAFPObject.Type; import org.apache.fop.afp.util.BinaryUtils; /** @@ -49,13 +47,12 @@ import org.apache.fop.afp.util.BinaryUtils; */ public class ImageRasterData extends AbstractAFPObject { - /** - * The image raster data - */ + /** the image raster data */ private final byte[] rasterData; /** * Constructor for the image raster data object + * * @param data The raster image data */ public ImageRasterData(byte[] data) { diff --git a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java index f34ac7d00..f1b76c447 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java @@ -82,13 +82,13 @@ public abstract class AbstractAFPObject implements Streamable { } /** - * Help method to write a set of AFPObjects to the AFP datastream. + * Writes a collection of Streamable to the AFP Datastream. * * @param objects a list of AFPObjects * @param os The stream to write to * @throws java.io.IOException an I/O exception of some sort has occurred. */ - protected void writeObjects(Collection/**/ objects, OutputStream os) + protected void writeObjects(Collection/**/ objects, OutputStream os) throws IOException { if (objects != null && objects.size() > 0) { Iterator it = objects.iterator(); @@ -103,14 +103,14 @@ public abstract class AbstractAFPObject implements Streamable { } /** - * Reads data chunks from an inputstream - * and then formats them with a structured header to a given outputstream + * Reads data chunks from an InputStream + * and then formats them with a structured header to a given OutputStream * * @param dataHeader the header data * @param lengthOffset offset of length field in data chunk * @param maxChunkLength the maximum chunk length - * @param inputStream the inputstream to read from - * @param outputStream the outputstream to write to + * @param inputStream the InputStream to read from + * @param outputStream the OutputStream to write to * @throws IOException thrown if an I/O exception of some sort has occurred. */ protected static void copyChunks(byte[] dataHeader, int lengthOffset, diff --git a/src/java/org/apache/fop/afp/modca/AbstractDataObject.java b/src/java/org/apache/fop/afp/modca/AbstractDataObject.java index c7b987a9e..ec1b45be6 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractDataObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractDataObject.java @@ -26,13 +26,15 @@ import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; import org.apache.fop.afp.AFPResourceInfo; import org.apache.fop.afp.AFPResourceLevel; +import org.apache.fop.afp.Completable; import org.apache.fop.afp.Factory; +import org.apache.fop.afp.Startable; /** * Abstract base class used by the ImageObject and GraphicsObject which both * have define an ObjectEnvironmentGroup */ -public abstract class AbstractDataObject extends AbstractNamedAFPObject { +public abstract class AbstractDataObject extends AbstractNamedAFPObject implements Startable, Completable { /** the object environment group */ protected ObjectEnvironmentGroup objectEnvironmentGroup = null; @@ -40,6 +42,12 @@ public abstract class AbstractDataObject extends AbstractNamedAFPObject { /** the object factory */ protected final Factory factory; + /** the completion status of this object */ + private boolean complete; + + /** the starting status of this object */ + private boolean started; + /** * Named constructor * @@ -97,12 +105,35 @@ public abstract class AbstractDataObject extends AbstractNamedAFPObject { return objectEnvironmentGroup; } + /** {@inheritDoc} */ + protected void writeStart(OutputStream os) throws IOException { + setStarted(true); + } + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { - super.writeContent(os); // write triplets if (objectEnvironmentGroup != null) { objectEnvironmentGroup.writeToStream(os); } } + /** {@inheritDoc} */ + public void setStarted(boolean started) { + this.started = started; + } + + /** {@inheritDoc} */ + public boolean isStarted() { + return this.started; + } + + /** {@inheritDoc} */ + public void setComplete(boolean complete) { + this.complete = complete; + } + + /** {@inheritDoc} */ + public boolean isComplete() { + return this.complete; + } } diff --git a/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java b/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java index c3c158825..4e0dbc349 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java @@ -66,7 +66,7 @@ public abstract class AbstractNamedAFPObject extends AbstractTripletStructuredOb * * @return the name as a byte array in EBCIDIC encoding */ - protected byte[] getNameBytes() { + public byte[] getNameBytes() { int afpNameLen = getNameLength(); int nameLen = name.length(); if (nameLen < afpNameLen) { @@ -103,7 +103,16 @@ public abstract class AbstractNamedAFPObject extends AbstractTripletStructuredOb * @return the name of this object */ public String getName() { - return name; + return this.name; + } + + /** + * Sets the name of this object + * + * @param name the object name + */ + public void setName(String name) { + this.name = name; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/afp/modca/AbstractPageObject.java b/src/java/org/apache/fop/afp/modca/AbstractPageObject.java index d7252c390..c7559a87f 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractPageObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractPageObject.java @@ -25,6 +25,7 @@ import java.util.List; import org.apache.fop.afp.AFPLineDataInfo; import org.apache.fop.afp.AFPTextDataInfo; +import org.apache.fop.afp.Completable; import org.apache.fop.afp.Factory; import org.apache.fop.afp.fonts.AFPFont; @@ -48,7 +49,7 @@ import org.apache.fop.afp.fonts.AFPFont; * in page state. * */ -public abstract class AbstractPageObject extends AbstractNamedAFPObject { +public abstract class AbstractPageObject extends AbstractNamedAFPObject implements Completable { /** The active environment group for the page */ protected ActiveEnvironmentGroup activeEnvironmentGroup = null; @@ -183,7 +184,7 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { if (currentPresentationTextObject != null) { currentPresentationTextObject.endControlSequence(); } - complete = true; + setComplete(true); } /** @@ -293,15 +294,6 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { return activeEnvironmentGroup; } - /** - * Returns an indication if the page is complete - * - * @return whether this page is complete - */ - public boolean isComplete() { - return complete; - } - /** * Returns the height of the page * @@ -343,4 +335,14 @@ public abstract class AbstractPageObject extends AbstractNamedAFPObject { public void addObject(Object obj) { objects.add(obj); } + + /** {@inheritDoc} */ + public void setComplete(boolean complete) { + this.complete = complete; + } + + /** {@inheritDoc} */ + public boolean isComplete() { + return this.complete; + } } diff --git a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java index 860c6b56a..9dcd56277 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java +++ b/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java @@ -24,6 +24,7 @@ import java.io.OutputStream; import java.util.Collection; import java.util.Iterator; +import org.apache.fop.afp.Completable; import org.apache.fop.afp.Factory; import org.apache.fop.afp.Streamable; @@ -109,7 +110,7 @@ implements Streamable { * * @return the resource group in this resource group container */ - protected ResourceGroup getResourceGroup() { + public ResourceGroup getResourceGroup() { if (resourceGroup == null) { resourceGroup = factory.createResourceGroup(); } @@ -162,6 +163,6 @@ implements Streamable { * @return true if this object can be written */ protected boolean canWrite(AbstractAFPObject obj) { - return obj instanceof AbstractPageObject && ((AbstractPageObject)obj).isComplete(); + return obj instanceof AbstractPageObject && ((Completable)obj).isComplete(); } } diff --git a/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java b/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java index c1686d07c..a14af2967 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java @@ -31,6 +31,9 @@ import org.apache.fop.afp.modca.triplets.CommentTriplet; import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; import org.apache.fop.afp.modca.triplets.ObjectClassificationTriplet; +/** + * A MODCA structured object base class providing support for Triplets + */ public class AbstractTripletStructuredObject extends AbstractStructuredObject { /** list of object triplets */ diff --git a/src/java/org/apache/fop/afp/modca/DataStream.java b/src/java/org/apache/fop/afp/modca/DataStream.java deleted file mode 100644 index 00d2b6f16..000000000 --- a/src/java/org/apache/fop/afp/modca/DataStream.java +++ /dev/null @@ -1,593 +0,0 @@ -/* - * 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.afp.modca; - -import java.awt.Color; -import java.awt.Point; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Iterator; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.afp.AFPLineDataInfo; -import org.apache.fop.afp.AFPPaintingState; -import org.apache.fop.afp.AFPResourceLevel; -import org.apache.fop.afp.AFPTextDataInfo; -import org.apache.fop.afp.Factory; -import org.apache.fop.afp.fonts.AFPFont; -import org.apache.fop.afp.fonts.AFPFontAttributes; -import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet; - -/** - * A data stream is a continuous ordered stream of data elements and objects - * conforming to a given format. Application programs can generate data streams - * destined for a presentation service, archive library, presentation device or - * another application program. The strategic presentation data stream - * architectures used is Mixed Object Document Content Architecture (MO:DCA). - * - * The MO:DCA architecture defines the data stream used by applications to - * describe documents and object envelopes for interchange with other - * applications and application services. Documents defined in the MO:DCA format - * may be archived in a database, then later retrieved, viewed, annotated and - * printed in local or distributed systems environments. Presentation fidelity - * is accommodated by including resource objects in the documents that reference - * them. - */ -public class DataStream { - - /** Static logging instance */ - protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp.modca"); - - /** Boolean completion indicator */ - private boolean complete = false; - - /** The AFP document object */ - private Document document = null; - - /** The current page group object */ - private PageGroup currentPageGroup = null; - - /** The current page object */ - private PageObject currentPageObject = null; - - /** The current overlay object */ - private Overlay currentOverlay = null; - - /** The current page */ - private AbstractPageObject currentPage = null; - - /** The MO:DCA interchange set in use (default to MO:DCA-P IS/2 set) */ - private InterchangeSet interchangeSet - = InterchangeSet.valueOf(InterchangeSet.MODCA_PRESENTATION_INTERCHANGE_SET_2); - - private final Factory factory; - - private OutputStream outputStream; - - /** the afp painting state */ - private final AFPPaintingState state; - - /** - * Default constructor for the AFPDocumentStream. - * - * @param factory the resource factory - * @param state the AFP painting state - * @param outputStream the outputstream to write to - */ - public DataStream(Factory factory, AFPPaintingState state, OutputStream outputStream) { - this.state = state; - this.factory = factory; - this.outputStream = outputStream; - } - - /** - * Returns the outputstream - * - * @return the outputstream - */ - public OutputStream getOutputStream() { - return this.outputStream; - } - - /** - * Returns the document object - * - * @return the document object - */ - private Document getDocument() { - return this.document; - } - - /** - * Returns the current page - * - * @return the current page - */ - public AbstractPageObject getCurrentPage() { - return this.currentPage; - } - - /** - * The document is started by invoking this method which creates an instance - * of the AFP Document object. - * - * @param name - * the name of this document. - */ - public void setDocumentName(String name) { - if (name != null) { - getDocument().setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_BEGIN_DOCUMENT_REF, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, name); - } - } - - /** {@inheritDoc} */ - public void endDocument() throws IOException { - if (complete) { - String msg = "Invalid state - document already ended."; - log.warn("endDocument():: " + msg); - throw new IllegalStateException(msg); - } - - if (currentPageObject != null) { - // End the current page if necessary - endPage(); - } - - if (currentPageGroup != null) { - // End the current page group if necessary - endPageGroup(); - } - - // Write out document - if (document != null) { - document.endDocument(); - document.writeToStream(this.outputStream); - } - - this.outputStream.flush(); - - this.complete = true; - - this.document = null; - - this.outputStream = null; - } - - /** - * Start a new page. When processing has finished on the current page, the - * {@link #endPage()}method must be invoked to mark the page ending. - * - * @param pageWidth - * the width of the page - * @param pageHeight - * the height of the page - * @param pageRotation - * the rotation of the page - * @param pageWidthRes - * the width resolution of the page - * @param pageHeightRes - * the height resolution of the page - */ - public void startPage(int pageWidth, int pageHeight, int pageRotation, - int pageWidthRes, int pageHeightRes) { - currentPageObject = factory.createPage(pageWidth, pageHeight, - pageRotation, pageWidthRes, pageHeightRes); - currentPage = currentPageObject; - currentOverlay = null; - } - - /** - * Start a new overlay. When processing has finished on the current overlay, - * the {@link #endOverlay()}method must be invoked to mark the overlay - * ending. - * - * @param x - * the x position of the overlay on the page - * @param y - * the y position of the overlay on the page - * @param width - * the width of the overlay - * @param height - * the height of the overlay - * @param widthRes - * the width resolution of the overlay - * @param heightRes - * the height resolution of the overlay - * @param overlayRotation - * the rotation of the overlay - */ - public void startOverlay(int x, int y, int width, int height, int widthRes, - int heightRes, int overlayRotation) { - this.currentOverlay = factory.createOverlay( - width, height, widthRes, heightRes, overlayRotation); - - String overlayName = currentOverlay.getName(); - currentPageObject.createIncludePageOverlay(overlayName, x, y, 0); - currentPage = currentOverlay; - } - - /** - * Helper method to mark the end of the current overlay. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void endOverlay() throws IOException { - if (currentOverlay != null) { - currentOverlay.endPage(); - currentOverlay = null; - currentPage = currentPageObject; - } - } - - /** - * Helper method to save the current page. - * - * @return current page object that was saved - */ - public PageObject savePage() { - PageObject pageObject = currentPageObject; - if (currentPageGroup != null) { - currentPageGroup.addPage(currentPageObject); - } else { - document.addPage(currentPageObject); - } - currentPageObject = null; - currentPage = null; - return pageObject; - } - - /** - * Helper method to restore the current page. - * - * @param pageObject - * page object - */ - public void restorePage(PageObject pageObject) { - currentPageObject = pageObject; - currentPage = pageObject; - } - - /** - * Helper method to mark the end of the current page. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void endPage() throws IOException { - if (currentPageObject != null) { - currentPageObject.endPage(); - if (currentPageGroup != null) { - currentPageGroup.addPage(currentPageObject); - currentPageGroup.writeToStream(this.outputStream); - } else { - document.addPage(currentPageObject); - document.writeToStream(this.outputStream); - } - currentPageObject = null; - currentPage = null; - } - } - - /** - * Creates the given page fonts in the current page - * - * @param pageFonts - * a collection of AFP font attributes - */ - public void addFontsToCurrentPage(Map pageFonts) { - Iterator iter = pageFonts.values().iterator(); - while (iter.hasNext()) { - AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter - .next(); - createFont(afpFontAttributes.getFontReference(), afpFontAttributes - .getFont(), afpFontAttributes.getPointSize()); - } - } - - /** - * Helper method to create a map coded font object on the current page, this - * method delegates the construction of the map coded font object to the - * active environment group on the current page. - * - * @param fontReference - * the font number used as the resource identifier - * @param font - * the font - * @param size - * the point size of the font - */ - public void createFont(int fontReference, AFPFont font, int size) { - currentPage.createFont(fontReference, font, size); - } - - /** - * Returns a point on the current page - * - * @param x the X-coordinate - * @param y the Y-coordinate - * @return a point on the current page - */ - private Point getPoint(int x, int y) { - Point p = new Point(); - int rotation = state.getRotation(); - switch (rotation) { - case 90: - p.x = y; - p.y = currentPage.getWidth() - x; - break; - case 180: - p.x = currentPage.getWidth() - x; - p.y = currentPage.getHeight() - y; - break; - case 270: - p.x = currentPage.getHeight() - y; - p.y = x; - break; - default: - p.x = x; - p.y = y; - break; - } - return p; - } - - /** - * Helper method to create text on the current page, this method delegates - * to the current presentation text object in order to construct the text. - * - * @param textDataInfo - * the afp text data - */ - public void createText(AFPTextDataInfo textDataInfo) { - int rotation = state.getRotation(); - if (rotation != 0) { - textDataInfo.setRotation(rotation); - Point p = getPoint(textDataInfo.getX(), textDataInfo.getY()); - textDataInfo.setX(p.x); - textDataInfo.setY(p.y); - } - currentPage.createText(textDataInfo); - } - - /** - * Method to create a line on the current page. - * - * @param lineDataInfo the line data information. - */ - public void createLine(AFPLineDataInfo lineDataInfo) { - currentPage.createLine(lineDataInfo); - } - - /** - * This method will create shading on the page using the specified - * coordinates (the shading contrast is controlled via the red, green, blue - * parameters, by converting this to grey scale). - * - * @param x - * the x coordinate of the shading - * @param y - * the y coordinate of the shading - * @param w - * the width of the shaded area - * @param h - * the height of the shaded area - * @param col - * the shading color - */ - public void createShading(int x, int y, int w, int h, Color col) { - currentPageObject.createShading(x, y, w, h, col.getRed(), col.getGreen(), col.getBlue()); - } - - /** - * Helper method which allows creation of the MPO object, via the AEG. And - * the IPO via the Page. (See actual object for descriptions.) - * - * @param name - * the name of the static overlay - */ - public void createIncludePageOverlay(String name) { - currentPageObject.createIncludePageOverlay(name, 0, 0, state.getRotation()); - currentPageObject.getActiveEnvironmentGroup().createOverlay(name); - } - - /** - * Helper method which allows creation of the IMM object. - * - * @param name - * the name of the medium map - */ - public void createInvokeMediumMap(String name) { - currentPageGroup.createInvokeMediumMap(name); - } - - /** - * Creates an IncludePageSegment on the current page. - * - * @param name - * the name of the include page segment - * @param x - * the x coordinate for the overlay - * @param y - * the y coordinate for the overlay - */ - public void createIncludePageSegment(String name, int x, int y) { - int xOrigin; - int yOrigin; - int orientation = state.getRotation(); - switch (orientation) { - case 90: - xOrigin = currentPage.getWidth() - y; - yOrigin = x; - break; - case 180: - xOrigin = currentPage.getWidth() - x; - yOrigin = currentPage.getHeight() - y; - break; - case 270: - xOrigin = y; - yOrigin = currentPage.getHeight() - x; - break; - default: - xOrigin = x; - yOrigin = y; - break; - } - currentPage.createIncludePageSegment(name, xOrigin, yOrigin); - } - - /** - * Creates a TagLogicalElement on the current page. - * - * @param attributes - * the array of key value pairs. - */ - public void createPageTagLogicalElement(TagLogicalElementBean[] attributes) { - for (int i = 0; i < attributes.length; i++) { - String name = attributes[i].getKey(); - String value = attributes[i].getValue(); - currentPage.createTagLogicalElement(name, value); - } - } - - /** - * Creates a TagLogicalElement on the current page group. - * - * @param attributes - * the array of key value pairs. - */ - public void createPageGroupTagLogicalElement(TagLogicalElementBean[] attributes) { - for (int i = 0; i < attributes.length; i++) { - String name = attributes[i].getKey(); - String value = attributes[i].getValue(); - currentPageGroup.createTagLogicalElement(name, value); - } - } - - /** - * Creates a TagLogicalElement on the current page or page group - * - * @param name - * The tag name - * @param value - * The tag value - */ - public void createTagLogicalElement(String name, String value) { - if (currentPageGroup != null) { - currentPageGroup.createTagLogicalElement(name, value); - } else { - currentPage.createTagLogicalElement(name, value); - } - } - - /** - * Creates a NoOperation item - * - * @param content - * byte data - */ - public void createNoOperation(String content) { - currentPage.createNoOperation(content); - } - - /** - * Returns the current page group - * - * @return the current page group - */ - public PageGroup getCurrentPageGroup() { - return this.currentPageGroup; - } - - /** - * Start a new document. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void startDocument() throws IOException { - this.document = factory.createDocument(); - document.writeToStream(this.outputStream); - } - - /** - * Start a new page group. When processing has finished on the current page - * group the {@link #endPageGroup()}method must be invoked to mark the page - * group ending. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void startPageGroup() throws IOException { - endPageGroup(); - this.currentPageGroup = factory.createPageGroup(); - } - - /** - * Helper method to mark the end of the page group. - * - * @throws IOException thrown if an I/O exception of some sort has occurred - */ - public void endPageGroup() throws IOException { - if (currentPageGroup != null) { - currentPageGroup.endPageGroup(); - document.addPageGroup(currentPageGroup); - document.writeToStream(outputStream); - currentPageGroup = null; - } - } - - /** - * Sets the MO:DCA interchange set to use - * - * @param interchangeSet the MO:DCA interchange set - */ - public void setInterchangeSet(InterchangeSet interchangeSet) { - this.interchangeSet = interchangeSet; - } - - /** - * Returns the MO:DCA interchange set in use - * - * @return the MO:DCA interchange set in use - */ - public InterchangeSet getInterchangeSet() { - return this.interchangeSet; - } - - /** - * Returns the resource group for a given resource info - * - * @param level a resource level - * @return a resource group for the given resource info - */ - public ResourceGroup getResourceGroup(AFPResourceLevel level) { - ResourceGroup resourceGroup = null; - if (level.isDocument()) { - resourceGroup = document.getResourceGroup(); - } else if (level.isPageGroup()) { - resourceGroup = currentPageGroup.getResourceGroup(); - } else if (level.isPage()) { - resourceGroup = currentPageObject.getResourceGroup(); - } - return resourceGroup; - } - -} diff --git a/src/java/org/apache/fop/afp/modca/Document.java b/src/java/org/apache/fop/afp/modca/Document.java index bb0dbebe3..02a7b64e1 100644 --- a/src/java/org/apache/fop/afp/modca/Document.java +++ b/src/java/org/apache/fop/afp/modca/Document.java @@ -69,11 +69,7 @@ public final class Document extends AbstractResourceEnvironmentGroupContainer { complete = true; } - /** - * Returns an indication if the page group is complete - * - * @return whether or not this page group is complete - */ + /** {@inheritDoc} */ public boolean isComplete() { return complete; } diff --git a/src/java/org/apache/fop/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/afp/modca/GraphicsObject.java index da6079d33..710e7364b 100644 --- a/src/java/org/apache/fop/afp/modca/GraphicsObject.java +++ b/src/java/org/apache/fop/afp/modca/GraphicsObject.java @@ -22,18 +22,24 @@ package org.apache.fop.afp.modca; import java.awt.Color; import java.io.IOException; import java.io.OutputStream; +import java.util.Iterator; import java.util.List; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.Completable; import org.apache.fop.afp.Factory; +import org.apache.fop.afp.StructuredData; +import org.apache.fop.afp.goca.GraphicsAreaBegin; +import org.apache.fop.afp.goca.GraphicsAreaEnd; import org.apache.fop.afp.goca.GraphicsBox; +import org.apache.fop.afp.goca.GraphicsChainedSegment; +import org.apache.fop.afp.goca.GraphicsCharacterString; import org.apache.fop.afp.goca.GraphicsData; import org.apache.fop.afp.goca.GraphicsFillet; -import org.apache.fop.afp.goca.GraphicsFilletRelative; import org.apache.fop.afp.goca.GraphicsFullArc; +import org.apache.fop.afp.goca.GraphicsImage; import org.apache.fop.afp.goca.GraphicsLine; -import org.apache.fop.afp.goca.GraphicsLineRelative; import org.apache.fop.afp.goca.GraphicsSetArcParameters; import org.apache.fop.afp.goca.GraphicsSetCharacterSet; import org.apache.fop.afp.goca.GraphicsSetCurrentPosition; @@ -41,7 +47,6 @@ import org.apache.fop.afp.goca.GraphicsSetLineType; import org.apache.fop.afp.goca.GraphicsSetLineWidth; import org.apache.fop.afp.goca.GraphicsSetPatternSymbol; import org.apache.fop.afp.goca.GraphicsSetProcessColor; -import org.apache.fop.afp.goca.GraphicsString; /** * Top-level GOCA graphics object. @@ -51,12 +56,27 @@ import org.apache.fop.afp.goca.GraphicsString; public class GraphicsObject extends AbstractDataObject { /** The graphics data */ - private GraphicsData data = null; + private GraphicsData currentData = null; /** list of objects contained within this container */ protected List/**/ objects = new java.util.ArrayList/**/(); + /** the current color */ + private Color currentColor; + + /** the current line type */ + private byte currentLineType; + + /** the current line width */ + private int currentLineWidth; + + /** the current fill pattern */ + private byte currentPatternSymbol; + + /** the current character set */ + private int currentCharacterSet; + /** * Default constructor * @@ -85,13 +105,18 @@ public class GraphicsObject extends AbstractDataObject { } /** {@inheritDoc} */ - public void addObject(StructuredDataObject drawingOrder) { - if (data == null - || (data.getDataLength() + drawingOrder.getDataLength()) - >= GraphicsData.MAX_DATA_LEN) { + public void addObject(StructuredData object) { + if (currentData == null) { newData(); + } else if (currentData.getDataLength() + object.getDataLength() + >= GraphicsData.MAX_DATA_LEN) { + // graphics data full so transfer current incomplete segment to new data + GraphicsChainedSegment currentSegment + = (GraphicsChainedSegment)currentData.removeCurrentSegment(); + currentSegment.setName(newData().createSegmentName()); + currentData.addSegment(currentSegment); } - data.addObject(drawingOrder); + currentData.addObject(object); } /** @@ -100,10 +125,10 @@ public class GraphicsObject extends AbstractDataObject { * @return the current graphics data */ private GraphicsData getData() { - if (this.data == null) { + if (this.currentData == null) { return newData(); } - return this.data; + return this.currentData; } /** @@ -112,9 +137,12 @@ public class GraphicsObject extends AbstractDataObject { * @return a newly created graphics data */ private GraphicsData newData() { - this.data = factory.createGraphicsData(); - objects.add(data); - return data; + if (currentData != null) { + currentData.setComplete(true); + } + this.currentData = factory.createGraphicsData(); + objects.add(currentData); + return currentData; } /** @@ -123,7 +151,10 @@ public class GraphicsObject extends AbstractDataObject { * @param color the active color to use */ public void setColor(Color color) { - addObject(new GraphicsSetProcessColor(color)); + if (!color.equals(currentColor)) { + this.currentColor = color; + addObject(new GraphicsSetProcessColor(color)); + } } /** @@ -138,43 +169,60 @@ public class GraphicsObject extends AbstractDataObject { /** * Sets the line width * - * @param multiplier the line width multiplier + * @param lineWidth the line width multiplier */ - public void setLineWidth(int multiplier) { - GraphicsSetLineWidth graphicsSetLineWidth = new GraphicsSetLineWidth(multiplier); - addObject(graphicsSetLineWidth); + public void setLineWidth(int lineWidth) { + if (lineWidth != currentLineWidth) { + currentLineWidth = lineWidth; + addObject(new GraphicsSetLineWidth(lineWidth)); + } } /** * Sets the line type * - * @param type the line type + * @param lineType the line type */ - public void setLineType(byte type) { - GraphicsSetLineType graphicsSetLineType = new GraphicsSetLineType(type); - addObject(graphicsSetLineType); + public void setLineType(byte lineType) { + if (lineType != currentLineType) { + currentLineType = lineType; + addObject(new GraphicsSetLineType(lineType)); + } } /** - * Sets whether to fill the next shape + * Sets whether the following shape is to be filled * - * @param fill whether to fill the next shape + * @param fill true if the following shape is to be filled */ public void setFill(boolean fill) { - GraphicsSetPatternSymbol graphicsSetPattern = new GraphicsSetPatternSymbol( - fill ? GraphicsSetPatternSymbol.SOLID_FILL - : GraphicsSetPatternSymbol.NO_FILL - ); - addObject(graphicsSetPattern); + setPatternSymbol(fill ? + GraphicsSetPatternSymbol.SOLID_FILL : + GraphicsSetPatternSymbol.NO_FILL); + } + + /** + * Sets the fill pattern of the next shape + * + * @param the fill pattern of the next shape + */ + public void setPatternSymbol(byte patternSymbol) { + if (currentPatternSymbol != patternSymbol) { + currentPatternSymbol = patternSymbol; + addObject(new GraphicsSetPatternSymbol(patternSymbol)); + } } /** * Sets the character set to use * - * @param fontReference the character set (font) reference + * @param characterSet the character set (font) reference */ - public void setCharacterSet(int fontReference) { - addObject(new GraphicsSetCharacterSet(fontReference)); + public void setCharacterSet(int characterSet) { + if (currentCharacterSet != characterSet) { + currentCharacterSet = characterSet; + addObject(new GraphicsSetCharacterSet(characterSet)); + } } /** @@ -193,11 +241,7 @@ public class GraphicsObject extends AbstractDataObject { * @param relative relative true for a line at current position (relative to) */ public void addLine(int[] coords, boolean relative) { - if (relative) { - addObject(new GraphicsLineRelative(coords)); - } else { - addObject(new GraphicsLine(coords)); - } + addObject(new GraphicsLine(coords, relative)); } /** @@ -222,14 +266,10 @@ public class GraphicsObject extends AbstractDataObject { * Adds a fillet (curve) at the given coordinates * * @param coords the x/y coordinates - * @param relative relative true for a fillet at current position (relative to) + * @param relative relative true for a fillet (curve) at current position (relative to) */ public void addFillet(int[] coords, boolean relative) { - if (relative) { - addObject(new GraphicsFilletRelative(coords)); - } else { - addObject(new GraphicsFillet(coords)); - } + addObject(new GraphicsFillet(coords, relative)); } /** @@ -245,7 +285,7 @@ public class GraphicsObject extends AbstractDataObject { } /** - * Adds an arc + * Adds a full arc * * @param x the x coordinate * @param y the y coordinate @@ -256,18 +296,18 @@ public class GraphicsObject extends AbstractDataObject { addObject(new GraphicsFullArc(x, y, mh, mhr)); } -// /** -// * Adds an image -// * -// * @param x the x coordinate -// * @param y the y coordinate -// * @param width the image width -// * @param height the image height -// * @param imgData the image data -// */ -// public void addImage(int x, int y, int width, int height, byte[] imgData) { -// addObject(new GraphicsImage(x, y, width, height, imgData)); -// } + /** + * Adds an image + * + * @param x the x coordinate + * @param y the y coordinate + * @param width the image width + * @param height the image height + * @param imgData the image data + */ + public void addImage(int x, int y, int width, int height, byte[] imgData) { + addObject(new GraphicsImage(x, y, width, height, imgData)); + } /** * Adds a string @@ -277,26 +317,21 @@ public class GraphicsObject extends AbstractDataObject { * @param y the y coordinate */ public void addString(String str, int x, int y) { - addObject(new GraphicsString(str, x, y)); + addObject(new GraphicsCharacterString(str, x, y)); } /** * Begins a graphics area (start of fill) */ public void beginArea() { - if (data == null) { - newData(); - } - data.beginArea(); + addObject(new GraphicsAreaBegin()); } /** * Ends a graphics area (end of fill) */ public void endArea() { - if (data != null) { - data.endArea(); - } + addObject(new GraphicsAreaEnd()); } /** {@inheritDoc} */ @@ -311,8 +346,19 @@ public class GraphicsObject extends AbstractDataObject { getData().newSegment(); } + /** {@inheritDoc} */ + public void setComplete(boolean complete) { + Iterator it = objects.iterator(); + while (it.hasNext()) { + Completable completedObject = (Completable)it.next(); + completedObject.setComplete(true); + } + super.setComplete(complete); + } + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { + super.writeStart(os); byte[] data = new byte[17]; copySF(data, Type.BEGIN, Category.GRAPHICS); os.write(data); @@ -321,7 +367,7 @@ public class GraphicsObject extends AbstractDataObject { /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); - super.writeObjects(objects, os); + writeObjects(objects, os); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/afp/modca/MapCodedFont.java b/src/java/org/apache/fop/afp/modca/MapCodedFont.java index 01e9abc6f..54b4d1796 100644 --- a/src/java/org/apache/fop/afp/modca/MapCodedFont.java +++ b/src/java/org/apache/fop/afp/modca/MapCodedFont.java @@ -43,14 +43,12 @@ import org.apache.fop.afp.util.BinaryUtils; */ public class MapCodedFont extends AbstractStructuredObject { - /** - * The collection of map coded fonts (maximum of 254) - */ + /** the collection of map coded fonts (maximum of 254) */ private final List/**/ fontList = new java.util.ArrayList/**/(); /** - * Constructor for the MapCodedFont + * Main constructor */ public MapCodedFont() { } diff --git a/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java index 8cb610d9e..883a5446d 100644 --- a/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java +++ b/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java @@ -38,13 +38,13 @@ import org.apache.fop.afp.util.BinaryUtils; public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { /** the PresentationEnvironmentControl for the object environment group */ - private PresentationEnvironmentControl presentationEnvironmentControl = null; + private PresentationEnvironmentControl presentationEnvironmentControl; /** the ObjectAreaDescriptor for the object environment group */ - private ObjectAreaDescriptor objectAreaDescriptor = null; + private ObjectAreaDescriptor objectAreaDescriptor; /** the ObjectAreaPosition for the object environment group */ - private ObjectAreaPosition objectAreaPosition = null; + private ObjectAreaPosition objectAreaPosition; /** the DataDescriptor for the object environment group */ private AbstractDescriptor dataDescriptor; @@ -95,6 +95,8 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { data[2] = len[1]; os.write(data); + + writeTriplets(os); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/afp/modca/PageGroup.java b/src/java/org/apache/fop/afp/modca/PageGroup.java index 47e378d72..13be9745e 100644 --- a/src/java/org/apache/fop/afp/modca/PageGroup.java +++ b/src/java/org/apache/fop/afp/modca/PageGroup.java @@ -74,7 +74,7 @@ public class PageGroup extends AbstractResourceEnvironmentGroupContainer { /** * Method to mark the end of the page group. */ - protected void endPageGroup() { + public void endPageGroup() { complete = true; } diff --git a/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java index cb0653ddd..2e4f57314 100644 --- a/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java +++ b/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in 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,34 +23,27 @@ import java.io.IOException; import java.io.OutputStream; import java.util.List; +import org.apache.fop.afp.Completable; + /** * A Resource Environment Group contains a set of resources for a document * or for a group of pages in a document. */ -public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup { - /** - * Default name for the resource group - */ +public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup implements Completable { + + /** default name for the resource group */ private static final String DEFAULT_NAME = "REG00001"; - /** - * The maps data resources contained in this resource environment group - */ + /** the maps data resources contained in this resource environment group */ private List/**/ mapDataResources = null; - - /** - * The maps page overlays contained in this resource environment group - */ + + /** the maps page overlays contained in this resource environment group */ private List mapPageOverlays = null; - - /** - * The pre-process presentation objects contained in this resource environment group - */ + + /** the pre-process presentation objects contained in this resource environment group */ private List/**/ preProcessPresentationObjects = null; - /** - * The resource environment group state - */ + /** the resource environment group state */ private boolean complete = false; /** @@ -100,16 +93,7 @@ public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup { // createOverlay(obj.get); // getPreprocessPresentationObjects().add(new PreprocessPresentationObject(obj)); // } - - /** - * Returns an indication if the resource environment group is complete - * - * @return whether or not this resource environment group is complete or not - */ - public boolean isComplete() { - return complete; - } - + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { byte[] data = new byte[17]; @@ -131,4 +115,14 @@ public class ResourceEnvironmentGroup extends AbstractEnvironmentGroup { writeObjects(preProcessPresentationObjects, os); } + /** {@inheritDoc} */ + public void setComplete(boolean complete) { + this.complete = complete; + } + + /** {@inheritDoc} */ + public boolean isComplete() { + return complete; + } + } diff --git a/src/java/org/apache/fop/afp/modca/StreamedResourceGroup.java b/src/java/org/apache/fop/afp/modca/StreamedResourceGroup.java index d6ab741b6..65df33ae4 100644 --- a/src/java/org/apache/fop/afp/modca/StreamedResourceGroup.java +++ b/src/java/org/apache/fop/afp/modca/StreamedResourceGroup.java @@ -22,10 +22,12 @@ package org.apache.fop.afp.modca; import java.io.IOException; import java.io.OutputStream; +import org.apache.fop.afp.Completable; + /** * A print-file resource group */ -public class StreamedResourceGroup extends ResourceGroup { +public class StreamedResourceGroup extends ResourceGroup implements Completable { /** the outputstream to write to */ private final OutputStream os; @@ -72,15 +74,6 @@ public class StreamedResourceGroup extends ResourceGroup { complete = true; } - /** - * Returns true if this resource group is complete - * - * @return true if this resource group is complete - */ - public boolean isComplete() { - return this.complete; - } - /** * Returns the outputstream * @@ -89,4 +82,15 @@ public class StreamedResourceGroup extends ResourceGroup { public OutputStream getOutputStream() { return this.os; } + + /** {@inheritDoc} */ + public void setComplete(boolean complete) { + this.complete = complete; + } + + /** {@inheritDoc} */ + public boolean isComplete() { + return this.complete; + } + } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/StructuredDataObject.java b/src/java/org/apache/fop/afp/modca/StructuredDataObject.java deleted file mode 100644 index f95810ff2..000000000 --- a/src/java/org/apache/fop/afp/modca/StructuredDataObject.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.afp.modca; - -/** - * An AFP object which is able to know its own data length before writeToStream() - */ -public interface StructuredDataObject { - - /** - * Returns the data length of this structured field - * - * @return the data length of this structured field - */ - int getDataLength(); -} \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/modca/triplets/AbstractTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/AbstractTriplet.java index 63914eb73..4e75d4204 100644 --- a/src/java/org/apache/fop/afp/modca/triplets/AbstractTriplet.java +++ b/src/java/org/apache/fop/afp/modca/triplets/AbstractTriplet.java @@ -20,12 +20,12 @@ package org.apache.fop.afp.modca.triplets; import org.apache.fop.afp.Streamable; -import org.apache.fop.afp.modca.StructuredDataObject; +import org.apache.fop.afp.StructuredData; /** * A simple implementation of a MOD:CA triplet */ -public abstract class AbstractTriplet implements Streamable, StructuredDataObject { +public abstract class AbstractTriplet implements Streamable, StructuredData { public static final byte CODED_GRAPHIC_CHARACTER_SET_GLOBAL_IDENTIFIER = 0x01; /** Triplet identifiers */ diff --git a/src/java/org/apache/fop/afp/modca/triplets/DescriptorPositionTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/DescriptorPositionTriplet.java index 61b279b5c..cff6400af 100644 --- a/src/java/org/apache/fop/afp/modca/triplets/DescriptorPositionTriplet.java +++ b/src/java/org/apache/fop/afp/modca/triplets/DescriptorPositionTriplet.java @@ -22,6 +22,9 @@ package org.apache.fop.afp.modca.triplets; import java.io.IOException; import java.io.OutputStream; +/** + * Associates an ObjectAreaPosition with and ObjectAreaDescriptor structured field + */ public class DescriptorPositionTriplet extends AbstractTriplet { private final byte oapId; diff --git a/src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java b/src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java index ecc12122d..e4b13177d 100644 --- a/src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java +++ b/src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java @@ -22,7 +22,7 @@ package org.apache.fop.afp.modca.triplets; import java.io.IOException; import java.io.OutputStream; -/** resource object type triplet */ +/** A Resource Object Type Triplet */ public class ResourceObjectTypeTriplet extends AbstractTriplet { private static final byte RESOURCE_OBJECT = 0x21; diff --git a/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java b/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java index 039c1ab91..48c1001ef 100644 --- a/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java +++ b/src/java/org/apache/fop/afp/svg/AFPBridgeContext.java @@ -31,6 +31,9 @@ import org.apache.fop.svg.AbstractFOPBridgeContext; import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; +/** + * An AFP specific implementation of a Batik BridgeContext + */ public class AFPBridgeContext extends AbstractFOPBridgeContext { private final AFPGraphics2D g2d; diff --git a/src/java/org/apache/fop/afp/svg/AFPImageElementBridge.java b/src/java/org/apache/fop/afp/svg/AFPImageElementBridge.java index de677e7ab..63661940d 100644 --- a/src/java/org/apache/fop/afp/svg/AFPImageElementBridge.java +++ b/src/java/org/apache/fop/afp/svg/AFPImageElementBridge.java @@ -22,6 +22,9 @@ package org.apache.fop.afp.svg; import org.apache.fop.svg.AbstractFOPImageElementBridge; import org.apache.xmlgraphics.image.loader.ImageFlavor; +/** + * An AFP specific implementation of a Batik SVGImageElementBridge + */ public class AFPImageElementBridge extends AbstractFOPImageElementBridge { private final ImageFlavor[] supportedFlavors = new ImageFlavor[] diff --git a/src/java/org/apache/fop/afp/svg/package.html b/src/java/org/apache/fop/afp/svg/package.html new file mode 100644 index 000000000..bd24b246f --- /dev/null +++ b/src/java/org/apache/fop/afp/svg/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.afp.modca.svg Package + +

      Contains a collection of AFP specific Batik bridges.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/util/package.html b/src/java/org/apache/fop/afp/util/package.html new file mode 100644 index 000000000..525bdbe2a --- /dev/null +++ b/src/java/org/apache/fop/afp/util/package.html @@ -0,0 +1,23 @@ + + + +org.apache.fop.afp.modca.triplets Package + +

      Contains a collection of useful AFP utility classes.

      + + \ No newline at end of file diff --git a/src/java/org/apache/fop/pdf/PDFPaintingState.java b/src/java/org/apache/fop/pdf/PDFPaintingState.java index 7dd876c25..11dfc635a 100644 --- a/src/java/org/apache/fop/pdf/PDFPaintingState.java +++ b/src/java/org/apache/fop/pdf/PDFPaintingState.java @@ -170,7 +170,7 @@ public class PDFPaintingState extends org.apache.fop.util.AbstractPaintingState * This call should be used when the q operator is used * so that the state is known when popped. */ - public void push() { + public void save() { AbstractData data = getData(); AbstractData copy = (AbstractData)data.clone(); data.clearTransform(); diff --git a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java index 8e43d1c28..becafda23 100644 --- a/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java @@ -61,7 +61,7 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { final boolean textAsShapes = false; AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes); - paintingState.push(); + paintingState.save(); //Fallback solution: Paint to a BufferedImage if (afpInfo.paintAsBitmap()) { @@ -95,7 +95,7 @@ public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter { resourceManager.createObject(graphicsObjectInfo); } - paintingState.pop(); + paintingState.restore(); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/AFPInfo.java b/src/java/org/apache/fop/render/afp/AFPInfo.java index 59050b66d..fb1ec87a8 100644 --- a/src/java/org/apache/fop/render/afp/AFPInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPInfo.java @@ -215,10 +215,10 @@ public final class AFPInfo { /** * Sets the AFP state * - * @param state the AFP state + * @param paintingState the AFP state */ - public void setPaintingState(AFPPaintingState state) { - this.paintingState = state; + public void setPaintingState(AFPPaintingState paintingState) { + this.paintingState = paintingState; } /** diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index b85dd96f9..918c67e33 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -41,13 +41,13 @@ import org.apache.fop.afp.AFPRectanglePainter; import org.apache.fop.afp.AFPResourceManager; import org.apache.fop.afp.AFPTextDataInfo; import org.apache.fop.afp.AFPUnitConverter; -import org.apache.fop.afp.BorderPaintInfo; -import org.apache.fop.afp.RectanglePaintInfo; +import org.apache.fop.afp.BorderPaintingInfo; +import org.apache.fop.afp.DataStream; +import org.apache.fop.afp.RectanglePaintingInfo; import org.apache.fop.afp.fonts.AFPFont; import org.apache.fop.afp.fonts.AFPFontAttributes; import org.apache.fop.afp.fonts.AFPFontCollection; import org.apache.fop.afp.fonts.AFPPageFonts; -import org.apache.fop.afp.modca.DataStream; import org.apache.fop.afp.modca.PageObject; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; @@ -171,9 +171,9 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { */ public AFPRenderer() { super(); + this.imageHandlerRegistry = new AFPImageHandlerRegistry(); this.resourceManager = new AFPResourceManager(); this.paintingState = new AFPPaintingState(); - this.imageHandlerRegistry = new AFPImageHandlerRegistry(); this.unitConv = paintingState.getUnitConverter(); } @@ -335,13 +335,13 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { - BorderPaintInfo borderPaintInfo = new BorderPaintInfo(x1, y1, x2, y2, horz, style, col); + BorderPaintingInfo borderPaintInfo = new BorderPaintingInfo(x1, y1, x2, y2, horz, style, col); borderPainter.paint(borderPaintInfo); } /** {@inheritDoc} */ public void fillRect(float x, float y, float width, float height) { - RectanglePaintInfo rectanglePaintInfo = new RectanglePaintInfo(x, y, width, height); + RectanglePaintingInfo rectanglePaintInfo = new RectanglePaintingInfo(x, y, width, height); rectanglePainter.paint(rectanglePaintInfo); } @@ -485,23 +485,23 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ public void restoreStateStackAfterBreakOut(List breakOutList) { log.debug("Block.FIXED --> restoring context after break-out"); - paintingState.pushAll(breakOutList); + paintingState.saveAll(breakOutList); } /** {@inheritDoc} */ protected List breakOutOfStateStack() { log.debug("Block.FIXED --> break out"); - return paintingState.popAll(); + return paintingState.restoreAll(); } /** {@inheritDoc} */ public void saveGraphicsState() { - paintingState.push(); + paintingState.save(); } /** {@inheritDoc} */ public void restoreGraphicsState() { - paintingState.pop(); + paintingState.restore(); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index bf74b4053..9deea77b4 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -125,7 +125,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { int height = afpInfo.getHeight(); int resolution = afpInfo.getResolution(); - paintingState.push(); // save + paintingState.save(); // save AFPObjectAreaInfo objectAreaInfo = createObjectAreaInfo(paintingState, x, y, width, height, resolution); @@ -140,7 +140,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { AFPResourceManager resourceManager = afpInfo.getResourceManager(); resourceManager.createObject(graphicsObjectInfo); - paintingState.pop(); // resume + paintingState.restore(); // resume } private AFPObjectAreaInfo createObjectAreaInfo(AFPPaintingState paintingState, diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index ba3d89195..e31f1eaea 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -640,7 +640,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** {@inheritDoc} */ protected void saveGraphicsState() { endTextObject(); - paintingState.push(); + paintingState.save(); currentStream.add("q\n"); } @@ -648,7 +648,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { endTextObject(); currentStream.add("Q\n"); if (popState) { - paintingState.pop(); + paintingState.restore(); } } @@ -1099,7 +1099,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { AbstractPaintingState.AbstractData data; while (true) { data = paintingState.getData(); - if (paintingState.pop() == null) { + if (paintingState.restore() == null) { break; } if (breakOutList.size() == 0) { @@ -1747,7 +1747,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { public void renderLeader(Leader area) { renderInlineAreaBackAndBorders(area); - paintingState.push(); + paintingState.save(); saveGraphicsState(); int style = area.getRuleStyle(); float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f; @@ -1805,7 +1805,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } restoreGraphicsState(); - paintingState.pop(); + paintingState.restore(); beginTextObject(); super.renderLeader(area); } diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java index e83579728..5d027aefe 100644 --- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java @@ -243,7 +243,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler pdfInfo.currentStream.add("%SVG start\n"); //Save state and update coordinate system for the SVG image - pdfInfo.pdfPaintingState.push(); + pdfInfo.pdfPaintingState.save(); pdfInfo.pdfPaintingState.concatenate(imageTransform); //Now that we have the complete transformation matrix for the image, we can update the @@ -262,7 +262,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler context.getUserAgent().getEventBroadcaster()); eventProducer.svgRenderingError(this, e, getDocumentURI(doc)); } - pdfInfo.pdfPaintingState.pop(); + pdfInfo.pdfPaintingState.restore(); renderer.restoreGraphicsState(); pdfInfo.currentStream.add("%SVG end\n"); } diff --git a/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java b/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java index be1c3c122..ae4d67516 100644 --- a/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java +++ b/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java @@ -30,6 +30,9 @@ import org.apache.fop.fonts.FontInfo; import org.apache.xmlgraphics.image.loader.ImageManager; import org.apache.xmlgraphics.image.loader.ImageSessionContext; +/** + * A FOP base implementation of a Batik BridgeContext. + */ public abstract class AbstractFOPBridgeContext extends BridgeContext { /** The font list. */ diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index ab0ece2a7..5053209e3 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -608,7 +608,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand if (newClip || newTransform) { currentStream.write("q\n"); - paintingState.push(); + paintingState.save(); if (newTransform) { concatMatrix(tranvals); } @@ -634,7 +634,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand if (newClip || newTransform) { currentStream.write("Q\n"); - paintingState.pop(); + paintingState.restore(); } return; } @@ -646,7 +646,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand doDrawing(false, true, false); if (newClip || newTransform) { currentStream.write("Q\n"); - paintingState.pop(); + paintingState.restore(); } } @@ -1614,7 +1614,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand if (newClip || newTransform) { currentStream.write("q\n"); - paintingState.push(); + paintingState.save(); if (newTransform) { concatMatrix(tranvals); } @@ -1638,7 +1638,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand if (newClip || newTransform) { currentStream.write("Q\n"); - paintingState.pop(); + paintingState.restore(); } return; } @@ -1651,7 +1651,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand iter.getWindingRule() == PathIterator.WIND_EVEN_ODD); if (newClip || newTransform) { currentStream.write("Q\n"); - paintingState.pop(); + paintingState.restore(); } } diff --git a/src/java/org/apache/fop/util/AbstractPaintingState.java b/src/java/org/apache/fop/util/AbstractPaintingState.java index e712ce74f..4fb6b173c 100644 --- a/src/java/org/apache/fop/util/AbstractPaintingState.java +++ b/src/java/org/apache/fop/util/AbstractPaintingState.java @@ -28,9 +28,8 @@ import java.util.Iterator; import java.util.List; import java.util.Stack; - /** - * A base class which holds information about the current rendering state. + * A base class which holds information about the current painting state. */ public abstract class AbstractPaintingState implements Cloneable, Serializable { @@ -278,23 +277,23 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { /** - * Push the current painting state onto the stack. + * Save the current painting state. + * This pushes the current painting state onto the stack. * This call should be used when the Q operator is used * so that the state is known when popped. */ - public void push() { + public void save() { AbstractData copy = (AbstractData)getData().clone(); stateStack.push(copy); } /** - * Pop the painting state from the stack and set current values to popped state. - * This should be called when a Q operator is used so - * the state is restored to the correct values. + * Restore the current painting state. + * This pops the painting state from the stack and sets current values to popped state. * * @return the restored state, null if the stack is empty */ - public AbstractData pop() { + public AbstractData restore() { if (!stateStack.isEmpty()) { setData((AbstractData)stateStack.pop()); return this.data; @@ -304,30 +303,32 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { } /** - * Pushes all painting state data in the given list to the stack + * Save all painting state data. + * This pushes all painting state data in the given list to the stack * * @param dataList a state data list */ - public void pushAll(List/**/ dataList) { + public void saveAll(List/**/ dataList) { Iterator it = dataList.iterator(); while (it.hasNext()) { // save current data on stack - push(); + save(); setData((AbstractData)it.next()); } } /** - * Pops all painting state data from the stack + * Restore all painting state data. + * This pops all painting state data from the stack * * @return a list of state data popped from the stack */ - public List/**/ popAll() { + public List/**/ restoreAll() { List/**/ dataList = new java.util.ArrayList/**/(); AbstractData data; while (true) { data = getData(); - if (pop() == null) { + if (restore() == null) { break; } // insert because of stack-popping -- cgit v1.2.3 From 382636ee6b35783d5d1885b5bb84f87d7b518c02 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Tue, 25 Nov 2008 18:34:05 +0000 Subject: * Reverted back the interface changes I made to ImageHandler. * Created AbstractAFPImageHandlerRawStream base class to handle raw image streams for AFP. * Fixed a bug in handling native embedded TIFF images. I think its finally ready to roll now guys, sorry for the last minute glitches. My apologies for not finding time to respond to the fop-dev mailing list this afternoon but have been trying to put my efforts into applying the final touches to the branch. If my good lady allows I'll respond to your comments later this evening :). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@720561 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/afp/AFPDataObjectFactory.java | 3 +- src/java/org/apache/fop/afp/AFPDataObjectInfo.java | 87 ++++++++++++++++------ .../org/apache/fop/afp/AFPImageObjectInfo.java | 23 +----- src/java/org/apache/fop/afp/ioca/ImageContent.java | 11 +-- src/java/org/apache/fop/afp/ioca/ImageSegment.java | 4 +- .../apache/fop/afp/modca/AbstractDataObject.java | 1 + src/java/org/apache/fop/afp/modca/ImageObject.java | 17 +++-- .../org/apache/fop/afp/modca/ObjectContainer.java | 13 ++-- .../fop/render/AbstractImageHandlerRegistry.java | 5 +- src/java/org/apache/fop/render/ImageHandler.java | 11 ++- .../org/apache/fop/render/afp/AFPImageHandler.java | 3 + .../fop/render/afp/AFPImageHandlerGraphics2D.java | 8 +- .../fop/render/afp/AFPImageHandlerRawCCITTFax.java | 28 ++----- .../fop/render/afp/AFPImageHandlerRawStream.java | 56 +------------- .../render/afp/AFPImageHandlerRenderedImage.java | 24 +++--- .../apache/fop/render/afp/AFPImageHandlerXML.java | 8 +- .../org/apache/fop/render/afp/AFPRenderer.java | 10 --- .../fop/render/afp/AFPRendererImageInfo.java | 13 ++++ .../afp/AbstractAFPImageHandlerRawStream.java | 79 ++++++++++++++++++++ .../fop/render/pdf/PDFImageHandlerGraphics2D.java | 8 +- .../fop/render/pdf/PDFImageHandlerRawCCITTFax.java | 8 +- .../fop/render/pdf/PDFImageHandlerRawJPEG.java | 8 +- .../render/pdf/PDFImageHandlerRenderedImage.java | 9 +-- .../apache/fop/render/pdf/PDFImageHandlerXML.java | 8 +- 24 files changed, 228 insertions(+), 217 deletions(-) create mode 100644 src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java index aba181358..80cb40713 100644 --- a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java +++ b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java @@ -77,7 +77,7 @@ public class AFPDataObjectFactory { ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, objectType, dataInContainer, containerHasOEG, dataInOCD); - objectContainer.setInputStream(dataObjectInfo.getInputStream()); + objectContainer.setData(dataObjectInfo.getData()); return objectContainer; } @@ -117,6 +117,7 @@ public class AFPDataObjectFactory { } else { imageObj.setIDESize((byte) imageObjectInfo.getBitsPerPixel()); } + imageObj.setData(imageObjectInfo.getData()); return imageObj; diff --git a/src/java/org/apache/fop/afp/AFPDataObjectInfo.java b/src/java/org/apache/fop/afp/AFPDataObjectInfo.java index c618a53fc..f6ff0046a 100644 --- a/src/java/org/apache/fop/afp/AFPDataObjectInfo.java +++ b/src/java/org/apache/fop/afp/AFPDataObjectInfo.java @@ -19,8 +19,6 @@ package org.apache.fop.afp; -import java.io.InputStream; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.afp.modca.Registry; @@ -43,12 +41,18 @@ public class AFPDataObjectInfo { /** the data object height */ private int dataHeight; - /** the object data in an inputstream */ - private InputStream inputStream; - /** the object registry mimetype */ private String mimeType; + /** the object data in a byte array */ + private byte[] data; + + /** the object data height resolution */ + private int dataHeightRes; + + /** the object data width resolution */ + private int dataWidthRes; + /** * Default constructor */ @@ -121,16 +125,6 @@ public class AFPDataObjectInfo { return this.objectAreaInfo; } - /** {@inheritDoc} */ - public String toString() { - return "AFPDataObjectInfo{" - + "mimeType=" + mimeType - + ", dataWidth=" + dataWidth - + ", dataHeight=" + dataHeight - + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "") - + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : ""); - } - /** * Returns the uri of this data object * @@ -186,21 +180,68 @@ public class AFPDataObjectInfo { } /** - * Sets the object data inputstream + * Returns the data height resolution + * + * @return the data height resolution + */ + public int getDataHeightRes() { + return this.dataHeightRes; + } + + /** + * Sets the data width resolution + * + * @param dataWidthRes the data width resolution + */ + public void setDataHeightRes(int dataHeightRes) { + this.dataHeightRes = dataHeightRes; + } + + /** + * Returns the data width resolution + * + * @return the data width resolution + */ + public int getDataWidthRes() { + return this.dataWidthRes; + } + + /** + * Sets the data width resolution + * + * @param dataWidthRes the data width resolution + */ + public void setDataWidthRes(int dataWidthRes) { + this.dataWidthRes = dataWidthRes; + } + + /** + * Sets the object data * - * @param inputStream the object data inputstream + * @param data the object data */ - public void setInputStream(InputStream inputStream) { - this.inputStream = inputStream; + public void setData(byte[] data) { + this.data = data; } /** - * Returns the object data inputstream + * Returns the object data * - * @return the object data inputstream + * @return the object data */ - public InputStream getInputStream() { - return this.inputStream; + public byte[] getData() { + return this.data; } + /** {@inheritDoc} */ + public String toString() { + return "AFPDataObjectInfo{" + + "mimeType=" + mimeType + + ", dataWidth=" + dataWidth + + ", dataHeight=" + dataHeight + + ", dataWidthRes=" + dataWidthRes + + ", dataHeightRes=" + dataHeightRes + + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "") + + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : ""); + } } diff --git a/src/java/org/apache/fop/afp/AFPImageObjectInfo.java b/src/java/org/apache/fop/afp/AFPImageObjectInfo.java index 561ad438b..f3677534f 100644 --- a/src/java/org/apache/fop/afp/AFPImageObjectInfo.java +++ b/src/java/org/apache/fop/afp/AFPImageObjectInfo.java @@ -24,6 +24,7 @@ package org.apache.fop.afp; * A list of parameters associated with an image */ public class AFPImageObjectInfo extends AFPDataObjectInfo { + /** number of bits per pixel used */ private int bitsPerPixel; @@ -33,9 +34,6 @@ public class AFPImageObjectInfo extends AFPDataObjectInfo { /** compression type if any */ private int compression = -1; - /** the object data in a byte array */ - private byte[] data; - /** * Default constructor */ @@ -106,24 +104,6 @@ public class AFPImageObjectInfo extends AFPDataObjectInfo { this.compression = compression; } - /** - * Sets the object data - * - * @param data the object data - */ - public void setData(byte[] data) { - this.data = data; - } - - /** - * Returns the object data - * - * @return the object data - */ - public byte[] getData() { - return this.data; - } - /** {@inheritDoc} */ public String toString() { return "AFPImageObjectInfo{" + super.toString() @@ -132,5 +112,4 @@ public class AFPImageObjectInfo extends AFPDataObjectInfo { + ", bitsPerPixel=" + bitsPerPixel + "}"; } - } \ No newline at end of file diff --git a/src/java/org/apache/fop/afp/ioca/ImageContent.java b/src/java/org/apache/fop/afp/ioca/ImageContent.java index 028d08475..40e51578b 100644 --- a/src/java/org/apache/fop/afp/ioca/ImageContent.java +++ b/src/java/org/apache/fop/afp/ioca/ImageContent.java @@ -123,7 +123,7 @@ public class ImageContent extends AbstractStructuredObject { } /** - * Set the data image store information. + * Set the image data (can be byte array or inputstream) * * @param imageData the image data */ @@ -148,15 +148,16 @@ public class ImageContent extends AbstractStructuredObject { os.write(getExternalAlgorithmParameter()); - // Image Data - if (data != null) { - final byte[] dataHeader = new byte[] { + final byte[] dataHeader = new byte[] { (byte)0xFE, // ID (byte)0x92, // ID 0x00, // length 0x00 // length }; - final int lengthOffset = 2; + final int lengthOffset = 2; + + // Image Data + if (data != null) { writeChunksToStream(data, dataHeader, lengthOffset, MAX_DATA_LEN, os); } } diff --git a/src/java/org/apache/fop/afp/ioca/ImageSegment.java b/src/java/org/apache/fop/afp/ioca/ImageSegment.java index eab8b931a..9fb544719 100644 --- a/src/java/org/apache/fop/afp/ioca/ImageSegment.java +++ b/src/java/org/apache/fop/afp/ioca/ImageSegment.java @@ -118,8 +118,8 @@ public class ImageSegment extends AbstractNamedAFPObject { * * @param data the image data */ - public void setData(byte[] data) { - getImageContent().setImageData(data); + public void setData(byte[] imageData) { + getImageContent().setImageData(imageData); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/afp/modca/AbstractDataObject.java b/src/java/org/apache/fop/afp/modca/AbstractDataObject.java index ec1b45be6..4a13b4a55 100644 --- a/src/java/org/apache/fop/afp/modca/AbstractDataObject.java +++ b/src/java/org/apache/fop/afp/modca/AbstractDataObject.java @@ -112,6 +112,7 @@ public abstract class AbstractDataObject extends AbstractNamedAFPObject implemen /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { + writeTriplets(os); if (objectEnvironmentGroup != null) { objectEnvironmentGroup.writeToStream(os); } diff --git a/src/java/org/apache/fop/afp/modca/ImageObject.java b/src/java/org/apache/fop/afp/modca/ImageObject.java index 8ab56691f..24ac0cb22 100644 --- a/src/java/org/apache/fop/afp/modca/ImageObject.java +++ b/src/java/org/apache/fop/afp/modca/ImageObject.java @@ -25,7 +25,6 @@ import java.io.OutputStream; import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPImageObjectInfo; -import org.apache.fop.afp.AFPObjectAreaInfo; import org.apache.fop.afp.Factory; import org.apache.fop.afp.ioca.ImageSegment; @@ -65,15 +64,17 @@ public class ImageObject extends AbstractDataObject { int dataWidth = imageObjectInfo.getDataWidth(); int dataHeight = imageObjectInfo.getDataHeight(); - AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - int widthRes = objectAreaInfo.getWidthRes(); - int heightRes = objectAreaInfo.getHeightRes(); +// AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); +// int widthRes = objectAreaInfo.getWidthRes(); +// int heightRes = objectAreaInfo.getHeightRes(); + int dataWidthRes = imageObjectInfo.getDataWidthRes(); + int dataHeightRes = imageObjectInfo.getDataWidthRes(); ImageDataDescriptor imageDataDescriptor - = factory.createImageDataDescriptor(dataWidth, dataHeight, widthRes, heightRes); + = factory.createImageDataDescriptor(dataWidth, dataHeight, dataWidthRes, dataHeightRes); getObjectEnvironmentGroup().setDataDescriptor(imageDataDescriptor); - getImageSegment().setImageSize(dataWidth, dataHeight, widthRes, heightRes); + getImageSegment().setImageSize(dataWidth, dataHeight, dataWidthRes, dataHeightRes); } /** @@ -117,8 +118,8 @@ public class ImageObject extends AbstractDataObject { * * @param data the image data */ - public void setData(byte[] data) { - getImageSegment().setData(data); + public void setData(byte[] imageData) { + getImageSegment().setData(imageData); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/afp/modca/ObjectContainer.java b/src/java/org/apache/fop/afp/modca/ObjectContainer.java index 791f4da1b..39b935d01 100644 --- a/src/java/org/apache/fop/afp/modca/ObjectContainer.java +++ b/src/java/org/apache/fop/afp/modca/ObjectContainer.java @@ -20,10 +20,8 @@ package org.apache.fop.afp.modca; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; -import org.apache.commons.io.IOUtils; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; import org.apache.fop.afp.AFPResourceInfo; @@ -40,7 +38,7 @@ public class ObjectContainer extends AbstractDataObject { /** the object container data maximum length */ private static final int MAX_DATA_LEN = 32759; - private InputStream inputStream; + private byte[] data; /** * Main constructor @@ -75,8 +73,9 @@ public class ObjectContainer extends AbstractDataObject { copySF(dataHeader, SF_CLASS, Type.DATA, Category.OBJECT_CONTAINER); final int lengthOffset = 1; - copyChunks(dataHeader, lengthOffset, MAX_DATA_LEN, inputStream, os); - IOUtils.closeQuietly(inputStream); + if (data != null) { + writeChunksToStream(data, dataHeader, lengthOffset, MAX_DATA_LEN, os); + } } /** {@inheritDoc} */ @@ -118,7 +117,7 @@ public class ObjectContainer extends AbstractDataObject { * * @param inputStream the inputstream for the object container data */ - public void setInputStream(InputStream inputStream) { - this.inputStream = inputStream; + public void setData(byte[] data) { + this.data = data; } } diff --git a/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java b/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java index e305e0a55..e8001f2fa 100644 --- a/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java +++ b/src/java/org/apache/fop/render/AbstractImageHandlerRegistry.java @@ -100,10 +100,7 @@ public abstract class AbstractImageHandlerRegistry { * @param handler the ImageHandler instance */ public synchronized void addHandler(ImageHandler handler) { - Class[] imageClasses = handler.getSupportedImageClasses(); - for (int i = 0; i < imageClasses.length; i++) { - this.handlers.put(imageClasses[i], handler); - } + this.handlers.put(handler.getSupportedImageClass(), handler); //Sorted insert ListIterator iter = this.handlerList.listIterator(); diff --git a/src/java/org/apache/fop/render/ImageHandler.java b/src/java/org/apache/fop/render/ImageHandler.java index 05d1e2e79..6a44c01a9 100644 --- a/src/java/org/apache/fop/render/ImageHandler.java +++ b/src/java/org/apache/fop/render/ImageHandler.java @@ -19,15 +19,14 @@ package org.apache.fop.render; -import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageFlavor; public interface ImageHandler { /** * Returns the priority for this image handler. A lower value means higher priority. This - * information is used to build the ordered/prioritized list of supported ImageFlavors for - * the PDF renderer. The built-in handlers use priorities between 100 and 999. + * information is used to build the ordered/prioritized list of supported ImageFlavors. + * The built-in handlers use priorities between 100 and 999. * @return a positive integer (>0) indicating the priority */ int getPriority(); @@ -39,8 +38,8 @@ public interface ImageHandler { ImageFlavor[] getSupportedImageFlavors(); /** - * Returns the {@link Image} subclasses supported by this instance. - * @return the Image types + * Returns the {@link Class} subclass supported by this instance. + * @return the image Class type */ - Class[] getSupportedImageClasses(); + Class getSupportedImageClass(); } diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandler.java b/src/java/org/apache/fop/render/afp/AFPImageHandler.java index 8e925d460..3ec3ea0b1 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandler.java @@ -31,6 +31,9 @@ import org.apache.fop.afp.AFPResourceInfo; import org.apache.fop.afp.AFPUnitConverter; import org.apache.fop.render.ImageHandler; +/** + * A base abstract AFP image handler + */ public abstract class AFPImageHandler implements ImageHandler { private static final int X = 0; private static final int Y = 1; diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java index fa3f00cdb..0780e8a59 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java @@ -41,10 +41,6 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler { ImageFlavor.GRAPHICS2D }; - private static final Class[] CLASSES = new Class[] { - ImageGraphics2D.class - }; - /** {@inheritDoc} */ public AFPDataObjectInfo generateDataObjectInfo( AFPRendererImageInfo rendererImageInfo) throws IOException { @@ -98,8 +94,8 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageGraphics2D.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java index aa91bb660..3ac1d5696 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java @@ -23,24 +23,18 @@ import java.io.IOException; import org.apache.fop.afp.AFPDataObjectInfo; import org.apache.fop.afp.AFPImageObjectInfo; -import org.apache.fop.afp.AFPObjectAreaInfo; import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.ImageSize; import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; /** - * PDFImageHandler implementation which handles CCITT encoded images (CCITT fax group 3/4). + * AFPImageHandler implementation which handles CCITT encoded images (CCITT fax group 3/4). */ -public class AFPImageHandlerRawCCITTFax extends AFPImageHandler { +public class AFPImageHandlerRawCCITTFax extends AbstractAFPImageHandlerRawStream { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.RAW_CCITTFAX, }; - private static final Class[] CLASSES = new Class[] { - ImageRawCCITTFax.class, - }; - /** {@inheritDoc} */ public AFPDataObjectInfo generateDataObjectInfo( AFPRendererImageInfo rendererImageInfo) throws IOException { @@ -48,18 +42,10 @@ public class AFPImageHandlerRawCCITTFax extends AFPImageHandler { = (AFPImageObjectInfo)super.generateDataObjectInfo(rendererImageInfo); ImageRawCCITTFax ccitt = (ImageRawCCITTFax) rendererImageInfo.getImage(); - imageObjectInfo.setCompression(ccitt.getCompression()); - - AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); - ImageSize imageSize = ccitt.getSize(); - int widthRes = (int) (imageSize.getDpiHorizontal() * 10); - objectAreaInfo.setWidthRes(widthRes); - - int heightRes = (int) (imageSize.getDpiVertical() * 10); - objectAreaInfo.setHeightRes(heightRes); - - imageObjectInfo.setInputStream(ccitt.createInputStream()); + int compression = ccitt.getCompression(); + imageObjectInfo.setCompression(compression); + imageObjectInfo.setBitsPerPixel(1); return imageObjectInfo; } @@ -74,8 +60,8 @@ public class AFPImageHandlerRawCCITTFax extends AFPImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageRawCCITTFax.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java index 47344b200..ded9ec9d5 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java @@ -19,76 +19,28 @@ package org.apache.fop.render.afp; -import java.io.IOException; -import java.io.InputStream; - import org.apache.fop.afp.AFPDataObjectInfo; -import org.apache.fop.afp.AFPObjectAreaInfo; -import org.apache.fop.afp.AFPPaintingState; import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.ImageInfo; -import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax; -import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS; -import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG; import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; /** * AFPImageHandler implementation which handles raw stream images. */ -public class AFPImageHandlerRawStream extends AFPImageHandler { +public class AFPImageHandlerRawStream extends AbstractAFPImageHandlerRawStream { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.RAW_JPEG, - ImageFlavor.RAW_CCITTFAX, ImageFlavor.RAW_EPS, }; - private static final Class[] CLASSES = new Class[] { - ImageRawJPEG.class, - ImageRawCCITTFax.class, - ImageRawEPS.class - }; - - /** {@inheritDoc} */ - public AFPDataObjectInfo generateDataObjectInfo( - AFPRendererImageInfo rendererImageInfo) throws IOException { - AFPDataObjectInfo dataObjectInfo = super.generateDataObjectInfo(rendererImageInfo); - ImageInfo imageInfo = rendererImageInfo.getImageInfo(); - String mimeType = imageInfo.getMimeType(); - if (mimeType != null) { - dataObjectInfo.setMimeType(mimeType); - } - ImageRawStream rawStream = (ImageRawStream) rendererImageInfo.getImage(); - - AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); - - AFPRendererContext rendererContext - = (AFPRendererContext)rendererImageInfo.getRendererContext(); - AFPInfo afpInfo = rendererContext.getInfo(); - AFPPaintingState paintingState = afpInfo.getPaintingState(); - int resolution = paintingState.getResolution(); - objectAreaInfo.setWidthRes(resolution); - objectAreaInfo.setHeightRes(resolution); - - InputStream inputStream = rawStream.createInputStream(); - dataObjectInfo.setInputStream(inputStream); - - int dataHeight = rawStream.getSize().getHeightPx(); - dataObjectInfo.setDataHeight(dataHeight); - - int dataWidth = rawStream.getSize().getWidthPx(); - dataObjectInfo.setDataWidth(dataWidth); - return dataObjectInfo; - } - /** {@inheritDoc} */ public int getPriority() { - return 100; + return 200; } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageRawStream.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java index ef6a6bb65..28c942a08 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java @@ -28,7 +28,6 @@ import org.apache.fop.afp.AFPImageObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; import org.apache.fop.afp.AFPPaintingState; import org.apache.xmlgraphics.image.loader.ImageFlavor; -import org.apache.xmlgraphics.image.loader.impl.ImageBuffered; import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.ps.ImageEncodingHelper; import org.apache.xmlgraphics.util.MimeConstants; @@ -43,27 +42,21 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler { ImageFlavor.RENDERED_IMAGE }; - private static final Class[] CLASSES = new Class[] { - ImageBuffered.class, - ImageRendered.class - }; - /** {@inheritDoc} */ public AFPDataObjectInfo generateDataObjectInfo( AFPRendererImageInfo rendererImageInfo) throws IOException { AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)super.generateDataObjectInfo(rendererImageInfo); - imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); - - AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); AFPRendererContext rendererContext = (AFPRendererContext)rendererImageInfo.getRendererContext(); AFPInfo afpInfo = rendererContext.getInfo(); AFPPaintingState paintingState = afpInfo.getPaintingState(); int resolution = paintingState.getResolution(); - objectAreaInfo.setWidthRes(resolution); - objectAreaInfo.setHeightRes(resolution); + + imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45); + imageObjectInfo.setDataHeightRes(resolution); + imageObjectInfo.setDataWidthRes(resolution); ImageRendered imageRendered = (ImageRendered) rendererImageInfo.img; RenderedImage renderedImage = imageRendered.getRenderedImage(); @@ -92,6 +85,11 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler { } imageObjectInfo.setData(imageData); + // set object area info + AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); + objectAreaInfo.setWidthRes(resolution); + objectAreaInfo.setHeightRes(resolution); + return imageObjectInfo; } @@ -106,8 +104,8 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageRendered.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java index b7345811a..7ea1a7a10 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerXML.java @@ -39,10 +39,6 @@ public class AFPImageHandlerXML extends AFPImageHandler { ImageFlavor.XML_DOM, }; - private static final Class[] CLASSES = new Class[] { - ImageXMLDOM.class, - }; - /** {@inheritDoc} */ public AFPDataObjectInfo generateDataObjectInfo(AFPRendererImageInfo rendererImageInfo) throws IOException { @@ -64,8 +60,8 @@ public class AFPImageHandlerXML extends AFPImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageXMLDOM.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 903099610..b73b036c3 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -71,7 +71,6 @@ import org.apache.fop.render.Graphics2DAdapter; import org.apache.fop.render.RendererContext; import org.apache.fop.render.afp.extensions.AFPElementMapping; import org.apache.fop.render.afp.extensions.AFPPageSetup; -import org.apache.fop.util.AbstractPaintingState; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageInfo; @@ -742,15 +741,6 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { return paintingState.getResolution(); } - /** - * Returns the current AFP state - * - * @return the current AFP state - */ - public AbstractPaintingState getState() { - return this.paintingState; - } - /** * Sets the default resource group file path * @param filePath the default resource group file path diff --git a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java index 0aa3eb6ab..2687d9071 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererImageInfo.java @@ -146,4 +146,17 @@ public class AFPRendererImageInfo { return this.pos; } + /** {@inheritDoc} */ + public String toString() { + return "AFPRendererImageInfo{\n" + + "\turi=" + uri + ",\n" + + "\tinfo=" + info + ",\n" + + "\tpos=" + pos + ",\n" + + "\torigin=" + origin + ",\n" + + "\timg=" + img + ",\n" + + "\tforeignAttributes=" + foreignAttributes + ",\n" + + "\trendererContext=" + rendererContext + "\n" + + "}"; + + } } diff --git a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java new file mode 100644 index 000000000..ae8ac9950 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java @@ -0,0 +1,79 @@ +/* + * 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 java.io.IOException; +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; +import org.apache.fop.afp.AFPDataObjectInfo; +import org.apache.fop.afp.AFPObjectAreaInfo; +import org.apache.fop.afp.AFPPaintingState; +import org.apache.xmlgraphics.image.loader.ImageInfo; +import org.apache.xmlgraphics.image.loader.ImageSize; +import org.apache.xmlgraphics.image.loader.impl.ImageRawStream; + +/** + * A base abstract AFP raw stream image handler + */ +public abstract class AbstractAFPImageHandlerRawStream extends AFPImageHandler { + + /** {@inheritDoc} */ + public AFPDataObjectInfo generateDataObjectInfo( + AFPRendererImageInfo rendererImageInfo) throws IOException { + AFPDataObjectInfo dataObjectInfo = super.generateDataObjectInfo(rendererImageInfo); + + ImageInfo imageInfo = rendererImageInfo.getImageInfo(); + String mimeType = imageInfo.getMimeType(); + if (mimeType != null) { + dataObjectInfo.setMimeType(mimeType); + } + ImageRawStream rawStream = (ImageRawStream) rendererImageInfo.getImage(); + InputStream inputStream = rawStream.createInputStream(); + try { + dataObjectInfo.setData(IOUtils.toByteArray(inputStream)); + } finally { + IOUtils.closeQuietly(inputStream); + } + + int dataHeight = rawStream.getSize().getHeightPx(); + dataObjectInfo.setDataHeight(dataHeight); + + int dataWidth = rawStream.getSize().getWidthPx(); + dataObjectInfo.setDataWidth(dataWidth); + + ImageSize imageSize = rawStream.getSize(); + dataObjectInfo.setDataHeightRes((int) (imageSize.getDpiHorizontal() * 10)); + dataObjectInfo.setDataWidthRes((int) (imageSize.getDpiVertical() * 10)); + + // set object area info + AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + AFPRendererContext rendererContext + = (AFPRendererContext)rendererImageInfo.getRendererContext(); + AFPInfo afpInfo = rendererContext.getInfo(); + AFPPaintingState paintingState = afpInfo.getPaintingState(); + int resolution = paintingState.getResolution(); + objectAreaInfo.setWidthRes(resolution); + objectAreaInfo.setHeightRes(resolution); + + return dataObjectInfo; + } + +} diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java index 9f44e58b5..3e4a9b354 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java @@ -38,10 +38,6 @@ public class PDFImageHandlerGraphics2D implements PDFImageHandler { ImageFlavor.GRAPHICS2D, }; - private static final Class[] CLASSES = new Class[] { - ImageGraphics2D.class, - }; - /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -59,8 +55,8 @@ public class PDFImageHandlerGraphics2D implements PDFImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageGraphics2D.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java index 158e93c86..1ba498ff0 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java @@ -41,10 +41,6 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler { ImageFlavor.RAW_CCITTFAX, }; - private static final Class[] CLASSES = new Class[] { - ImageRawCCITTFax.class, - }; - /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -74,8 +70,8 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageRawCCITTFax.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java index 1432547da..41a2d7565 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java @@ -41,10 +41,6 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler { ImageFlavor.RAW_JPEG, }; - private static final Class[] CLASSES = new Class[] { - ImageRawJPEG.class, - }; - /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -74,8 +70,8 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageRawJPEG.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java index edbe9005d..268ff8862 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java @@ -42,11 +42,6 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler { ImageFlavor.RENDERED_IMAGE }; - private static final Class[] CLASSES = new Class[] { - ImageRendered.class, - }; - - /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -76,8 +71,8 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageRendered.class; } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java index 069fef172..26ba83371 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java @@ -40,10 +40,6 @@ public class PDFImageHandlerXML implements PDFImageHandler { ImageFlavor.XML_DOM, }; - private static final Class[] CLASSES = new Class[] { - ImageXMLDOM.class, - }; - /** {@inheritDoc} */ public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) @@ -64,8 +60,8 @@ public class PDFImageHandlerXML implements PDFImageHandler { } /** {@inheritDoc} */ - public Class[] getSupportedImageClasses() { - return CLASSES; + public Class getSupportedImageClass() { + return ImageXMLDOM.class; } /** {@inheritDoc} */ -- cgit v1.2.3 From 790875d4101f90ab3419025717b581c255d87fe1 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Sun, 7 Dec 2008 18:01:24 +0000 Subject: Bugzilla #46360: Fixed a multi-threading issue when rendering SVG. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@724163 13f79535-47bb-0310-9956-ffa450edef68 --- .../image/loader/batik/ImageConverterSVG2G2D.java | 13 +++++++++++-- .../fop/render/AbstractGenericSVGHandler.java | 21 ++++++++++++++------- .../org/apache/fop/render/afp/AFPSVGHandler.java | 20 ++++++++++++++------ .../apache/fop/render/java2d/Java2DSVGHandler.java | 13 ++++++++++--- src/java/org/apache/fop/render/pdf/PDFRenderer.java | 1 + .../org/apache/fop/render/pdf/PDFSVGHandler.java | 15 ++++++++++----- src/java/org/apache/fop/render/ps/PSSVGHandler.java | 10 +++++++--- status.xml | 3 +++ 8 files changed, 70 insertions(+), 26 deletions(-) (limited to 'src/java/org/apache/fop/render/pdf') 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 81c12a628..2bb521dc9 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java @@ -23,6 +23,8 @@ import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.util.Map; +import org.w3c.dom.Document; + import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; import org.apache.batik.bridge.UserAgent; @@ -30,7 +32,7 @@ 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.fop.svg.SimpleSVGUserAgent; + import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageException; import org.apache.xmlgraphics.image.loader.ImageFlavor; @@ -43,6 +45,8 @@ 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.SimpleSVGUserAgent; + /** * This ImageConverter converts SVG images to Java2D. *

      @@ -75,10 +79,15 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter { GVTBuilder builder = new GVTBuilder(); final BridgeContext ctx = new BridgeContext(ua); + Document doc = svg.getDocument(); + //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) + //to it. + Document clonedDoc = BatikUtil.cloneSVGDocument(doc); + //Build the GVT tree final GraphicsNode root; try { - root = builder.build(ctx, svg.getDocument()); + root = builder.build(ctx, clonedDoc); } catch (Exception e) { throw new ImageException("GVT tree could not be built for SVG graphic", e); } diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index 5c253fe94..35876a728 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -24,22 +24,25 @@ import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.io.IOException; +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.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; + +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; +import org.apache.xmlgraphics.util.QName; + import org.apache.fop.apps.FOUserAgent; import org.apache.fop.events.EventBroadcaster; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl; import org.apache.fop.render.RendererContext.RendererContextWrapper; -import org.apache.fop.render.afp.AFPGraphics2DAdapter; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; -import org.apache.xmlgraphics.util.QName; -import org.w3c.dom.Document; /** * Generic XML handler for SVG. Uses Apache Batik for SVG processing and simply paints to @@ -133,15 +136,19 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC //Create Batik BridgeContext final BridgeContext bridgeContext = new BridgeContext(svgUserAgent); - //Build the GVT tree + //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) + //to it. + Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); - final GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, doc); + //Build the GVT tree + final GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc); // Create Graphics2DImagePainter final RendererContextWrapper wrappedContext = RendererContext.wrapRendererContext( rendererContext); Dimension imageSize = getImageSize(wrappedContext); - final Graphics2DImagePainter painter = createGraphics2DImagePainter(root, bridgeContext, imageSize); + final Graphics2DImagePainter painter = createGraphics2DImagePainter( + root, bridgeContext, imageSize); //Let the painter paint the SVG on the Graphics2D instance Graphics2DAdapter g2dAdapter = rendererContext.getRenderer().getGraphics2DAdapter(); diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index 9deea77b4..ca64d6bc2 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -24,9 +24,18 @@ import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.io.IOException; +import org.w3c.dom.Document; + import org.apache.batik.bridge.BridgeContext; import org.apache.batik.dom.svg.SVGDOMImplementation; +import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; + +import org.apache.xmlgraphics.image.loader.ImageManager; +import org.apache.xmlgraphics.image.loader.ImageSessionContext; +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; +import org.apache.xmlgraphics.util.MimeConstants; + import org.apache.fop.afp.AFPGraphics2D; import org.apache.fop.afp.AFPGraphicsObjectInfo; import org.apache.fop.afp.AFPObjectAreaInfo; @@ -44,11 +53,6 @@ import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContext.RendererContextWrapper; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; -import org.apache.xmlgraphics.image.loader.ImageManager; -import org.apache.xmlgraphics.image.loader.ImageSessionContext; -import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; -import org.apache.xmlgraphics.util.MimeConstants; -import org.w3c.dom.Document; /** * AFP XML handler for SVG. Uses Apache Batik for SVG processing. @@ -107,8 +111,12 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { // Create an AFPBridgeContext BridgeContext bridgeContext = createBridgeContext(userAgent, g2d); + //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) + //to it. + Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + // Build the SVG DOM and provide the painter with it - GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, doc); + GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc); // Create Graphics2DImagePainter final RendererContextWrapper wrappedContext diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java index ba5c86059..2d16b120d 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java +++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java @@ -23,18 +23,21 @@ import java.awt.geom.AffineTransform; import java.io.IOException; import java.util.Map; +import org.w3c.dom.Document; + import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; +import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.RendererContextConstants; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; -import org.w3c.dom.Document; /** * Java2D XML handler for SVG (uses Apache Batik). @@ -128,12 +131,16 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler SVGUserAgent ua = new SVGUserAgent(context.getUserAgent(), new AffineTransform()); - GVTBuilder builder = new GVTBuilder(); BridgeContext ctx = new BridgeContext(ua); + //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) + //to it. + Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + GraphicsNode root; try { - root = builder.build(ctx, doc); + GVTBuilder builder = new GVTBuilder(); + root = builder.build(ctx, clonedDoc); } catch (Exception e) { SVGEventProducer eventProducer = SVGEventProducer.Provider.get( context.getUserAgent().getEventBroadcaster()); diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index e31f1eaea..dda7e2083 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -1635,6 +1635,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { (int)pos.getHeight()); uri = URISpecification.getURL(uri); + uri = URISpecification.preResolveURI(uri, userAgent.getBaseURL()); PDFXObject xobject = pdfDoc.getXObject(uri); if (xobject != null) { float w = (float) pos.getWidth() / 1000f; diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java index 5d027aefe..0bf9bd95b 100644 --- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java @@ -25,14 +25,18 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Map; +import org.w3c.dom.Document; + import org.apache.avalon.framework.configuration.Configuration; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; import org.apache.batik.dom.svg.SVGDOMImplementation; +import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.util.SVGConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontInfo; import org.apache.fop.pdf.PDFDocument; @@ -49,7 +53,6 @@ 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.w3c.dom.Document; /** * PDF XML handler for SVG (uses Apache Batik). @@ -164,8 +167,6 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler 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; @@ -179,10 +180,14 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler userAgent.getImageSessionContext(), new AffineTransform()); + //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) + //to it. + Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + GraphicsNode root; try { - root = builder.build(ctx, doc); - builder = null; + GVTBuilder builder = new GVTBuilder(); + root = builder.build(ctx, clonedDoc); } catch (Exception e) { SVGEventProducer eventProducer = SVGEventProducer.Provider.get( context.getUserAgent().getEventBroadcaster()); diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java index 1e65dfb98..646cd3823 100644 --- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java +++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java @@ -29,6 +29,7 @@ import org.w3c.dom.Document; import org.apache.avalon.framework.configuration.Configuration; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; +import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -258,7 +259,6 @@ public class PSSVGHandler extends AbstractGenericSVGHandler PSGraphics2D graphics = new PSGraphics2D(strokeText, gen); graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - GVTBuilder builder = new GVTBuilder(); NativeTextHandler nativeTextHandler = null; BridgeContext ctx = new BridgeContext(ua); if (!strokeText) { @@ -271,9 +271,14 @@ public class PSSVGHandler extends AbstractGenericSVGHandler ctx.putBridge(tBridge); } + //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) + //to it. + Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + GraphicsNode root; try { - root = builder.build(ctx, doc); + GVTBuilder builder = new GVTBuilder(); + root = builder.build(ctx, clonedDoc); } catch (Exception e) { SVGEventProducer eventProducer = SVGEventProducer.Provider.get( context.getUserAgent().getEventBroadcaster()); @@ -288,7 +293,6 @@ public class PSSVGHandler extends AbstractGenericSVGHandler float sy = psInfo.getHeight() / h; ctx = null; - builder = null; try { gen.commentln("%FOPBeginSVG"); diff --git a/status.xml b/status.xml index 0f139fba7..b2e37dd33 100644 --- a/status.xml +++ b/status.xml @@ -53,6 +53,9 @@ + + Fixed a multi-threading issue when rendering SVG. + AFP Output: An AFPGraphics2D implementation which provides the ability to use Batik to drive the production of AFP Graphics (GOCA) output from SVG. -- cgit v1.2.3 From f455ebac165a6b9fd8c0f58e6ddc999b7e08c3e5 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 8 Dec 2008 07:39:44 +0000 Subject: Reverted accidental commit of unfinished change. Sorry about that. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@724271 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/render/pdf/PDFRenderer.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/java/org/apache/fop/render/pdf') diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index dda7e2083..e31f1eaea 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -1635,7 +1635,6 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { (int)pos.getHeight()); uri = URISpecification.getURL(uri); - uri = URISpecification.preResolveURI(uri, userAgent.getBaseURL()); PDFXObject xobject = pdfDoc.getXObject(uri); if (xobject != null) { float w = (float) pos.getWidth() / 1000f; -- cgit v1.2.3 From 607aeaa986fbf0ecbc55684dad0b3286613f56dd Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Mon, 8 Dec 2008 11:30:11 +0000 Subject: Batik's DOMUtilities.deepCloneDocument() doesn't propagate the document URI which makes relative image URIs fail. Fixes one of our unit tests. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@724310 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/image/loader/batik/BatikUtil.java | 19 +++++++++++++++++++ .../fop/image/loader/batik/ImageConverterSVG2G2D.java | 3 +-- .../apache/fop/render/AbstractGenericSVGHandler.java | 4 ++-- src/java/org/apache/fop/render/afp/AFPSVGHandler.java | 4 ++-- .../apache/fop/render/java2d/Java2DSVGHandler.java | 4 ++-- src/java/org/apache/fop/render/pdf/PDFSVGHandler.java | 4 ++-- src/java/org/apache/fop/render/ps/PSSVGHandler.java | 4 ++-- 7 files changed, 30 insertions(+), 12 deletions(-) (limited to 'src/java/org/apache/fop/render/pdf') 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 558c3b043..20a7bf767 100644 --- a/src/java/org/apache/fop/image/loader/batik/BatikUtil.java +++ b/src/java/org/apache/fop/image/loader/batik/BatikUtil.java @@ -19,6 +19,11 @@ package org.apache.fop.image.loader.batik; +import org.w3c.dom.Document; + +import org.apache.batik.dom.AbstractDocument; +import org.apache.batik.dom.util.DOMUtilities; + /** * Helper utilities for Apache Batik. */ @@ -38,4 +43,18 @@ public class BatikUtil { return false; } + /** + * Clones an SVG DOM document. This is used for making SVG production thread-safe when the + * SVG document is cached and re-used. + * @param doc the SVG DOM to be cloned + * @return the cloned SVG DOM + */ + public static Document cloneSVGDocument(Document doc) { + Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + if (clonedDoc instanceof AbstractDocument) { + ((AbstractDocument)clonedDoc).setDocumentURI(((AbstractDocument)doc).getDocumentURI()); + } + return clonedDoc; + } + } 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 8d9399a3c..2bb521dc9 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java @@ -29,7 +29,6 @@ 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.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -83,7 +82,7 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter { Document doc = svg.getDocument(); //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) //to it. - Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + Document clonedDoc = BatikUtil.cloneSVGDocument(doc); //Build the GVT tree final GraphicsNode root; diff --git a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java index 35876a728..731f0bae2 100644 --- a/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java +++ b/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java @@ -30,7 +30,6 @@ 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.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; @@ -39,6 +38,7 @@ import org.apache.xmlgraphics.util.QName; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.events.EventBroadcaster; import org.apache.fop.fo.extensions.ExtensionElementMapping; +import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl; import org.apache.fop.render.RendererContext.RendererContextWrapper; import org.apache.fop.svg.SVGEventProducer; @@ -138,7 +138,7 @@ public abstract class AbstractGenericSVGHandler implements XMLHandler, RendererC //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) //to it. - Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + Document clonedDoc = BatikUtil.cloneSVGDocument(doc); //Build the GVT tree final GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc); diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index ca64d6bc2..161217a54 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -28,7 +28,6 @@ import org.w3c.dom.Document; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.dom.svg.SVGDOMImplementation; -import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.xmlgraphics.image.loader.ImageManager; @@ -46,6 +45,7 @@ import org.apache.fop.afp.AFPUnitConverter; import org.apache.fop.afp.svg.AFPBridgeContext; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; @@ -113,7 +113,7 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) //to it. - Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + Document clonedDoc = BatikUtil.cloneSVGDocument(doc); // Build the SVG DOM and provide the painter with it GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, clonedDoc); diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java index 2d16b120d..99502096c 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java +++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java @@ -27,11 +27,11 @@ import org.w3c.dom.Document; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; -import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; @@ -135,7 +135,7 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) //to it. - Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + Document clonedDoc = BatikUtil.cloneSVGDocument(doc); GraphicsNode root; try { diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java index 0bf9bd95b..41f48df55 100644 --- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java @@ -31,7 +31,6 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; import org.apache.batik.dom.svg.SVGDOMImplementation; -import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.batik.util.SVGConstants; import org.apache.commons.logging.Log; @@ -39,6 +38,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFPage; import org.apache.fop.pdf.PDFPaintingState; @@ -182,7 +182,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) //to it. - Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + Document clonedDoc = BatikUtil.cloneSVGDocument(doc); GraphicsNode root; try { diff --git a/src/java/org/apache/fop/render/ps/PSSVGHandler.java b/src/java/org/apache/fop/render/ps/PSSVGHandler.java index 646cd3823..7171efb4e 100644 --- a/src/java/org/apache/fop/render/ps/PSSVGHandler.java +++ b/src/java/org/apache/fop/render/ps/PSSVGHandler.java @@ -29,7 +29,6 @@ import org.w3c.dom.Document; import org.apache.avalon.framework.configuration.Configuration; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.GVTBuilder; -import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.gvt.GraphicsNode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -38,6 +37,7 @@ import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; import org.apache.xmlgraphics.ps.PSGenerator; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; @@ -273,7 +273,7 @@ public class PSSVGHandler extends AbstractGenericSVGHandler //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) //to it. - Document clonedDoc = DOMUtilities.deepCloneDocument(doc, doc.getImplementation()); + Document clonedDoc = BatikUtil.cloneSVGDocument(doc); GraphicsNode root; try { -- cgit v1.2.3