aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/documentation/content/xdocs/0.94/extensions.xml2
-rw-r--r--src/documentation/content/xdocs/0.95/extensions.xml2
-rw-r--r--src/documentation/content/xdocs/trunk/extensions.xml2
-rw-r--r--src/java/org/apache/fop/fo/PropertyList.java9
-rw-r--r--src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java1
-rw-r--r--src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java66
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequence.java59
-rw-r--r--src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java6
-rw-r--r--src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java3
-rw-r--r--src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java1
-rw-r--r--src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java5
-rw-r--r--src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java2
-rw-r--r--src/java/org/apache/fop/fonts/apps/PFMReader.java8
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFFile.java45
-rw-r--r--src/java/org/apache/fop/fonts/type1/PFMInputStream.java9
-rw-r--r--src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java7
-rw-r--r--src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java3
-rw-r--r--src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageProvider.java7
-rw-r--r--src/java/org/apache/fop/pdf/AlphaRasterImage.java15
-rw-r--r--src/java/org/apache/fop/pdf/PDFFilterList.java10
-rw-r--r--src/java/org/apache/fop/render/rtf/RTFHandler.java2
-rw-r--r--src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java17
23 files changed, 138 insertions, 147 deletions
diff --git a/src/documentation/content/xdocs/0.94/extensions.xml b/src/documentation/content/xdocs/0.94/extensions.xml
index dd4a79535..04d44ef6f 100644
--- a/src/documentation/content/xdocs/0.94/extensions.xml
+++ b/src/documentation/content/xdocs/0.94/extensions.xml
@@ -48,7 +48,7 @@
<p>
By convention, FO extensions in FOP use the "fox" namespace prefix.
To use any of the FO extensions, add a namespace entry for
- <code>http://xml.apache.org/fop/extensions</code> to the root element:
+ <code>http://xmlgraphics.apache.org/fop/extensions</code> to the root element:
</p>
<source><![CDATA[<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">]]></source>
diff --git a/src/documentation/content/xdocs/0.95/extensions.xml b/src/documentation/content/xdocs/0.95/extensions.xml
index 483866e61..878494ecb 100644
--- a/src/documentation/content/xdocs/0.95/extensions.xml
+++ b/src/documentation/content/xdocs/0.95/extensions.xml
@@ -48,7 +48,7 @@
<p>
By convention, FO extensions in FOP use the "fox" namespace prefix.
To use any of the FO extensions, add a namespace entry for
- <code>http://xml.apache.org/fop/extensions</code> to the root element:
+ <code>http://xmlgraphics.apache.org/fop/extensions</code> to the root element:
</p>
<source><![CDATA[<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">]]></source>
diff --git a/src/documentation/content/xdocs/trunk/extensions.xml b/src/documentation/content/xdocs/trunk/extensions.xml
index 483866e61..878494ecb 100644
--- a/src/documentation/content/xdocs/trunk/extensions.xml
+++ b/src/documentation/content/xdocs/trunk/extensions.xml
@@ -48,7 +48,7 @@
<p>
By convention, FO extensions in FOP use the "fox" namespace prefix.
To use any of the FO extensions, add a namespace entry for
- <code>http://xml.apache.org/fop/extensions</code> to the root element:
+ <code>http://xmlgraphics.apache.org/fop/extensions</code> to the root element:
</p>
<source><![CDATA[<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">]]></source>
diff --git a/src/java/org/apache/fop/fo/PropertyList.java b/src/java/org/apache/fop/fo/PropertyList.java
index 13f983841..709c4303b 100644
--- a/src/java/org/apache/fop/fo/PropertyList.java
+++ b/src/java/org/apache/fop/fo/PropertyList.java
@@ -370,8 +370,10 @@ public abstract class PropertyList {
if (attributeValue != null) {
- if (attributeName.startsWith("xmlns:")) {
- //Ignore namespace declarations
+ if (attributeName.startsWith("xmlns:")
+ || "xmlns".equals(attributeName)) {
+ //Ignore namespace declarations if the XML parser/XSLT processor
+ //reports them as 'regular' attributes
return;
}
@@ -519,7 +521,7 @@ public abstract class PropertyList {
}
/**
- * @param propID ID of property
+ * @param propId ID of property
* @return new Property object
* @throws PropertyException if there's a problem while processing the property
*/
@@ -638,7 +640,6 @@ public abstract class PropertyList {
return new CommonAbsolutePosition(this);
}
-
/**
* Constructs a CommonFont object.
*
diff --git a/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java b/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java
index 759cdaed9..cad9fb729 100644
--- a/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java
+++ b/src/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java
@@ -228,6 +228,7 @@ public class XMLWhiteSpaceHandler {
nestedBlockStack.pop();
}
charIter = null;
+ firstWhiteSpaceInSeq = null;
}
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
index eaa8c2491..7953731f1 100644
--- a/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/ConditionalPageMasterReference.java
@@ -94,61 +94,33 @@ public class ConditionalPageMasterReference extends FObj {
* @param isFirstPage True if page is first page
* @param isLastPage True if page is last page
* @param isBlankPage True if page is blank
- * @param isOnlyPage True if page is the only page
* @return True if the conditions for this reference are met
*/
protected boolean isValid(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
- boolean isOnlyPage,
boolean isBlankPage) {
- // page-position
- if (isOnlyPage) {
- if (pagePosition != EN_ONLY) {
- return false;
- }
- } else if (isFirstPage) {
- if (pagePosition == EN_REST) {
- return false;
- } else if (pagePosition == EN_LAST) {
- return false;
- }
- } else if (isLastPage) {
- if (pagePosition == EN_REST) {
- return false;
- } else if (pagePosition == EN_FIRST) {
- return false;
- }
- } else {
- if (pagePosition == EN_FIRST) {
- return false;
- } else if (pagePosition == EN_LAST) {
- return false;
- }
- }
- // odd-or-even
- if (isOddPage) {
- if (oddOrEven == EN_EVEN) {
- return false;
- }
- } else {
- if (oddOrEven == EN_ODD) {
- return false;
- }
- }
+ return (
+ // page-position
+ (pagePosition == EN_ANY
+ || (pagePosition == EN_FIRST && isFirstPage)
+ || (pagePosition == EN_LAST && isLastPage)
+ || (pagePosition == EN_ONLY && (isFirstPage && isLastPage))
+ || (pagePosition == EN_REST && !(isFirstPage || isLastPage))
+ )
+ // odd-or-even
+ && (oddOrEven == EN_ANY
+ || (oddOrEven == EN_ODD && isOddPage)
+ || (oddOrEven == EN_EVEN && !isOddPage)
+ )
+ // blank-or-not-blank
+ && (blankOrNotBlank == EN_ANY
+ || (blankOrNotBlank == EN_BLANK && isBlankPage)
+ || (blankOrNotBlank == EN_NOT_BLANK && !isBlankPage)
+ ));
+
- // blank-or-not-blank
- if (isBlankPage) {
- if (blankOrNotBlank == EN_NOT_BLANK) {
- return false;
- }
- } else {
- if (blankOrNotBlank == EN_BLANK) {
- return false;
- }
- }
- return true;
}
/**
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java
index bdcb27198..d41ac86ab 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequence.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java
@@ -127,19 +127,19 @@ public class PageSequence extends AbstractPageSequence {
protected void validateChildNode(Locator loc, String nsURI, String localName)
throws ValidationException {
if (FO_URI.equals(nsURI)) {
- if (localName.equals("title")) {
+ if ("title".equals(localName)) {
if (titleFO != null) {
tooManyNodesError(loc, "fo:title");
- } else if (flowMap.size() > 0) {
+ } else if (!flowMap.isEmpty()) {
nodesOutOfOrderError(loc, "fo:title", "fo:static-content");
} else if (mainFlow != null) {
nodesOutOfOrderError(loc, "fo:title", "fo:flow");
}
- } else if (localName.equals("static-content")) {
+ } else if ("static-content".equals(localName)) {
if (mainFlow != null) {
nodesOutOfOrderError(loc, "fo:static-content", "fo:flow");
}
- } else if (localName.equals("flow")) {
+ } else if ("flow".equals(localName)) {
if (mainFlow != null) {
tooManyNodesError(loc, "fo:flow");
}
@@ -157,15 +157,20 @@ public class PageSequence extends AbstractPageSequence {
public void addChildNode(FONode child) throws FOPException {
int childId = child.getNameId();
- if (childId == FO_TITLE) {
- this.titleFO = (Title) child;
- } else if (childId == FO_FLOW) {
- this.mainFlow = (Flow) child;
+ switch (childId) {
+ case FO_TITLE:
+ this.titleFO = (Title)child;
+ break;
+ case FO_FLOW:
+ this.mainFlow = (Flow)child;
addFlow(mainFlow);
- } else if (childId == FO_STATIC_CONTENT) {
- addFlow((StaticContent) child);
- String flowName = ((StaticContent) child).getFlowName();
- flowMap.put(flowName, child);
+ break;
+ case FO_STATIC_CONTENT:
+ addFlow((StaticContent)child);
+ flowMap.put(((StaticContent)child).getFlowName(), child);
+ break;
+ default:
+ assert false;
}
}
@@ -245,17 +250,14 @@ public class PageSequence extends AbstractPageSequence {
* page sequence
* @param isLastPage indicator whether this page is the last page of the
* page sequence
- * @param isOnlyPage indicator whether this page is the only page of the
- * page sequence
* @param isBlank indicator whether the page will be blank
* @return the SimplePageMaster to use for this page
* @throws PageProductionException if there's a problem determining the page master
*/
public SimplePageMaster getNextSimplePageMaster(int page,
- boolean isFirstPage,
- boolean isLastPage,
- boolean isOnlyPage,
- boolean isBlank) throws PageProductionException {
+ boolean isFirstPage,
+ boolean isLastPage,
+ boolean isBlank) throws PageProductionException {
if (pageSequenceMaster == null) {
return simplePageMaster;
@@ -266,11 +268,10 @@ public class PageSequence extends AbstractPageSequence {
+ " isOdd=" + isOddPage
+ " isFirst=" + isFirstPage
+ " isLast=" + isLastPage
- + " isOnly=" + isOnlyPage
+ " isBlank=" + isBlank + ")");
}
return pageSequenceMaster.getNextSimplePageMaster(isOddPage,
- isFirstPage, isLastPage, isOnlyPage, isBlank);
+ isFirstPage, isLastPage, isBlank);
}
/**
@@ -278,29 +279,17 @@ public class PageSequence extends AbstractPageSequence {
* @return true if there is a previous item, false if the current one was the first one.
*/
public boolean goToPreviousSimplePageMaster() {
- if (pageSequenceMaster == null) {
- return true;
- } else {
- return pageSequenceMaster.goToPreviousSimplePageMaster();
- }
+ return pageSequenceMaster == null || pageSequenceMaster.goToPreviousSimplePageMaster();
}
/** @return true if the page-sequence has a page-master with page-position="last" */
public boolean hasPagePositionLast() {
- if (pageSequenceMaster == null) {
- return false;
- } else {
- return pageSequenceMaster.hasPagePositionLast();
- }
+ return pageSequenceMaster != null && pageSequenceMaster.hasPagePositionLast();
}
/** @return true if the page-sequence has a page-master with page-position="only" */
public boolean hasPagePositionOnly() {
- if (pageSequenceMaster == null) {
- return false;
- } else {
- return pageSequenceMaster.hasPagePositionOnly();
- }
+ return pageSequenceMaster != null && pageSequenceMaster.hasPagePositionOnly();
}
/**
diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
index b1d8d4055..705b955e9 100644
--- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
+++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
@@ -177,7 +177,6 @@ public class PageSequenceMaster extends FObj {
* @param isOddPage True if the next page number is odd
* @param isFirstPage True if the next page is the first
* @param isLastPage True if the next page is the last
- * @param isOnlyPage True if the next page is the only page
* @param isBlankPage True if the next page is blank
* @return the requested page master
* @throws PageProductionException if there's a problem determining the next page master
@@ -185,7 +184,6 @@ public class PageSequenceMaster extends FObj {
public SimplePageMaster getNextSimplePageMaster(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
- boolean isOnlyPage,
boolean isBlankPage)
throws PageProductionException {
if (currentSubSequence == null) {
@@ -198,7 +196,7 @@ public class PageSequenceMaster extends FObj {
}
}
String pageMasterName = currentSubSequence
- .getNextPageMasterName(isOddPage, isFirstPage, isLastPage, isOnlyPage, isBlankPage);
+ .getNextPageMasterName(isOddPage, isFirstPage, isLastPage, isBlankPage);
boolean canRecover = true;
while (pageMasterName == null) {
SubSequenceSpecifier nextSubSequence = getNextSubSequence();
@@ -213,7 +211,7 @@ public class PageSequenceMaster extends FObj {
currentSubSequence = nextSubSequence;
}
pageMasterName = currentSubSequence
- .getNextPageMasterName(isOddPage, isFirstPage, isLastPage, isOnlyPage, isBlankPage);
+ .getNextPageMasterName(isOddPage, isFirstPage, isLastPage, isBlankPage);
}
SimplePageMaster pageMaster = this.layoutMasterSet
.getSimplePageMaster(pageMasterName);
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
index d1e710c89..9b4c6544f 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java
@@ -117,7 +117,6 @@ public class RepeatablePageMasterAlternatives extends FObj
public String getNextPageMasterName(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
- boolean isOnlyPage,
boolean isBlankPage) {
if (getMaximumRepeats() != INFINITE) {
if (numberConsumed < getMaximumRepeats()) {
@@ -132,7 +131,7 @@ public class RepeatablePageMasterAlternatives extends FObj
for (int i = 0; i < conditionalPageMasterRefs.size(); i++) {
ConditionalPageMasterReference cpmr
= (ConditionalPageMasterReference)conditionalPageMasterRefs.get(i);
- if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isOnlyPage, isBlankPage)) {
+ if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) {
return cpmr.getMasterReference();
}
}
diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
index 60f8e0d6a..9bbe55939 100644
--- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
@@ -90,7 +90,6 @@ public class RepeatablePageMasterReference extends FObj
public String getNextPageMasterName(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
- boolean isOnlyPage,
boolean isEmptyPage) {
if (getMaximumRepeats() != INFINITE) {
if (numberConsumed < getMaximumRepeats()) {
diff --git a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
index 89416a534..be13455d7 100644
--- a/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
+++ b/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
@@ -86,8 +86,7 @@ public class SinglePageMasterReference extends FObj
public String getNextPageMasterName(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
- boolean isOnlyPage,
- boolean isEmptyPage) {
+ boolean isBlankPage) {
if (this.state == FIRST) {
this.state = DONE;
return masterReference;
@@ -101,8 +100,6 @@ public class SinglePageMasterReference extends FObj
this.state = FIRST;
}
-
-
/** {@inheritDoc} */
public boolean goToPrevious() {
if (state == FIRST) {
diff --git a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
index a8eddf5d3..aa2c2bb8b 100644
--- a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
+++ b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java
@@ -31,7 +31,6 @@ public interface SubSequenceSpecifier {
* @param isOddPage True if the next page number is odd
* @param isFirstPage True if the next page is the first
* @param isLastPage True if the next page is the last
- * @param isOnlyPage True if the next page is the only page
* @param isBlankPage True if the next page is blank
* @return the page master name
* @throws PageProductionException if there's a problem determining the next page master
@@ -39,7 +38,6 @@ public interface SubSequenceSpecifier {
String getNextPageMasterName(boolean isOddPage,
boolean isFirstPage,
boolean isLastPage,
- boolean isOnlyPage,
boolean isBlankPage)
throws PageProductionException;
diff --git a/src/java/org/apache/fop/fonts/apps/PFMReader.java b/src/java/org/apache/fop/fonts/apps/PFMReader.java
index 18b40993d..90dd1fd28 100644
--- a/src/java/org/apache/fop/fonts/apps/PFMReader.java
+++ b/src/java/org/apache/fop/fonts/apps/PFMReader.java
@@ -26,12 +26,14 @@ import java.util.Map;
import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.Version;
import org.apache.fop.fonts.type1.PFMFile;
import org.apache.fop.util.CommandLineLogger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
/**
* A tool which reads PFM files from Adobe Type 1 fonts and creates
@@ -256,7 +258,7 @@ public class PFMReader extends AbstractFontReader {
el = doc.createElement("descender");
root.appendChild(el);
- value = new Integer(-pfm.getLowerCaseDescent());
+ value = new Integer(pfm.getLowerCaseDescent());
el.appendChild(doc.createTextNode(value.toString()));
Element bbox = doc.createElement("bbox");
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
index f6b9ac020..409b3908b 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
@@ -983,10 +983,17 @@ public class TTFFile {
/**
* Read the "OS/2" table
*/
- private final void readOS2(FontFileReader in) throws IOException {
+ private void readOS2(FontFileReader in) throws IOException {
// Check if font is embeddable
- if (dirTabs.get("OS/2") != null) {
- seekTab(in, "OS/2", 2 * 2);
+ TTFDirTabEntry os2Entry = (TTFDirTabEntry)dirTabs.get("OS/2");
+ if (os2Entry != null) {
+ seekTab(in, "OS/2", 0);
+ int version = in.readTTFUShort();
+ if (log.isDebugEnabled()) {
+ log.debug("OS/2 table: version=" + version
+ + ", offset=" + os2Entry.getOffset() + ", len=" + os2Entry.getLength());
+ }
+ in.skip(2); //xAvgCharWidth
this.usWeightClass = in.readTTFUShort();
// usWidthClass
@@ -1005,22 +1012,30 @@ public class TTFFile {
in.skip(3 * 2);
int v;
os2Ascender = in.readTTFShort(); //sTypoAscender
- log.debug("sTypoAscender: " + os2Ascender
- + " " + convertTTFUnit2PDFUnit(os2Ascender));
os2Descender = in.readTTFShort(); //sTypoDescender
- log.debug("sTypoDescender: " + os2Descender
- + " " + convertTTFUnit2PDFUnit(os2Descender));
v = in.readTTFShort(); //sTypoLineGap
- log.debug("sTypoLineGap: " + v);
v = in.readTTFUShort(); //usWinAscent
- log.debug("usWinAscent: " + v + " " + convertTTFUnit2PDFUnit(v));
v = in.readTTFUShort(); //usWinDescent
- log.debug("usWinDescent: " + v + " " + convertTTFUnit2PDFUnit(v));
- in.skip(2 * 4);
- this.os2xHeight = in.readTTFShort(); //sxHeight
- log.debug("sxHeight: " + this.os2xHeight);
- this.os2CapHeight = in.readTTFShort(); //sCapHeight
- log.debug("sCapHeight: " + this.os2CapHeight);
+ if (log.isDebugEnabled()) {
+ log.debug("sTypoAscender: " + os2Ascender
+ + " " + convertTTFUnit2PDFUnit(os2Ascender));
+ log.debug("sTypoDescender: " + os2Descender
+ + " " + convertTTFUnit2PDFUnit(os2Descender));
+ log.debug("sTypoLineGap: " + v);
+ log.debug("usWinAscent: " + v + " " + convertTTFUnit2PDFUnit(v));
+ log.debug("usWinDescent: " + v + " " + convertTTFUnit2PDFUnit(v));
+ }
+
+ //version 1 OS/2 table might end here
+ if (os2Entry.getLength() >= 78 + (2 * 4) + (2 * 2)) {
+ in.skip(2 * 4);
+ this.os2xHeight = in.readTTFShort(); //sxHeight
+ this.os2CapHeight = in.readTTFShort(); //sCapHeight
+ if (log.isDebugEnabled()) {
+ log.debug("sxHeight: " + this.os2xHeight);
+ log.debug("sCapHeight: " + this.os2CapHeight);
+ }
+ }
} else {
isEmbeddable = true;
diff --git a/src/java/org/apache/fop/fonts/type1/PFMInputStream.java b/src/java/org/apache/fop/fonts/type1/PFMInputStream.java
index 596bf69bd..f563059c3 100644
--- a/src/java/org/apache/fop/fonts/type1/PFMInputStream.java
+++ b/src/java/org/apache/fop/fonts/type1/PFMInputStream.java
@@ -19,6 +19,7 @@
package org.apache.fop.fonts.type1;
+import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.DataInputStream;
@@ -30,7 +31,7 @@ import java.io.InputStreamReader;
*/
public class PFMInputStream extends java.io.FilterInputStream {
- private DataInputStream datain;
+ private final DataInputStream datain;
/**
* Constructs a PFMInputStream based on an InputStream representing the
@@ -97,11 +98,15 @@ public class PFMInputStream extends java.io.FilterInputStream {
public String readString() throws IOException {
InputStreamReader reader = new InputStreamReader(in, "ISO-8859-1");
StringBuffer buf = new StringBuffer();
+
int ch = reader.read();
- while (ch != 0) {
+ while (ch > 0) {
buf.append((char)ch);
ch = reader.read();
}
+ if (ch == -1) {
+ throw new EOFException("Unexpected end of stream reached");
+ }
return buf.toString();
}
diff --git a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
index 624d99fc0..4d01e20fa 100644
--- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
+++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
@@ -32,19 +32,18 @@ import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
+import org.apache.fop.svg.SimpleSVGUserAgent;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageProcessingHints;
+import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageConverter;
import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.xmlgraphics.util.UnitConv;
-import org.apache.fop.svg.SimpleSVGUserAgent;
-
/**
* This ImageConverter converts SVG images to Java2D.
* <p>
@@ -132,7 +131,7 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter {
/** {@inheritDoc} */
public ImageFlavor getSourceFlavor() {
- return ImageFlavor.XML_DOM;
+ return XMLNamespaceEnabledImageFlavor.SVG_DOM;
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java
index 9203bf7e8..b37ba925b 100644
--- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java
+++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderFactorySVG.java
@@ -20,6 +20,7 @@
package org.apache.fop.image.loader.batik;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageLoaderFactory;
import org.apache.xmlgraphics.image.loader.spi.ImageLoader;
import org.apache.xmlgraphics.util.MimeConstants;
@@ -30,7 +31,7 @@ import org.apache.xmlgraphics.util.MimeConstants;
public class ImageLoaderFactorySVG extends AbstractImageLoaderFactory {
private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
- ImageFlavor.XML_DOM};
+ XMLNamespaceEnabledImageFlavor.SVG_DOM};
private static final String[] MIMES = new String[] {
MimeConstants.MIME_SVG};
diff --git a/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java b/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java
index 483d6c502..c5c113b04 100644
--- a/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java
+++ b/src/java/org/apache/fop/image/loader/batik/ImageLoaderSVG.java
@@ -23,12 +23,12 @@ import java.io.IOException;
import java.util.Map;
import org.apache.batik.dom.svg.SVGDOMImplementation;
-
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageLoader;
import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
import org.apache.xmlgraphics.util.MimeConstants;
@@ -45,7 +45,7 @@ public class ImageLoaderSVG extends AbstractImageLoader {
* @param targetFlavor the target flavor
*/
public ImageLoaderSVG(ImageFlavor targetFlavor) {
- if (!(ImageFlavor.XML_DOM.equals(targetFlavor))) {
+ if (!(XMLNamespaceEnabledImageFlavor.SVG_DOM.equals(targetFlavor))) {
throw new IllegalArgumentException("Unsupported target ImageFlavor: " + targetFlavor);
}
this.targetFlavor = targetFlavor;
diff --git a/src/java/org/apache/fop/layoutmgr/PageProvider.java b/src/java/org/apache/fop/layoutmgr/PageProvider.java
index 55c78ba52..9073c48bb 100644
--- a/src/java/org/apache/fop/layoutmgr/PageProvider.java
+++ b/src/java/org/apache/fop/layoutmgr/PageProvider.java
@@ -234,13 +234,13 @@ public class PageProvider implements Constants {
indexOfCachedLastPage = (isLastPage ? intIndex : -1);
}
if (replace) {
- disardCacheStartingWith(intIndex);
+ discardCacheStartingWith(intIndex);
page = cacheNextPage(index, isBlank, isLastPage);
}
return page;
}
- private void disardCacheStartingWith(int index) {
+ private void discardCacheStartingWith(int index) {
while (index < cachedPages.size()) {
this.cachedPages.remove(cachedPages.size() - 1);
if (!pageSeq.goToPreviousSimplePageMaster()) {
@@ -251,8 +251,9 @@ public class PageProvider implements Constants {
private Page cacheNextPage(int index, boolean isBlank, boolean isLastPage) {
String pageNumberString = pageSeq.makeFormattedPageNumber(index);
+ boolean isFirstPage = (startPageOfPageSequence == index);
SimplePageMaster spm = pageSeq.getNextSimplePageMaster(
- index, (startPageOfPageSequence == index), isLastPage, false, isBlank);
+ index, isFirstPage, isLastPage, isBlank);
Region body = spm.getRegion(FO_REGION_BODY);
if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) {
diff --git a/src/java/org/apache/fop/pdf/AlphaRasterImage.java b/src/java/org/apache/fop/pdf/AlphaRasterImage.java
index ae39cadb7..bd31148be 100644
--- a/src/java/org/apache/fop/pdf/AlphaRasterImage.java
+++ b/src/java/org/apache/fop/pdf/AlphaRasterImage.java
@@ -48,6 +48,9 @@ public class AlphaRasterImage implements PDFImage {
*/
public AlphaRasterImage(String k, Raster alpha) {
this.key = k;
+ //Enable the commented line below if 16-bit alpha channels are desired.
+ //Otherwise, we compress the alpha channel to 8 bit which should be sufficient.
+ //this.bitsPerComponent = alpha.getSampleModel().getSampleSize(0);
this.bitsPerComponent = 8;
this.colorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY);
if (alpha == null) {
@@ -148,6 +151,18 @@ public class AlphaRasterImage implements PDFImage {
alpha.getDataElements(0, y, w, 1, line);
out.write(line);
}
+ } else if (dataType == DataBuffer.TYPE_USHORT) {
+ short[] sline = new short[nbands * w];
+ byte[] line = new byte[nbands * w];
+ for (int y = 0; y < h; y++) {
+ alpha.getDataElements(0, y, w, 1, sline);
+ for (int i = 0; i < w; i++) {
+ //this compresses a 16-bit alpha channel to 8 bits!
+ //we probably don't ever need a 16-bit channel
+ line[i] = (byte)(sline[i] >> 8);
+ }
+ out.write(line);
+ }
} else if (dataType == DataBuffer.TYPE_INT) {
//Is there an better way to get a 8bit raster from a TYPE_INT raster?
int shift = 24;
diff --git a/src/java/org/apache/fop/pdf/PDFFilterList.java b/src/java/org/apache/fop/pdf/PDFFilterList.java
index 5eab5c81a..3025b8788 100644
--- a/src/java/org/apache/fop/pdf/PDFFilterList.java
+++ b/src/java/org/apache/fop/pdf/PDFFilterList.java
@@ -163,6 +163,11 @@ public class PDFFilterList {
* @param type which filter list to modify
*/
public void addDefaultFilters(Map filters, String type) {
+ if (METADATA_FILTER.equals(type)) {
+ //XMP metadata should not be embedded in clear-text
+ addFilter(new NullFilter());
+ return;
+ }
List filterset = null;
if (filters != null) {
filterset = (List)filters.get(type);
@@ -171,10 +176,7 @@ public class PDFFilterList {
}
}
if (filterset == null || filterset.size() == 0) {
- if (METADATA_FILTER.equals(type)) {
- //XMP metadata should not be embedded in clear-text
- addFilter(new NullFilter());
- } else if (JPEG_FILTER.equals(type)) {
+ if (JPEG_FILTER.equals(type)) {
//JPEG is already well compressed
addFilter(new NullFilter());
} else if (TIFF_FILTER.equals(type)) {
diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java
index 65c7bf681..d3762a436 100644
--- a/src/java/org/apache/fop/render/rtf/RTFHandler.java
+++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java
@@ -222,7 +222,7 @@ public class RTFHandler extends FOEventHandler {
PageSequenceMaster master
= pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(reference);
this.pagemaster = master.getNextSimplePageMaster(
- false, false, false, false, false);
+ false, false, false, false);
}
}
diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
index 740ea36e5..09c39be12 100644
--- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
+++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableCell.java
@@ -26,8 +26,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc;
* the FOP project.
*/
-import java.io.Writer;
import java.io.IOException;
+import java.io.Writer;
import java.util.Iterator;
/** A cell in an RTF table, container for paragraphs, lists, etc.
@@ -237,12 +237,12 @@ public class RtfTableCell
// Reach the column index in table context corresponding to the current column cell
// id is the index of the current cell (it begins at 1)
// getColumnIndex() is the index of the current column in table context (it begins at 0)
- // => so we must widthdraw 1 when comparing these two variables.
+ // => so we must withdraw 1 when comparing these two variables.
while ((this.id - 1) != tableColumnsInfo.getColumnIndex()) {
tableColumnsInfo.selectNextColumn();
}
- // We widthdraw one cell because the first cell is already created
+ // We withdraw one cell because the first cell is already created
// (it's the current cell) !
int i = nbMergedCells - 1;
while (i > 0) {
@@ -255,21 +255,18 @@ public class RtfTableCell
final int xPos = offset + iCurrentWidth;
//these lines added by Chris Scott, Westinghouse
- //some attributes need to be writting before opening block
+ //some attributes need to be written before opening block
if (setCenter) {
- writeControlWord("qc");
+ writeControlWord("trqc");
} else if (setRight) {
- writeControlWord("qr");
+ writeControlWord("trqr");
} else {
- writeControlWord("ql");
+ writeControlWord("trql");
}
writeAttributes (attrib, ITableAttributes.CELL_VERT_ALIGN);
writeControlWord("cellx" + xPos);
- //TODO Why is this here, right after an alignment command is written (see above)?
- writeControlWord("ql");
-
return xPos;
}