diff options
Diffstat (limited to 'src/java/org')
102 files changed, 3749 insertions, 3749 deletions
diff --git a/src/java/org/apache/fop/Version.java b/src/java/org/apache/fop/Version.java index 7e421ad29..4545d071e 100644 --- a/src/java/org/apache/fop/Version.java +++ b/src/java/org/apache/fop/Version.java @@ -41,7 +41,7 @@ public final class Version { if (version == null) { //Fallback if FOP is used in a development environment String headURL - = "$HeadURL$"; + = "$HeadURL: http://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/src/java/org/apache/fop/Version.java $"; version = headURL; final String pathPrefix = "/xmlgraphics/fop/"; int pos = version.indexOf(pathPrefix); diff --git a/src/java/org/apache/fop/apps/FopFactory.java b/src/java/org/apache/fop/apps/FopFactory.java index dc94d92fb..de4c43626 100644 --- a/src/java/org/apache/fop/apps/FopFactory.java +++ b/src/java/org/apache/fop/apps/FopFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.apps; diff --git a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java index d708cd989..4d4f8d3eb 100644 --- a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java +++ b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.apps; diff --git a/src/java/org/apache/fop/apps/FormattingResults.java b/src/java/org/apache/fop/apps/FormattingResults.java index 86ac72a97..af421f4ac 100644 --- a/src/java/org/apache/fop/apps/FormattingResults.java +++ b/src/java/org/apache/fop/apps/FormattingResults.java @@ -1,85 +1,85 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.apps;
-
-import java.util.List;
-
-import org.apache.fop.fo.pagination.AbstractPageSequence;
-
-/**
- * Class for reporting back formatting results to the calling application.
- */
-public class FormattingResults {
-
- private int pageCount = 0;
- private List pageSequences = null;
-
- /**
- * Constructor for the FormattingResults object
- */
- public FormattingResults() {
- }
-
- /**
- * Gets the number of pages rendered
- *
- * @return The number of pages overall
- */
- public int getPageCount() {
- return this.pageCount;
- }
-
- /**
- * Gets the results for the individual page-sequences.
- *
- * @return A List with PageSequenceResults objects
- */
- public List getPageSequences() {
- return this.pageSequences;
- }
-
- /**
- * Resets this object
- */
- public void reset() {
- this.pageCount = 0;
- if (this.pageSequences != null) {
- this.pageSequences.clear();
- }
- }
-
- /**
- * Reports the result of one page sequence rendering
- * back into this object.
- *
- * @param pageSequence the page sequence which just completed rendering
- * @param pageCount the number of pages rendered for that PageSequence
- */
- public void haveFormattedPageSequence(AbstractPageSequence pageSequence, int pageCount) {
- this.pageCount += pageCount;
- if (this.pageSequences == null) {
- this.pageSequences = new java.util.ArrayList();
- }
- this.pageSequences.add(
- new PageSequenceResults(pageSequence.getId(),
- pageCount));
- }
-}
-
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.apps; + +import java.util.List; + +import org.apache.fop.fo.pagination.AbstractPageSequence; + +/** + * Class for reporting back formatting results to the calling application. + */ +public class FormattingResults { + + private int pageCount = 0; + private List pageSequences = null; + + /** + * Constructor for the FormattingResults object + */ + public FormattingResults() { + } + + /** + * Gets the number of pages rendered + * + * @return The number of pages overall + */ + public int getPageCount() { + return this.pageCount; + } + + /** + * Gets the results for the individual page-sequences. + * + * @return A List with PageSequenceResults objects + */ + public List getPageSequences() { + return this.pageSequences; + } + + /** + * Resets this object + */ + public void reset() { + this.pageCount = 0; + if (this.pageSequences != null) { + this.pageSequences.clear(); + } + } + + /** + * Reports the result of one page sequence rendering + * back into this object. + * + * @param pageSequence the page sequence which just completed rendering + * @param pageCount the number of pages rendered for that PageSequence + */ + public void haveFormattedPageSequence(AbstractPageSequence pageSequence, int pageCount) { + this.pageCount += pageCount; + if (this.pageSequences == null) { + this.pageSequences = new java.util.ArrayList(); + } + this.pageSequences.add( + new PageSequenceResults(pageSequence.getId(), + pageCount)); + } +} + diff --git a/src/java/org/apache/fop/apps/MimeConstants.java b/src/java/org/apache/fop/apps/MimeConstants.java index b17998393..31bdaaab1 100644 --- a/src/java/org/apache/fop/apps/MimeConstants.java +++ b/src/java/org/apache/fop/apps/MimeConstants.java @@ -1,80 +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.apps;
-
-/**
- * Frequently used MIME types for various file formats used when working with Apache FOP.
- */
-public interface MimeConstants {
-
- /** Portable Document Format */
- String MIME_PDF = "application/pdf";
-
- /** PostScript */
- String MIME_POSTSCRIPT = "application/postscript";
- /** Encapsulated PostScript (same MIME type as PostScript) */
- String MIME_EPS = MIME_POSTSCRIPT;
-
- /** HP's PCL */
- String MIME_PCL = "application/x-pcl";
- /** HP's PCL (alternative MIME type) */
- String MIME_PCL_ALT = "application/vnd.hp-PCL";
-
- /** IBM's AFP */
- String MIME_AFP = "application/x-afp";
- /** IBM's AFP (alternative MIME type) */
- String MIME_AFP_ALT = "application/vnd.ibm.modcap";
-
- /** Plain text */
- String MIME_PLAIN_TEXT = "text/plain";
-
- /** Rich text format */
- String MIME_RTF = "application/rtf";
- /** Rich text format (alternative 1) */
- String MIME_RTF_ALT1 = "text/richtext";
- /** Rich text format (alternative 2) */
- String MIME_RTF_ALT2 = "text/rtf";
-
- /** FrameMaker's MIF */
- String MIME_MIF = "application/mif";
-
- /** Structured Vector Graphics */
- String MIME_SVG = "image/svg+xml";
-
- /** GIF images */
- String MIME_GIF = "image/gif";
- /** PNG images */
- String MIME_PNG = "image/png";
- /** JPEG images */
- String MIME_JPEG = "image/jpeg";
- /** TIFF images */
- String MIME_TIFF = "image/tiff";
-
- /** Apache FOP's AWT preview (non-standard MIME type) */
- String MIME_FOP_AWT_PREVIEW = "application/X-fop-awt-preview";
- /** Apache FOP's Direct Printing (non-standard MIME type) */
- String MIME_FOP_PRINT = "application/X-fop-print";
- /** Apache FOP's area tree XML */
- String MIME_FOP_AREA_TREE = "application/X-fop-areatree";
-
- /** Proposed but non-registered MIME type for XSL-FO */
- String MIME_XSL_FO = "text/xsl";
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.apps; + +/** + * Frequently used MIME types for various file formats used when working with Apache FOP. + */ +public interface MimeConstants { + + /** Portable Document Format */ + String MIME_PDF = "application/pdf"; + + /** PostScript */ + String MIME_POSTSCRIPT = "application/postscript"; + /** Encapsulated PostScript (same MIME type as PostScript) */ + String MIME_EPS = MIME_POSTSCRIPT; + + /** HP's PCL */ + String MIME_PCL = "application/x-pcl"; + /** HP's PCL (alternative MIME type) */ + String MIME_PCL_ALT = "application/vnd.hp-PCL"; + + /** IBM's AFP */ + String MIME_AFP = "application/x-afp"; + /** IBM's AFP (alternative MIME type) */ + String MIME_AFP_ALT = "application/vnd.ibm.modcap"; + + /** Plain text */ + String MIME_PLAIN_TEXT = "text/plain"; + + /** Rich text format */ + String MIME_RTF = "application/rtf"; + /** Rich text format (alternative 1) */ + String MIME_RTF_ALT1 = "text/richtext"; + /** Rich text format (alternative 2) */ + String MIME_RTF_ALT2 = "text/rtf"; + + /** FrameMaker's MIF */ + String MIME_MIF = "application/mif"; + + /** Structured Vector Graphics */ + String MIME_SVG = "image/svg+xml"; + + /** GIF images */ + String MIME_GIF = "image/gif"; + /** PNG images */ + String MIME_PNG = "image/png"; + /** JPEG images */ + String MIME_JPEG = "image/jpeg"; + /** TIFF images */ + String MIME_TIFF = "image/tiff"; + + /** Apache FOP's AWT preview (non-standard MIME type) */ + String MIME_FOP_AWT_PREVIEW = "application/X-fop-awt-preview"; + /** Apache FOP's Direct Printing (non-standard MIME type) */ + String MIME_FOP_PRINT = "application/X-fop-print"; + /** Apache FOP's area tree XML */ + String MIME_FOP_AREA_TREE = "application/X-fop-areatree"; + + /** Proposed but non-registered MIME type for XSL-FO */ + String MIME_XSL_FO = "text/xsl"; + +} diff --git a/src/java/org/apache/fop/apps/PageSequenceResults.java b/src/java/org/apache/fop/apps/PageSequenceResults.java index ae873b5e3..16c74f66b 100644 --- a/src/java/org/apache/fop/apps/PageSequenceResults.java +++ b/src/java/org/apache/fop/apps/PageSequenceResults.java @@ -1,59 +1,59 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.apps;
-
-/**
- * Class for reporting back formatting results to the calling application. This
- * particular class is used to report the results of a single page-sequence.
- */
-public class PageSequenceResults {
-
- private String id;
- private int pageCount;
-
- /**
- * Constructor for the PageSequenceResults object
- *
- * @param id ID of the page-sequence, if available
- * @param pageCount The number of resulting pages
- */
- public PageSequenceResults(String id, int pageCount) {
- this.id = id;
- this.pageCount = pageCount;
- }
-
- /**
- * Gets the ID of the page-sequence if one was specified.
- *
- * @return The ID
- */
- public String getID() {
- return this.id;
- }
-
- /**
- * Gets the number of pages that resulted by processing the page-sequence.
- *
- * @return The number of pages generated
- */
- public int getPageCount() {
- return this.pageCount;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.apps; + +/** + * Class for reporting back formatting results to the calling application. This + * particular class is used to report the results of a single page-sequence. + */ +public class PageSequenceResults { + + private String id; + private int pageCount; + + /** + * Constructor for the PageSequenceResults object + * + * @param id ID of the page-sequence, if available + * @param pageCount The number of resulting pages + */ + public PageSequenceResults(String id, int pageCount) { + this.id = id; + this.pageCount = pageCount; + } + + /** + * Gets the ID of the page-sequence if one was specified. + * + * @return The ID + */ + public String getID() { + return this.id; + } + + /** + * Gets the number of pages that resulted by processing the page-sequence. + * + * @return The number of pages generated + */ + public int getPageCount() { + return this.pageCount; + } +} diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java index 2dcf3d188..9481795a4 100644 --- a/src/java/org/apache/fop/area/inline/SpaceArea.java +++ b/src/java/org/apache/fop/area/inline/SpaceArea.java @@ -1,59 +1,59 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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;
-
-/**
- * A space
- */
-public class SpaceArea extends InlineArea {
-
- /**
- * The space for this space area
- */
- protected String space;
-
- /**
- * Is this space adjustable?
- */
- protected boolean isAdjustable;
-
- /**
- * Create a space area
- * @param s the space character
- * @param o the offset for the next area
- * @param a is this space adjustable?
- */
- public SpaceArea(char s, int o, boolean a) {
- space = new String() + s;
- offset = o;
- isAdjustable = a;
- }
-
- /**
- * @return Returns the space.
- */
- public String getSpace() {
- return new String(space);
- }
-
- /** @return true if the space is adjustable (WRT word-space processing) */
- public boolean isAdjustable() {
- return this.isAdjustable;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; + +/** + * A space + */ +public class SpaceArea extends InlineArea { + + /** + * The space for this space area + */ + protected String space; + + /** + * Is this space adjustable? + */ + protected boolean isAdjustable; + + /** + * Create a space area + * @param s the space character + * @param o the offset for the next area + * @param a is this space adjustable? + */ + public SpaceArea(char s, int o, boolean a) { + space = new String() + s; + offset = o; + isAdjustable = a; + } + + /** + * @return Returns the space. + */ + public String getSpace() { + return new String(space); + } + + /** @return true if the space is adjustable (WRT word-space processing) */ + public boolean isAdjustable() { + return this.isAdjustable; + } +} diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java index a592bdd80..1f5fa2037 100644 --- a/src/java/org/apache/fop/area/inline/WordArea.java +++ b/src/java/org/apache/fop/area/inline/WordArea.java @@ -1,72 +1,72 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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;
-
-/**
- * A string of characters without spaces
- */
-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;
-
- /**
- * Create a word area
- * @param w the word string
- * @param o the offset for the next area
- * @param la the letter adjust array (may be null)
- */
- public WordArea(String w, int o, int[] la) {
- word = w;
- offset = o;
- this.letterAdjust = la;
- }
-
- /**
- * @return Returns the word.
- */
- public String getWord() {
- return word;
- }
-
- /**
- * @return Returns the offset.
- */
- public int getOffset() {
- return offset;
- }
- /**
- * @param o The offset to set.
- */
- public void setOffset(int o) {
- offset = o;
- }
-
- /** @return the array of letter adjust widths */
- public int[] getLetterAdjustArray() {
- return this.letterAdjust;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; + +/** + * A string of characters without spaces + */ +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; + + /** + * Create a word area + * @param w the word string + * @param o the offset for the next area + * @param la the letter adjust array (may be null) + */ + public WordArea(String w, int o, int[] la) { + word = w; + offset = o; + this.letterAdjust = la; + } + + /** + * @return Returns the word. + */ + public String getWord() { + return word; + } + + /** + * @return Returns the offset. + */ + public int getOffset() { + return offset; + } + /** + * @param o The offset to set. + */ + 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/fo/properties/ColorProperty.java b/src/java/org/apache/fop/fo/properties/ColorProperty.java index d961ec3a3..de648420b 100644 --- a/src/java/org/apache/fop/fo/properties/ColorProperty.java +++ b/src/java/org/apache/fop/fo/properties/ColorProperty.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: ColorTypeProperty.java 377045 2006-02-11 20:23:47Z jeremias $ */ +/* $Id$ */ package org.apache.fop.fo.properties; diff --git a/src/java/org/apache/fop/fonts/CachedFontInfo.java b/src/java/org/apache/fop/fonts/CachedFontInfo.java index 35fec529c..3de3cfd4e 100644 --- a/src/java/org/apache/fop/fonts/CachedFontInfo.java +++ b/src/java/org/apache/fop/fonts/CachedFontInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts; diff --git a/src/java/org/apache/fop/fonts/FontCache.java b/src/java/org/apache/fop/fonts/FontCache.java index 036ec724e..efd7ea603 100644 --- a/src/java/org/apache/fop/fonts/FontCache.java +++ b/src/java/org/apache/fop/fonts/FontCache.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts; diff --git a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java index 7c0b4fcfa..aaefc789b 100644 --- a/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.autodetect; diff --git a/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java index 60d3fd7d3..8083eebb8 100644 --- a/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/MacFontDirFinder.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.autodetect; diff --git a/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java index 0c885ce7d..5339d541b 100644 --- a/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.autodetect; diff --git a/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java index 0d02c6daf..55a7ae1c0 100644 --- a/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/UnixFontDirFinder.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.autodetect; diff --git a/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java b/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java index bcb4ebb99..d87d22708 100644 --- a/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java +++ b/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.fonts.autodetect; diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java index 53f091f59..58267571e 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java @@ -1,129 +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.fonts.truetype;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.fop.fonts.BFEntry;
-import org.apache.fop.fonts.CIDFontType;
-import org.apache.fop.fonts.FontLoader;
-import org.apache.fop.fonts.FontResolver;
-import org.apache.fop.fonts.MultiByteFont;
-
-/**
- * Loads a font into memory directly from the original font file.
- */
-public class TTFFontLoader extends FontLoader {
-
- private MultiByteFont multiFont;
-
- /**
- * Default constructor
- * @param fontFileURI the URI representing the font file
- * @param in the InputStream to load the font from
- * @param resolver the FontResolver for font URI resolution
- */
- public TTFFontLoader(String fontFileURI, InputStream in, FontResolver resolver) {
- super(fontFileURI, in, resolver);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void read() throws IOException {
- TTFFile ttf = new TTFFile();
- FontFileReader reader = new FontFileReader(in);
- boolean supported = ttf.readFont(reader, null);
- if (!supported) {
- throw new IOException("Could not load TrueType font: " + fontFileURI);
- }
- if (ttf.isCFF()) {
- throw new UnsupportedOperationException(
- "OpenType fonts with CFF data are not supported, yet");
- }
- multiFont = new MultiByteFont();
- multiFont.setResolver(this.resolver);
- returnFont = multiFont;
-
- returnFont.setFontName(ttf.getPostScriptName());
- returnFont.setFullName(ttf.getFullName());
- returnFont.setFamilyNames(ttf.getFamilyNames());
- returnFont.setFontSubFamilyName(ttf.getSubFamilyName());
- //multiFont.setTTCName(ttcName)
- returnFont.setCapHeight(ttf.getCapHeight());
- returnFont.setXHeight(ttf.getXHeight());
- returnFont.setAscender(ttf.getLowerCaseAscent());
- returnFont.setDescender(ttf.getLowerCaseDescent());
- returnFont.setFontBBox(ttf.getFontBBox());
- //returnFont.setFirstChar(ttf.getFirstChar();)
- returnFont.setFlags(ttf.getFlags());
- returnFont.setStemV(Integer.parseInt(ttf.getStemV())); //not used for TTF
- returnFont.setItalicAngle(Integer.parseInt(ttf.getItalicAngle()));
- returnFont.setMissingWidth(0);
-
- multiFont.setCIDType(CIDFontType.CIDTYPE2);
- int[] wx = ttf.getWidths();
- multiFont.setWidthArray(wx);
- List entries = ttf.getCMaps();
- BFEntry[] bfentries = new BFEntry[entries.size()];
- int pos = 0;
- Iterator iter = ttf.getCMaps().listIterator();
- while (iter.hasNext()) {
- TTFCmapEntry ce = (TTFCmapEntry)iter.next();
- bfentries[pos] = new BFEntry(ce.getUnicodeStart(), ce.getUnicodeEnd(),
- ce.getGlyphStartIndex());
- pos++;
- }
- multiFont.setBFEntries(bfentries);
- copyKerning(ttf, true);
- multiFont.setEmbedFileName(this.fontFileURI);
- loaded = true;
- }
-
- /**
- * Copy kerning information.
- */
- private void copyKerning(TTFFile ttf, boolean isCid) {
-
- // Get kerning
- Iterator iter;
- if (isCid) {
- iter = ttf.getKerning().keySet().iterator();
- } else {
- iter = ttf.getAnsiKerning().keySet().iterator();
- }
-
- while (iter.hasNext()) {
- Integer kpx1 = (Integer)iter.next();
-
- Map h2;
- if (isCid) {
- h2 = (Map)ttf.getKerning().get(kpx1);
- } else {
- h2 = (Map)ttf.getAnsiKerning().get(kpx1);
- }
- returnFont.putKerningEntry(kpx1, h2);
- }
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.truetype; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.fop.fonts.BFEntry; +import org.apache.fop.fonts.CIDFontType; +import org.apache.fop.fonts.FontLoader; +import org.apache.fop.fonts.FontResolver; +import org.apache.fop.fonts.MultiByteFont; + +/** + * Loads a font into memory directly from the original font file. + */ +public class TTFFontLoader extends FontLoader { + + private MultiByteFont multiFont; + + /** + * Default constructor + * @param fontFileURI the URI representing the font file + * @param in the InputStream to load the font from + * @param resolver the FontResolver for font URI resolution + */ + public TTFFontLoader(String fontFileURI, InputStream in, FontResolver resolver) { + super(fontFileURI, in, resolver); + } + + /** + * {@inheritDoc} + */ + protected void read() throws IOException { + TTFFile ttf = new TTFFile(); + FontFileReader reader = new FontFileReader(in); + boolean supported = ttf.readFont(reader, null); + if (!supported) { + throw new IOException("Could not load TrueType font: " + fontFileURI); + } + if (ttf.isCFF()) { + throw new UnsupportedOperationException( + "OpenType fonts with CFF data are not supported, yet"); + } + multiFont = new MultiByteFont(); + multiFont.setResolver(this.resolver); + returnFont = multiFont; + + returnFont.setFontName(ttf.getPostScriptName()); + returnFont.setFullName(ttf.getFullName()); + returnFont.setFamilyNames(ttf.getFamilyNames()); + returnFont.setFontSubFamilyName(ttf.getSubFamilyName()); + //multiFont.setTTCName(ttcName) + returnFont.setCapHeight(ttf.getCapHeight()); + returnFont.setXHeight(ttf.getXHeight()); + returnFont.setAscender(ttf.getLowerCaseAscent()); + returnFont.setDescender(ttf.getLowerCaseDescent()); + returnFont.setFontBBox(ttf.getFontBBox()); + //returnFont.setFirstChar(ttf.getFirstChar();) + returnFont.setFlags(ttf.getFlags()); + returnFont.setStemV(Integer.parseInt(ttf.getStemV())); //not used for TTF + returnFont.setItalicAngle(Integer.parseInt(ttf.getItalicAngle())); + returnFont.setMissingWidth(0); + + multiFont.setCIDType(CIDFontType.CIDTYPE2); + int[] wx = ttf.getWidths(); + multiFont.setWidthArray(wx); + List entries = ttf.getCMaps(); + BFEntry[] bfentries = new BFEntry[entries.size()]; + int pos = 0; + Iterator iter = ttf.getCMaps().listIterator(); + while (iter.hasNext()) { + TTFCmapEntry ce = (TTFCmapEntry)iter.next(); + bfentries[pos] = new BFEntry(ce.getUnicodeStart(), ce.getUnicodeEnd(), + ce.getGlyphStartIndex()); + pos++; + } + multiFont.setBFEntries(bfentries); + copyKerning(ttf, true); + multiFont.setEmbedFileName(this.fontFileURI); + loaded = true; + } + + /** + * Copy kerning information. + */ + private void copyKerning(TTFFile ttf, boolean isCid) { + + // Get kerning + Iterator iter; + if (isCid) { + iter = ttf.getKerning().keySet().iterator(); + } else { + iter = ttf.getAnsiKerning().keySet().iterator(); + } + + while (iter.hasNext()) { + Integer kpx1 = (Integer)iter.next(); + + Map h2; + if (isCid) { + h2 = (Map)ttf.getKerning().get(kpx1); + } else { + h2 = (Map)ttf.getAnsiKerning().get(kpx1); + } + returnFont.putKerningEntry(kpx1, h2); + } + } +} diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java index 63962321c..1a1f691b2 100644 --- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java +++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java @@ -1,92 +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.fonts.type1;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-import org.apache.fop.fonts.FontLoader;
-import org.apache.fop.fonts.FontResolver;
-import org.apache.fop.fonts.FontType;
-import org.apache.fop.fonts.SingleByteFont;
-
-/**
- * Loads a Type 1 font into memory directly from the original font file.
- */
-public class Type1FontLoader extends FontLoader {
-
- private PFMFile pfm;
- private SingleByteFont singleFont;
-
- /**
- * Constructs a new Type 1 font loader.
- * @param fontFileURI the URI to the PFB file of a Type 1 font
- * @param in the InputStream reading the PFM file of a Type 1 font
- * @param resolver the font resolver used to resolve URIs
- * @throws IOException In case of an I/O error
- */
- public Type1FontLoader(String fontFileURI, InputStream in, FontResolver resolver)
- throws IOException {
- super(fontFileURI, in, resolver);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void read() throws IOException {
- pfm = new PFMFile();
- pfm.load(in);
- singleFont = new SingleByteFont();
- singleFont.setFontType(FontType.TYPE1);
- if (pfm.getCharSet() >= 0 && pfm.getCharSet() <= 2) {
- singleFont.setEncoding(pfm.getCharSetName() + "Encoding");
- } else {
- log.warn("The PFM reports an unsupported encoding ("
- + pfm.getCharSetName() + "). The font may not work as expected.");
- singleFont.setEncoding("WinAnsiEncoding"); //Try fallback, no guarantees!
- }
- singleFont.setResolver(this.resolver);
- returnFont = singleFont;
- returnFont.setFontName(pfm.getPostscriptName());
- String fullName = pfm.getPostscriptName();
- fullName = fullName.replace('-', ' '); //Hack! Try to emulate full name
- returnFont.setFullName(fullName); //should be afm.getFullName()!!
- //TODO not accurate: we need FullName from the AFM file but we don't have an AFM parser
- Set names = new java.util.HashSet();
- names.add(pfm.getWindowsName()); //should be afm.getFamilyName()!!
- returnFont.setFamilyNames(names);
- returnFont.setCapHeight(pfm.getCapHeight());
- returnFont.setXHeight(pfm.getXHeight());
- returnFont.setAscender(pfm.getLowerCaseAscent());
- returnFont.setDescender(pfm.getLowerCaseDescent());
- returnFont.setFontBBox(pfm.getFontBBox());
- returnFont.setFirstChar(pfm.getFirstChar());
- returnFont.setLastChar(pfm.getLastChar());
- returnFont.setFlags(pfm.getFlags());
- returnFont.setStemV(pfm.getStemV());
- returnFont.setItalicAngle(pfm.getItalicAngle());
- returnFont.setMissingWidth(0);
- for (short i = pfm.getFirstChar(); i <= pfm.getLastChar(); i++) {
- singleFont.setWidth(i, pfm.getCharWidth(i));
- }
- singleFont.setEmbedFileName(this.fontFileURI);
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.type1; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Set; + +import org.apache.fop.fonts.FontLoader; +import org.apache.fop.fonts.FontResolver; +import org.apache.fop.fonts.FontType; +import org.apache.fop.fonts.SingleByteFont; + +/** + * Loads a Type 1 font into memory directly from the original font file. + */ +public class Type1FontLoader extends FontLoader { + + private PFMFile pfm; + private SingleByteFont singleFont; + + /** + * Constructs a new Type 1 font loader. + * @param fontFileURI the URI to the PFB file of a Type 1 font + * @param in the InputStream reading the PFM file of a Type 1 font + * @param resolver the font resolver used to resolve URIs + * @throws IOException In case of an I/O error + */ + public Type1FontLoader(String fontFileURI, InputStream in, FontResolver resolver) + throws IOException { + super(fontFileURI, in, resolver); + } + + /** + * {@inheritDoc} + */ + protected void read() throws IOException { + pfm = new PFMFile(); + pfm.load(in); + singleFont = new SingleByteFont(); + singleFont.setFontType(FontType.TYPE1); + if (pfm.getCharSet() >= 0 && pfm.getCharSet() <= 2) { + singleFont.setEncoding(pfm.getCharSetName() + "Encoding"); + } else { + log.warn("The PFM reports an unsupported encoding (" + + pfm.getCharSetName() + "). The font may not work as expected."); + singleFont.setEncoding("WinAnsiEncoding"); //Try fallback, no guarantees! + } + singleFont.setResolver(this.resolver); + returnFont = singleFont; + returnFont.setFontName(pfm.getPostscriptName()); + String fullName = pfm.getPostscriptName(); + fullName = fullName.replace('-', ' '); //Hack! Try to emulate full name + returnFont.setFullName(fullName); //should be afm.getFullName()!! + //TODO not accurate: we need FullName from the AFM file but we don't have an AFM parser + Set names = new java.util.HashSet(); + names.add(pfm.getWindowsName()); //should be afm.getFamilyName()!! + returnFont.setFamilyNames(names); + returnFont.setCapHeight(pfm.getCapHeight()); + returnFont.setXHeight(pfm.getXHeight()); + returnFont.setAscender(pfm.getLowerCaseAscent()); + returnFont.setDescender(pfm.getLowerCaseDescent()); + returnFont.setFontBBox(pfm.getFontBBox()); + returnFont.setFirstChar(pfm.getFirstChar()); + returnFont.setLastChar(pfm.getLastChar()); + returnFont.setFlags(pfm.getFlags()); + returnFont.setStemV(pfm.getStemV()); + returnFont.setItalicAngle(pfm.getItalicAngle()); + returnFont.setMissingWidth(0); + for (short i = pfm.getFirstChar(); i <= pfm.getLastChar(); i++) { + singleFont.setWidth(i, pfm.getCharWidth(i)); + } + singleFont.setEmbedFileName(this.fontFileURI); + } +} diff --git a/src/java/org/apache/fop/image/EmfImage.java b/src/java/org/apache/fop/image/EmfImage.java index 1221b9b2b..73bbad232 100644 --- a/src/java/org/apache/fop/image/EmfImage.java +++ b/src/java/org/apache/fop/image/EmfImage.java @@ -1,51 +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.image;
-
-/**
- * Enhanced metafile image.
- * This supports loading a EMF image.
- *
- * @see AbstractFopImage
- * @see FopImage
- */
-public class EmfImage extends AbstractFopImage {
-
- /**
- * Create a bitmap image with the image data.
- *
- * @param imgInfo the image information
- */
- public EmfImage(FopImage.ImageInfo imgInfo) {
- super(imgInfo);
- }
-
- /**
- * Load the original EMF data.
- * This loads the original EMF data and reads the color space,
- * and icc profile if any.
- *
- * @return true if loaded false for any error
- */
- protected boolean loadOriginalData() {
- return loadDefaultOriginalData();
- }
-}
-
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.image; + +/** + * Enhanced metafile image. + * This supports loading a EMF image. + * + * @see AbstractFopImage + * @see FopImage + */ +public class EmfImage extends AbstractFopImage { + + /** + * Create a bitmap image with the image data. + * + * @param imgInfo the image information + */ + public EmfImage(FopImage.ImageInfo imgInfo) { + super(imgInfo); + } + + /** + * Load the original EMF data. + * This loads the original EMF data and reads the color space, + * and icc profile if any. + * + * @return true if loaded false for any error + */ + protected boolean loadOriginalData() { + return loadDefaultOriginalData(); + } +} + diff --git a/src/java/org/apache/fop/image/analyser/EMFReader.java b/src/java/org/apache/fop/image/analyser/EMFReader.java index bdc4e97ff..d6e2f2975 100644 --- a/src/java/org/apache/fop/image/analyser/EMFReader.java +++ b/src/java/org/apache/fop/image/analyser/EMFReader.java @@ -1,162 +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.image.analyser;
-
-// Java
-import java.io.InputStream;
-import java.io.IOException;
-
-// FOP
-import org.apache.fop.image.FopImage;
-import org.apache.fop.apps.FOUserAgent;
-
-/**
- * ImageReader object for EMF image type.
- *
- * @author Peter Herweg
- */
-public class EMFReader implements ImageReader {
-
- /** Length of the EMF header */
- protected static final int EMF_SIG_LENGTH = 88;
-
- /** offset to signature */
- private static final int SIGNATURE_OFFSET = 40;
- /** offset to width */
- private static final int WIDTH_OFFSET = 32;
- /** offset to height */
- private static final int HEIGHT_OFFSET = 36;
- /** offset to horizontal resolution in pixel */
- private static final int HRES_PIXEL_OFFSET = 72;
- /** offset to vertical resolution in pixel */
- private static final int VRES_PIXEL_OFFSET = 76;
- /** offset to horizontal resolution in mm */
- private static final int HRES_MM_OFFSET = 80;
- /** offset to vertical resolution in mm */
- private static final int VRES_MM_OFFSET = 84;
-
- /** {@inheritDoc} */
- public FopImage.ImageInfo verifySignature(String uri, InputStream bis,
- FOUserAgent ua) throws IOException {
- byte[] header = getDefaultHeader(bis);
- boolean supported
- = ( (header[SIGNATURE_OFFSET + 0] == (byte) 0x20)
- && (header[SIGNATURE_OFFSET + 1] == (byte) 0x45)
- && (header[SIGNATURE_OFFSET + 2] == (byte) 0x4D)
- && (header[SIGNATURE_OFFSET + 3] == (byte) 0x46) );
-
- if (supported) {
- FopImage.ImageInfo info = getDimension(header);
- info.originalURI = uri;
- info.mimeType = getMimeType();
- info.inputStream = bis;
- return info;
- } else {
- return null;
- }
- }
-
- /**
- * Returns the MIME type supported by this implementation.
- *
- * @return The MIME type
- */
- public String getMimeType() {
- return "image/emf";
- }
-
- private FopImage.ImageInfo getDimension(byte[] header) {
- FopImage.ImageInfo info = new FopImage.ImageInfo();
- long value = 0;
- int byte1;
- int byte2;
- int byte3;
- int byte4;
-
- // little endian notation
-
- //resolution
- byte1 = header[HRES_MM_OFFSET] & 0xff;
- byte2 = header[HRES_MM_OFFSET + 1] & 0xff;
- byte3 = header[HRES_MM_OFFSET + 2] & 0xff;
- byte4 = header[HRES_MM_OFFSET + 3] & 0xff;
- long hresMM = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1);
-
- byte1 = header[VRES_MM_OFFSET] & 0xff;
- byte2 = header[VRES_MM_OFFSET + 1] & 0xff;
- byte3 = header[VRES_MM_OFFSET + 2] & 0xff;
- byte4 = header[VRES_MM_OFFSET + 3] & 0xff;
- long vresMM = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1);
-
- byte1 = header[HRES_PIXEL_OFFSET] & 0xff;
- byte2 = header[HRES_PIXEL_OFFSET + 1] & 0xff;
- byte3 = header[HRES_PIXEL_OFFSET + 2] & 0xff;
- byte4 = header[HRES_PIXEL_OFFSET + 3] & 0xff;
- long hresPixel = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1);
-
- byte1 = header[VRES_PIXEL_OFFSET] & 0xff;
- byte2 = header[VRES_PIXEL_OFFSET + 1] & 0xff;
- byte3 = header[VRES_PIXEL_OFFSET + 2] & 0xff;
- byte4 = header[VRES_PIXEL_OFFSET + 3] & 0xff;
- long vresPixel = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1);
-
- info.dpiHorizontal = hresPixel / (hresMM / 25.4f);
- info.dpiVertical = vresPixel / (vresMM / 25.4f);
-
- //width
- byte1 = header[WIDTH_OFFSET] & 0xff;
- byte2 = header[WIDTH_OFFSET + 1] & 0xff;
- byte3 = header[WIDTH_OFFSET + 2] & 0xff;
- byte4 = header[WIDTH_OFFSET + 3] & 0xff;
- value = (long) ((byte4 << 24) | (byte3 << 16)
- | (byte2 << 8) | byte1);
- value = Math.round(value / 100f / 25.4f * info.dpiHorizontal);
- info.width = (int) (value & 0xffffffff);
-
- //height
- byte1 = header[HEIGHT_OFFSET] & 0xff;
- byte2 = header[HEIGHT_OFFSET + 1] & 0xff;
- byte3 = header[HEIGHT_OFFSET + 2] & 0xff;
- byte4 = header[HEIGHT_OFFSET + 3] & 0xff;
- value = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1);
- value = Math.round(value / 100f / 25.4f * info.dpiVertical);
- info.height = (int) (value & 0xffffffff);
-
- return info;
- }
-
- private byte[] getDefaultHeader(InputStream imageStream)
- throws IOException {
- byte[] header = new byte[EMF_SIG_LENGTH];
- try {
- imageStream.mark(EMF_SIG_LENGTH + 1);
- imageStream.read(header);
- imageStream.reset();
- } catch (IOException ex) {
- try {
- imageStream.reset();
- } catch (IOException exbis) {
- // throw the original exception, not this one
- }
- throw ex;
- }
- return header;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.image.analyser; + +// Java +import java.io.InputStream; +import java.io.IOException; + +// FOP +import org.apache.fop.image.FopImage; +import org.apache.fop.apps.FOUserAgent; + +/** + * ImageReader object for EMF image type. + * + * @author Peter Herweg + */ +public class EMFReader implements ImageReader { + + /** Length of the EMF header */ + protected static final int EMF_SIG_LENGTH = 88; + + /** offset to signature */ + private static final int SIGNATURE_OFFSET = 40; + /** offset to width */ + private static final int WIDTH_OFFSET = 32; + /** offset to height */ + private static final int HEIGHT_OFFSET = 36; + /** offset to horizontal resolution in pixel */ + private static final int HRES_PIXEL_OFFSET = 72; + /** offset to vertical resolution in pixel */ + private static final int VRES_PIXEL_OFFSET = 76; + /** offset to horizontal resolution in mm */ + private static final int HRES_MM_OFFSET = 80; + /** offset to vertical resolution in mm */ + private static final int VRES_MM_OFFSET = 84; + + /** {@inheritDoc} */ + public FopImage.ImageInfo verifySignature(String uri, InputStream bis, + FOUserAgent ua) throws IOException { + byte[] header = getDefaultHeader(bis); + boolean supported + = ( (header[SIGNATURE_OFFSET + 0] == (byte) 0x20) + && (header[SIGNATURE_OFFSET + 1] == (byte) 0x45) + && (header[SIGNATURE_OFFSET + 2] == (byte) 0x4D) + && (header[SIGNATURE_OFFSET + 3] == (byte) 0x46) ); + + if (supported) { + FopImage.ImageInfo info = getDimension(header); + info.originalURI = uri; + info.mimeType = getMimeType(); + info.inputStream = bis; + return info; + } else { + return null; + } + } + + /** + * Returns the MIME type supported by this implementation. + * + * @return The MIME type + */ + public String getMimeType() { + return "image/emf"; + } + + private FopImage.ImageInfo getDimension(byte[] header) { + FopImage.ImageInfo info = new FopImage.ImageInfo(); + long value = 0; + int byte1; + int byte2; + int byte3; + int byte4; + + // little endian notation + + //resolution + byte1 = header[HRES_MM_OFFSET] & 0xff; + byte2 = header[HRES_MM_OFFSET + 1] & 0xff; + byte3 = header[HRES_MM_OFFSET + 2] & 0xff; + byte4 = header[HRES_MM_OFFSET + 3] & 0xff; + long hresMM = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1); + + byte1 = header[VRES_MM_OFFSET] & 0xff; + byte2 = header[VRES_MM_OFFSET + 1] & 0xff; + byte3 = header[VRES_MM_OFFSET + 2] & 0xff; + byte4 = header[VRES_MM_OFFSET + 3] & 0xff; + long vresMM = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1); + + byte1 = header[HRES_PIXEL_OFFSET] & 0xff; + byte2 = header[HRES_PIXEL_OFFSET + 1] & 0xff; + byte3 = header[HRES_PIXEL_OFFSET + 2] & 0xff; + byte4 = header[HRES_PIXEL_OFFSET + 3] & 0xff; + long hresPixel = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1); + + byte1 = header[VRES_PIXEL_OFFSET] & 0xff; + byte2 = header[VRES_PIXEL_OFFSET + 1] & 0xff; + byte3 = header[VRES_PIXEL_OFFSET + 2] & 0xff; + byte4 = header[VRES_PIXEL_OFFSET + 3] & 0xff; + long vresPixel = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1); + + info.dpiHorizontal = hresPixel / (hresMM / 25.4f); + info.dpiVertical = vresPixel / (vresMM / 25.4f); + + //width + byte1 = header[WIDTH_OFFSET] & 0xff; + byte2 = header[WIDTH_OFFSET + 1] & 0xff; + byte3 = header[WIDTH_OFFSET + 2] & 0xff; + byte4 = header[WIDTH_OFFSET + 3] & 0xff; + value = (long) ((byte4 << 24) | (byte3 << 16) + | (byte2 << 8) | byte1); + value = Math.round(value / 100f / 25.4f * info.dpiHorizontal); + info.width = (int) (value & 0xffffffff); + + //height + byte1 = header[HEIGHT_OFFSET] & 0xff; + byte2 = header[HEIGHT_OFFSET + 1] & 0xff; + byte3 = header[HEIGHT_OFFSET + 2] & 0xff; + byte4 = header[HEIGHT_OFFSET + 3] & 0xff; + value = (long) ((byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1); + value = Math.round(value / 100f / 25.4f * info.dpiVertical); + info.height = (int) (value & 0xffffffff); + + return info; + } + + private byte[] getDefaultHeader(InputStream imageStream) + throws IOException { + byte[] header = new byte[EMF_SIG_LENGTH]; + try { + imageStream.mark(EMF_SIG_LENGTH + 1); + imageStream.read(header); + imageStream.reset(); + } catch (IOException ex) { + try { + imageStream.reset(); + } catch (IOException exbis) { + // throw the original exception, not this one + } + throw ex; + } + return header; + } +} diff --git a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java index 8d7375451..a28fdbfbc 100644 --- a/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/BalancingColumnBreakingAlgorithm.java @@ -1,107 +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.layoutmgr;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.fop.traits.MinOptMax;
-
-/**
- * This is a the breaking algorithm that is responsible for balancing columns in multi-column
- * layout.
- */
-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,
- int alignment, int alignmentLast,
- MinOptMax footnoteSeparatorLength,
- boolean partOverflowRecovery,
- int columnCount) {
- super(topLevelLM, pageProvider, layoutListener,
- 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
- + " line=" + activeNode.line + "/" + columnCount
- + " pos=" + activeNode.position + "/" + (par.size() - 1));
- }
- int remParts = columnCount - activeNode.line;
- int curPos = par.indexOf(element);
- if (fullLen == 0) {
- fullLen = ElementListUtils.calcContentLength(par, activeNode.position, par.size() - 1);
- this.idealPartLen = (fullLen / columnCount);
- }
- int partLen = ElementListUtils.calcContentLength(par, activeNode.position, curPos - 1);
- int restLen = ElementListUtils.calcContentLength(par, curPos - 1, par.size() - 1);
- int avgRestLen = 0;
- if (remParts > 0) {
- avgRestLen = restLen / remParts;
- }
- if (log.isTraceEnabled()) {
- log.trace("remaining parts: " + remParts + " rest len: " + restLen
- + " avg=" + avgRestLen);
- }
- double balance = (idealPartLen - partLen) / 1000f;
- if (log.isTraceEnabled()) {
- log.trace("balance=" + balance);
- }
- double absBalance = Math.abs(balance);
- dem = absBalance;
- //Step 1: This does the rough balancing
- if (columnCount > 2) {
- if (balance > 0) {
- //shorter parts are less desired than longer ones
- dem = dem * 1.2f;
- }
- } else {
- if (balance < 0) {
- //shorter parts are less desired than longer ones
- dem = dem * 1.2f;
- }
- }
- //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;
- }
- if (log.isTraceEnabled()) {
- log.trace("effective dem=" + dem + " " + totalWidth);
- }
- return dem;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.traits.MinOptMax; + +/** + * This is a the breaking algorithm that is responsible for balancing columns in multi-column + * layout. + */ +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, + int alignment, int alignmentLast, + MinOptMax footnoteSeparatorLength, + boolean partOverflowRecovery, + int columnCount) { + super(topLevelLM, pageProvider, layoutListener, + 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 + + " line=" + activeNode.line + "/" + columnCount + + " pos=" + activeNode.position + "/" + (par.size() - 1)); + } + int remParts = columnCount - activeNode.line; + int curPos = par.indexOf(element); + if (fullLen == 0) { + fullLen = ElementListUtils.calcContentLength(par, activeNode.position, par.size() - 1); + this.idealPartLen = (fullLen / columnCount); + } + int partLen = ElementListUtils.calcContentLength(par, activeNode.position, curPos - 1); + int restLen = ElementListUtils.calcContentLength(par, curPos - 1, par.size() - 1); + int avgRestLen = 0; + if (remParts > 0) { + avgRestLen = restLen / remParts; + } + if (log.isTraceEnabled()) { + log.trace("remaining parts: " + remParts + " rest len: " + restLen + + " avg=" + avgRestLen); + } + double balance = (idealPartLen - partLen) / 1000f; + if (log.isTraceEnabled()) { + log.trace("balance=" + balance); + } + double absBalance = Math.abs(balance); + dem = absBalance; + //Step 1: This does the rough balancing + if (columnCount > 2) { + if (balance > 0) { + //shorter parts are less desired than longer ones + dem = dem * 1.2f; + } + } else { + if (balance < 0) { + //shorter parts are less desired than longer ones + dem = dem * 1.2f; + } + } + //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; + } + if (log.isTraceEnabled()) { + log.trace("effective dem=" + dem + " " + totalWidth); + } + return dem; + } +} diff --git a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java index 72dae25c3..09e22d481 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java @@ -1,81 +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.layoutmgr.inline;
-
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.fo.flow.Wrapper;
-import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.PositionIterator;
-import org.apache.fop.layoutmgr.TraitSetter;
-
-/**
- * This is the layout manager for the fo:wrapper formatting object.
- */
-public class WrapperLayoutManager extends LeafNodeLayoutManager {
-
- private Wrapper fobj;
-
- /**
- * Creates a new LM for fo:wrapper.
- * @param node the fo:wrapper
- */
- public WrapperLayoutManager(Wrapper node) {
- super(node);
- fobj = node;
- }
-
- /** {@inheritDoc} */
- public InlineArea get(LayoutContext context) {
- // Create a zero-width, zero-height dummy area so this node can
- // participate in the ID handling. Otherwise, addId() wouldn't
- // be called. The area must also be added to the tree, because
- // determination of the X,Y position is done in the renderer.
- InlineArea area = new InlineArea();
- if (fobj.hasId()) {
- TraitSetter.setProducerID(area, fobj.getId());
- }
- return area;
- }
-
- /**
- * Add the area for this layout manager.
- * This adds the dummy area to the parent, *if* it has an id
- * - otherwise it serves no purpose.
- *
- * @param posIter the position iterator
- * @param context the layout context for adding the area
- */
- public void addAreas(PositionIterator posIter, LayoutContext context) {
- if (fobj.hasId()) {
- addId();
- InlineArea area = getEffectiveArea();
- parentLM.addChildArea(area);
- }
- while (posIter.hasNext()) {
- posIter.next();
- }
- }
-
- /** {@inheritDoc} */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.apache.fop.area.inline.InlineArea; +import org.apache.fop.fo.flow.Wrapper; +import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.TraitSetter; + +/** + * This is the layout manager for the fo:wrapper formatting object. + */ +public class WrapperLayoutManager extends LeafNodeLayoutManager { + + private Wrapper fobj; + + /** + * Creates a new LM for fo:wrapper. + * @param node the fo:wrapper + */ + public WrapperLayoutManager(Wrapper node) { + super(node); + fobj = node; + } + + /** {@inheritDoc} */ + public InlineArea get(LayoutContext context) { + // Create a zero-width, zero-height dummy area so this node can + // participate in the ID handling. Otherwise, addId() wouldn't + // be called. The area must also be added to the tree, because + // determination of the X,Y position is done in the renderer. + InlineArea area = new InlineArea(); + if (fobj.hasId()) { + TraitSetter.setProducerID(area, fobj.getId()); + } + return area; + } + + /** + * Add the area for this layout manager. + * This adds the dummy area to the parent, *if* it has an id + * - otherwise it serves no purpose. + * + * @param posIter the position iterator + * @param context the layout context for adding the area + */ + public void addAreas(PositionIterator posIter, LayoutContext context) { + if (fobj.hasId()) { + addId(); + InlineArea area = getEffectiveArea(); + parentLM.addChildArea(area); + } + while (posIter.hasNext()) { + posIter.next(); + } + } + + /** {@inheritDoc} */ + protected void addId() { + getPSLM().addIDToPage(fobj.getId()); + } + +} diff --git a/src/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java b/src/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java index ffa76dff4..b122db56f 100644 --- a/src/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java +++ b/src/java/org/apache/fop/render/AbstractFOEventHandlerMaker.java @@ -1,69 +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.render;
-
-import java.io.OutputStream;
-
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.fo.FOEventHandler;
-
-/**
- * Base class for factory classes which instantiate FOEventHandlers and provide information
- * about them.
- */
-public abstract class AbstractFOEventHandlerMaker {
-
- /**
- * Instantiates a new FOEventHandler.
- * @param ua the user agent
- * @param out OutputStream for the FOEventHandler to use
- * @return the newly instantiated FOEventHandler
- * @throws FOPException if a problem occurs while creating the event handler
- */
- public abstract FOEventHandler makeFOEventHandler(FOUserAgent ua, OutputStream out)
- throws FOPException;
-
- /**
- * @return Indicates whether this renderer requires an OutputStream to work with.
- */
- public abstract boolean needsOutputStream();
-
- /**
- * @return an array of MIME types the renderer supports.
- */
- public abstract String[] getSupportedMimeTypes();
-
- /**
- * Indicates whether a specific MIME type is supported by this renderer.
- * @param mimeType the MIME type (ex. "application/rtf")
- * @return true if the MIME type is supported
- */
- public boolean isMimeTypeSupported(String mimeType) {
- String[] mimes = getSupportedMimeTypes();
- for (int i = 0; i < mimes.length; i++) {
- if (mimes[i].equals(mimeType)) {
- return true;
- }
- }
- return false;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.OutputStream; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.fo.FOEventHandler; + +/** + * Base class for factory classes which instantiate FOEventHandlers and provide information + * about them. + */ +public abstract class AbstractFOEventHandlerMaker { + + /** + * Instantiates a new FOEventHandler. + * @param ua the user agent + * @param out OutputStream for the FOEventHandler to use + * @return the newly instantiated FOEventHandler + * @throws FOPException if a problem occurs while creating the event handler + */ + public abstract FOEventHandler makeFOEventHandler(FOUserAgent ua, OutputStream out) + throws FOPException; + + /** + * @return Indicates whether this renderer requires an OutputStream to work with. + */ + public abstract boolean needsOutputStream(); + + /** + * @return an array of MIME types the renderer supports. + */ + public abstract String[] getSupportedMimeTypes(); + + /** + * Indicates whether a specific MIME type is supported by this renderer. + * @param mimeType the MIME type (ex. "application/rtf") + * @return true if the MIME type is supported + */ + public boolean isMimeTypeSupported(String mimeType) { + String[] mimes = getSupportedMimeTypes(); + for (int i = 0; i < mimes.length; i++) { + if (mimes[i].equals(mimeType)) { + return true; + } + } + return false; + } + +} diff --git a/src/java/org/apache/fop/render/AbstractRendererConfigurator.java b/src/java/org/apache/fop/render/AbstractRendererConfigurator.java index 670881643..d6851c3c5 100644 --- a/src/java/org/apache/fop/render/AbstractRendererConfigurator.java +++ b/src/java/org/apache/fop/render/AbstractRendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render; diff --git a/src/java/org/apache/fop/render/AbstractRendererMaker.java b/src/java/org/apache/fop/render/AbstractRendererMaker.java index ab1ddb338..381d2e134 100644 --- a/src/java/org/apache/fop/render/AbstractRendererMaker.java +++ b/src/java/org/apache/fop/render/AbstractRendererMaker.java @@ -1,71 +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.render;
-
-import org.apache.fop.apps.FOUserAgent;
-
-/**
- * Base class for factory classes which instantiate Renderers and provide information
- * about them.
- */
-public abstract class AbstractRendererMaker {
-
- /**
- * Instantiates a new renderer.
- * @param userAgent the user agent
- * @return the newly instantiated renderer
- */
- public abstract Renderer makeRenderer(FOUserAgent userAgent);
-
- /**
- * @return Indicates whether this renderer requires an OutputStream to work with.
- */
- public abstract boolean needsOutputStream();
-
- /**
- * @return an array of MIME types the renderer supports.
- */
- public abstract String[] getSupportedMimeTypes();
-
- /**
- * Returns a renderer config object that can be used to
- * configure the renderer.
- * @param userAgent user agent
- * @return a config object that can be used to configure the renderer
- */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return null;
- }
-
- /**
- * Indicates whether a specific MIME type is supported by this renderer.
- * @param mimeType the MIME type (ex. "application/pdf")
- * @return true if the MIME type is supported
- */
- public boolean isMimeTypeSupported(String mimeType) {
- String[] mimes = getSupportedMimeTypes();
- for (int i = 0; i < mimes.length; i++) {
- if (mimes[i].equals(mimeType)) {
- return true;
- }
- }
- return false;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.fop.apps.FOUserAgent; + +/** + * Base class for factory classes which instantiate Renderers and provide information + * about them. + */ +public abstract class AbstractRendererMaker { + + /** + * Instantiates a new renderer. + * @param userAgent the user agent + * @return the newly instantiated renderer + */ + public abstract Renderer makeRenderer(FOUserAgent userAgent); + + /** + * @return Indicates whether this renderer requires an OutputStream to work with. + */ + public abstract boolean needsOutputStream(); + + /** + * @return an array of MIME types the renderer supports. + */ + public abstract String[] getSupportedMimeTypes(); + + /** + * Returns a renderer config object that can be used to + * configure the renderer. + * @param userAgent user agent + * @return a config object that can be used to configure the renderer + */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return null; + } + + /** + * Indicates whether a specific MIME type is supported by this renderer. + * @param mimeType the MIME type (ex. "application/pdf") + * @return true if the MIME type is supported + */ + public boolean isMimeTypeSupported(String mimeType) { + String[] mimes = getSupportedMimeTypes(); + for (int i = 0; i < mimes.length; i++) { + if (mimes[i].equals(mimeType)) { + return true; + } + } + return false; + } +} diff --git a/src/java/org/apache/fop/render/Graphics2DAdapter.java b/src/java/org/apache/fop/render/Graphics2DAdapter.java index e9b00f103..0123e04a1 100644 --- a/src/java/org/apache/fop/render/Graphics2DAdapter.java +++ b/src/java/org/apache/fop/render/Graphics2DAdapter.java @@ -1,50 +1,50 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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;
-
-/**
- * This interface represents an optional feature that can be provided by
- * a renderer. It is exposed by calling the getGraphics2DAdapter() method
- * on the renderer. Renderers that support this feature allow painting
- * of arbitrary images through a Graphics2D instance.
- */
-public interface Graphics2DAdapter {
-
- /**
- * Paints an arbitrary images on a given Graphics2D instance. The renderer
- * providing this functionality must set up a Graphics2D instance so that
- * the image with the given extents (in mpt) can be painted by the painter
- * passed to this method. The Graphics2DImagePainter is then passed this
- * Graphics2D instance so the image can be painted.
- * @param painter the painter which will paint the actual image
- * @param context the renderer context for the current renderer
- * @param x X position of the image
- * @param y Y position of the image
- * @param width width of the image
- * @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,
- RendererContext context,
- int x, int y, int width, int height) throws IOException;
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; + +/** + * This interface represents an optional feature that can be provided by + * a renderer. It is exposed by calling the getGraphics2DAdapter() method + * on the renderer. Renderers that support this feature allow painting + * of arbitrary images through a Graphics2D instance. + */ +public interface Graphics2DAdapter { + + /** + * Paints an arbitrary images on a given Graphics2D instance. The renderer + * providing this functionality must set up a Graphics2D instance so that + * the image with the given extents (in mpt) can be painted by the painter + * passed to this method. The Graphics2DImagePainter is then passed this + * Graphics2D instance so the image can be painted. + * @param painter the painter which will paint the actual image + * @param context the renderer context for the current renderer + * @param x X position of the image + * @param y Y position of the image + * @param width width of the image + * @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, + 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 9301a6962..0167417fe 100644 --- a/src/java/org/apache/fop/render/Graphics2DImagePainter.java +++ b/src/java/org/apache/fop/render/Graphics2DImagePainter.java @@ -1,30 +1,30 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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;
-
-/**
- * This interface is used by the Graphics2DAdapter. Components that can paint using
- * a Graphics2D instance can implement this interface to paint themselves.
- * @deprecated use {@link org.apache.xmlgraphics.java2d.Graphics2DImagePainter} directly!
- */
-public interface Graphics2DImagePainter
- extends org.apache.xmlgraphics.java2d.Graphics2DImagePainter {
-
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; + +/** + * This interface is used by the Graphics2DAdapter. Components that can paint using + * a Graphics2D instance can implement this interface to paint themselves. + * @deprecated use {@link org.apache.xmlgraphics.java2d.Graphics2DImagePainter} directly! + */ +public interface Graphics2DImagePainter + extends org.apache.xmlgraphics.java2d.Graphics2DImagePainter { + }
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/ImageAdapter.java b/src/java/org/apache/fop/render/ImageAdapter.java index 93d6856d7..1984cfa96 100644 --- a/src/java/org/apache/fop/render/ImageAdapter.java +++ b/src/java/org/apache/fop/render/ImageAdapter.java @@ -1,47 +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.render;
-
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-
-/**
- * This interface represents an optional feature that can be provided by
- * a renderer. It is exposed by calling the getImageAdapter() method
- * on the renderer. Renderers that support this feature allow painting
- * of images (RendererImage instances).
- */
-public interface ImageAdapter {
-
- /**
- * Paints an image at the given position.
- * @param image the image which will be painted
- * @param context the renderer context for the current renderer
- * @param x X position of the image
- * @param y Y position of the image
- * @param width width of the image
- * @param height height of the image
- * @throws IOException In case of an I/O error while writing the output format
- */
- void paintImage(RenderedImage image,
- RendererContext context,
- int x, int y, int width, int height) throws IOException;
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.image.RenderedImage; +import java.io.IOException; + +/** + * This interface represents an optional feature that can be provided by + * a renderer. It is exposed by calling the getImageAdapter() method + * on the renderer. Renderers that support this feature allow painting + * of images (RendererImage instances). + */ +public interface ImageAdapter { + + /** + * Paints an image at the given position. + * @param image the image which will be painted + * @param context the renderer context for the current renderer + * @param x X position of the image + * @param y Y position of the image + * @param width width of the image + * @param height height of the image + * @throws IOException In case of an I/O error while writing the output format + */ + 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 0f53f2edc..0f0acd60d 100644 --- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java +++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render; diff --git a/src/java/org/apache/fop/render/RendererConfigurator.java b/src/java/org/apache/fop/render/RendererConfigurator.java index 566daf07d..028a4863b 100644 --- a/src/java/org/apache/fop/render/RendererConfigurator.java +++ b/src/java/org/apache/fop/render/RendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render; diff --git a/src/java/org/apache/fop/render/XMLHandlerConfigurator.java b/src/java/org/apache/fop/render/XMLHandlerConfigurator.java index bf63329d7..78822e9c0 100644 --- a/src/java/org/apache/fop/render/XMLHandlerConfigurator.java +++ b/src/java/org/apache/fop/render/XMLHandlerConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render; diff --git a/src/java/org/apache/fop/render/XMLHandlerRegistry.java b/src/java/org/apache/fop/render/XMLHandlerRegistry.java index 0a105262f..533534c4c 100644 --- a/src/java/org/apache/fop/render/XMLHandlerRegistry.java +++ b/src/java/org/apache/fop/render/XMLHandlerRegistry.java @@ -1,166 +1,166 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.util.Service;
-
-/**
- * This class holds references to various XML handlers used by FOP. It also
- * supports automatic discovery of additional XML handlers available through
- * the class path.
- */
-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
- */
- 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
- */
- public void addXMLHandler(String classname) {
- try {
- XMLHandler handlerInstance = (XMLHandler)Class.forName(classname).newInstance();
- addXMLHandler(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 "
- + XMLHandler.class.getName());
- }
- }
-
- /**
- * Add an XML handler. The handler itself is inspected to find out what it supports.
- * @param handler the XMLHandler instance
- */
- public void addXMLHandler(XMLHandler handler) {
- String ns = handler.getNamespace();
- if (ns == null) {
- setDefaultXMLHandler(handler);
- } else {
- addXMLHandler(ns, handler);
- }
- }
-
- /**
- * Add an XML handler for the given MIME type and XML namespace.
- * @param ns Namespace URI
- * @param handler XMLHandler to use
- */
- private void addXMLHandler(String ns,
- XMLHandler handler) {
- List lst = (List)handlers.get(ns);
- if (lst == null) {
- lst = new java.util.ArrayList();
- handlers.put(ns, lst);
- }
- 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.
- * @param renderer the Renderer for which to retrieve a Renderer
- * @param ns the XML namespace associated with the XML to be rendered
- * @return the XMLHandler responsible for handling the XML or null if none is available
- */
- public XMLHandler getXMLHandler(Renderer renderer, String ns) {
- XMLHandler handler;
-
- List lst = (List)handlers.get(ns);
- handler = getXMLHandler(renderer, lst);
- if (handler == null) {
- lst = (List)handlers.get(XMLHandler.HANDLE_ALL);
- handler = getXMLHandler(renderer, lst);
- }
- return handler;
- }
-
- private XMLHandler getXMLHandler(Renderer renderer, List lst) {
- XMLHandler handler;
- if (lst != null) {
- for (int i = 0, c = lst.size(); i < c; i++) {
- //TODO Maybe add priorities later
- handler = (XMLHandler)lst.get(i);
- if (handler.supportsRenderer(renderer)) {
- return handler;
- }
- }
- }
- return null; //No handler found
- }
-
- /**
- * Discovers XMLHandler implementations through the classpath and dynamically
- * registers them.
- */
- private void discoverXMLHandlers() {
- // add mappings from available services
- Iterator providers = Service.providers(XMLHandler.class);
- if (providers != null) {
- while (providers.hasNext()) {
- XMLHandler handler = (XMLHandler)providers.next();
- try {
- if (log.isDebugEnabled()) {
- log.debug("Dynamically adding XMLHandler: " + handler.getClass().getName());
- }
- addXMLHandler(handler);
- } catch (IllegalArgumentException e) {
- log.error("Error while adding XMLHandler", e);
- }
-
- }
- }
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.apache.xmlgraphics.util.Service; + +/** + * This class holds references to various XML handlers used by FOP. It also + * supports automatic discovery of additional XML handlers available through + * the class path. + */ +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 + */ + 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 + */ + public void addXMLHandler(String classname) { + try { + XMLHandler handlerInstance = (XMLHandler)Class.forName(classname).newInstance(); + addXMLHandler(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 " + + XMLHandler.class.getName()); + } + } + + /** + * Add an XML handler. The handler itself is inspected to find out what it supports. + * @param handler the XMLHandler instance + */ + public void addXMLHandler(XMLHandler handler) { + String ns = handler.getNamespace(); + if (ns == null) { + setDefaultXMLHandler(handler); + } else { + addXMLHandler(ns, handler); + } + } + + /** + * Add an XML handler for the given MIME type and XML namespace. + * @param ns Namespace URI + * @param handler XMLHandler to use + */ + private void addXMLHandler(String ns, + XMLHandler handler) { + List lst = (List)handlers.get(ns); + if (lst == null) { + lst = new java.util.ArrayList(); + handlers.put(ns, lst); + } + 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. + * @param renderer the Renderer for which to retrieve a Renderer + * @param ns the XML namespace associated with the XML to be rendered + * @return the XMLHandler responsible for handling the XML or null if none is available + */ + public XMLHandler getXMLHandler(Renderer renderer, String ns) { + XMLHandler handler; + + List lst = (List)handlers.get(ns); + handler = getXMLHandler(renderer, lst); + if (handler == null) { + lst = (List)handlers.get(XMLHandler.HANDLE_ALL); + handler = getXMLHandler(renderer, lst); + } + return handler; + } + + private XMLHandler getXMLHandler(Renderer renderer, List lst) { + XMLHandler handler; + if (lst != null) { + for (int i = 0, c = lst.size(); i < c; i++) { + //TODO Maybe add priorities later + handler = (XMLHandler)lst.get(i); + if (handler.supportsRenderer(renderer)) { + return handler; + } + } + } + return null; //No handler found + } + + /** + * Discovers XMLHandler implementations through the classpath and dynamically + * registers them. + */ + private void discoverXMLHandlers() { + // add mappings from available services + Iterator providers = Service.providers(XMLHandler.class); + if (providers != null) { + while (providers.hasNext()) { + XMLHandler handler = (XMLHandler)providers.next(); + try { + if (log.isDebugEnabled()) { + log.debug("Dynamically adding XMLHandler: " + handler.getClass().getName()); + } + addXMLHandler(handler); + } catch (IllegalArgumentException e) { + log.error("Error while adding XMLHandler", e); + } + + } + } + } +} diff --git a/src/java/org/apache/fop/render/afp/AFPGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPGraphics2D.java index a64b77d35..3e477e224 100644 --- a/src/java/org/apache/fop/render/afp/AFPGraphics2D.java +++ b/src/java/org/apache/fop/render/afp/AFPGraphics2D.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java b/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java index 086308975..1f40b7cfd 100644 --- a/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java +++ b/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java b/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java index dd31af9f1..d4c756a5a 100644 --- a/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java +++ b/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPInfo.java b/src/java/org/apache/fop/render/afp/AFPInfo.java index cd291da56..026ab4dfe 100644 --- a/src/java/org/apache/fop/render/afp/AFPInfo.java +++ b/src/java/org/apache/fop/render/afp/AFPInfo.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPPageFonts.java b/src/java/org/apache/fop/render/afp/AFPPageFonts.java index 1ca38a58f..e09167ff5 100644 --- a/src/java/org/apache/fop/render/afp/AFPPageFonts.java +++ b/src/java/org/apache/fop/render/afp/AFPPageFonts.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index c0f6a9c6f..9917eec70 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index 1506acb4b..13fa62514 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPState.java b/src/java/org/apache/fop/render/afp/AFPState.java index a86d55cf9..7cb37e2f3 100644 --- a/src/java/org/apache/fop/render/afp/AFPState.java +++ b/src/java/org/apache/fop/render/afp/AFPState.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java b/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java index 150cbb236..fc26801ec 100644 --- a/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java +++ b/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: PSTextElementBridge.java 426576 2006-07-28 15:44:37Z jeremias $ */ +/* $Id$ */ package org.apache.fop.render.afp; diff --git a/src/java/org/apache/fop/render/afp/AFPTextPainter.java b/src/java/org/apache/fop/render/afp/AFPTextPainter.java index 66183080f..850db550a 100644 --- a/src/java/org/apache/fop/render/afp/AFPTextPainter.java +++ b/src/java/org/apache/fop/render/afp/AFPTextPainter.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: PSTextPainter.java 542237 2007-05-28 14:31:24Z jeremias $ */ +/* $Id$ */ package org.apache.fop.render.afp; 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 cc99295fb..7fdf7cd11 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java @@ -1,121 +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.render.afp.extensions;
-
-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 AFPExtension objects from XML.
- */
-public class AFPExtensionHandler extends DefaultHandler
- implements ContentHandlerFactory.ObjectSource {
-
- /** Logger instance */
- protected static Log log = LogFactory.getLog(AFPExtensionHandler.class);
-
- 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)
- throws SAXException {
- boolean handled = false;
- if (AFPPageSetup.CATEGORY.equals(uri)) {
- lastAttributes = attributes;
- handled = true;
- if (localName.equals(AFPElementMapping.NO_OPERATION)
- || localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT)
- || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY)
- || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT)
- || localName.equals(AFPElementMapping.PAGE)
- || localName.equals(AFPElementMapping.PAGE_GROUP)) {
- //handled in endElement
- } else {
- handled = false;
- }
- }
- if (!handled) {
- if (AFPPageSetup.CATEGORY.equals(uri)) {
- throw new SAXException("Unhandled element " + localName
- + " in namespace: " + uri);
- } else {
- log.warn("Unhandled element " + localName
- + " in namespace: " + uri);
- }
- }
- }
-
- /** {@inheritDoc} */
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (AFPPageSetup.CATEGORY.equals(uri)) {
- this.returnedObject = new AFPPageSetup(localName);
- String name = lastAttributes.getValue("name");
- if (name != null) {
- returnedObject.setName(name);
- }
- String value = lastAttributes.getValue("value");
- if (value != null) {
- returnedObject.setValue(value);
- }
- if (content.length() > 0) {
- returnedObject.setContent(content.toString());
- content.setLength(0); //Reset text buffer (see characters())
- }
- }
- }
-
- /** {@inheritDoc} */
- public void characters(char[] ch, int start, int length) throws SAXException {
- content.append(ch, start, length);
- }
-
- /**
- * {@inheritDoc}
- */
- public void endDocument() throws SAXException {
- if (listener != null) {
- listener.notifyObjectBuilt(getObject());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getObject() {
- return returnedObject;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setObjectBuiltListener(ObjectBuiltListener listen) {
- this.listener = listen;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.extensions; + +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 AFPExtension objects from XML. + */ +public class AFPExtensionHandler extends DefaultHandler + implements ContentHandlerFactory.ObjectSource { + + /** Logger instance */ + protected static Log log = LogFactory.getLog(AFPExtensionHandler.class); + + 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) + throws SAXException { + boolean handled = false; + if (AFPPageSetup.CATEGORY.equals(uri)) { + lastAttributes = attributes; + handled = true; + if (localName.equals(AFPElementMapping.NO_OPERATION) + || localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT) + || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY) + || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT) + || localName.equals(AFPElementMapping.PAGE) + || localName.equals(AFPElementMapping.PAGE_GROUP)) { + //handled in endElement + } else { + handled = false; + } + } + if (!handled) { + if (AFPPageSetup.CATEGORY.equals(uri)) { + throw new SAXException("Unhandled element " + localName + + " in namespace: " + uri); + } else { + log.warn("Unhandled element " + localName + + " in namespace: " + uri); + } + } + } + + /** {@inheritDoc} */ + public void endElement(String uri, String localName, String qName) throws SAXException { + if (AFPPageSetup.CATEGORY.equals(uri)) { + this.returnedObject = new AFPPageSetup(localName); + String name = lastAttributes.getValue("name"); + if (name != null) { + returnedObject.setName(name); + } + String value = lastAttributes.getValue("value"); + if (value != null) { + returnedObject.setValue(value); + } + if (content.length() > 0) { + returnedObject.setContent(content.toString()); + content.setLength(0); //Reset text buffer (see characters()) + } + } + } + + /** {@inheritDoc} */ + public void characters(char[] ch, int start, int length) throws SAXException { + content.append(ch, start, length); + } + + /** + * {@inheritDoc} + */ + public void endDocument() throws SAXException { + if (listener != null) { + listener.notifyObjectBuilt(getObject()); + } + } + + /** + * {@inheritDoc} + */ + public Object getObject() { + return returnedObject; + } + + /** + * {@inheritDoc} + */ + public void setObjectBuiltListener(ObjectBuiltListener listen) { + this.listener = listen; + } + +} 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 4fe5eaab2..efd351c33 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandlerFactory.java @@ -1,41 +1,41 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.extensions;
-
-import org.apache.fop.util.ContentHandlerFactory;
-import org.xml.sax.ContentHandler;
-
-/**
- * Factory for the ContentHandler that handles serialized AFPPageSetup instances.
- */
-public class AFPExtensionHandlerFactory implements ContentHandlerFactory {
-
- private static final String[] NAMESPACES = new String[] {AFPPageSetup.CATEGORY};
-
- /** {@inheritDoc} */
- public String[] getSupportedNamespaces() {
- return NAMESPACES;
- }
-
- /** {@inheritDoc} */
- public ContentHandler createContentHandler() {
- return new AFPExtensionHandler();
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.extensions; + +import org.apache.fop.util.ContentHandlerFactory; +import org.xml.sax.ContentHandler; + +/** + * Factory for the ContentHandler that handles serialized AFPPageSetup instances. + */ +public class AFPExtensionHandlerFactory implements ContentHandlerFactory { + + private static final String[] NAMESPACES = new String[] {AFPPageSetup.CATEGORY}; + + /** {@inheritDoc} */ + public String[] getSupportedNamespaces() { + return NAMESPACES; + } + + /** {@inheritDoc} */ + public ContentHandler createContentHandler() { + return new AFPExtensionHandler(); + } +} 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 363e5c6e4..cf5aad382 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca; 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 f9348b81c..e061748ca 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca; diff --git a/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java b/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java index fdeb5c418..8fecc0e5b 100644 --- a/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java +++ b/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca; 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 45c9f5751..065ca6626 100644 --- a/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java +++ b/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca; diff --git a/src/java/org/apache/fop/render/afp/modca/PreparedAFPObject.java b/src/java/org/apache/fop/render/afp/modca/PreparedAFPObject.java index 8da724f36..c62577ca6 100644 --- a/src/java/org/apache/fop/render/afp/modca/PreparedAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/PreparedAFPObject.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsContainer.java b/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsContainer.java index 27a80acc4..c0520fbf1 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsContainer.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsContainer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsCoord.java b/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsCoord.java index 7378a5c07..8f6e55b23 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsCoord.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/AbstractGraphicsCoord.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/AbstractPreparedAFPObject.java b/src/java/org/apache/fop/render/afp/modca/goca/AbstractPreparedAFPObject.java index ed10e5456..b064896c7 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/AbstractPreparedAFPObject.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/AbstractPreparedAFPObject.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsArea.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsArea.java index c96ca2973..88173d6d1 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsArea.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsArea.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsBox.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsBox.java index ea4894e84..ba87dad9f 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsBox.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsBox.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsChainedSegment.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsChainedSegment.java index 2c8f68857..4485370b9 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsChainedSegment.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsChainedSegment.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsData.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsData.java index b660d5b9a..ccbb537f6 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsData.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsData.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFillet.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFillet.java index ab30a3d93..1bac5b149 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFillet.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFillet.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFullArc.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFullArc.java index b0dcf9c22..43f0d370d 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFullArc.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsFullArc.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageBegin.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageBegin.java index f7511e54f..e37b4b196 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageBegin.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageBegin.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageData.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageData.java index 4cb59e51a..38b81ecd6 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageData.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageData.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageEnd.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageEnd.java index e365e4444..40a518c4b 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageEnd.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsImageEnd.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsLine.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsLine.java index 4bf396d0b..07127c387 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsLine.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsLine.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetArcParameters.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetArcParameters.java index 6e1c7abf9..d39e1e167 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetArcParameters.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetArcParameters.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCharacterSet.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCharacterSet.java index be244bd06..aeca3e9c5 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCharacterSet.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCharacterSet.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCurrentPosition.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCurrentPosition.java index afa825a84..91597e8e3 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCurrentPosition.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetCurrentPosition.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineType.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineType.java index 99c2902c0..339902e2c 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineType.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineWidth.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineWidth.java index 8e08d09e2..0cd077567 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineWidth.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetLineWidth.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetPatternSymbol.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetPatternSymbol.java index 9a04139a2..23c0ac73c 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetPatternSymbol.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetPatternSymbol.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetProcessColor.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetProcessColor.java index 47df7ba14..51153f065 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetProcessColor.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsSetProcessColor.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsString.java b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsString.java index 1750c4348..7033ce92f 100644 --- a/src/java/org/apache/fop/render/afp/modca/goca/GraphicsString.java +++ b/src/java/org/apache/fop/render/afp/modca/goca/GraphicsString.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.modca.goca; diff --git a/src/java/org/apache/fop/render/awt/AWTRendererMaker.java b/src/java/org/apache/fop/render/awt/AWTRendererMaker.java index 77bfd9166..bca4c0817 100644 --- a/src/java/org/apache/fop/render/awt/AWTRendererMaker.java +++ b/src/java/org/apache/fop/render/awt/AWTRendererMaker.java @@ -1,50 +1,50 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.awt;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-
-/**
- * RendererMaker for the AWT Preview 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();
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return false;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.awt; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.Renderer; + +/** + * RendererMaker for the AWT Preview 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(); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return false; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } + +} diff --git a/src/java/org/apache/fop/render/bitmap/MultiFileRenderingUtil.java b/src/java/org/apache/fop/render/bitmap/MultiFileRenderingUtil.java index ca757fccf..7c1c4ee31 100644 --- a/src/java/org/apache/fop/render/bitmap/MultiFileRenderingUtil.java +++ b/src/java/org/apache/fop/render/bitmap/MultiFileRenderingUtil.java @@ -1,75 +1,75 @@ -package org.apache.fop.render.bitmap;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * This utility class helps renderers who generate one file per page,
- * like the PNG renderer.
- */
-public class MultiFileRenderingUtil {
-
- /** The file syntax prefix, eg. "page" will output "page1.png" etc */
- private String filePrefix;
-
- private String fileExtension;
-
- /** The output directory where images are to be written */
- private File outputDir;
-
- /**
- * Creates a new instance.
- * <p>
- * The file name must not have an extension, or must have extension "png",
- * and its last period must not be at the start (empty file prefix).
- * @param ext the extension to be used
- * @param outputFile the output file or null if there's no such information
- */
- public MultiFileRenderingUtil(String ext, File outputFile) {
- this.fileExtension = ext;
- // the file provided on the command line
- if (outputFile == null) {
- //No filename information available. Only the first page will be rendered.
- outputDir = null;
- filePrefix = null;
- } else {
- outputDir = outputFile.getParentFile();
-
- // extracting file name syntax
- String s = outputFile.getName();
- int i = s.lastIndexOf(".");
- if (i > 0) {
- // Make sure that the file extension was "png"
- String extension = s.substring(i + 1).toLowerCase();
- if (!ext.equals(extension)) {
- throw new IllegalArgumentException("Invalid file extension ('"
- + extension + "') specified");
- }
- } else if (i == -1) {
- i = s.length();
- } else { // i == 0
- throw new IllegalArgumentException("Invalid file name ('"
- + s + "') specified");
- }
- if (s.charAt(i - 1) == '1') {
- i--; // getting rid of the "1"
- }
- filePrefix = s.substring(0, i);
- }
- }
-
- public OutputStream createOutputStream(int pageNumber) throws IOException {
- if (filePrefix == null) {
- return null;
- } else {
- File f = new File(outputDir,
- filePrefix + (pageNumber + 1) + "." + fileExtension);
- OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
- return os;
- }
- }
-
-}
+package org.apache.fop.render.bitmap; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * This utility class helps renderers who generate one file per page, + * like the PNG renderer. + */ +public class MultiFileRenderingUtil { + + /** The file syntax prefix, eg. "page" will output "page1.png" etc */ + private String filePrefix; + + private String fileExtension; + + /** The output directory where images are to be written */ + private File outputDir; + + /** + * Creates a new instance. + * <p> + * The file name must not have an extension, or must have extension "png", + * and its last period must not be at the start (empty file prefix). + * @param ext the extension to be used + * @param outputFile the output file or null if there's no such information + */ + public MultiFileRenderingUtil(String ext, File outputFile) { + this.fileExtension = ext; + // the file provided on the command line + if (outputFile == null) { + //No filename information available. Only the first page will be rendered. + outputDir = null; + filePrefix = null; + } else { + outputDir = outputFile.getParentFile(); + + // extracting file name syntax + String s = outputFile.getName(); + int i = s.lastIndexOf("."); + if (i > 0) { + // Make sure that the file extension was "png" + String extension = s.substring(i + 1).toLowerCase(); + if (!ext.equals(extension)) { + throw new IllegalArgumentException("Invalid file extension ('" + + extension + "') specified"); + } + } else if (i == -1) { + i = s.length(); + } else { // i == 0 + throw new IllegalArgumentException("Invalid file name ('" + + s + "') specified"); + } + if (s.charAt(i - 1) == '1') { + i--; // getting rid of the "1" + } + filePrefix = s.substring(0, i); + } + } + + public OutputStream createOutputStream(int pageNumber) throws IOException { + if (filePrefix == null) { + return null; + } else { + File f = new File(outputDir, + filePrefix + (pageNumber + 1) + "." + fileExtension); + OutputStream os = new BufferedOutputStream(new FileOutputStream(f)); + return os; + } + } + +} diff --git a/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java b/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java index 63b901668..0f4c4c4fb 100644 --- a/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java +++ b/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java @@ -1,57 +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.render.bitmap;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-import org.apache.fop.render.java2d.Java2DRendererConfigurator;
-
-/**
- * RendererMaker for the PNG Renderer.
- */
-public class PNGRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {MimeConstants.MIME_PNG};
-
-
- /** {@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent ua) {
- return new PNGRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new Java2DRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfigurator; +import org.apache.fop.render.java2d.Java2DRendererConfigurator; + +/** + * RendererMaker for the PNG Renderer. + */ +public class PNGRendererMaker extends AbstractRendererMaker { + + private static final String[] MIMES = new String[] {MimeConstants.MIME_PNG}; + + + /** {@inheritDoc} */ + public Renderer makeRenderer(FOUserAgent ua) { + return new PNGRenderer(); + } + + /** {@inheritDoc} */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return new Java2DRendererConfigurator(userAgent); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return true; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } + +} diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java index 14e6734dd..71ad0b286 100644 --- a/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java +++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.bitmap; diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java b/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java index 09af92b05..69463d127 100644 --- a/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java +++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java @@ -1,55 +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.render.bitmap;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the TIFF Renderer.
- */
-public class TIFFRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {MimeConstants.MIME_TIFF};
-
- /** {@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent userAgent) {
- return new TIFFRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new TIFFRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfigurator; + +/** + * RendererMaker for the TIFF Renderer. + */ +public class TIFFRendererMaker extends AbstractRendererMaker { + + private static final String[] MIMES = new String[] {MimeConstants.MIME_TIFF}; + + /** {@inheritDoc} */ + public Renderer makeRenderer(FOUserAgent userAgent) { + return new TIFFRenderer(); + } + + /** {@inheritDoc} */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return new TIFFRendererConfigurator(userAgent); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return true; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } + +} diff --git a/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java b/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java index 1182fe42d..48feba135 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/java2d/Java2DGraphics2DAdapter.java @@ -1,82 +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.java2d;
-
-import java.awt.Color;
-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.xmlgraphics.java2d.Graphics2DImagePainter;
-
-import org.apache.fop.render.Graphics2DAdapter;
-import org.apache.fop.render.RendererContext;
-
-/**
- * Graphics2DAdapter implementation for Java2D.
- */
-public class Java2DGraphics2DAdapter implements Graphics2DAdapter {
-
- /** {@inheritDoc} */
- 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;
- float imh = (float)dim.getHeight() / 1000f;
-
- float sx = fwidth / (float)imw;
- float sy = fheight / (float)imh;
-
- 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
- // and positive is down and to the right. (0,0) is where the
- // viewBox puts it.
- g2d.translate(fx, fy);
- AffineTransform at = AffineTransform.getScaleInstance(sx, sy);
- if (!at.isIdentity()) {
- g2d.transform(at);
- }
-
- Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
- painter.paint(g2d, area);
-
- g2d.dispose();
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.java2d; + +import java.awt.Color; +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.xmlgraphics.java2d.Graphics2DImagePainter; + +import org.apache.fop.render.Graphics2DAdapter; +import org.apache.fop.render.RendererContext; + +/** + * Graphics2DAdapter implementation for Java2D. + */ +public class Java2DGraphics2DAdapter implements Graphics2DAdapter { + + /** {@inheritDoc} */ + 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; + float imh = (float)dim.getHeight() / 1000f; + + float sx = fwidth / (float)imw; + float sy = fheight / (float)imh; + + 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 + // and positive is down and to the right. (0,0) is where the + // viewBox puts it. + g2d.translate(fx, fy); + AffineTransform at = AffineTransform.getScaleInstance(sx, sy); + if (!at.isIdentity()) { + g2d.transform(at); + } + + Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh); + painter.paint(g2d, area); + + g2d.dispose(); + } + +} diff --git a/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java b/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java index cc8d3d07f..a18f71cc0 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.java2d; diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java index 03b60f316..b9c772dcb 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java +++ b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.pcl; diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java b/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java index 025a1cb4b..f18446506 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java +++ b/src/java/org/apache/fop/render/pcl/PCLRendererMaker.java @@ -1,57 +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.render.pcl;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the PCL Renderer.
- */
-public class PCLRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {
- MimeConstants.MIME_PCL,
- MimeConstants.MIME_PCL_ALT
- };
-
- /**{@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent userAgent) {
- return new PCLRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new PCLRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfigurator; + +/** + * RendererMaker for the PCL Renderer. + */ +public class PCLRendererMaker extends AbstractRendererMaker { + + private static final String[] MIMES = new String[] { + MimeConstants.MIME_PCL, + MimeConstants.MIME_PCL_ALT + }; + + /**{@inheritDoc} */ + public Renderer makeRenderer(FOUserAgent userAgent) { + return new PCLRenderer(); + } + + /** {@inheritDoc} */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return new PCLRendererConfigurator(userAgent); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return true; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } +} diff --git a/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java b/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java index 863140688..1c540718b 100644 --- a/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java +++ b/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: AFPElementMapping.java 397875 2006-04-28 11:58:33Z manuel $ */ +/* $Id$ */ package org.apache.fop.render.pcl.extensions; diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java index d1e0abd5c..1a121e294 100644 --- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java @@ -1,130 +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.render.pdf;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-
-import org.apache.fop.render.AbstractGraphics2DAdapter;
-import org.apache.fop.render.RendererContext;
-import org.apache.fop.render.RendererContext.RendererContextWrapper;
-import org.apache.fop.svg.PDFGraphics2D;
-
-/**
- * Graphics2DAdapter implementation for PDF.
- */
-public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter {
-
- private PDFRenderer renderer;
-
- /**
- * Main constructor
- * @param renderer the Renderer instance to which this instance belongs
- */
- 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;
- float imh = (float)dim.getHeight() / 1000f;
-
- float sx = fwidth / (float)imw;
- float sy = fheight / (float)imh;
-
- 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
- // and positive is down and to the right. (0,0) is where the
- // viewBox puts it.
- renderer.currentStream.add(sx + " 0 0 " + sy + " " + fx + " "
- + fy + " cm\n");
-
-
- final boolean textAsShapes = false;
- if (pdfInfo.pdfContext == null) {
- pdfInfo.pdfContext = pdfInfo.pdfPage;
- }
- PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes,
- pdfInfo.fi, pdfInfo.pdfDoc,
- pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(),
- renderer.currentFontName,
- renderer.currentFontSize);
- graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
-
- AffineTransform transform = new AffineTransform();
- transform.translate(fx, fy);
- pdfInfo.pdfState.concatenate(transform);
- graphics.setPDFState(pdfInfo.pdfState);
- graphics.setOutputStream(pdfInfo.outputStream);
-
- if (pdfInfo.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);
- }
-
- pdfInfo.currentStream.add(graphics.getString());
- renderer.restoreGraphicsState();
- pdfInfo.pdfState.pop();
- }
-
- /** {@inheritDoc} */
- protected void setRenderingHintsForBufferedImage(Graphics2D g2d) {
- super.setRenderingHintsForBufferedImage(g2d);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; + +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; + +import org.apache.fop.render.AbstractGraphics2DAdapter; +import org.apache.fop.render.RendererContext; +import org.apache.fop.render.RendererContext.RendererContextWrapper; +import org.apache.fop.svg.PDFGraphics2D; + +/** + * Graphics2DAdapter implementation for PDF. + */ +public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { + + private PDFRenderer renderer; + + /** + * Main constructor + * @param renderer the Renderer instance to which this instance belongs + */ + 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; + float imh = (float)dim.getHeight() / 1000f; + + float sx = fwidth / (float)imw; + float sy = fheight / (float)imh; + + 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 + // and positive is down and to the right. (0,0) is where the + // viewBox puts it. + renderer.currentStream.add(sx + " 0 0 " + sy + " " + fx + " " + + fy + " cm\n"); + + + final boolean textAsShapes = false; + if (pdfInfo.pdfContext == null) { + pdfInfo.pdfContext = pdfInfo.pdfPage; + } + PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes, + pdfInfo.fi, pdfInfo.pdfDoc, + pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(), + renderer.currentFontName, + renderer.currentFontSize); + graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); + + AffineTransform transform = new AffineTransform(); + transform.translate(fx, fy); + pdfInfo.pdfState.concatenate(transform); + graphics.setPDFState(pdfInfo.pdfState); + graphics.setOutputStream(pdfInfo.outputStream); + + if (pdfInfo.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); + } + + pdfInfo.currentStream.add(graphics.getString()); + renderer.restoreGraphicsState(); + pdfInfo.pdfState.pop(); + } + + /** {@inheritDoc} */ + protected void setRenderingHintsForBufferedImage(Graphics2D g2d) { + super.setRenderingHintsForBufferedImage(g2d); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + } + +} diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java b/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java index 0e36e177b..98fd7b5db 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java @@ -1,55 +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.render.pdf;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the PDF Renderer.
- */
-public class PDFRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF};
-
- /** {@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent userAgent) {
- return new PDFRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new PDFRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfigurator; + +/** + * RendererMaker for the PDF Renderer. + */ +public class PDFRendererMaker extends AbstractRendererMaker { + + private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF}; + + /** {@inheritDoc} */ + public Renderer makeRenderer(FOUserAgent userAgent) { + return new PDFRenderer(); + } + + /** {@inheritDoc} */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return new PDFRendererConfigurator(userAgent); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return true; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } + +} diff --git a/src/java/org/apache/fop/render/print/PrintRendererMaker.java b/src/java/org/apache/fop/render/print/PrintRendererMaker.java index 4b0523458..2390567ef 100644 --- a/src/java/org/apache/fop/render/print/PrintRendererMaker.java +++ b/src/java/org/apache/fop/render/print/PrintRendererMaker.java @@ -1,56 +1,56 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.print;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.PrintRendererConfigurator;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the Print Renderer.
- */
-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();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new PrintRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return false;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.print; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.PrintRendererConfigurator; +import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfigurator; + +/** + * RendererMaker for the Print Renderer. + */ +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(); + } + + /** {@inheritDoc} */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return new PrintRendererConfigurator(userAgent); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return false; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } + +} diff --git a/src/java/org/apache/fop/render/ps/PSDictionary.java b/src/java/org/apache/fop/render/ps/PSDictionary.java index dbf7173a5..5a8f1ea14 100644 --- a/src/java/org/apache/fop/render/ps/PSDictionary.java +++ b/src/java/org/apache/fop/render/ps/PSDictionary.java @@ -1,312 +1,312 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * This class is used to encapsulate postscript dictionary objects.
- */
-public class PSDictionary extends java.util.HashMap {
-
- private static final long serialVersionUID = 815367222496219197L;
-
- /**
- * This class is used to parse dictionary strings.
- */
- private static class Maker {
-
- /**
- * Simple token holding class
- */
- private class Token {
- /**
- * start index in string
- */
- private int startIndex = -1;
-
- /**
- * end index in string
- */
- private int endIndex = -1;
-
- /**
- * token string value
- */
- private String value;
- }
-
- private static final String[][] BRACES = {
- {"<<", ">>"},
- {"[", "]"},
- {"{", "}"}
- };
-
- private static final int OPENING = 0;
- private static final int CLOSING = 1;
- private static final int DICTIONARY = 0;
- private static final int ARRAY = 1;
- private static final int PROCEDURE = 2;
-
- /**
- * Returns a Token containing the start, end index and value of the next token
- * found in a given string
- *
- * @param str
- * string to search
- * @param fromIndex
- * search from index
- * @return Token containing the start, end index and value of the next token
- */
- protected Token nextToken(String str, int fromIndex) {
- Token t = null;
- for (int i = fromIndex; i < str.length(); i++) {
- boolean isWhitespace = Character.isWhitespace(str.charAt(i));
- // start index found
- if (t == null && !isWhitespace) {
- t = new Token();
- t.startIndex = i;
- // end index found
- } else if (t != null && isWhitespace) {
- t.endIndex = i;
- break;
- }
- }
- // start index found
- if (t != null) {
- // end index not found so take end of string
- if (t.endIndex == -1) {
- t.endIndex = str.length();
- }
- t.value = str.substring(t.startIndex, t.endIndex);
- }
- return t;
- }
-
- /**
- * Returns the closing brace index from a given string searches from a
- * given index
- *
- * @param str
- * string to search
- * @param braces
- * string array of opening and closing brace
- * @param fromIndex
- * searches from index
- * @return matching brace index
- * @throws org.apache.fop.render.ps.PSDictionaryFormatException
- * thrown in the event that a parsing error occurred
- */
- private int indexOfMatchingBrace(String str, String[] braces,
- int fromIndex) throws PSDictionaryFormatException {
- final int len = str.length();
- if (braces.length != 2) {
- throw new PSDictionaryFormatException("Wrong number of braces");
- }
- for (int openCnt = 0, closeCnt = 0; fromIndex < len; fromIndex++) {
- if (str.startsWith(braces[OPENING], fromIndex)) {
- openCnt++;
- } else if (str.startsWith(braces[CLOSING], fromIndex)) {
- closeCnt++;
- if (openCnt > 0 && openCnt == closeCnt) {
- return fromIndex; // found
- }
- }
- }
- return -1; // not found
- }
-
- /**
- * Strips braces from complex object string
- *
- * @param str
- * String to parse
- * @param braces
- * String array containing opening and closing braces
- * @return String with braces stripped
- * @throws
- * org.apache.fop.render.ps.PSDictionaryFormatException object format exception
- */
- private String stripBraces(String str, String[] braces) throws PSDictionaryFormatException {
- // find first opening brace
- int firstIndex = str.indexOf(braces[OPENING]);
- if (firstIndex == -1) {
- throw new PSDictionaryFormatException(
- "Failed to find opening parameter '" + braces[OPENING]
- + "");
- }
-
- // find last matching brace
- int lastIndex = indexOfMatchingBrace(str, braces, firstIndex);
- if (lastIndex == -1) {
- throw new PSDictionaryFormatException(
- "Failed to find matching closing parameter '"
- + braces[CLOSING] + "'");
- }
-
- // strip brace and trim
- int braceLen = braces[OPENING].length();
- str = str.substring(firstIndex + braceLen, lastIndex).trim();
- return str;
- }
-
- /**
- * Parses a dictionary string and provides a dictionary object
- *
- * @param str a dictionary string
- * @return A postscript dictionary object
- * @throws
- * PSDictionaryFormatException thrown if a dictionary format exception occurs
- */
- public PSDictionary parseDictionary(String str) throws PSDictionaryFormatException {
- PSDictionary dictionary = new PSDictionary();
- str = stripBraces(str.trim(), BRACES[DICTIONARY]);
- // length of dictionary string
- final int len = str.length();
-
- Token keyToken;
- for (int currIndex = 0; (keyToken = nextToken(str, currIndex)) != null
- && currIndex <= len;) {
- if (keyToken.value == null) {
- throw new PSDictionaryFormatException("Failed to parse object key");
- }
- Token valueToken = nextToken(str, keyToken.endIndex + 1);
- String[] braces = null;
- for (int i = 0; i < BRACES.length; i++) {
- if (valueToken.value.startsWith(BRACES[i][OPENING])) {
- braces = BRACES[i];
- break;
- }
- }
- Object obj = null;
- if (braces != null) {
- // find closing brace
- valueToken.endIndex = indexOfMatchingBrace(str, braces,
- valueToken.startIndex)
- + braces[OPENING].length();
- if (valueToken.endIndex < 0) {
- throw new PSDictionaryFormatException("Closing value brace '"
- + braces[CLOSING] + "' not found for key '"
- + keyToken.value + "'");
- }
- valueToken.value = str.substring(valueToken.startIndex, valueToken.endIndex);
- }
- if (braces == null || braces == BRACES[PROCEDURE]) {
- obj = valueToken.value;
- } else if (BRACES[ARRAY] == braces) {
- List objList = new java.util.ArrayList();
- String objString = stripBraces(valueToken.value, braces);
- StringTokenizer tokenizer = new StringTokenizer(objString, ",");
- while (tokenizer.hasMoreTokens()) {
- objList.add(tokenizer.nextToken());
- }
- obj = objList;
- } else if (BRACES[DICTIONARY] == braces) {
- obj = parseDictionary(valueToken.value);
- }
- dictionary.put(keyToken.value, obj);
- currIndex = valueToken.endIndex + 1;
- }
- return dictionary;
- }
- }
-
- /**
- * Parses a given a dictionary string and returns an object
- *
- * @param str dictionary string
- * @return dictionary object
- * @throws PSDictionaryFormatException object format exception
- */
- public static PSDictionary valueOf(String str) throws PSDictionaryFormatException {
- return (new Maker()).parseDictionary(str);
- }
-
- /**
- * @param obj object to test equality against
- * @return whether a given object is equal to this dictionary object
- * @see java.lang.Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (!(obj instanceof PSPageDeviceDictionary)) {
- return false;
- }
- PSDictionary dictionaryObj = (PSDictionary) obj;
- if (dictionaryObj.size() != size()) {
- return false;
- }
- for (Iterator it = keySet().iterator(); it.hasNext();) {
- String key = (String) it.next();
- if (!dictionaryObj.containsKey(key)) {
- return false;
- }
- if (!dictionaryObj.get(key).equals(get(key))) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * @return a hash code value for this object.
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- int hashCode = 7;
- for (Iterator it = values().iterator(); it.hasNext();) {
- Object value = it.next();
- hashCode += value.hashCode();
- }
- return hashCode;
- }
-
- /**
- * @return a string representation of this dictionary
- * @see java.lang.String#toString()
- */
- public String toString() {
- if (isEmpty()) {
- return "";
- }
- StringBuffer sb = new StringBuffer("<<\n");
- for (Iterator it = super.keySet().iterator(); it.hasNext();) {
- String key = (String) it.next();
- sb.append(" " + key + " ");
- Object obj = super.get(key);
- if (obj instanceof java.util.ArrayList) {
- List array = (List)obj;
- String str = "[";
- for (int i = 0; i < array.size(); i++) {
- Object element = array.get(i);
- str += element + " ";
- }
- str = str.trim();
- str += "]";
- sb.append(str + "\n");
- } else {
- sb.append(obj.toString() + "\n");
- }
- }
- sb.append(">>");
- return sb.toString();
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; + +/** + * This class is used to encapsulate postscript dictionary objects. + */ +public class PSDictionary extends java.util.HashMap { + + private static final long serialVersionUID = 815367222496219197L; + + /** + * This class is used to parse dictionary strings. + */ + private static class Maker { + + /** + * Simple token holding class + */ + private class Token { + /** + * start index in string + */ + private int startIndex = -1; + + /** + * end index in string + */ + private int endIndex = -1; + + /** + * token string value + */ + private String value; + } + + private static final String[][] BRACES = { + {"<<", ">>"}, + {"[", "]"}, + {"{", "}"} + }; + + private static final int OPENING = 0; + private static final int CLOSING = 1; + private static final int DICTIONARY = 0; + private static final int ARRAY = 1; + private static final int PROCEDURE = 2; + + /** + * Returns a Token containing the start, end index and value of the next token + * found in a given string + * + * @param str + * string to search + * @param fromIndex + * search from index + * @return Token containing the start, end index and value of the next token + */ + protected Token nextToken(String str, int fromIndex) { + Token t = null; + for (int i = fromIndex; i < str.length(); i++) { + boolean isWhitespace = Character.isWhitespace(str.charAt(i)); + // start index found + if (t == null && !isWhitespace) { + t = new Token(); + t.startIndex = i; + // end index found + } else if (t != null && isWhitespace) { + t.endIndex = i; + break; + } + } + // start index found + if (t != null) { + // end index not found so take end of string + if (t.endIndex == -1) { + t.endIndex = str.length(); + } + t.value = str.substring(t.startIndex, t.endIndex); + } + return t; + } + + /** + * Returns the closing brace index from a given string searches from a + * given index + * + * @param str + * string to search + * @param braces + * string array of opening and closing brace + * @param fromIndex + * searches from index + * @return matching brace index + * @throws org.apache.fop.render.ps.PSDictionaryFormatException + * thrown in the event that a parsing error occurred + */ + private int indexOfMatchingBrace(String str, String[] braces, + int fromIndex) throws PSDictionaryFormatException { + final int len = str.length(); + if (braces.length != 2) { + throw new PSDictionaryFormatException("Wrong number of braces"); + } + for (int openCnt = 0, closeCnt = 0; fromIndex < len; fromIndex++) { + if (str.startsWith(braces[OPENING], fromIndex)) { + openCnt++; + } else if (str.startsWith(braces[CLOSING], fromIndex)) { + closeCnt++; + if (openCnt > 0 && openCnt == closeCnt) { + return fromIndex; // found + } + } + } + return -1; // not found + } + + /** + * Strips braces from complex object string + * + * @param str + * String to parse + * @param braces + * String array containing opening and closing braces + * @return String with braces stripped + * @throws + * org.apache.fop.render.ps.PSDictionaryFormatException object format exception + */ + private String stripBraces(String str, String[] braces) throws PSDictionaryFormatException { + // find first opening brace + int firstIndex = str.indexOf(braces[OPENING]); + if (firstIndex == -1) { + throw new PSDictionaryFormatException( + "Failed to find opening parameter '" + braces[OPENING] + + ""); + } + + // find last matching brace + int lastIndex = indexOfMatchingBrace(str, braces, firstIndex); + if (lastIndex == -1) { + throw new PSDictionaryFormatException( + "Failed to find matching closing parameter '" + + braces[CLOSING] + "'"); + } + + // strip brace and trim + int braceLen = braces[OPENING].length(); + str = str.substring(firstIndex + braceLen, lastIndex).trim(); + return str; + } + + /** + * Parses a dictionary string and provides a dictionary object + * + * @param str a dictionary string + * @return A postscript dictionary object + * @throws + * PSDictionaryFormatException thrown if a dictionary format exception occurs + */ + public PSDictionary parseDictionary(String str) throws PSDictionaryFormatException { + PSDictionary dictionary = new PSDictionary(); + str = stripBraces(str.trim(), BRACES[DICTIONARY]); + // length of dictionary string + final int len = str.length(); + + Token keyToken; + for (int currIndex = 0; (keyToken = nextToken(str, currIndex)) != null + && currIndex <= len;) { + if (keyToken.value == null) { + throw new PSDictionaryFormatException("Failed to parse object key"); + } + Token valueToken = nextToken(str, keyToken.endIndex + 1); + String[] braces = null; + for (int i = 0; i < BRACES.length; i++) { + if (valueToken.value.startsWith(BRACES[i][OPENING])) { + braces = BRACES[i]; + break; + } + } + Object obj = null; + if (braces != null) { + // find closing brace + valueToken.endIndex = indexOfMatchingBrace(str, braces, + valueToken.startIndex) + + braces[OPENING].length(); + if (valueToken.endIndex < 0) { + throw new PSDictionaryFormatException("Closing value brace '" + + braces[CLOSING] + "' not found for key '" + + keyToken.value + "'"); + } + valueToken.value = str.substring(valueToken.startIndex, valueToken.endIndex); + } + if (braces == null || braces == BRACES[PROCEDURE]) { + obj = valueToken.value; + } else if (BRACES[ARRAY] == braces) { + List objList = new java.util.ArrayList(); + String objString = stripBraces(valueToken.value, braces); + StringTokenizer tokenizer = new StringTokenizer(objString, ","); + while (tokenizer.hasMoreTokens()) { + objList.add(tokenizer.nextToken()); + } + obj = objList; + } else if (BRACES[DICTIONARY] == braces) { + obj = parseDictionary(valueToken.value); + } + dictionary.put(keyToken.value, obj); + currIndex = valueToken.endIndex + 1; + } + return dictionary; + } + } + + /** + * Parses a given a dictionary string and returns an object + * + * @param str dictionary string + * @return dictionary object + * @throws PSDictionaryFormatException object format exception + */ + public static PSDictionary valueOf(String str) throws PSDictionaryFormatException { + return (new Maker()).parseDictionary(str); + } + + /** + * @param obj object to test equality against + * @return whether a given object is equal to this dictionary object + * @see java.lang.Object#equals(Object) + */ + public boolean equals(Object obj) { + if (!(obj instanceof PSPageDeviceDictionary)) { + return false; + } + PSDictionary dictionaryObj = (PSDictionary) obj; + if (dictionaryObj.size() != size()) { + return false; + } + for (Iterator it = keySet().iterator(); it.hasNext();) { + String key = (String) it.next(); + if (!dictionaryObj.containsKey(key)) { + return false; + } + if (!dictionaryObj.get(key).equals(get(key))) { + return false; + } + } + return true; + } + + /** + * @return a hash code value for this object. + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + int hashCode = 7; + for (Iterator it = values().iterator(); it.hasNext();) { + Object value = it.next(); + hashCode += value.hashCode(); + } + return hashCode; + } + + /** + * @return a string representation of this dictionary + * @see java.lang.String#toString() + */ + public String toString() { + if (isEmpty()) { + return ""; + } + StringBuffer sb = new StringBuffer("<<\n"); + for (Iterator it = super.keySet().iterator(); it.hasNext();) { + String key = (String) it.next(); + sb.append(" " + key + " "); + Object obj = super.get(key); + if (obj instanceof java.util.ArrayList) { + List array = (List)obj; + String str = "["; + for (int i = 0; i < array.size(); i++) { + Object element = array.get(i); + str += element + " "; + } + str = str.trim(); + str += "]"; + sb.append(str + "\n"); + } else { + sb.append(obj.toString() + "\n"); + } + } + sb.append(">>"); + return sb.toString(); + } +} diff --git a/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java b/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java index 2153e8116..1a0171d68 100644 --- a/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java +++ b/src/java/org/apache/fop/render/ps/PSDictionaryFormatException.java @@ -1,37 +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.render.ps;
-
-/**
- * Thrown to indicate that a formatting error has occured when
- * trying to parse a postscript dictionary object
- */
-public class PSDictionaryFormatException extends Exception {
-
- private static final long serialVersionUID = 6492321557297860931L;
-
- /**
- * Default constructor
- * @param string error message
- */
- public PSDictionaryFormatException(String string) {
- super(string);
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; + +/** + * Thrown to indicate that a formatting error has occured when + * trying to parse a postscript dictionary object + */ +public class PSDictionaryFormatException extends Exception { + + private static final long serialVersionUID = 6492321557297860931L; + + /** + * Default constructor + * @param string error message + */ + public PSDictionaryFormatException(String string) { + super(string); + } +} diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java index 787af69a1..a592b4f44 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java @@ -1,105 +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.render.ps;
-
-import java.awt.Dimension;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.io.IOException;
-
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.ps.PSGenerator;
-
-import org.apache.fop.render.Graphics2DAdapter;
-import org.apache.fop.render.RendererContext;
-
-/**
- * Graphics2DAdapter implementation for PostScript.
- */
-public class PSGraphics2DAdapter implements Graphics2DAdapter {
-
- private PSGenerator gen;
- private boolean clip = true;
-
- /**
- * Main constructor
- * @param renderer the Renderer instance to which this instance belongs
- */
- public PSGraphics2DAdapter(PSRenderer renderer) {
- this(renderer.gen, true);
- }
-
- /**
- * Constructor for use without a PSRenderer instance.
- * @param gen the PostScript generator
- * @param clip true if the image should be clipped
- */
- public PSGraphics2DAdapter(PSGenerator gen, boolean clip) {
- this.gen = gen;
- this.clip = clip;
- }
-
- /** {@inheritDoc} */
- 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;
- float imh = (float)dim.getHeight() / 1000f;
-
- float sx = fwidth / (float)imw;
- float sy = fheight / (float)imh;
-
- gen.commentln("%FOPBeginGraphics2D");
- gen.saveGraphicsState();
- if (clip) {
- // Clip to the image area.
- gen.writeln("newpath");
- 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.
- gen.concatMatrix(sx, 0, 0, sy, fx, fy);
-
- final boolean textAsShapes = false;
- PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen);
- graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
- AffineTransform transform = new AffineTransform();
- // 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);
-
- gen.restoreGraphicsState();
- gen.commentln("%FOPEndGraphics2D");
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 java.awt.Dimension; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.io.IOException; + +import org.apache.xmlgraphics.java2d.Graphics2DImagePainter; +import org.apache.xmlgraphics.java2d.ps.PSGraphics2D; +import org.apache.xmlgraphics.ps.PSGenerator; + +import org.apache.fop.render.Graphics2DAdapter; +import org.apache.fop.render.RendererContext; + +/** + * Graphics2DAdapter implementation for PostScript. + */ +public class PSGraphics2DAdapter implements Graphics2DAdapter { + + private PSGenerator gen; + private boolean clip = true; + + /** + * Main constructor + * @param renderer the Renderer instance to which this instance belongs + */ + public PSGraphics2DAdapter(PSRenderer renderer) { + this(renderer.gen, true); + } + + /** + * Constructor for use without a PSRenderer instance. + * @param gen the PostScript generator + * @param clip true if the image should be clipped + */ + public PSGraphics2DAdapter(PSGenerator gen, boolean clip) { + this.gen = gen; + this.clip = clip; + } + + /** {@inheritDoc} */ + 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; + float imh = (float)dim.getHeight() / 1000f; + + float sx = fwidth / (float)imw; + float sy = fheight / (float)imh; + + gen.commentln("%FOPBeginGraphics2D"); + gen.saveGraphicsState(); + if (clip) { + // Clip to the image area. + gen.writeln("newpath"); + 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. + gen.concatMatrix(sx, 0, 0, sy, fx, fy); + + final boolean textAsShapes = false; + PSGraphics2D graphics = new PSGraphics2D(textAsShapes, gen); + graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); + AffineTransform transform = new AffineTransform(); + // 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); + + gen.restoreGraphicsState(); + gen.commentln("%FOPEndGraphics2D"); + } + +} diff --git a/src/java/org/apache/fop/render/ps/PSPageDeviceDictionary.java b/src/java/org/apache/fop/render/ps/PSPageDeviceDictionary.java index c327423ef..88667c24d 100644 --- a/src/java/org/apache/fop/render/ps/PSPageDeviceDictionary.java +++ b/src/java/org/apache/fop/render/ps/PSPageDeviceDictionary.java @@ -1,110 +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.render.ps;
-
-/**
- * Postscript page device dictionary object
- *
- * This object is used by the postscript renderer to hold postscript page device
- * values. It can also be used to minimize the number of setpagedevice calls when
- * DSC compliance is false.
- */
-public class PSPageDeviceDictionary extends PSDictionary {
-
- private static final long serialVersionUID = 845943256485806509L;
-
- /**
- * Whether or not the contents of the dictionary are flushed on retrieval
- */
- private boolean flushOnRetrieval = false;
-
- /**
- * Dictionary content that has not been output/written yet
- */
- private PSDictionary unRetrievedContentDictionary;
-
- /**
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @return the previous value associated with the key or null
- * @see java.util.Map#put(Object, Object)
- */
- public Object put(Object key, Object value) {
- Object previousValue = super.put(key, value);
- if (flushOnRetrieval) {
- if (previousValue == null || !previousValue.equals(value)) {
- unRetrievedContentDictionary.put(key, value);
- }
- }
- return previousValue;
- }
-
- /**
- * @see java.util.Map#clear()
- */
- public void clear() {
- super.clear();
- if (unRetrievedContentDictionary != null) {
- unRetrievedContentDictionary.clear();
- }
- }
-
- /**
- * Returns <tt>true</tt> if this map contains no key-value mappings.
- *
- * @return <tt>true</tt> if this map contains no key-value mappings.
- */
- public boolean isEmpty() {
- if (flushOnRetrieval) {
- return unRetrievedContentDictionary.isEmpty();
- }
- return super.isEmpty();
- }
-
- /**
- * The contents of the dictionary are flushed when written
- * @param flushOnRetrieval boolean value
- */
- public void setFlushOnRetrieval(boolean flushOnRetrieval) {
- this.flushOnRetrieval = flushOnRetrieval;
- if (flushOnRetrieval) {
- unRetrievedContentDictionary = new PSDictionary();
- }
- }
-
- /**
- * Returns a dictionary string with containing all unwritten content note:
- * unnecessary writes are important as there is a device specific
- * initgraphics call by the underlying postscript interpreter on every
- * setpagedevice call which can result in blank pages etc.
- *
- * @return unwritten content dictionary string
- */
- public String getContent() {
- String content;
- if (flushOnRetrieval) {
- content = unRetrievedContentDictionary.toString();
- unRetrievedContentDictionary.clear();
- } else {
- content = super.toString();
- }
- return content;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; + +/** + * Postscript page device dictionary object + * + * This object is used by the postscript renderer to hold postscript page device + * values. It can also be used to minimize the number of setpagedevice calls when + * DSC compliance is false. + */ +public class PSPageDeviceDictionary extends PSDictionary { + + private static final long serialVersionUID = 845943256485806509L; + + /** + * Whether or not the contents of the dictionary are flushed on retrieval + */ + private boolean flushOnRetrieval = false; + + /** + * Dictionary content that has not been output/written yet + */ + private PSDictionary unRetrievedContentDictionary; + + /** + * @param key key with which the specified value is to be associated. + * @param value value to be associated with the specified key. + * @return the previous value associated with the key or null + * @see java.util.Map#put(Object, Object) + */ + public Object put(Object key, Object value) { + Object previousValue = super.put(key, value); + if (flushOnRetrieval) { + if (previousValue == null || !previousValue.equals(value)) { + unRetrievedContentDictionary.put(key, value); + } + } + return previousValue; + } + + /** + * @see java.util.Map#clear() + */ + public void clear() { + super.clear(); + if (unRetrievedContentDictionary != null) { + unRetrievedContentDictionary.clear(); + } + } + + /** + * Returns <tt>true</tt> if this map contains no key-value mappings. + * + * @return <tt>true</tt> if this map contains no key-value mappings. + */ + public boolean isEmpty() { + if (flushOnRetrieval) { + return unRetrievedContentDictionary.isEmpty(); + } + return super.isEmpty(); + } + + /** + * The contents of the dictionary are flushed when written + * @param flushOnRetrieval boolean value + */ + public void setFlushOnRetrieval(boolean flushOnRetrieval) { + this.flushOnRetrieval = flushOnRetrieval; + if (flushOnRetrieval) { + unRetrievedContentDictionary = new PSDictionary(); + } + } + + /** + * Returns a dictionary string with containing all unwritten content note: + * unnecessary writes are important as there is a device specific + * initgraphics call by the underlying postscript interpreter on every + * setpagedevice call which can result in blank pages etc. + * + * @return unwritten content dictionary string + */ + public String getContent() { + String content; + if (flushOnRetrieval) { + content = unRetrievedContentDictionary.toString(); + unRetrievedContentDictionary.clear(); + } else { + content = super.toString(); + } + return content; + } +} diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java index e94d873cb..3ce9751b5 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java +++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.ps; diff --git a/src/java/org/apache/fop/render/ps/PSRendererMaker.java b/src/java/org/apache/fop/render/ps/PSRendererMaker.java index d879c054c..657a65f70 100644 --- a/src/java/org/apache/fop/render/ps/PSRendererMaker.java +++ b/src/java/org/apache/fop/render/ps/PSRendererMaker.java @@ -1,54 +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.render.ps;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the PostScript Renderer.
- */
-public class PSRendererMaker extends AbstractRendererMaker {
-
- private static final String[] MIMES = new String[] {MimeConstants.MIME_POSTSCRIPT};
-
- /** {@inheritDoc} */
- public Renderer makeRenderer(FOUserAgent userAgent) {
- return new PSRenderer();
- }
-
- /** {@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new PSRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfigurator; + +/** + * RendererMaker for the PostScript Renderer. + */ +public class PSRendererMaker extends AbstractRendererMaker { + + private static final String[] MIMES = new String[] {MimeConstants.MIME_POSTSCRIPT}; + + /** {@inheritDoc} */ + public Renderer makeRenderer(FOUserAgent userAgent) { + return new PSRenderer(); + } + + /** {@inheritDoc} */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return new PSRendererConfigurator(userAgent); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return true; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } +} 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 f2a9c56d9..a10bb7518 100644 --- a/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/AbstractPSExtensionElement.java @@ -1,133 +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: AbstractPSExtensionObject.java 426576 2006-07-28 15:44:37Z jeremias $ */
-
-package org.apache.fop.render.ps.extensions;
-
-// FOP
-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.
- */
-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)
- */
- public AbstractPSExtensionElement(FONode parent) {
- super(parent);
- }
-
- /**
- * 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)
- throws ValidationException {
- if (FO_URI.equals(nsURI)) {
- invalidChildError(loc, nsURI, localName);
- }
- }
-
- /**
- * Adds characters (does nothing here)
- * @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 locator location in fo source file.
- * @see org.apache.fop.fo.FONode#addCharacters(char[], int, int, PropertyList, Locator)
- */
- protected void addCharacters(char[] data, int start, int length,
- PropertyList pList, Locator locator) {
- PSExtensionAttachment a = (PSExtensionAttachment)getExtensionAttachment();
- if (a.getContent() != null) {
- StringBuffer sb = new StringBuffer(a.getContent());
- sb.append(data, start, length - start);
- a.setContent(sb.toString());
- } else {
- a.setContent(new String(data, start, length - start));
- }
- }
-
- /**
- * @return a String representation of this object
- * @see org.apache.fop.fo.FONode#getNamespaceURI()
- */
- public String getNamespaceURI() {
- return PSExtensionElementMapping.NAMESPACE;
- }
-
- /**
- * @return a String representation of this object
- * @see org.apache.fop.fo.FONode#getNormalNamespacePrefix()
- */
- public String getNormalNamespacePrefix() {
- return "fox";
- }
-
- /**
- * @see org.apache.fop.fo.FONode#endOfNode()
- * @throws FOPException if there's a problem during processing
- */
- protected void endOfNode() throws FOPException {
- super.endOfNode();
- String s = ((PSExtensionAttachment)getExtensionAttachment()).getContent();
- if (s == null || s.length() == 0) {
- missingChildElementError("#PCDATA");
- }
- }
-
- /**
- * @return the extension attachment if one is created by the extension element, null otherwise.
- * @see org.apache.fop.fo.FONode#getExtensionAttachment()
- */
- public ExtensionAttachment getExtensionAttachment() {
- if (attachment == null) {
- this.attachment = (PSExtensionAttachment)instantiateExtensionAttachment();
- }
- return this.attachment;
- }
-
- /**
- * Instantiates extension attachment object
- * @return extension attachment
- */
- protected abstract ExtensionAttachment instantiateExtensionAttachment();
-}
-
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.extensions; + +// FOP +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. + */ +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) + */ + public AbstractPSExtensionElement(FONode parent) { + super(parent); + } + + /** + * 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) + throws ValidationException { + if (FO_URI.equals(nsURI)) { + invalidChildError(loc, nsURI, localName); + } + } + + /** + * Adds characters (does nothing here) + * @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 locator location in fo source file. + * @see org.apache.fop.fo.FONode#addCharacters(char[], int, int, PropertyList, Locator) + */ + protected void addCharacters(char[] data, int start, int length, + PropertyList pList, Locator locator) { + PSExtensionAttachment a = (PSExtensionAttachment)getExtensionAttachment(); + if (a.getContent() != null) { + StringBuffer sb = new StringBuffer(a.getContent()); + sb.append(data, start, length - start); + a.setContent(sb.toString()); + } else { + a.setContent(new String(data, start, length - start)); + } + } + + /** + * @return a String representation of this object + * @see org.apache.fop.fo.FONode#getNamespaceURI() + */ + public String getNamespaceURI() { + return PSExtensionElementMapping.NAMESPACE; + } + + /** + * @return a String representation of this object + * @see org.apache.fop.fo.FONode#getNormalNamespacePrefix() + */ + public String getNormalNamespacePrefix() { + return "fox"; + } + + /** + * @see org.apache.fop.fo.FONode#endOfNode() + * @throws FOPException if there's a problem during processing + */ + protected void endOfNode() throws FOPException { + super.endOfNode(); + String s = ((PSExtensionAttachment)getExtensionAttachment()).getContent(); + if (s == null || s.length() == 0) { + missingChildElementError("#PCDATA"); + } + } + + /** + * @return the extension attachment if one is created by the extension element, null otherwise. + * @see org.apache.fop.fo.FONode#getExtensionAttachment() + */ + public ExtensionAttachment getExtensionAttachment() { + if (attachment == null) { + this.attachment = (PSExtensionAttachment)instantiateExtensionAttachment(); + } + return this.attachment; + } + + /** + * Instantiates extension attachment object + * @return extension attachment + */ + protected abstract ExtensionAttachment instantiateExtensionAttachment(); +} + 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 80a2aeee3..3fccf4f67 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionAttachment.java @@ -1,110 +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.render.ps.extensions;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-import org.apache.xmlgraphics.util.XMLizable;
-
-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;
-
- /** The category URI for this extension attachment. */
- public static final String CATEGORY = "apache:fop:extensions:postscript";
-
- /**
- * Default constructor.
- * @param content the content of the setup code object
- */
- public PSExtensionAttachment(String content) {
- this.content = content;
- }
-
- /**
- * No-argument contructor.
- */
- public PSExtensionAttachment() {
- }
-
- /**
- * @return the category URI
- * @see org.apache.fop.fo.extensions.ExtensionAttachment#getCategory()
- */
- 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.
- */
- 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.fop.util.XMLizable#toSAX(org.xml.sax.ContentHandler)
- */
- public void toSAX(ContentHandler handler) throws SAXException {
- AttributesImpl atts = new AttributesImpl();
- String element = getElement();
- handler.startElement(CATEGORY, element, element, atts);
- if (content != null && content.length() > 0) {
- char[] chars = content.toCharArray();
- handler.characters(chars, 0, chars.length);
- }
- handler.endElement(CATEGORY, element, element);
- }
-
- /** @return type name */
- public String getType() {
- String className = getClass().getName();
- return className.substring(className.lastIndexOf('.') + 3);
- }
-
- /**
- * @return a string representation of this object
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return getType() + ": content=" + content;
- }
-
- /** @return element */
- protected abstract String getElement();
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.extensions; + +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + +import org.apache.xmlgraphics.util.XMLizable; + +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; + + /** The category URI for this extension attachment. */ + public static final String CATEGORY = "apache:fop:extensions:postscript"; + + /** + * Default constructor. + * @param content the content of the setup code object + */ + public PSExtensionAttachment(String content) { + this.content = content; + } + + /** + * No-argument contructor. + */ + public PSExtensionAttachment() { + } + + /** + * @return the category URI + * @see org.apache.fop.fo.extensions.ExtensionAttachment#getCategory() + */ + 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. + */ + 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.fop.util.XMLizable#toSAX(org.xml.sax.ContentHandler) + */ + public void toSAX(ContentHandler handler) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + String element = getElement(); + handler.startElement(CATEGORY, element, element, atts); + if (content != null && content.length() > 0) { + char[] chars = content.toCharArray(); + handler.characters(chars, 0, chars.length); + } + handler.endElement(CATEGORY, element, element); + } + + /** @return type name */ + public String getType() { + String className = getClass().getName(); + return className.substring(className.lastIndexOf('.') + 3); + } + + /** + * @return a string representation of this object + * @see java.lang.Object#toString() + */ + public String toString() { + return getType() + ": content=" + content; + } + + /** @return element */ + protected abstract String getElement(); +} 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 72f665a0f..456d97430 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.ps.extensions; 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 da84f97a2..28ea3c24c 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java @@ -1,114 +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.render.ps.extensions;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * Element for postscript setpagedevice instruction
- * This is a an extension which provides a pass-through value
- * dictionary object for the postscript setpagedevice instruction.
- */
-public class PSSetPageDevice extends PSExtensionAttachment {
- /** element name */
- protected static final String ELEMENT = "ps-setpagedevice";
-
- private static final String ATT_NAME = "name";
-
- /**
- * name attribute
- */
- protected String name = null;
-
- /**
- * default constructor
- * @param content set page device dictionary
- */
- public PSSetPageDevice(String content) {
- super(content);
- }
-
- /**
- * constructor
- * @param name name attribute of this setpagedevice content
- * @param content set page device dictionary
- */
- public PSSetPageDevice(String name, String content) {
- this(content);
- this.name = name;
- }
-
- /**
- * constructor
- */
- public PSSetPageDevice() {
- }
-
- /** @return the name */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the name of the setup code object.
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return a string representation of this object
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return "PSSetPageDevice(name=" + getName() + ", content='" + getContent() + "')";
- }
-
- /**
- * @return a string representation of this object
- * @see org.apache.fop.render.ps.extensions.PSExtensionAttachment#getElement()
- */
- protected String getElement() {
- return ELEMENT;
- }
-
- /**
- * 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)
- */
- public void toSAX(ContentHandler handler) throws SAXException {
- AttributesImpl atts = new AttributesImpl();
- if (name != null && name.length() > 0) {
- atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name);
- }
- String element = getElement();
- handler.startElement(CATEGORY, element, element, atts);
- if (content != null && content.length() > 0) {
- char[] chars = content.toCharArray();
- handler.characters(chars, 0, chars.length);
- }
- handler.endElement(CATEGORY, element, element);
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.extensions; + +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + +/** + * Element for postscript setpagedevice instruction + * This is a an extension which provides a pass-through value + * dictionary object for the postscript setpagedevice instruction. + */ +public class PSSetPageDevice extends PSExtensionAttachment { + /** element name */ + protected static final String ELEMENT = "ps-setpagedevice"; + + private static final String ATT_NAME = "name"; + + /** + * name attribute + */ + protected String name = null; + + /** + * default constructor + * @param content set page device dictionary + */ + public PSSetPageDevice(String content) { + super(content); + } + + /** + * constructor + * @param name name attribute of this setpagedevice content + * @param content set page device dictionary + */ + public PSSetPageDevice(String name, String content) { + this(content); + this.name = name; + } + + /** + * constructor + */ + public PSSetPageDevice() { + } + + /** @return the name */ + public String getName() { + return name; + } + + /** + * Sets the name of the setup code object. + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return a string representation of this object + * @see java.lang.Object#toString() + */ + public String toString() { + return "PSSetPageDevice(name=" + getName() + ", content='" + getContent() + "')"; + } + + /** + * @return a string representation of this object + * @see org.apache.fop.render.ps.extensions.PSExtensionAttachment#getElement() + */ + protected String getElement() { + return ELEMENT; + } + + /** + * 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) + */ + public void toSAX(ContentHandler handler) throws SAXException { + AttributesImpl atts = new AttributesImpl(); + if (name != null && name.length() > 0) { + atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); + } + String element = getElement(); + handler.startElement(CATEGORY, element, element, atts); + if (content != null && content.length() > 0) { + char[] chars = content.toCharArray(); + handler.characters(chars, 0, chars.length); + } + handler.endElement(CATEGORY, element, element); + } +} 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 ff7e8f792..b512c6888 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSSetPageDeviceElement.java @@ -1,95 +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.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.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 {
-
- protected static final String ELEMENT = "ps-setpagedevice";
-
- /**
- * Main constructor
- * @param parent parent FO node
- */
- protected PSSetPageDeviceElement(FONode parent) {
- super(parent);
- }
-
- /**
- * Called after processNode() is called. Subclasses can do additional processing.
- * @throws FOPException if there's a problem during processing
- * @see org.apache.fop.fo.FONode#startOfNode()
- */
- protected void startOfNode() throws FOPException {
- 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.");
- }
- }
-
- /**
- * Initialize the node with its name, location information, and attributes
- * The attributes must be used immediately as the sax attributes
- * will be altered for the next element.
- * @param elementName element name (e.g., "fo:block")
- * @param locator Locator object (ignored by default)
- * @param attlist Collection of attributes passed to us from the parser.
- * @param propertyList property list
- * @throws FOPException if there's a problem during processing
- * @see org.apache.fop.fo.FONode#processNode
- */
- public void processNode(String elementName, Locator locator,
- Attributes attlist, PropertyList propertyList)
- throws FOPException {
- String name = attlist.getValue("name");
- if (name != null && name.length() > 0) {
- ((PSSetPageDevice)getExtensionAttachment()).setName(name);
- }
- }
-
- /**
- * @return local name
- * @see org.apache.fop.fo.FONode#getLocalName() */
- public String getLocalName() {
- return ELEMENT;
- }
-
- /**
- * @return a new PSSetPageDevice object
- * @see org.apache.fop.render.ps.extensions.AbstractPSExtensionElement
- * #instantiateExtensionAttachment()
- */
- protected ExtensionAttachment instantiateExtensionAttachment() {
- return new PSSetPageDevice();
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.extensions; + +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 { + + protected static final String ELEMENT = "ps-setpagedevice"; + + /** + * Main constructor + * @param parent parent FO node + */ + protected PSSetPageDeviceElement(FONode parent) { + super(parent); + } + + /** + * Called after processNode() is called. Subclasses can do additional processing. + * @throws FOPException if there's a problem during processing + * @see org.apache.fop.fo.FONode#startOfNode() + */ + protected void startOfNode() throws FOPException { + 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."); + } + } + + /** + * Initialize the node with its name, location information, and attributes + * The attributes must be used immediately as the sax attributes + * will be altered for the next element. + * @param elementName element name (e.g., "fo:block") + * @param locator Locator object (ignored by default) + * @param attlist Collection of attributes passed to us from the parser. + * @param propertyList property list + * @throws FOPException if there's a problem during processing + * @see org.apache.fop.fo.FONode#processNode + */ + public void processNode(String elementName, Locator locator, + Attributes attlist, PropertyList propertyList) + throws FOPException { + String name = attlist.getValue("name"); + if (name != null && name.length() > 0) { + ((PSSetPageDevice)getExtensionAttachment()).setName(name); + } + } + + /** + * @return local name + * @see org.apache.fop.fo.FONode#getLocalName() */ + public String getLocalName() { + return ELEMENT; + } + + /** + * @return a new PSSetPageDevice object + * @see org.apache.fop.render.ps.extensions.AbstractPSExtensionElement + * #instantiateExtensionAttachment() + */ + protected ExtensionAttachment instantiateExtensionAttachment() { + return new PSSetPageDevice(); + } +} diff --git a/src/java/org/apache/fop/render/rtf/RTFFOEventHandlerMaker.java b/src/java/org/apache/fop/render/rtf/RTFFOEventHandlerMaker.java index 40583253d..a15d206ee 100644 --- a/src/java/org/apache/fop/render/rtf/RTFFOEventHandlerMaker.java +++ b/src/java/org/apache/fop/render/rtf/RTFFOEventHandlerMaker.java @@ -1,66 +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.rtf;
-
-import java.io.OutputStream;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.fo.FOEventHandler;
-import org.apache.fop.render.AbstractFOEventHandlerMaker;
-
-/**
- * Maker class for RTF support.
- */
-public class RTFFOEventHandlerMaker extends AbstractFOEventHandlerMaker {
-
- private static final String[] MIMES = new String[] {
- MimeConstants.MIME_RTF,
- MimeConstants.MIME_RTF_ALT1,
- MimeConstants.MIME_RTF_ALT2};
-
-
- /**
- * {@inheritDoc}
- * @param ua FOUserAgent
- * @param out OutputStream
- * @return created RTFHandler
- */
- public FOEventHandler makeFOEventHandler(FOUserAgent ua, OutputStream out) {
- return new RTFHandler(ua, out);
- }
-
- /**
- * {@inheritDoc}
- * @return true, if an outputstream is needed
- */
- public boolean needsOutputStream() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- * @return array of MIME types
- */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 java.io.OutputStream; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.fo.FOEventHandler; +import org.apache.fop.render.AbstractFOEventHandlerMaker; + +/** + * Maker class for RTF support. + */ +public class RTFFOEventHandlerMaker extends AbstractFOEventHandlerMaker { + + private static final String[] MIMES = new String[] { + MimeConstants.MIME_RTF, + MimeConstants.MIME_RTF_ALT1, + MimeConstants.MIME_RTF_ALT2}; + + + /** + * {@inheritDoc} + * @param ua FOUserAgent + * @param out OutputStream + * @return created RTFHandler + */ + public FOEventHandler makeFOEventHandler(FOUserAgent ua, OutputStream out) { + return new RTFHandler(ua, out); + } + + /** + * {@inheritDoc} + * @return true, if an outputstream is needed + */ + public boolean needsOutputStream() { + return true; + } + + /** + * {@inheritDoc} + * @return array of MIME types + */ + public String[] getSupportedMimeTypes() { + return MIMES; + } + +} 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 89cd45efc..0e9820994 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 @@ -1,117 +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.render.rtf.rtflib.rtfdoc;
-
-/*
- * This file is part of the RTF library of the FOP project, which was originally
- * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
- * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
- * the FOP project.
- */
-
-
-
-/** Constants for RTF border attribute names. */
-
-public interface IBorderAttributes {
-
- /** Constant for border left */
- String BORDER_LEFT = "brdrl";
- /** Constant for border right */
- String BORDER_RIGHT = "brdrr";
- /** Constant for border top */
- String BORDER_TOP = "brdrt";
- /** Constant for border bottom */
- String BORDER_BOTTOM = "brdrb";
- /** Constant for character border (border always appears on all sides) */
- String BORDER_CHARACTER = "chbrdr";
- /** Constant for a single-thick border */
- String BORDER_SINGLE_THICKNESS = "brdrs";
- /** Constant for a double-thick border */
- String BORDER_DOUBLE_THICKNESS = "brdrth";
- /** Constant for a shadowed border */
- String BORDER_SHADOWED = "brdrsh";
- /** Constant for a double border */
- String BORDER_DOUBLE = "brdrdb";
- /** Constant for a dotted border */
- String BORDER_DOTTED = "brdrdot";
- /** Constant for a dashed border */
- String BORDER_DASH = "brdrdash";
- /** Constant for a hairline border */
- String BORDER_HAIRLINE = "brdrhair";
- /** Constant for a small-dashed border */
- String BORDER_DASH_SMALL = "brdrdashsm";
- /** Constant for a dot-dashed border */
- String BORDER_DOT_DASH = "brdrdashd";
- /** Constant for a dot-dot-dashed border */
- String BORDER_DOT_DOT_DASH = "brdrdashdd";
- /** Constant for a triple border */
- String BORDER_TRIPLE = "brdrtriple";
- /** Constant for a think-thin-small border */
- String BORDER_THINK_THIN_SMALL = "brdrtnthsg";
- /** Constant for a thin-thick-small border */
- String BORDER_THIN_THICK_SMALL = "brdrthtnsg";
- /** Constant for a thin-thick-thin-small border */
- String BORDER_THIN_THICK_THIN_SMALL = "brdrthtnthsg";
- /** Constant for a think-thin-medium border */
- String BORDER_THINK_THIN_MEDIUM = "brdrtnthmg";
- /** Constant for a thin-thick-medium border */
- String BORDER_THIN_THICK_MEDIUM = "brdrthtnmg";
- /** Constant for a thin-thick-thin-medium border */
- String BORDER_THIN_THICK_THIN_MEDIUM = "brdrthtnthmg";
- /** Constant for a think-thin-large border */
- String BORDER_THINK_THIN_LARGE = "brdrtnthlg";
- /** Constant for a thin-thick-large border */
- String BORDER_THIN_THICK_LARGE = "brdrthtnlg";
- /** Constant for a thin-thick-thin-large border */
- String BORDER_THIN_THICK_THIN_LARGE = "brdrthtnthlg";
- /** Constant for a wavy border */
- String BORDER_WAVY = "brdrwavy";
- /** Constant for a double wavy border */
- String BORDER_WAVY_DOUBLE = "brdrwavydb";
- /** Constant for a striped border */
- String BORDER_STRIPED = "brdrdashdotstr";
- /** Constant for an embossed border */
- String BORDER_EMBOSS = "brdremboss";
- /** Constant for an engraved border */
- String BORDER_ENGRAVE = "brdrengrave";
- /** Constant for an nil border */
- String BORDER_NIL = "brdrnil";
- /** Constant for border color */
- String BORDER_COLOR = "brdrcf";
- /** Constant for border space */
- String BORDER_SPACE = "brsp";
- /** Constant for border width */
- String BORDER_WIDTH = "brdrw";
-
- /** String array of border attributes */
- String [] BORDERS = new String[] {
- BORDER_SINGLE_THICKNESS, BORDER_DOUBLE_THICKNESS, BORDER_SHADOWED,
- BORDER_DOUBLE, BORDER_DOTTED, BORDER_DASH,
- BORDER_HAIRLINE, BORDER_DASH_SMALL, BORDER_DOT_DASH,
- BORDER_DOT_DOT_DASH, BORDER_TRIPLE, BORDER_THINK_THIN_SMALL,
- BORDER_THIN_THICK_SMALL, BORDER_THIN_THICK_THIN_SMALL, BORDER_THINK_THIN_MEDIUM,
- BORDER_THIN_THICK_MEDIUM, BORDER_THIN_THICK_THIN_MEDIUM, BORDER_THINK_THIN_LARGE,
- BORDER_THIN_THICK_LARGE, BORDER_THIN_THICK_THIN_LARGE, BORDER_WAVY,
- BORDER_WAVY_DOUBLE, BORDER_STRIPED, BORDER_EMBOSS,
- BORDER_ENGRAVE, BORDER_COLOR, BORDER_SPACE,
- BORDER_WIDTH
- };
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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; + +/* + * This file is part of the RTF library of the FOP project, which was originally + * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other + * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to + * the FOP project. + */ + + + +/** Constants for RTF border attribute names. */ + +public interface IBorderAttributes { + + /** Constant for border left */ + String BORDER_LEFT = "brdrl"; + /** Constant for border right */ + String BORDER_RIGHT = "brdrr"; + /** Constant for border top */ + String BORDER_TOP = "brdrt"; + /** Constant for border bottom */ + String BORDER_BOTTOM = "brdrb"; + /** Constant for character border (border always appears on all sides) */ + String BORDER_CHARACTER = "chbrdr"; + /** Constant for a single-thick border */ + String BORDER_SINGLE_THICKNESS = "brdrs"; + /** Constant for a double-thick border */ + String BORDER_DOUBLE_THICKNESS = "brdrth"; + /** Constant for a shadowed border */ + String BORDER_SHADOWED = "brdrsh"; + /** Constant for a double border */ + String BORDER_DOUBLE = "brdrdb"; + /** Constant for a dotted border */ + String BORDER_DOTTED = "brdrdot"; + /** Constant for a dashed border */ + String BORDER_DASH = "brdrdash"; + /** Constant for a hairline border */ + String BORDER_HAIRLINE = "brdrhair"; + /** Constant for a small-dashed border */ + String BORDER_DASH_SMALL = "brdrdashsm"; + /** Constant for a dot-dashed border */ + String BORDER_DOT_DASH = "brdrdashd"; + /** Constant for a dot-dot-dashed border */ + String BORDER_DOT_DOT_DASH = "brdrdashdd"; + /** Constant for a triple border */ + String BORDER_TRIPLE = "brdrtriple"; + /** Constant for a think-thin-small border */ + String BORDER_THINK_THIN_SMALL = "brdrtnthsg"; + /** Constant for a thin-thick-small border */ + String BORDER_THIN_THICK_SMALL = "brdrthtnsg"; + /** Constant for a thin-thick-thin-small border */ + String BORDER_THIN_THICK_THIN_SMALL = "brdrthtnthsg"; + /** Constant for a think-thin-medium border */ + String BORDER_THINK_THIN_MEDIUM = "brdrtnthmg"; + /** Constant for a thin-thick-medium border */ + String BORDER_THIN_THICK_MEDIUM = "brdrthtnmg"; + /** Constant for a thin-thick-thin-medium border */ + String BORDER_THIN_THICK_THIN_MEDIUM = "brdrthtnthmg"; + /** Constant for a think-thin-large border */ + String BORDER_THINK_THIN_LARGE = "brdrtnthlg"; + /** Constant for a thin-thick-large border */ + String BORDER_THIN_THICK_LARGE = "brdrthtnlg"; + /** Constant for a thin-thick-thin-large border */ + String BORDER_THIN_THICK_THIN_LARGE = "brdrthtnthlg"; + /** Constant for a wavy border */ + String BORDER_WAVY = "brdrwavy"; + /** Constant for a double wavy border */ + String BORDER_WAVY_DOUBLE = "brdrwavydb"; + /** Constant for a striped border */ + String BORDER_STRIPED = "brdrdashdotstr"; + /** Constant for an embossed border */ + String BORDER_EMBOSS = "brdremboss"; + /** Constant for an engraved border */ + String BORDER_ENGRAVE = "brdrengrave"; + /** Constant for an nil border */ + String BORDER_NIL = "brdrnil"; + /** Constant for border color */ + String BORDER_COLOR = "brdrcf"; + /** Constant for border space */ + String BORDER_SPACE = "brsp"; + /** Constant for border width */ + String BORDER_WIDTH = "brdrw"; + + /** String array of border attributes */ + String [] BORDERS = new String[] { + BORDER_SINGLE_THICKNESS, BORDER_DOUBLE_THICKNESS, BORDER_SHADOWED, + BORDER_DOUBLE, BORDER_DOTTED, BORDER_DASH, + BORDER_HAIRLINE, BORDER_DASH_SMALL, BORDER_DOT_DASH, + BORDER_DOT_DOT_DASH, BORDER_TRIPLE, BORDER_THINK_THIN_SMALL, + BORDER_THIN_THICK_SMALL, BORDER_THIN_THICK_THIN_SMALL, BORDER_THINK_THIN_MEDIUM, + BORDER_THIN_THICK_MEDIUM, BORDER_THIN_THICK_THIN_MEDIUM, BORDER_THINK_THIN_LARGE, + BORDER_THIN_THICK_LARGE, BORDER_THIN_THICK_THIN_LARGE, BORDER_WAVY, + BORDER_WAVY_DOUBLE, BORDER_STRIPED, BORDER_EMBOSS, + BORDER_ENGRAVE, BORDER_COLOR, BORDER_SPACE, + BORDER_WIDTH + }; +} diff --git a/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java b/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java index ab655c92e..0ca509b66 100644 --- a/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java +++ b/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.txt; diff --git a/src/java/org/apache/fop/render/txt/TXTRendererMaker.java b/src/java/org/apache/fop/render/txt/TXTRendererMaker.java index b18c3faa0..24e24ea87 100644 --- a/src/java/org/apache/fop/render/txt/TXTRendererMaker.java +++ b/src/java/org/apache/fop/render/txt/TXTRendererMaker.java @@ -1,54 +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.render.txt;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the Plain Text Renderer.
- */
-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();
- }
-
- /**{@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new TXTRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.txt; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfigurator; + +/** + * RendererMaker for the Plain Text Renderer. + */ +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(); + } + + /**{@inheritDoc} */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return new TXTRendererConfigurator(userAgent); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return true; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } +} diff --git a/src/java/org/apache/fop/render/xml/XMLRendererMaker.java b/src/java/org/apache/fop/render/xml/XMLRendererMaker.java index 3ed62a6e1..5aa0deb2b 100644 --- a/src/java/org/apache/fop/render/xml/XMLRendererMaker.java +++ b/src/java/org/apache/fop/render/xml/XMLRendererMaker.java @@ -1,56 +1,56 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.xml;
-
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.AbstractRendererMaker;
-import org.apache.fop.render.PrintRendererConfigurator;
-import org.apache.fop.render.Renderer;
-import org.apache.fop.render.RendererConfigurator;
-
-/**
- * RendererMaker for the Area Tree XML Renderer.
- */
-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();
- }
-
- /**{@inheritDoc} */
- public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
- return new PrintRendererConfigurator(userAgent);
- }
-
- /** {@inheritDoc} */
- public boolean needsOutputStream() {
- return true;
- }
-
- /** {@inheritDoc} */
- public String[] getSupportedMimeTypes() {
- return MIMES;
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.xml; + +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.MimeConstants; +import org.apache.fop.render.AbstractRendererMaker; +import org.apache.fop.render.PrintRendererConfigurator; +import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfigurator; + +/** + * RendererMaker for the Area Tree XML Renderer. + */ +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(); + } + + /**{@inheritDoc} */ + public RendererConfigurator getConfigurator(FOUserAgent userAgent) { + return new PrintRendererConfigurator(userAgent); + } + + /** {@inheritDoc} */ + public boolean needsOutputStream() { + return true; + } + + /** {@inheritDoc} */ + public String[] getSupportedMimeTypes() { + return MIMES; + } + +} diff --git a/src/java/org/apache/fop/util/LogUtil.java b/src/java/org/apache/fop/util/LogUtil.java index 60eafb51a..e33397fcb 100644 --- a/src/java/org/apache/fop/util/LogUtil.java +++ b/src/java/org/apache/fop/util/LogUtil.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.util; diff --git a/src/java/org/apache/fop/util/QName.java b/src/java/org/apache/fop/util/QName.java index 0794d3088..390e29dd9 100644 --- a/src/java/org/apache/fop/util/QName.java +++ b/src/java/org/apache/fop/util/QName.java @@ -1,138 +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.util;
-
-import java.io.Serializable;
-
-/**
- * Represents a qualified name of an XML element or an XML attribute.
- * <p>
- * Note: This class allows to carry a namespace prefix but it is not used in the equals() and
- * hashCode() methods.
- */
-public class QName implements Serializable {
-
- 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
- * @param prefix the namespace prefix, may be null
- * @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();
- }
-
- /**
- * Main constructor.
- * @param namespaceURI the namespace URI
- * @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();
- }
-
- /** @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);
- }
-
-}
+/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.Serializable; + +/** + * Represents a qualified name of an XML element or an XML attribute. + * <p> + * Note: This class allows to carry a namespace prefix but it is not used in the equals() and + * hashCode() methods. + */ +public class QName implements Serializable { + + 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 + * @param prefix the namespace prefix, may be null + * @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(); + } + + /** + * Main constructor. + * @param namespaceURI the namespace URI + * @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(); + } + + /** @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/UnitConv.java b/src/java/org/apache/fop/util/UnitConv.java index 626321ff9..cd3276b9f 100644 --- a/src/java/org/apache/fop/util/UnitConv.java +++ b/src/java/org/apache/fop/util/UnitConv.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: FixedLength.java 279656 2005-09-08 22:06:48Z pietsch $ */ +/* $Id$ */ package org.apache.fop.util; |