aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-09-28 11:38:15 +0000
committerJeremias Maerki <jeremias@apache.org>2008-09-28 11:38:15 +0000
commitc785bd37ca4848a0a0022eb9a480560c1a0b7af1 (patch)
tree68aa661b654aa226eef94cecec8f078c955f3958 /src/java/org/apache
parent9ef69cb34586ac529223de0e09834980e72250b6 (diff)
parent6207a76684ee6ee373c893d6d698062647efdf64 (diff)
downloadxmlgraphics-fop-c785bd37ca4848a0a0022eb9a480560c1a0b7af1.tar.gz
xmlgraphics-fop-c785bd37ca4848a0a0022eb9a480560c1a0b7af1.zip
Merge from Trunk revisions 685575-699792.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@699801 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/apps/FOURIResolver.java12
-rw-r--r--src/java/org/apache/fop/events/EventFormatter.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/fo/properties/PropertyCache.java105
-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/BlockStackingLayoutManager.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageProvider.java7
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java3
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java26
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/RowPainter.java105
-rw-r--r--src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java14
-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/AbstractGraphics2DAdapter.java2
-rw-r--r--src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java17
-rw-r--r--src/java/org/apache/fop/render/PrintRenderer.java24
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderer.java9
-rw-r--r--src/java/org/apache/fop/render/java2d/Java2DRenderer.java15
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLGenerator.java9
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLGraphics2D.java4
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java4
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLPageDefinition.java12
-rw-r--r--src/java/org/apache/fop/render/pcl/PCLRenderer.java32
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFBorderPainter.java16
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderer.java1
-rw-r--r--src/java/org/apache/fop/render/ps/PSRenderer.java15
-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
-rw-r--r--src/java/org/apache/fop/render/txt/TXTRenderer.java9
-rw-r--r--src/java/org/apache/fop/svg/PDFGraphics2D.java6
-rw-r--r--src/java/org/apache/fop/svg/PDFTextPainter.java4
-rw-r--r--src/java/org/apache/fop/traits/BlockProps.java36
-rw-r--r--src/java/org/apache/fop/traits/InlineProps.java35
-rw-r--r--src/java/org/apache/fop/traits/LayoutProps.java88
-rw-r--r--src/java/org/apache/fop/util/ColorUtil.java23
-rw-r--r--src/java/org/apache/fop/util/DataURIResolver.java51
-rw-r--r--src/java/org/apache/fop/util/DataURLUtil.java46
-rw-r--r--src/java/org/apache/fop/util/UnitConv.java76
-rw-r--r--src/java/org/apache/fop/util/WriterOutputStream.java54
52 files changed, 546 insertions, 592 deletions
diff --git a/src/java/org/apache/fop/apps/FOURIResolver.java b/src/java/org/apache/fop/apps/FOURIResolver.java
index 1f4425a95..58ae6e8e6 100644
--- a/src/java/org/apache/fop/apps/FOURIResolver.java
+++ b/src/java/org/apache/fop/apps/FOURIResolver.java
@@ -34,14 +34,12 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.xmlgraphics.util.io.Base64EncodeStream;
-
-import org.apache.fop.util.DataURIResolver;
+import org.apache.xmlgraphics.util.uri.CommonURIResolver;
/**
* Provides FOP specific URI resolution. This is the default URIResolver
- * {@link FOUserAgent} will use unless overidden.
+ * {@link FOUserAgent} will use unless overridden.
*
* @see javax.xml.transform.URIResolver
*/
@@ -50,8 +48,8 @@ public class FOURIResolver implements javax.xml.transform.URIResolver {
// log
private Log log = LogFactory.getLog("FOP");
- /** URIResolver for RFC 2397 data URLs */
- private URIResolver dataURIResolver = new DataURIResolver();
+ /** Common URIResolver */
+ private CommonURIResolver commonURIResolver = new CommonURIResolver();
/** A user settable URI Resolver */
private URIResolver uriResolver = null;
@@ -152,7 +150,7 @@ public class FOURIResolver implements javax.xml.transform.URIResolver {
// data URLs can be quite long so evaluate early and don't try to build a File
// (can lead to problems)
- source = dataURIResolver.resolve(href, base);
+ source = commonURIResolver.resolve(href, base);
// Custom uri resolution
if (source == null && uriResolver != null) {
diff --git a/src/java/org/apache/fop/events/EventFormatter.xml b/src/java/org/apache/fop/events/EventFormatter.xml
index 82c976c27..cd956ed6a 100644
--- a/src/java/org/apache/fop/events/EventFormatter.xml
+++ b/src/java/org/apache/fop/events/EventFormatter.xml
@@ -47,7 +47,7 @@ Any reference to it will be considered a reference to the first occurrence in th
<message key="org.apache.fop.fo.FOValidationEventProducer.flowNameNotMapped">The flow-name "{flowName}" on {elementName} could not be mapped to a region-name in the layout-master-set.{{locator}}</message>
<message key="org.apache.fop.fo.FOValidationEventProducer.masterNotFound">The master-reference "{masterReference}" on {elementName} matches no simple-page-master or page-sequence-master.{{locator}}</message>
<message key="org.apache.fop.fo.FOValidationEventProducer.illegalRegionName">The region-name "{regionName}" for {elementName} is not permitted.{{locator}}</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.nonZeroBorderPaddingOnRegion">Border and padding for {elementName} "{regionName}" must be '0' (See 6.4.13 in XSL 1.0).{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.nonZeroBorderPaddingOnRegion">Border and padding for {elementName} "{regionName}" should be '0' (See 6.4.14 in XSL 1.1); non-standard values are allowed if relaxed validation is enabled. {{locator}}</message>
<message key="org.apache.fop.fo.FOValidationEventProducer.columnCountErrorOnRegionBodyOverflowScroll">If overflow property is set to "scroll" on {elementName}, a column-count other than "1" may not be specified.{{locator}}</message>
<message key="org.apache.fop.fo.FOValidationEventProducer.invalidFORoot">First element must be the fo:root formatting object. Found {elementName} instead. Please make sure you're producing a valid XSL-FO document.</message>
<message key="org.apache.fop.fo.FOValidationEventProducer.emptyDocument">Document is empty (something might be wrong with your XSLT stylesheet).</message>
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/fo/properties/PropertyCache.java b/src/java/org/apache/fop/fo/properties/PropertyCache.java
index f834a78ae..d472b574c 100644
--- a/src/java/org/apache/fop/fo/properties/PropertyCache.java
+++ b/src/java/org/apache/fop/fo/properties/PropertyCache.java
@@ -33,9 +33,12 @@ import java.lang.ref.WeakReference;
*/
public final class PropertyCache {
+ private static final int SEGMENT_COUNT = 32; //0x20
+ private static final int INITIAL_BUCKET_COUNT = SEGMENT_COUNT;
+
/** bitmask to apply to the hash to get to the
* corresponding cache segment */
- private static final int SEGMENT_MASK = 0x1F;
+ private static final int SEGMENT_MASK = SEGMENT_COUNT - 1; //0x1F
/**
* Indicates whether the cache should be used at all
* Can be controlled by the system property:
@@ -44,13 +47,13 @@ public final class PropertyCache {
private final boolean useCache;
/** the segments array (length = 32) */
- private CacheSegment[] segments = new CacheSegment[SEGMENT_MASK + 1];
+ private CacheSegment[] segments = new CacheSegment[SEGMENT_COUNT];
/** the table of hash-buckets */
- private CacheEntry[] table = new CacheEntry[8];
+ private CacheEntry[] table = new CacheEntry[INITIAL_BUCKET_COUNT];
private Class runtimeType;
- final boolean[] votesForRehash = new boolean[SEGMENT_MASK + 1];
+ private boolean[] votesForRehash = new boolean[SEGMENT_COUNT];
/* same hash function as used by java.util.HashMap */
private static int hash(Object x) {
@@ -72,53 +75,61 @@ public final class PropertyCache {
}
/* Class modeling a cached entry */
- private final class CacheEntry extends WeakReference {
- volatile CacheEntry nextEntry;
- final int hash;
+ private static class CacheEntry extends WeakReference {
+ private volatile CacheEntry nextEntry;
+ private final int hash;
/* main constructor */
public CacheEntry(Object p, CacheEntry nextEntry, ReferenceQueue refQueue) {
super(p, refQueue);
this.nextEntry = nextEntry;
- this.hash = p.hashCode();
+ this.hash = hash(p);
+ }
+
+ /* main constructor */
+ public CacheEntry(Object p, CacheEntry nextEntry) {
+ super(p);
+ this.nextEntry = nextEntry;
+ this.hash = hash(p);
}
}
/* Wrapper objects to synchronize on */
- private final class CacheSegment {
+ private static class CacheSegment {
private int count = 0;
- private volatile ReferenceQueue staleEntries = new ReferenceQueue();
}
private void cleanSegment(int segmentIndex) {
- CacheEntry entry;
CacheSegment segment = segments[segmentIndex];
- int bucketIndex;
+
int oldCount = segment.count;
- while ((entry = (CacheEntry) segment.staleEntries.poll()) != null) {
- bucketIndex = hash(entry.hash) & (table.length - 1);
- /* remove obsolete entry */
- /* 1. move to the corresponding entry */
+ /* clean all buckets in this segment */
+ for (int bucketIndex = segmentIndex;
+ bucketIndex < table.length;
+ bucketIndex += SEGMENT_COUNT) {
CacheEntry prev = null;
- CacheEntry e = table[bucketIndex];
- while (e != null
- && e.nextEntry != null
- && e.hash != entry.hash) {
- prev = e;
- e = e.nextEntry;
+ CacheEntry entry = table[bucketIndex];
+ if (entry == null) {
+ continue;
}
- if (e != null) {
- /* 2. remove reference from the chain */
- if (prev == null) {
- table[bucketIndex] = e.nextEntry;
+ do {
+ if (entry.get() == null) {
+ if (prev == null) {
+ table[bucketIndex] = entry.nextEntry;
+ } else {
+ prev.nextEntry = entry.nextEntry;
+ }
+ segment.count--;
+ assert segment.count >= 0;
} else {
- prev.nextEntry = e.nextEntry;
+ prev = entry;
}
- segment.count--;
- }
+ entry = entry.nextEntry;
+ } while (entry != null);
}
+
synchronized (votesForRehash) {
if (oldCount > segment.count) {
votesForRehash[segmentIndex] = false;
@@ -129,7 +140,7 @@ public final class PropertyCache {
/* first time for this segment */
votesForRehash[segmentIndex] = true;
int voteCount = 0;
- for (int i = SEGMENT_MASK + 1; --i >= 0; ) {
+ for (int i = SEGMENT_MASK + 1; --i >= 0;) {
if (votesForRehash[i]) {
voteCount++;
}
@@ -156,14 +167,15 @@ public final class PropertyCache {
private void put(Object o) {
int hash = hash(o);
- CacheSegment segment = segments[hash & SEGMENT_MASK];
+ int segmentIndex = hash & SEGMENT_MASK;
+ CacheSegment segment = segments[segmentIndex];
synchronized (segment) {
int index = hash & (table.length - 1);
CacheEntry entry = table[index];
if (entry == null) {
- entry = new CacheEntry(o, null, segment.staleEntries);
+ entry = new CacheEntry(o, null);
table[index] = entry;
segment.count++;
} else {
@@ -171,14 +183,14 @@ public final class PropertyCache {
if (eq(p, o)) {
return;
} else {
- CacheEntry newEntry = new CacheEntry(o, entry, segment.staleEntries);
+ CacheEntry newEntry = new CacheEntry(o, entry);
table[index] = newEntry;
segment.count++;
}
}
if (segment.count > (2 * table.length)) {
- cleanSegment(hash & SEGMENT_MASK);
+ cleanSegment(segmentIndex);
}
}
}
@@ -195,7 +207,7 @@ public final class PropertyCache {
/* try non-synched first */
for (CacheEntry e = entry; e != null; e = e.nextEntry) {
- if (e.hash == o.hashCode()
+ if (e.hash == hash
&& (q = e.get()) != null
&& eq(q, o)) {
return q;
@@ -209,7 +221,7 @@ public final class PropertyCache {
synchronized (segment) {
entry = table[index];
for (CacheEntry e = entry; e != null; e = e.nextEntry) {
- if (e.hash == o.hashCode()
+ if (e.hash == hash
&& (q = e.get()) != null
&& eq(q, o)) {
return q;
@@ -235,7 +247,7 @@ public final class PropertyCache {
/* double the amount of buckets */
int newLength = table.length << 1;
if (newLength > 0) { //no overflow?
- /* reset segmentcounts */
+ /* reset segment counts */
for (int i = segments.length; --i >= 0;) {
segments[i].count = 0;
}
@@ -250,8 +262,7 @@ public final class PropertyCache {
if ((o = c.get()) != null) {
hash = c.hash;
idx = hash & newLength;
- newTable[idx] = new CacheEntry(o, newTable[idx],
- segments[hash & SEGMENT_MASK].staleEntries);
+ newTable[idx] = new CacheEntry(o, newTable[idx]);
segments[hash & SEGMENT_MASK].count++;
}
}
@@ -313,7 +324,7 @@ public final class PropertyCache {
* @param prop the Property instance to check for
* @return the cached instance
*/
- public final Property fetch(Property prop) {
+ public Property fetch(Property prop) {
return (Property) fetch((Object) prop);
}
@@ -326,7 +337,7 @@ public final class PropertyCache {
* @param chy the CommonHyphenation instance to check for
* @return the cached instance
*/
- public final CommonHyphenation fetch(CommonHyphenation chy) {
+ public CommonHyphenation fetch(CommonHyphenation chy) {
return (CommonHyphenation) fetch((Object) chy);
}
@@ -339,7 +350,7 @@ public final class PropertyCache {
* @param cf the CommonFont instance to check for
* @return the cached instance
*/
- public final CommonFont fetch(CommonFont cf) {
+ public CommonFont fetch(CommonFont cf) {
return (CommonFont) fetch((Object) cf);
}
@@ -352,21 +363,21 @@ public final class PropertyCache {
* @param cbpb the CommonBorderPaddingBackground instance to check for
* @return the cached instance
*/
- public final CommonBorderPaddingBackground fetch(CommonBorderPaddingBackground cbpb) {
+ public CommonBorderPaddingBackground fetch(CommonBorderPaddingBackground cbpb) {
return (CommonBorderPaddingBackground) fetch((Object) cbpb);
}
/**
- * Checks if the given {@link CommonBorderPaddingBackground.BorderInfo} is present in the cache -
- * if so, returns a reference to the cached instance.
+ * Checks if the given {@link CommonBorderPaddingBackground.BorderInfo} is present
+ * in the cache - if so, returns a reference to the cached instance.
* Otherwise the given object is added to the cache and returned.
*
* @param bi the BorderInfo instance to check for
* @return the cached instance
*/
- public final CommonBorderPaddingBackground.BorderInfo fetch(CommonBorderPaddingBackground.BorderInfo bi) {
-
+ public CommonBorderPaddingBackground.BorderInfo fetch(
+ CommonBorderPaddingBackground.BorderInfo bi) {
return (CommonBorderPaddingBackground.BorderInfo) fetch((Object) bi);
}
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 b5d7511ca..9ea333af0 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 BatikImageFlavors.SVG_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 8935ac8d4..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[] {
- BatikImageFlavors.SVG_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 c80f38c64..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 (!(targetFlavor.isCompatible(ImageFlavor.XML_DOM))) {
+ 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/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 8837b1a0f..64b8bbc0d 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -406,7 +406,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
if (forcedBreakAfterLast != null) {
forcedBreakAfterLast.clearPendingMarks();
- wrapPositionElement(forcedBreakAfterLast, returnList, false);
+ returnList.add(forcedBreakAfterLast);
}
context.updateKeepWithNextPending(getKeepWithNextStrength());
@@ -1043,7 +1043,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
}
return breakBefore;
}
-
+
/**
* Creates Knuth elements for break-after and adds them to the return list.
* @param returnList return list to add the additional elements to
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/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
index a27fc6516..963b98b37 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
@@ -334,7 +334,8 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
fromIndex = oldListIterator.previousIndex();
} else if (currLM == prevLM) {
bSomethingChanged
- = prevLM.applyChanges(oldList.subList(fromIndex, oldList.size()))
+ = (prevLM != null)
+ && prevLM.applyChanges(oldList.subList(fromIndex, oldList.size()))
|| bSomethingChanged;
} else {
bSomethingChanged
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
index 1e163bef8..f3bbc454a 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
@@ -183,17 +183,23 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
childContext.setAlignmentContext(context.getAlignmentContext());
contentList = clm.getNextKnuthElements(childContext, 0);
int width = clm.getStackingSize();
- Space spacer = null;
- if (fobj.getLeaderPatternWidth().getValue(this) > width) {
- spacer = new Space();
- spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width);
- width = fobj.getLeaderPatternWidth().getValue(this);
- }
- fa.setUnitWidth(width);
- if (spacer != null) {
- fa.addChildArea(spacer);
+ if (width != 0) {
+ Space spacer = null;
+ if (fobj.getLeaderPatternWidth().getValue(this) > width) {
+ spacer = new Space();
+ spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width);
+ width = fobj.getLeaderPatternWidth().getValue(this);
+ }
+ fa.setUnitWidth(width);
+ if (spacer != null) {
+ fa.addChildArea(spacer);
+ }
+ leaderArea = fa;
+ } else {
+ //Content collapsed to nothing, so use a space
+ leaderArea = new Space();
+ leaderArea.setBPD(1);
}
- leaderArea = fa;
}
TraitSetter.setProducerID(leaderArea, fobj.getId());
return leaderArea;
diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
index b2851c39f..7e32fdd5e 100644
--- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
+++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
@@ -27,13 +27,19 @@ import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.area.Block;
+import org.apache.fop.area.Trait;
import org.apache.fop.fo.flow.table.ConditionalBorder;
import org.apache.fop.fo.flow.table.EffRow;
+import org.apache.fop.fo.flow.table.EmptyGridUnit;
import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
+import org.apache.fop.fo.flow.table.Table;
+import org.apache.fop.fo.flow.table.TableColumn;
import org.apache.fop.fo.flow.table.TablePart;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthPossPosIter;
@@ -202,10 +208,16 @@ class RowPainter {
recordRowOffset(currentRow.getIndex(), currentRowOffset);
// Need to compute the actual row height first
+ // and determine border behaviour for empty cells
+ boolean firstCellPart = true;
+ boolean lastCellPart = true;
int actualRowHeight = 0;
for (int i = 0; i < colCount; i++) {
GridUnit currentGU = currentRow.getGridUnit(i);
- if (!currentGU.isEmpty() && currentGU.getColSpanIndex() == 0
+ if (currentGU.isEmpty()) {
+ continue;
+ }
+ if (currentGU.getColSpanIndex() == 0
&& (lastInPart || currentGU.isLastGridUnitRowSpan())
&& firstCellParts[i] != null) {
// TODO
@@ -225,21 +237,53 @@ class RowPainter {
actualRowHeight = Math.max(actualRowHeight, cellOffset + cellHeight
- currentRowOffset);
}
+
+ if (firstCellParts[i] != null && !firstCellParts[i].isFirstPart()) {
+ firstCellPart = false;
+ }
+ if (lastCellParts[i] != null && !lastCellParts[i].isLastPart()) {
+ lastCellPart = false;
+ }
}
// Then add areas for cells finishing on the current row
for (int i = 0; i < colCount; i++) {
GridUnit currentGU = currentRow.getGridUnit(i);
- if (currentGU.isEmpty()) {
- // TODO remove once missing cells are properly implemented (i.e., replaced
- // by an fo:table-cell element containing an empty fo:block)
+ if (currentGU.isEmpty() && !tclm.isSeparateBorderModel()) {
+ int borderBeforeWhich;
+ if (firstCellPart) {
+ if (firstCellOnPage[i]) {
+ borderBeforeWhich = ConditionalBorder.LEADING_TRAILING;
+ } else {
+ borderBeforeWhich = ConditionalBorder.NORMAL;
+ }
+ } else {
+ borderBeforeWhich = ConditionalBorder.REST;
+ }
+ int borderAfterWhich;
+ if (lastCellPart) {
+ if (lastInPart) {
+ borderAfterWhich = ConditionalBorder.LEADING_TRAILING;
+ } else {
+ borderAfterWhich = ConditionalBorder.NORMAL;
+ }
+ } else {
+ borderAfterWhich = ConditionalBorder.REST;
+ }
+ addAreaForEmptyGridUnit((EmptyGridUnit)currentGU,
+ currentRow.getIndex(), i,
+ actualRowHeight,
+ borderBeforeWhich, borderAfterWhich,
+ lastOnPage);
+
firstCellOnPage[i] = false;
} else if (currentGU.getColSpanIndex() == 0
&& (lastInPart || currentGU.isLastGridUnitRowSpan())
&& firstCellParts[i] != null) {
assert firstCellParts[i].pgu == currentGU.getPrimary();
+
int borderBeforeWhich;
- if (firstCellParts[i].start == 0) {
+ if (firstCellParts[i].isFirstPart()) {
if (firstCellOnPage[i]) {
borderBeforeWhich = ConditionalBorder.LEADING_TRAILING;
} else {
@@ -259,6 +303,7 @@ class RowPainter {
} else {
borderAfterWhich = ConditionalBorder.REST;
}
+
addAreasForCell(firstCellParts[i].pgu,
firstCellParts[i].start, lastCellParts[i].end,
actualRowHeight, borderBeforeWhich, borderAfterWhich,
@@ -387,6 +432,56 @@ class RowPainter {
startRowIndex == firstRowOnPageIndex, lastOnPage, this, firstRowHeight);
}
+ private void addAreaForEmptyGridUnit(EmptyGridUnit gu, int rowIndex, int colIndex,
+ int actualRowHeight,
+ int borderBeforeWhich, int borderAfterWhich, boolean lastOnPage) {
+
+ //get effective borders
+ BorderInfo borderBefore = gu.getBorderBefore(borderBeforeWhich);
+ BorderInfo borderAfter = gu.getBorderAfter(borderAfterWhich);
+ BorderInfo borderStart = gu.getBorderStart();
+ BorderInfo borderEnd = gu.getBorderEnd();
+ if (borderBefore.getRetainedWidth() == 0
+ && borderAfter.getRetainedWidth() == 0
+ && borderStart.getRetainedWidth() == 0
+ && borderEnd.getRetainedWidth() == 0) {
+ return; //no borders, no area necessary
+ }
+
+ TableLayoutManager tableLM = tclm.getTableLM();
+ Table table = tableLM.getTable();
+ TableColumn col = tclm.getColumns().getColumn(colIndex + 1);
+
+ //position information
+ boolean firstOnPage = (rowIndex == firstRowOnPageIndex);
+ boolean inFirstColumn = (colIndex == 0);
+ boolean inLastColumn = (colIndex == table.getNumberOfColumns() - 1);
+
+ //determine the block area's size
+ int ipd = col.getColumnWidth().getValue(tableLM);
+ ipd -= (borderStart.getRetainedWidth() + borderEnd.getRetainedWidth()) / 2;
+ int bpd = actualRowHeight;
+ bpd -= (borderBefore.getRetainedWidth() + borderAfter.getRetainedWidth()) / 2;
+
+ //generate the block area
+ Block block = new Block();
+ block.setPositioning(Block.ABSOLUTE);
+ block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
+ block.setIPD(ipd);
+ block.setBPD(bpd);
+ block.setXOffset(tclm.getXOffsetOfGridUnit(colIndex)
+ + (borderStart.getRetainedWidth() / 2));
+ block.setYOffset(getRowOffset(rowIndex)
+ - (borderBefore.getRetainedWidth() / 2));
+ boolean[] outer = new boolean[] {firstOnPage, lastOnPage, inFirstColumn,
+ inLastColumn};
+ TraitSetter.addCollapsingBorders(block,
+ borderBefore,
+ borderAfter,
+ borderStart,
+ borderEnd, outer);
+ tableLM.addChildArea(block);
+ }
/**
* Registers the given area, that will be used to render the part of
diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
index ad8bec715..2ff97a6a7 100644
--- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
@@ -305,13 +305,21 @@ public class TableContentLayoutManager implements PercentBaseContext {
}
/**
- * Retuns the X offset of the given grid unit.
+ * Returns the X offset of the given grid unit.
* @param gu the grid unit
* @return the requested X offset
*/
protected int getXOffsetOfGridUnit(PrimaryGridUnit gu) {
- int col = gu.getColIndex();
- return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM());
+ return getXOffsetOfGridUnit(gu.getColIndex());
+ }
+
+ /**
+ * Returns the X offset of the grid unit in the given column.
+ * @param colIndex the column index (zero-based)
+ * @return the requested X offset
+ */
+ protected int getXOffsetOfGridUnit(int colIndex) {
+ return startXOffset + getTableLM().getColumns().getXOffset(colIndex + 1, getTableLM());
}
/**
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/AbstractGraphics2DAdapter.java b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
index 3f9135d2a..5861fb042 100644
--- a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
@@ -35,7 +35,7 @@ import java.awt.image.WritableRaster;
import java.io.IOException;
import org.apache.fop.render.RendererContext.RendererContextWrapper;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Abstract base class for Graphics2DAdapter implementations.
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
index 4805d4df9..c57a9d566 100644
--- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
@@ -48,6 +48,7 @@ import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.traits.BorderProps;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Abstract base class for renderers like PDF and PostScript where many painting operations
@@ -485,8 +486,8 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
//This is the content-rect
- float width = (float)bv.getIPD() / 1000f;
- float height = (float)bv.getBPD() / 1000f;
+ float width = bv.getIPD() / 1000f;
+ float height = bv.getBPD() / 1000f;
if (bv.getPositioning() == Block.ABSOLUTE
|| bv.getPositioning() == Block.FIXED) {
@@ -515,7 +516,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
saveGraphicsState();
//Viewport position
- concatenateTransformationMatrix(mptToPt(positionTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(positionTransform));
//Background and borders
float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
@@ -525,7 +526,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
//Shift to content rectangle after border painting
AffineTransform contentRectTransform = new AffineTransform();
contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
- concatenateTransformationMatrix(mptToPt(contentRectTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(contentRectTransform));
//Clipping
if (bv.getClip()) {
@@ -535,7 +536,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
saveGraphicsState();
//Set up coordinate system for content rectangle
AffineTransform contentTransform = ctm.toAffineTransform();
- concatenateTransformationMatrix(mptToPt(contentTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(contentTransform));
currentIPPosition = 0;
currentBPPosition = 0;
@@ -581,7 +582,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
currentIPPosition = saveIP;
currentBPPosition = saveBP;
- currentBPPosition += (int)(bv.getAllocBPD());
+ currentBPPosition += (bv.getAllocBPD());
}
}
@@ -599,7 +600,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
if (!at.isIdentity()) {
saveGraphicsState();
- concatenateTransformationMatrix(mptToPt(at));
+ concatenateTransformationMatrix(UnitConv.mptToPt(at));
}
currentIPPosition = 0;
@@ -632,7 +633,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
if (!at.isIdentity()) {
saveGraphicsState();
- concatenateTransformationMatrix(mptToPt(at));
+ concatenateTransformationMatrix(UnitConv.mptToPt(at));
}
currentIPPosition = 0;
diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java
index 44b0a211d..56504ff53 100644
--- a/src/java/org/apache/fop/render/PrintRenderer.java
+++ b/src/java/org/apache/fop/render/PrintRenderer.java
@@ -20,7 +20,6 @@
package org.apache.fop.render;
// FOP
-import java.awt.Color;
import java.awt.geom.Rectangle2D;
import java.util.List;
import java.util.Map;
@@ -113,29 +112,6 @@ public abstract class PrintRenderer extends AbstractRenderer {
}
/**
- * Lightens up a color for groove, ridge, inset and outset border effects.
- * @param col the color to lighten up
- * @param factor factor by which to lighten up (negative values darken the color)
- * @return the modified color
- */
- public static Color lightenColor(Color col, float factor) {
- // TODO: This function converts the color into the sRGB namespace.
- // This should be avoided if possible.
- float[] cols = new float[4];
- cols = col.getRGBComponents(cols);
- if (factor > 0) {
- cols[0] += (1.0 - cols[0]) * factor;
- cols[1] += (1.0 - cols[1]) * factor;
- cols[2] += (1.0 - cols[2]) * factor;
- } else {
- cols[0] -= cols[0] * -factor;
- cols[1] -= cols[1] * -factor;
- cols[2] -= cols[2] * -factor;
- }
- return new Color(cols[0], cols[1], cols[2], cols[3]);
- }
-
- /**
* Creates a RendererContext for an image.
* @param x the x coordinate (in millipoints)
* @param y the y coordinate (in millipoints)
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java
index b77ce9396..d5129f167 100644
--- a/src/java/org/apache/fop/render/afp/AFPRenderer.java
+++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java
@@ -88,6 +88,7 @@ import org.apache.fop.render.afp.modca.AFPConstants;
import org.apache.fop.render.afp.modca.AFPDataStream;
import org.apache.fop.render.afp.modca.ImageObject;
import org.apache.fop.render.afp.modca.PageObject;
+import org.apache.fop.util.ColorUtil;
/**
* This is an implementation of a FOP Renderer that renders areas to AFP.
@@ -850,8 +851,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
{
float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
if (horz) {
- Color uppercol = lightenColor(col, -colFactor);
- Color lowercol = lightenColor(col, colFactor);
+ Color uppercol = ColorUtil.lightenColor(col, -colFactor);
+ Color lowercol = ColorUtil.lightenColor(col, colFactor);
float h3 = h / 3;
float ym1 = y1;
afpDataStream.createLine(
@@ -879,8 +880,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
lowercol
);
} else {
- Color leftcol = lightenColor(col, -colFactor);
- Color rightcol = lightenColor(col, colFactor);
+ Color leftcol = ColorUtil.lightenColor(col, -colFactor);
+ Color rightcol = ColorUtil.lightenColor(col, colFactor);
float w3 = w / 3;
float xm1 = x1 + (w3 / 2);
afpDataStream.createLine(
diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
index 1dd353b3b..e3f79dea2 100644
--- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
+++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
@@ -77,6 +77,7 @@ import org.apache.fop.render.Graphics2DAdapter;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.pdf.CTMHelper;
import org.apache.fop.util.CharUtilities;
+import org.apache.fop.util.ColorUtil;
/**
* The <code>Java2DRenderer</code> class provides the abstract technical
@@ -652,8 +653,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
case Constants.EN_RIDGE:
float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
if (horz) {
- Color uppercol = lightenColor(col, -colFactor);
- Color lowercol = lightenColor(col, colFactor);
+ Color uppercol = ColorUtil.lightenColor(col, -colFactor);
+ Color lowercol = ColorUtil.lightenColor(col, colFactor);
float h3 = h / 3;
float ym1 = y1 + (h3 / 2);
g2d.setStroke(new BasicStroke(h3));
@@ -664,8 +665,8 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
g2d.setColor(lowercol);
g2d.draw(new Line2D.Float(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3));
} else {
- Color leftcol = lightenColor(col, -colFactor);
- Color rightcol = lightenColor(col, colFactor);
+ Color leftcol = ColorUtil.lightenColor(col, -colFactor);
+ Color rightcol = ColorUtil.lightenColor(col, colFactor);
float w3 = w / 3;
float xm1 = x1 + (w3 / 2);
g2d.setStroke(new BasicStroke(w3));
@@ -681,13 +682,13 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
case Constants.EN_OUTSET:
colFactor = (style == EN_OUTSET ? 0.4f : -0.4f);
if (horz) {
- col = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
+ col = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
g2d.setStroke(new BasicStroke(h));
float ym1 = y1 + (h / 2);
g2d.setColor(col);
g2d.draw(new Line2D.Float(x1, ym1, x2, ym1));
} else {
- col = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
+ col = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
float xm1 = x1 + (w / 2);
g2d.setStroke(new BasicStroke(w));
g2d.setColor(col);
@@ -859,7 +860,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
case EN_RIDGE:
float half = area.getRuleThickness() / 2000f;
- state.updateColor(lightenColor(col, 0.6f));
+ state.updateColor(ColorUtil.lightenColor(col, 0.6f));
moveTo(startx, starty);
lineTo(endx, starty);
lineTo(endx, starty + 2 * half);
diff --git a/src/java/org/apache/fop/render/pcl/PCLGenerator.java b/src/java/org/apache/fop/render/pcl/PCLGenerator.java
index 14add2d42..3a451c9ad 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGenerator.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGenerator.java
@@ -45,8 +45,7 @@ import java.util.Locale;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.xmlgraphics.image.GraphicsUtil;
-
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* This class provides methods for generating PCL print files.
@@ -72,7 +71,7 @@ public class PCLGenerator {
private final DecimalFormat df2 = new DecimalFormat("0.##", symbols);
private final DecimalFormat df4 = new DecimalFormat("0.####", symbols);
- private OutputStream out;
+ private final OutputStream out;
private boolean currentSourceTransparency = true;
private boolean currentPatternTransparency = true;
@@ -83,7 +82,7 @@ public class PCLGenerator {
* true: Standard PCL shades are used (poor quality). false: user-defined pattern are used
* to create custom dither patterns for better grayscale quality.
*/
- private boolean usePCLShades = false;
+ private final boolean usePCLShades = false;
/**
* Main constructor.
@@ -412,7 +411,7 @@ public class PCLGenerator {
private static void setValueInMatrix(int[] dn, int half, int part, int idx, int value) {
int xoff = (part & 1) * half;
int yoff = (part & 2) * half * half;
- int matrixIndex = yoff + ((int)(idx / half) * half * 2) + (idx % half) + xoff;
+ int matrixIndex = yoff + ((idx / half) * half * 2) + (idx % half) + xoff;
dn[matrixIndex] = value;
}
diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
index 3eef38b6b..ded87a057 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2D.java
@@ -42,9 +42,9 @@ import java.awt.image.renderable.RenderableImage;
import java.io.IOException;
import java.text.AttributedCharacterIterator;
-import org.apache.fop.util.UnitConv;
import org.apache.xmlgraphics.java2d.AbstractGraphics2D;
import org.apache.xmlgraphics.java2d.GraphicContext;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Graphics2D implementation implementing PCL and HP GL/2.
@@ -55,7 +55,7 @@ public class PCLGraphics2D extends AbstractGraphics2D {
/** The PCL generator */
protected PCLGenerator gen;
- private boolean failOnUnsupportedFeature = true;
+ private final boolean failOnUnsupportedFeature = true;
private boolean clippingDisabled = false;
/**
diff --git a/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java b/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
index 3878a84fb..f8c9682e9 100644
--- a/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
+++ b/src/java/org/apache/fop/render/pcl/PCLGraphics2DAdapter.java
@@ -34,7 +34,7 @@ import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
import org.apache.fop.render.AbstractGraphics2DAdapter;
import org.apache.fop.render.RendererContext;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Graphics2DAdapter implementation for PCL and HP GL/2.
@@ -111,7 +111,7 @@ public class PCLGraphics2DAdapter extends AbstractGraphics2DAdapter {
if (!painted) {
//Fallback solution: Paint to a BufferedImage
- int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
+ int resolution = Math.round(context.getUserAgent().getTargetResolution());
BufferedImage bi = paintToBufferedImage(painter, pclContext,
resolution, !pclContext.isColorCanvas(), false);
diff --git a/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java b/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
index e8c8814ab..e03a86b94 100644
--- a/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
+++ b/src/java/org/apache/fop/render/pcl/PCLPageDefinition.java
@@ -24,7 +24,7 @@ import java.awt.Rectangle;
import java.util.Iterator;
import java.util.List;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* This class represents a page format with PCL-specific properties.
@@ -34,11 +34,11 @@ public class PCLPageDefinition {
private static List pageDefinitions;
private static PCLPageDefinition defaultPageDefinition;
- private String name;
- private int selector;
- private Dimension physicalPageSize;
- private Rectangle logicalPageRect;
- private boolean landscape;
+ private final String name;
+ private final int selector;
+ private final Dimension physicalPageSize;
+ private final Rectangle logicalPageRect;
+ private final boolean landscape;
static {
createPageDefinitions();
diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
index 9b736db43..711b1a8bd 100644
--- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java
+++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java
@@ -96,7 +96,7 @@ import org.apache.fop.render.java2d.InstalledFontCollection;
import org.apache.fop.render.java2d.Java2DRenderer;
import org.apache.fop.render.pcl.extensions.PCLElementMapping;
import org.apache.fop.traits.BorderProps;
-import org.apache.fop.util.UnitConv;
+import org.apache.xmlgraphics.util.UnitConv;
/* Note:
* There are some commonalities with AbstractPathOrientedRenderer but it's not possible
@@ -122,7 +122,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
protected PCLGenerator gen;
private boolean ioTrouble = false;
- private Stack graphicContextStack = new Stack();
+ private final Stack graphicContextStack = new Stack();
private GraphicContext graphicContext = new GraphicContext();
private PCLPageDefinition currentPageDefinition;
@@ -147,7 +147,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
* This can be used to work around problems with Apache Batik, for example, but setting
* this to true will increase memory consumption.
*/
- private boolean useColorCanvas = false;
+ private final boolean useColorCanvas = false;
/**
* Controls whether the generation of PJL commands gets disabled.
@@ -239,7 +239,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
/** @return the target resolution */
protected int getResolution() {
- int resolution = (int)Math.round(userAgent.getTargetResolution());
+ int resolution = Math.round(userAgent.getTargetResolution());
if (resolution <= 300) {
return 300;
} else {
@@ -928,8 +928,8 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
//This is the content-rect
- float width = (float)bv.getIPD() / 1000f;
- float height = (float)bv.getBPD() / 1000f;
+ float width = bv.getIPD() / 1000f;
+ float height = bv.getBPD() / 1000f;
if (bv.getPositioning() == Block.ABSOLUTE
@@ -951,7 +951,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
saveGraphicsState();
//Viewport position
- concatenateTransformationMatrix(mptToPt(positionTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(positionTransform));
//Background and borders
float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
@@ -961,7 +961,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
//Shift to content rectangle after border painting
AffineTransform contentRectTransform = new AffineTransform();
contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
- concatenateTransformationMatrix(mptToPt(contentRectTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(contentRectTransform));
//Clipping
if (bv.getClip()) {
@@ -971,7 +971,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
saveGraphicsState();
//Set up coordinate system for content rectangle
AffineTransform contentTransform = ctm.toAffineTransform();
- concatenateTransformationMatrix(mptToPt(contentTransform));
+ concatenateTransformationMatrix(UnitConv.mptToPt(contentTransform));
currentIPPosition = 0;
currentBPPosition = 0;
@@ -1017,7 +1017,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
currentIPPosition = saveIP;
currentBPPosition = saveBP;
- currentBPPosition += (int)(bv.getAllocBPD());
+ currentBPPosition += (bv.getAllocBPD());
}
//currentFontName = saveFontName;
}
@@ -1041,7 +1041,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
if (!at.isIdentity()) {
saveGraphicsState();
- concatenateTransformationMatrix(mptToPt(at));
+ concatenateTransformationMatrix(UnitConv.mptToPt(at));
}
currentIPPosition = 0;
@@ -1079,7 +1079,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
if (!at.isIdentity()) {
saveGraphicsState();
- concatenateTransformationMatrix(mptToPt(at));
+ concatenateTransformationMatrix(UnitConv.mptToPt(at));
}
currentIPPosition = 0;
@@ -1102,7 +1102,7 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
*/
protected void concatenateTransformationMatrix(AffineTransform at) {
if (!at.isIdentity()) {
- graphicContext.transform(ptToMpt(at));
+ graphicContext.transform(UnitConv.ptToMpt(at));
changePrintDirection();
}
}
@@ -1416,13 +1416,13 @@ public class PCLRenderer extends PrintRenderer implements PCLConstants {
borderRect.width,
borderRect.height);
final Rectangle paintRect = new Rectangle(
- (int)Math.round(borderRect.x * 1000f),
- (int)Math.round(borderRect.y * 1000f),
+ Math.round(borderRect.x * 1000f),
+ Math.round(borderRect.y * 1000f),
(int)Math.floor(borderRect.width * 1000f) + 1,
(int)Math.floor(borderRect.height * 1000f) + 1);
//Add one pixel wide safety margin around the paint area
int pixelWidth = (int)Math.round(UnitConv.in2mpt(1) / userAgent.getTargetResolution());
- final int xoffset = (int)Math.round(-effBorderRect.x * 1000f) + pixelWidth;
+ final int xoffset = Math.round(-effBorderRect.x * 1000f) + pixelWidth;
final int yoffset = pixelWidth;
paintRect.x += xoffset;
paintRect.y += yoffset;
diff --git a/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java b/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java
index 309307a51..019ec82a0 100644
--- a/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java
+++ b/src/java/org/apache/fop/render/pdf/PDFBorderPainter.java
@@ -27,9 +27,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.Constants;
-import org.apache.fop.render.PrintRenderer;
import org.apache.fop.render.intermediate.BorderPainter;
import org.apache.fop.traits.RuleStyle;
+import org.apache.fop.util.ColorUtil;
/**
* PDF-specific implementation of the {@code BorderPainter}.
@@ -150,8 +150,8 @@ public class PDFBorderPainter extends BorderPainter {
float colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
generator.add("[] 0 d ");
if (horz) {
- Color uppercol = PrintRenderer.lightenColor(col, -colFactor);
- Color lowercol = PrintRenderer.lightenColor(col, colFactor);
+ Color uppercol = ColorUtil.lightenColor(col, -colFactor);
+ Color lowercol = ColorUtil.lightenColor(col, colFactor);
float h3 = h / 3;
generator.add(format(h3) + " w\n");
float ym1 = y1 + (h3 / 2);
@@ -165,8 +165,8 @@ public class PDFBorderPainter extends BorderPainter {
generator.add(format(x1) + " " + format(ym1 + h3 + h3) + " m "
+ format(x2) + " " + format(ym1 + h3 + h3) + " l S\n");
} else {
- Color leftcol = PrintRenderer.lightenColor(col, -colFactor);
- Color rightcol = PrintRenderer.lightenColor(col, colFactor);
+ Color leftcol = ColorUtil.lightenColor(col, -colFactor);
+ Color rightcol = ColorUtil.lightenColor(col, colFactor);
float w3 = w / 3;
generator.add(format(w3) + " w\n");
float xm1 = x1 + (w3 / 2);
@@ -189,14 +189,14 @@ public class PDFBorderPainter extends BorderPainter {
generator.add("[] 0 d ");
Color c = col;
if (horz) {
- c = PrintRenderer.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
+ c = ColorUtil.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
generator.add(format(h) + " w\n");
float ym1 = y1 + (h / 2);
generator.setColor(c, false);
generator.add(format(x1) + " " + format(ym1) + " m "
+ format(x2) + " " + format(ym1) + " l S\n");
} else {
- c = PrintRenderer.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
+ c = ColorUtil.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
generator.add(format(w) + " w\n");
float xm1 = x1 + (w / 2);
generator.setColor(c, false);
@@ -254,7 +254,7 @@ public class PDFBorderPainter extends BorderPainter {
break;
case Constants.EN_GROOVE:
case Constants.EN_RIDGE:
- generator.setColor(PrintRenderer.lightenColor(color, 0.6f), true);
+ generator.setColor(ColorUtil.lightenColor(color, 0.6f), true);
generator.add(format(start.x) + " " + format(starty) + " m\n");
generator.add(format(end.x) + " " + format(starty) + " l\n");
generator.add(format(end.x) + " " + format(starty + 2 * half) + " l\n");
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index ec41a313d..730acb540 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -93,6 +93,7 @@ import org.apache.fop.render.Graphics2DAdapter;
import org.apache.fop.render.RendererContext;
import org.apache.fop.traits.RuleStyle;
import org.apache.fop.util.CharUtilities;
+import org.apache.fop.util.ColorUtil;
/**
* Renderer that renders areas to PDF.
diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java
index 9f8cdc771..4785ea14f 100644
--- a/src/java/org/apache/fop/render/ps/PSRenderer.java
+++ b/src/java/org/apache/fop/render/ps/PSRenderer.java
@@ -106,6 +106,7 @@ import org.apache.fop.render.ps.extensions.PSExtensionAttachment;
import org.apache.fop.render.ps.extensions.PSSetPageDevice;
import org.apache.fop.render.ps.extensions.PSSetupCode;
import org.apache.fop.util.CharUtilities;
+import org.apache.fop.util.ColorUtil;
/**
* Renderer that renders to PostScript.
@@ -839,8 +840,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer
float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
gen.useDash(null);
if (horz) {
- Color uppercol = lightenColor(col, -colFactor);
- Color lowercol = lightenColor(col, colFactor);
+ Color uppercol = ColorUtil.lightenColor(col, -colFactor);
+ Color lowercol = ColorUtil.lightenColor(col, colFactor);
float h3 = h / 3;
gen.useLineWidth(h3);
float ym1 = y1 + (h3 / 2);
@@ -851,8 +852,8 @@ public class PSRenderer extends AbstractPathOrientedRenderer
gen.useColor(lowercol);
drawLine(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3);
} else {
- Color leftcol = lightenColor(col, -colFactor);
- Color rightcol = lightenColor(col, colFactor);
+ Color leftcol = ColorUtil.lightenColor(col, -colFactor);
+ Color rightcol = ColorUtil.lightenColor(col, colFactor);
float w3 = w / 3;
gen.useLineWidth(w3);
float xm1 = x1 + (w3 / 2);
@@ -869,13 +870,13 @@ public class PSRenderer extends AbstractPathOrientedRenderer
colFactor = (style == EN_OUTSET ? 0.4f : -0.4f);
gen.useDash(null);
if (horz) {
- Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
+ Color c = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
gen.useLineWidth(h);
float ym1 = y1 + (h / 2);
gen.useColor(c);
drawLine(x1, ym1, x2, ym1);
} else {
- Color c = lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
+ Color c = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
gen.useLineWidth(w);
float xm1 = x1 + (w / 2);
gen.useColor(c);
@@ -1570,7 +1571,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer
case EN_RIDGE:
float half = area.getRuleThickness() / 2000f;
- gen.useColor(lightenColor(col, 0.6f));
+ gen.useColor(ColorUtil.lightenColor(col, 0.6f));
moveTo(startx, starty);
lineTo(endx, starty);
lineTo(endx, starty + 2 * half);
diff --git a/src/java/org/apache/fop/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;
}
diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java
index 52c6912d4..575f1232f 100644
--- a/src/java/org/apache/fop/render/txt/TXTRenderer.java
+++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java
@@ -37,6 +37,7 @@ import org.apache.fop.area.inline.TextArea;
import org.apache.fop.render.AbstractPathOrientedRenderer;
import org.apache.fop.render.txt.border.AbstractBorderElement;
import org.apache.fop.render.txt.border.BorderManager;
+import org.apache.xmlgraphics.util.UnitConv;
/**
* Renderer that renders areas to plain text.
@@ -85,10 +86,10 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
* Every line except the last line on a page (which will end with
* pageEnding) will be terminated with this string.
*/
- private String lineEnding = "\r\n";
+ private final String lineEnding = "\r\n";
/** Every page except the last one will end with this string. */
- private String pageEnding = "\f";
+ private final String pageEnding = "\f";
/** Equals true, if current page is first. */
private boolean firstPage = false;
@@ -100,7 +101,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
private char fillChar;
/** Saves current coordinate transformation. */
- private TXTState currentState = new TXTState();
+ private final TXTState currentState = new TXTState();
private String encoding;
@@ -570,7 +571,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer {
/** {@inheritDoc} */
protected void concatenateTransformationMatrix(AffineTransform at) {
- currentState.push(new CTM(ptToMpt(at)));
+ currentState.push(new CTM(UnitConv.ptToMpt(at)));
}
}
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java
index 0b2f0a45f..08655fd47 100644
--- a/src/java/org/apache/fop/svg/PDFGraphics2D.java
+++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java
@@ -285,7 +285,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
/**
* Get the string containing all the commands written into this
- * Grpahics.
+ * Graphics.
* @return the string containing the PDF markup
*/
public String getString() {
@@ -294,7 +294,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
/**
* Get the string buffer from the currentStream, containing all
- * the commands written into this Grpahics so far.
+ * the commands written into this Graphics so far.
* @return the StringBuffer containing the PDF markup
*/
public StringBuffer getBuffer() {
@@ -876,7 +876,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
if (paint instanceof RadialGradientPaint) {
RadialGradientPaint rgp = (RadialGradientPaint)paint;
- // There is essentially no way to support repeate
+ // There is essentially no way to support repeats
// in PDF for radial gradients (the one option would
// be to 'grow' the outer circle until it fully covered
// the bounds and then grow the stops accordingly, the
diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java
index d8123c4fb..06fea54cc 100644
--- a/src/java/org/apache/fop/svg/PDFTextPainter.java
+++ b/src/java/org/apache/fop/svg/PDFTextPainter.java
@@ -147,7 +147,9 @@ public class PDFTextPainter extends StrokingTextPainter {
textUtil.beginTextObject();
textUtil.setFonts(fonts);
- textUtil.setTextRenderingMode(tpi.fillPaint != null, tpi.strokePaint != null, false);
+ boolean stroke = (tpi.strokePaint != null)
+ && (tpi.strokeStroke != null);
+ textUtil.setTextRenderingMode(tpi.fillPaint != null, stroke, false);
AffineTransform localTransform = new AffineTransform();
Point2D prevPos = null;
diff --git a/src/java/org/apache/fop/traits/BlockProps.java b/src/java/org/apache/fop/traits/BlockProps.java
deleted file mode 100644
index 370a97982..000000000
--- a/src/java/org/apache/fop/traits/BlockProps.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.traits;
-
-import org.apache.fop.datatypes.Length;
-
-/**
- * Store all block-level layout properties on an FO.
- * Public "structure" allows direct member access.
- */
-public class BlockProps {
-
- public Length firstIndent; // text-indent
- public int lastIndent; // last-line-indent
- public int textAlign;
- public int textAlignLast;
- public int lineStackType; // line-stacking-strategy (enum)
-
-}
diff --git a/src/java/org/apache/fop/traits/InlineProps.java b/src/java/org/apache/fop/traits/InlineProps.java
deleted file mode 100644
index 06ca2553d..000000000
--- a/src/java/org/apache/fop/traits/InlineProps.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.traits;
-
-/**
- * Store all inline "margin" related properties
- * Public "structure" allows direct member access.
- */
-public class InlineProps {
-
- public int marginTop;
- public int marginBottom;
- public int marginLeft;
- public int marginRight;
- public SpaceVal spaceStart;
- public SpaceVal spaceEnd;
-
-}
diff --git a/src/java/org/apache/fop/traits/LayoutProps.java b/src/java/org/apache/fop/traits/LayoutProps.java
deleted file mode 100644
index eff218b37..000000000
--- a/src/java/org/apache/fop/traits/LayoutProps.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.traits;
-
-import org.apache.fop.datatypes.KeepValue;
-import org.apache.fop.fo.Constants;
-
-/**
- * Store properties affecting layout: break-before, break-after, keeps, span.
- * for a block level FO.
- * Public "structure" allows direct member access.
- */
-public class LayoutProps {
-
- public int breakBefore; // enum constant BreakBefore.xxx
- public int breakAfter; // enum constant BreakAfter.xxx
- public KeepValue keepWithPrevious; /*LF*/
- public KeepValue keepWithNext; /*LF*/
- public KeepValue keepTogether; /*LF*/
- public int orphans; /*LF*/
- public int widows; /*LF*/
- public int blockProgressionUnit; /*LF*/
- public int lineStackingStrategy; /*LF*/
- public boolean bIsSpan;
- public SpaceVal spaceBefore;
- public SpaceVal spaceAfter;
-
- private static final int[] BREAK_PRIORITIES =
- new int[]{ Constants.EN_AUTO, Constants.EN_COLUMN, Constants.EN_PAGE };
-
-
- public LayoutProps() {
- breakBefore = breakAfter = Constants.EN_AUTO;
- bIsSpan = false;
- }
-
- // public static int higherBreak(int brkParent, int brkChild) {
- // if (brkParent == brkChild) return brkChild;
- // for (int i=0; i < s_breakPriorities.length; i++) {
- // int bp = s_breakPriorities[i];
- // if (bp == brkParent) return brkChild;
- // else if (bp == brkChild) return brkParent;
- // }
- // return brkChild;
- // }
-
- public void combineWithParent(LayoutProps parentLP) {
- if (parentLP.breakBefore != breakBefore) {
- for (int i = 0; i < BREAK_PRIORITIES.length; i++) {
- int bp = BREAK_PRIORITIES[i];
- if (bp == breakBefore) {
- breakBefore = parentLP.breakBefore;
- break;
- } else if (bp == parentLP.breakBefore) {
- break;
- }
- }
- }
- // Parent span always overrides child span
- bIsSpan = parentLP.bIsSpan;
- }
-
- public String toString() {
- return "LayoutProps:\n" +
- "breakBefore = " + breakBefore + "; breakAfter = " + breakAfter + "\n" +
- "spaceBefore = " + ((spaceBefore != null) ? spaceBefore.toString() : "null") + "\n" +
- "spaceAfter = " + ((spaceAfter != null) ? spaceAfter.toString() : "null") + "\n" +
- "bIsSpan = " + bIsSpan + "\n";
- }
-}
-
diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java
index b85b0c017..9534bfba3 100644
--- a/src/java/org/apache/fop/util/ColorUtil.java
+++ b/src/java/org/apache/fop/util/ColorUtil.java
@@ -658,4 +658,27 @@ public final class ColorUtil {
colorMap.put("transparent", new Color(0, 0, 0, 0));
}
+ /**
+ * Lightens up a color for groove, ridge, inset and outset border effects.
+ * @param col the color to lighten up
+ * @param factor factor by which to lighten up (negative values darken the color)
+ * @return the modified color
+ */
+ public static Color lightenColor(Color col, float factor) {
+ // TODO: This function converts the color into the sRGB namespace.
+ // This should be avoided if possible.
+ float[] cols = new float[4];
+ cols = col.getRGBComponents(cols);
+ if (factor > 0) {
+ cols[0] += (1.0 - cols[0]) * factor;
+ cols[1] += (1.0 - cols[1]) * factor;
+ cols[2] += (1.0 - cols[2]) * factor;
+ } else {
+ cols[0] -= cols[0] * -factor;
+ cols[1] -= cols[1] * -factor;
+ cols[2] -= cols[2] * -factor;
+ }
+ return new Color(cols[0], cols[1], cols[2], cols[3]);
+ }
+
}
diff --git a/src/java/org/apache/fop/util/DataURIResolver.java b/src/java/org/apache/fop/util/DataURIResolver.java
index 89db6dc9d..99a8318c8 100644
--- a/src/java/org/apache/fop/util/DataURIResolver.java
+++ b/src/java/org/apache/fop/util/DataURIResolver.java
@@ -19,60 +19,25 @@
package org.apache.fop.util;
-import java.io.ByteArrayInputStream;
-
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
-import javax.xml.transform.stream.StreamSource;
-
-// base64 support for "data" urls
-import org.apache.xmlgraphics.util.io.Base64DecodeStream;
/**
- * Resolves data URLs (described in RFC 2397) returning its data as a StreamSource.
- *
- * @see javax.xml.transform.URIResolver
- * @see <a href="http://www.ietf.org/rfc/rfc2397">RFC 2397</a>
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURIResolver
*/
public class DataURIResolver implements URIResolver {
- /**
- * {@inheritDoc}
- */
- public Source resolve(String href, String base) throws TransformerException {
- if (href.startsWith("data:")) {
- return parseDataURI(href);
- } else {
- return null;
- }
- }
+ private final URIResolver newResolver = new org.apache.xmlgraphics.util.uri.DataURIResolver();
/**
- * Parses inline data URIs as generated by MS Word's XML export and FO
- * stylesheet.
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2397">RFC 2397</a>
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURIResolver#resolve(String,
+ * String)
*/
- private Source parseDataURI(String href) {
- int commaPos = href.indexOf(',');
- // header is of the form data:[<mediatype>][;base64]
- String header = href.substring(0, commaPos);
- String data = href.substring(commaPos + 1);
- if (header.endsWith(";base64")) {
- byte[] bytes = data.getBytes();
- ByteArrayInputStream encodedStream = new ByteArrayInputStream(bytes);
- Base64DecodeStream decodedStream = new Base64DecodeStream(
- encodedStream);
- return new StreamSource(decodedStream);
- } else {
- // Note that this is not quite the full story here. But since we are
- // only interested
- // in base64-encoded binary data, the next line will probably never
- // be called.
- //TODO Handle un-escaping of special URL chars like %20
- return new StreamSource(new java.io.StringReader(data));
- }
+ public Source resolve(String href, String base) throws TransformerException {
+ return newResolver.resolve(href, base);
}
}
diff --git a/src/java/org/apache/fop/util/DataURLUtil.java b/src/java/org/apache/fop/util/DataURLUtil.java
index d8f7f17bf..8568df274 100644
--- a/src/java/org/apache/fop/util/DataURLUtil.java
+++ b/src/java/org/apache/fop/util/DataURLUtil.java
@@ -21,47 +21,33 @@ package org.apache.fop.util;
import java.io.IOException;
import java.io.InputStream;
-import java.io.StringWriter;
import java.io.Writer;
-import org.apache.commons.io.IOUtils;
-import org.apache.xmlgraphics.util.io.Base64EncodeStream;
-
/**
- * Utility classes for generating RFC 2397 data URLs.
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURLUtil
*/
public class DataURLUtil {
/**
- * Creates a new data URL and returns it as a String.
- * @param in the InputStream to read the data from
- * @param mediatype the MIME type of the content, or null
- * @return the newly created data URL
- * @throws IOException if an I/O error occurs
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURLUtil#createDataURL(InputStream,
+ * String)
*/
- public static String createDataURL(InputStream in, String mediatype) throws IOException {
- StringWriter writer = new StringWriter();
- writeDataURL(in, mediatype, writer);
- return writer.toString();
+ public static String createDataURL(InputStream in, String mediatype)
+ throws IOException {
+ return org.apache.xmlgraphics.util.uri.DataURLUtil.createDataURL(in,
+ mediatype);
}
/**
- * Generates a data URL and writes it to a Writer.
- * @param in the InputStream to read the data from
- * @param mediatype the MIME type of the content, or null
- * @param writer the Writer to write to
- * @throws IOException if an I/O error occurs
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURLUtil#writeDataURL(InputStream,
+ * String, Writer)
*/
- public static void writeDataURL(InputStream in, String mediatype, Writer writer)
- throws IOException {
- writer.write("data:");
- if (mediatype != null) {
- writer.write(mediatype);
- }
- writer.write(";base64,");
- Base64EncodeStream out = new Base64EncodeStream(
- new WriterOutputStream(writer, "US-ASCII"));
- IOUtils.copy(in, out);
- out.flush();
+ public static void writeDataURL(InputStream in, String mediatype,
+ Writer writer) throws IOException {
+ org.apache.xmlgraphics.util.uri.DataURLUtil.writeDataURL(in, mediatype,
+ writer);
}
}
diff --git a/src/java/org/apache/fop/util/UnitConv.java b/src/java/org/apache/fop/util/UnitConv.java
index 8bf7274eb..cf599712f 100644
--- a/src/java/org/apache/fop/util/UnitConv.java
+++ b/src/java/org/apache/fop/util/UnitConv.java
@@ -15,94 +15,114 @@
* limitations under the License.
*/
-/* $Id$ */
+/* $Id: $ */
package org.apache.fop.util;
+import java.awt.geom.AffineTransform;
+
/**
* Utility class for unit conversions.
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv instead.
*/
public final class UnitConv {
- /** conversion factory from millimeters to inches. */
- public static final float IN2MM = 25.4f;
+ /**
+ * conversion factory from millimeters to inches.
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.IN2MM instead.
+ */
+ public static final float IN2MM = org.apache.xmlgraphics.util.UnitConv.IN2MM;
- /** conversion factory from centimeters to inches. */
- public static final float IN2CM = 2.54f;
+ /**
+ * conversion factory from centimeters to inches.
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.IN2CM instead.
+ */
+ public static final float IN2CM = org.apache.xmlgraphics.util.UnitConv.IN2CM;
- /** conversion factory from inches to points. */
- public static final int IN2PT = 72;
+ /**
+ * conversion factory from inches to points.
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.IN2PT instead.
+ */
+ public static final int IN2PT = org.apache.xmlgraphics.util.UnitConv.IN2PT;
/**
* Converts millimeters (mm) to points (pt)
* @param mm the value in mm
* @return the value in pt
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mm2pt(mm) instead.
*/
public static double mm2pt(double mm) {
- return mm * IN2PT / IN2MM;
+ return org.apache.xmlgraphics.util.UnitConv.mm2pt(mm);
}
/**
* Converts millimeters (mm) to millipoints (mpt)
* @param mm the value in mm
* @return the value in mpt
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mm2mpt(mm) instead.
*/
public static double mm2mpt(double mm) {
- return mm * 1000 * IN2PT / IN2MM;
+ return org.apache.xmlgraphics.util.UnitConv.mm2mpt(mm);
}
/**
* Converts points (pt) to millimeters (mm)
* @param pt the value in pt
* @return the value in mm
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.pt2mm(pt) instead.
*/
public static double pt2mm(double pt) {
- return pt * IN2MM / IN2PT;
+ return org.apache.xmlgraphics.util.UnitConv.pt2mm(pt);
}
/**
* Converts millimeters (mm) to inches (in)
* @param mm the value in mm
* @return the value in inches
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.pt2mm(pt) instead.
*/
public static double mm2in(double mm) {
- return mm / IN2MM;
+ return org.apache.xmlgraphics.util.UnitConv.mm2in(mm);
}
/**
* Converts inches (in) to millimeters (mm)
* @param in the value in inches
* @return the value in mm
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.in2mm(in) instead.
*/
public static double in2mm(double in) {
- return in * IN2MM;
+ return org.apache.xmlgraphics.util.UnitConv.in2mm(in);
}
/**
* Converts inches (in) to millipoints (mpt)
* @param in the value in inches
* @return the value in mpt
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.in2mpt(in) instead.
*/
public static double in2mpt(double in) {
- return in * IN2PT * 1000;
+ return org.apache.xmlgraphics.util.UnitConv.in2mpt(in);
}
/**
* Converts inches (in) to points (pt)
* @param in the value in inches
* @return the value in pt
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.in2pt(in) instead.
*/
public static double in2pt(double in) {
- return in * IN2PT;
+ return org.apache.xmlgraphics.util.UnitConv.in2pt(in);
}
/**
* Converts millipoints (mpt) to inches (in)
* @param mpt the value in mpt
* @return the value in inches
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mpt2in(mpt) instead.
*/
public static double mpt2in(double mpt) {
- return mpt / IN2PT / 1000;
+ return org.apache.xmlgraphics.util.UnitConv.mpt2in(mpt);
}
/**
@@ -110,9 +130,10 @@ public final class UnitConv {
* @param mm the value in mm
* @param resolution the resolution in dpi (dots per inch)
* @return the value in pixels
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mm2px(mm, resolution) instead.
*/
public static double mm2px(double mm, int resolution) {
- return mm2in(mm) * resolution;
+ return org.apache.xmlgraphics.util.UnitConv.mm2px(mm, resolution);
}
/**
@@ -120,9 +141,30 @@ public final class UnitConv {
* @param mpt the value in mpt
* @param resolution the resolution in dpi (dots per inch)
* @return the value in pixels
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mpt2px(mpt, resolution) instead.
*/
public static double mpt2px(double mpt, int resolution) {
- return mpt2in(mpt) * resolution;
+ return org.apache.xmlgraphics.util.UnitConv.mpt2px(mpt, resolution);
+ }
+
+ /**
+ * Converts a millipoint-based transformation matrix to points.
+ * @param at a millipoint-based transformation matrix
+ * @return a point-based transformation matrix
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mptToPt(at) instead.
+ */
+ public static AffineTransform mptToPt(AffineTransform at) {
+ return org.apache.xmlgraphics.util.UnitConv.mptToPt(at);
+ }
+
+ /**
+ * Converts a point-based transformation matrix to millipoints.
+ * @param at a point-based transformation matrix
+ * @return a millipoint-based transformation matrix
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.ptToMpt(at) instead.
+ */
+ public static AffineTransform ptToMpt(AffineTransform at) {
+ return org.apache.xmlgraphics.util.UnitConv.ptToMpt(at);
}
}
diff --git a/src/java/org/apache/fop/util/WriterOutputStream.java b/src/java/org/apache/fop/util/WriterOutputStream.java
index fb6875498..e08109ab0 100644
--- a/src/java/org/apache/fop/util/WriterOutputStream.java
+++ b/src/java/org/apache/fop/util/WriterOutputStream.java
@@ -24,68 +24,72 @@ import java.io.OutputStream;
import java.io.Writer;
/**
- * An OutputStream wrapper for a Writer.
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream
*/
public class WriterOutputStream extends OutputStream {
- private Writer writer;
- private String encoding;
+ private final org.apache.xmlgraphics.util.WriterOutputStream writerOutputStream;
/**
- * Creates a new WriterOutputStream.
- * @param writer the Writer to write to
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#WriterOutputStream(Writer)
+ * String)
*/
public WriterOutputStream(Writer writer) {
- this(writer, null);
+ writerOutputStream = new org.apache.xmlgraphics.util.WriterOutputStream(
+ writer);
}
/**
- * Creates a new WriterOutputStream.
- * @param writer the Writer to write to
- * @param encoding the encoding to use, or null if the default encoding should be used
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#WriterOutputStream(Writer,
+ * String) String)
*/
public WriterOutputStream(Writer writer, String encoding) {
- this.writer = writer;
- this.encoding = encoding;
+ writerOutputStream = new org.apache.xmlgraphics.util.WriterOutputStream(
+ writer, encoding);
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#close()
*/
public void close() throws IOException {
- writer.close();
+ writerOutputStream.close();
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#flush()
*/
public void flush() throws IOException {
- writer.flush();
+ writerOutputStream.flush();
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#write(byte[], int,
+ * int)
*/
public void write(byte[] buf, int offset, int length) throws IOException {
- if (encoding != null) {
- writer.write(new String(buf, offset, length, encoding));
- } else {
- writer.write(new String(buf, offset, length));
- }
+ writerOutputStream.write(buf, offset, length);
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#write(byte[])
*/
public void write(byte[] buf) throws IOException {
- write(buf, 0, buf.length);
+ writerOutputStream.write(buf);
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#write(int)
*/
public void write(int b) throws IOException {
- write(new byte[] {(byte)b});
+ writerOutputStream.write(b);
}
}