Author: vhennebert
Date: Wed Jul 22 15:48:16 2009
New Revision: 796775
URL: http://svn.apache.org/viewvc?rev=796775&view=rev
Log:
Merged changes from Trunk
Added:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/render/DummyPercentBaseContext.java
- copied unchanged from r796742,
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/DummyPercentBaseContext.java
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/ (props changed)
xmlgraphics/fop/branches/Temp_ChangingIPDHack/checkstyle-4.0.xml (props
changed)
xmlgraphics/fop/branches/Temp_ChangingIPDHack/lib/xmlgraphics-commons-1.4svn.jar
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/documentation/content/xdocs/resources.xml
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/META-INF/services/org.apache.fop.render.intermediate.IFDocumentHandler
(props changed)
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/AFPResourceManager.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/DataStream.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPFontReader.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSet.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/OutlineFont.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/RasterFont.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/MapCodedFont.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/TagLogicalElement.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/FObj.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/flow/table/TablePart.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/KnuthSequence.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/PageBreaker.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/render/afp/AFPRenderer.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/render/rtf/FOPRtfAttributes.java
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/sandbox/org/apache/fop/render/svg/AbstractSVGDocumentHandler.java
(props changed)
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/sandbox/org/apache/fop/render/svg/SVGDocumentHandler.java
(props changed)
xmlgraphics/fop/branches/Temp_ChangingIPDHack/status.xml
Propchange: xmlgraphics/fop/branches/Temp_ChangingIPDHack/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 22 15:48:16 2009
@@ -1,3 +1,4 @@
/xmlgraphics/fop/branches/Temp_AFPGOCAResources:630874-721418
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign:603620-746655
/xmlgraphics/fop/branches/fop-0_95:684572,688085,688696
+/xmlgraphics/fop/trunk:784730-796742
Propchange: xmlgraphics/fop/branches/Temp_ChangingIPDHack/checkstyle-4.0.xml
('svn:executable' removed)
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/lib/xmlgraphics-commons-1.4svn.jar
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/lib/xmlgraphics-commons-1.4svn.jar?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
Binary files - no diff available.
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/documentation/content/xdocs/resources.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/documentation/content/xdocs/resources.xml?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/documentation/content/xdocs/resources.xml
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/documentation/content/xdocs/resources.xml
Wed Jul 22 15:48:16 2009
@@ -247,6 +247,7 @@
[software] <jump
href="http://www.ahmadsoft.org/fopbridge.html">FOP Bridge</jump> is an Eclipse
plug-in
that allows to convert FO documents using Apache FOP directly
inside the Eclipse workbench (LGPL).
</li>
+ <li>[software] <jump
href="http://maven.apache.org/doxia/doxia/doxia-modules/doxia-module-fo/">Maven
Doxia FO Module</jump>. Doxia is a content generation framework which aims to
provide its users with powerful techniques for generating static and dynamic
content: Doxia can be used in web-based publishing context to generate static
sites, in addition to being incorporated into dynamic content generation
systems like blogs, wikis and content management systems. Doxia provides a
module providing XSL Formatting Objects.</li>
</ul>
</section>
</section>
Propchange:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/META-INF/services/org.apache.fop.render.intermediate.IFDocumentHandler
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 22 15:48:16 2009
@@ -0,0 +1 @@
+/xmlgraphics/fop/trunk/src/java/META-INF/services/org.apache.fop.render.intermediate.IFDocumentHandler:784730-796742
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/AFPResourceManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/AFPResourceManager.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/AFPResourceManager.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/AFPResourceManager.java
Wed Jul 22 15:48:16 2009
@@ -165,39 +165,38 @@
AFPResourceLevel resourceLevel = resourceInfo.getLevel();
ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel);
+
useInclude &= resourceGroup != null;
if (useInclude) {
-
- boolean usePageSegment = dataObjectInfo.isCreatePageSegment();
-
- // if it is to reside within a resource group at print-file or
external level
- if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) {
+ boolean usePageSegment = dataObjectInfo.isCreatePageSegment();
+
+ // if it is to reside within a resource group at print-file or
external level
+ if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) {
+ if (usePageSegment) {
+ String pageSegmentName = "S10" +
namedObj.getName().substring(3);
+ namedObj.setName(pageSegmentName);
+ PageSegment seg = new PageSegment(pageSegmentName);
+ seg.addObject(namedObj);
+ namedObj = seg;
+ }
+
+ // wrap newly created data object in a resource object
+ namedObj = dataObjectFactory.createResource(namedObj,
resourceInfo, objectType);
+ }
+
+ // add data object into its resource group destination
+ resourceGroup.addObject(namedObj);
+
+ // create the include object
+ objectName = namedObj.getName();
if (usePageSegment) {
- String pageSegmentName = "S10" +
namedObj.getName().substring(3);
- namedObj.setName(pageSegmentName);
- PageSegment seg = new PageSegment(pageSegmentName);
- seg.addObject(namedObj);
- namedObj = seg;
+ includePageSegment(dataObjectInfo, objectName);
+ pageSegmentMap.put(resourceInfo, objectName);
+ } else {
+ includeObject(dataObjectInfo, objectName);
+ // record mapping of resource info to data object resource name
+ includeNameMap.put(resourceInfo, objectName);
}
-
- // wrap newly created data object in a resource object
- namedObj = dataObjectFactory.createResource(namedObj,
resourceInfo, objectType);
- }
-
- // add data object into its resource group destination
- resourceGroup.addObject(namedObj);
-
- // create the include object
- objectName = namedObj.getName();
- if (usePageSegment) {
- includePageSegment(dataObjectInfo, objectName);
- pageSegmentMap.put(resourceInfo, objectName);
- } else {
- includeObject(dataObjectInfo, objectName);
- // record mapping of resource info to data object resource name
- includeNameMap.put(resourceInfo, objectName);
- }
-
} else {
// not to be included so inline data object directly into the
current page
dataStream.getCurrentPage().addObject(namedObj);
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/DataStream.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/DataStream.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/DataStream.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/DataStream.java
Wed Jul 22 15:48:16 2009
@@ -30,8 +30,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.afp.fonts.AFPFont;
import org.apache.fop.afp.fonts.AFPFontAttributes;
+import org.apache.fop.afp.fonts.AFPFont;
+import org.apache.fop.afp.fonts.CharacterSet;
import org.apache.fop.afp.modca.AbstractPageObject;
import org.apache.fop.afp.modca.Document;
import org.apache.fop.afp.modca.InterchangeSet;
@@ -41,6 +42,10 @@
import org.apache.fop.afp.modca.ResourceGroup;
import org.apache.fop.afp.modca.TagLogicalElementBean;
import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet;
+import org.apache.fop.afp.ptoca.PtocaProducer;
+import org.apache.fop.afp.ptoca.PtocaBuilder;
+import org.apache.fop.util.CharUtilities;
+import org.apache.fop.fonts.Font;
/**
* A data stream is a continuous ordered stream of data elements and objects
@@ -347,11 +352,15 @@
* Helper method to create text on the current page, this method delegates
* to the current presentation text object in order to construct the text.
*
- * @param textDataInfo
- * the afp text data
+ * @param textDataInfo the afp text data
+ * @param letterSpacing letter spacing to draw text with
+ * @param wordSpacing word Spacing to draw text with
+ * @param font is the font to draw text with
+ * @param charSet is the AFP Character Set to use with the text
* @throws UnsupportedEncodingException thrown if character encoding is
not supported
*/
- public void createText(AFPTextDataInfo textDataInfo) throws
UnsupportedEncodingException {
+ public void createText(final AFPTextDataInfo textDataInfo, final int
letterSpacing, final int wordSpacing,
+ final Font font, final CharacterSet charSet) throws
UnsupportedEncodingException {
int rotation = paintingState.getRotation();
if (rotation != 0) {
textDataInfo.setRotation(rotation);
@@ -359,7 +368,86 @@
textDataInfo.setX(p.x);
textDataInfo.setY(p.y);
}
- currentPage.createText(textDataInfo);
+ // use PtocaProducer to create PTX records
+ PtocaProducer producer = new PtocaProducer() {
+
+ public void produce(PtocaBuilder builder) throws IOException {
+ builder.setTextOrientation(textDataInfo.getRotation());
+ builder.absoluteMoveBaseline(textDataInfo.getY());
+ builder.absoluteMoveInline(textDataInfo.getX());
+
+ builder.setExtendedTextColor(textDataInfo.getColor());
+ builder.setCodedFont((byte)textDataInfo.getFontReference());
+
+ int l = textDataInfo.getString().length();
+ StringBuffer sb = new StringBuffer();
+
+ int interCharacterAdjustment = 0;
+ AFPUnitConverter unitConv = paintingState.getUnitConverter();
+ if (letterSpacing != 0) {
+ interCharacterAdjustment =
Math.round(unitConv.mpt2units(letterSpacing));
+ }
+ builder.setInterCharacterAdjustment(interCharacterAdjustment);
+
+ int spaceWidth = font.getCharWidth(CharUtilities.SPACE);
+ int spacing = spaceWidth + letterSpacing;
+ int fixedSpaceCharacterIncrement =
Math.round(unitConv.mpt2units(spacing));
+ int varSpaceCharacterIncrement = fixedSpaceCharacterIncrement;
+ if (wordSpacing != 0) {
+ varSpaceCharacterIncrement = Math.round(unitConv.mpt2units(
+ spaceWidth + wordSpacing + letterSpacing));
+ }
+
builder.setVariableSpaceCharacterIncrement(varSpaceCharacterIncrement);
+
+ boolean fixedSpaceMode = false;
+
+ for (int i = 0; i < l; i++) {
+ char orgChar = textDataInfo.getString().charAt(i);
+ float glyphAdjust = 0;
+ if (CharUtilities.isFixedWidthSpace(orgChar)) {
+ flushText(builder, sb, charSet);
+ builder.setVariableSpaceCharacterIncrement(
+ fixedSpaceCharacterIncrement);
+ fixedSpaceMode = true;
+ sb.append(CharUtilities.SPACE);
+ int charWidth = font.getCharWidth(orgChar);
+ glyphAdjust += (charWidth - spaceWidth);
+ } else {
+ if (fixedSpaceMode) {
+ flushText(builder, sb, charSet);
+ builder.setVariableSpaceCharacterIncrement(
+ varSpaceCharacterIncrement);
+ fixedSpaceMode = false;
+ }
+ char ch;
+ if (orgChar == CharUtilities.NBSPACE) {
+ ch = ' '; //converted to normal space to allow
word spacing
+ } else {
+ ch = orgChar;
+ }
+ sb.append(ch);
+ }
+
+ if (glyphAdjust != 0) {
+ flushText(builder, sb, charSet);
+ int increment =
Math.round(unitConv.mpt2units(glyphAdjust));
+ builder.relativeMoveInline(increment);
+ }
+ }
+ flushText(builder, sb, charSet);
+ }
+
+ private void flushText(PtocaBuilder builder, StringBuffer sb,
+ final CharacterSet charSet) throws IOException {
+ if (sb.length() > 0) {
+ builder.addTransparentData(charSet.encodeChars(sb));
+ sb.setLength(0);
+ }
+ }
+
+ };
+
+ currentPage.createText(producer);
}
/**
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPBase12FontCollection.java
Wed Jul 22 15:48:16 2009
@@ -49,7 +49,7 @@
private void addCharacterSet(RasterFont font, String charsetName,
Base14Font base14) {
for (int i = 0; i < RASTER_SIZES.length; i++) {
- int size = RASTER_SIZES[i];
+ int size = RASTER_SIZES[i] * 1000;
FopCharacterSet characterSet = new FopCharacterSet(
CharacterSet.DEFAULT_CODEPAGE,
CharacterSet.DEFAULT_ENCODING,
charsetName + CHARSET_REF[i], base14);
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPFontReader.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPFontReader.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPFontReader.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/AFPFontReader.java
Wed Jul 22 15:48:16 2009
@@ -177,7 +177,8 @@
StructuredFieldReader structuredFieldReader = new
StructuredFieldReader(inputStream);
// Process D3A689 Font Descriptor
- int pointSize = processFontDescriptor(structuredFieldReader);
+ FontDescriptor fontDescriptor =
processFontDescriptor(structuredFieldReader);
+
characterSet.setNominalVerticalSize(fontDescriptor.getNominalFontSizeInMillipoints());
// Process D3A789 Font Control
FontControl fontControl =
processFontControl(structuredFieldReader);
@@ -187,12 +188,13 @@
CharacterSetOrientation[] characterSetOrientations
= processFontOrientation(structuredFieldReader);
- int dpi = fontControl.getDpi();
- int metricNormalizationFactor = 0;
+ int metricNormalizationFactor;
if (fontControl.isRelative()) {
metricNormalizationFactor = 1;
} else {
- metricNormalizationFactor = 72000 / dpi / pointSize;
+ int dpi = fontControl.getDpi();
+ metricNormalizationFactor = 1000 * 72000
+ / fontDescriptor.getNominalFontSizeInMillipoints() /
dpi;
}
//process D3AC89 Font Position
@@ -274,15 +276,13 @@
* Process the font descriptor details using the structured field reader.
*
* @param structuredFieldReader the structured field reader
- * @return the nominal size of the font (in points)
+ * @return a class representing the font descriptor
*/
- private static int processFontDescriptor(StructuredFieldReader
structuredFieldReader)
+ private static FontDescriptor processFontDescriptor(StructuredFieldReader
structuredFieldReader)
throws IOException {
byte[] fndData = structuredFieldReader.getNext(FONT_DESCRIPTOR_SF);
-
- int nominalPointSize = (((fndData[39] & 0xFF) << 8) + (fndData[40] &
0xFF)) / 10;
- return nominalPointSize;
+ return new FontDescriptor(fndData);
}
/**
@@ -303,8 +303,13 @@
if (fncData[7] == (byte) 0x02) {
fontControl.setRelative(true);
}
- int metricResolution = (((fncData[9] & 0xFF) << 8) + (fncData[10]
& 0xFF)) / 10;
- fontControl.setDpi(metricResolution);
+ int metricResolution = getUBIN(fncData, 9);
+ if (metricResolution == 1000) {
+ //Special case: 1000 units per em (rather than dpi)
+ fontControl.setUnitsPerEm(1000);
+ } else {
+ fontControl.setDpi(metricResolution / 10);
+ }
}
return fontControl;
}
@@ -378,7 +383,7 @@
* font metric values
*/
private void processFontPosition(StructuredFieldReader
structuredFieldReader,
- CharacterSetOrientation[] characterSetOrientations, int
metricNormalizationFactor)
+ CharacterSetOrientation[] characterSetOrientations, double
metricNormalizationFactor)
throws IOException {
byte[] data = structuredFieldReader.getNext(FONT_POSITION_SF);
@@ -397,17 +402,21 @@
CharacterSetOrientation characterSetOrientation
=
characterSetOrientations[characterSetOrientationIndex];
- int xHeight = ((fpData[2] & 0xFF) << 8) + (fpData[3] &
0xFF);
- int capHeight = ((fpData[4] & 0xFF) << 8) + (fpData[5] &
0xFF);
- int ascHeight = ((fpData[6] & 0xFF) << 8) + (fpData[7] &
0xFF);
- int dscHeight = ((fpData[8] & 0xFF) << 8) + (fpData[9] &
0xFF);
+ int xHeight = getSBIN(fpData, 2);
+ int capHeight = getSBIN(fpData, 4);
+ int ascHeight = getSBIN(fpData, 6);
+ int dscHeight = getSBIN(fpData, 8);
dscHeight = dscHeight * -1;
- characterSetOrientation.setXHeight(xHeight *
metricNormalizationFactor);
- characterSetOrientation.setCapHeight(capHeight *
metricNormalizationFactor);
- characterSetOrientation.setAscender(ascHeight *
metricNormalizationFactor);
- characterSetOrientation.setDescender(dscHeight *
metricNormalizationFactor);
+ characterSetOrientation.setXHeight(
+ (int)Math.round(xHeight *
metricNormalizationFactor));
+ characterSetOrientation.setCapHeight(
+ (int)Math.round(capHeight *
metricNormalizationFactor));
+ characterSetOrientation.setAscender(
+ (int)Math.round(ascHeight *
metricNormalizationFactor));
+ characterSetOrientation.setDescender(
+ (int)Math.round(dscHeight *
metricNormalizationFactor));
}
} else if (position == 22) {
position = 0;
@@ -430,7 +439,8 @@
* font metric values
*/
private void processFontIndex(StructuredFieldReader structuredFieldReader,
- CharacterSetOrientation cso, Map/*<String,String>*/ codepage, int
metricNormalizationFactor)
+ CharacterSetOrientation cso, Map/*<String,String>*/ codepage,
+ double metricNormalizationFactor)
throws IOException {
byte[] data = structuredFieldReader.getNext(FONT_INDEX_SF);
@@ -442,6 +452,7 @@
int lowest = 255;
int highest = 0;
+ String firstABCMismatch = null;
// Read data, ignoring bytes 0 - 2
for (int index = 3; index < data.length; index++) {
@@ -464,7 +475,26 @@
if (idx != null) {
int cidx = idx.charAt(0);
- int width = ((fiData[0] & 0xFF) << 8) + (fiData[1] & 0xFF);
+ int width = getUBIN(fiData, 0);
+ int a = getSBIN(fiData, 10);
+ int b = getUBIN(fiData, 12);
+ int c = getSBIN(fiData, 14);
+ int abc = a + b + c;
+ int diff = Math.abs(abc - width);
+ if (diff != 0 && width != 0) {
+ double diffPercent = 100 * diff / (double)width;
+ //if difference > 2%
+ if (diffPercent > 2) {
+ if (log.isTraceEnabled()) {
+ log.trace(gcgiString + ": "
+ + a + " + " + b + " + " + c + " = " +
(a + b + c)
+ + " but found: " + width);
+ }
+ if (firstABCMismatch == null) {
+ firstABCMismatch = gcgiString;
+ }
+ }
+ }
if (cidx < lowest) {
lowest = cidx;
@@ -474,9 +504,9 @@
highest = cidx;
}
- int a = (width * metricNormalizationFactor);
+ int normalizedWidth = (int)Math.round(width *
metricNormalizationFactor);
- cso.setWidth(cidx, a);
+ cso.setWidth(cidx, normalizedWidth);
}
@@ -486,11 +516,32 @@
cso.setFirstChar(lowest);
cso.setLastChar(highest);
+ if (log.isDebugEnabled() && firstABCMismatch != null) {
+ //Debug level because it usually is no problem.
+ log.debug("Font has metrics inconsitencies where A+B+C doesn't
equal the"
+ + " character increment. The first such character found: "
+ + firstABCMismatch);
+ }
+ }
+
+ private static int getUBIN(byte[] data, int start) {
+ return ((data[start] & 0xFF) << 8) + (data[start + 1] & 0xFF);
+ }
+
+ private static int getSBIN(byte[] data, int start) {
+ int ubin = ((data[start] & 0xFF) << 8) + (data[start + 1] & 0xFF);
+ if ((ubin & 0x8000) != 0) {
+ //extend sign
+ return ubin | 0xFFFF0000;
+ } else {
+ return ubin;
+ }
}
private class FontControl {
private int dpi;
+ private int unitsPerEm;
private boolean isRelative = false;
@@ -502,6 +553,14 @@
dpi = i;
}
+ public int getUnitsPerEm() {
+ return this.unitsPerEm;
+ }
+
+ public void setUnitsPerEm(int value) {
+ this.unitsPerEm = value;
+ }
+
public boolean isRelative() {
return isRelative;
}
@@ -511,4 +570,18 @@
}
}
+ private static class FontDescriptor {
+
+ private byte[] data;
+
+ public FontDescriptor(byte[] data) {
+ this.data = data;
+ }
+
+ public int getNominalFontSizeInMillipoints() {
+ int nominalFontSize = 100 * getUBIN(data, 39);
+ return nominalFontSize;
+ }
+ }
+
}
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSet.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSet.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSet.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSet.java
Wed Jul 22 15:48:16 2009
@@ -95,6 +95,9 @@
/** The collection of objects for each orientation */
private Map characterSetOrientations = null;
+ /** The nominal vertical size (in millipoints) for bitmap fonts. 0 for
outline fonts. */
+ private int nominalVerticalSize = 0;
+
/**
* Constructor for the CharacterSetMetric object, the character set is used
* to load the font information from the actual AFP font.
@@ -159,6 +162,23 @@
}
/**
+ * Sets the nominal vertical size of the font in the case of bitmap fonts.
+ * @param nominalVerticalSize the nominal vertical size (in millipoints)
+ */
+ public void setNominalVerticalSize(int nominalVerticalSize) {
+ this.nominalVerticalSize = nominalVerticalSize;
+ }
+
+ /**
+ * Returns the nominal vertical size of the font in the case of bitmap
fonts. For outline fonts,
+ * zero is returned, because these are scalable fonts.
+ * @return the nominal vertical size (in millipoints) for bitmap fonts, or
0 for outline fonts.
+ */
+ public int getNominalVerticalSize() {
+ return this.nominalVerticalSize;
+ }
+
+ /**
* Ascender height is the distance from the character baseline to the
* top of the character box. A negative ascender height signifies that
* all of the graphic character is below the character baseline. For
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/CharacterSetOrientation.java
Wed Jul 22 15:48:16 2009
@@ -191,7 +191,7 @@
* a character rotation other than 0, ascender height loses its
* meaning when the character is lying on its side or is upside down
* with respect to normal viewing orientation. For the general case,
- * Ascender Height is the character�s most positive y-axis value.
+ * Ascender Height is the character's most positive y-axis value.
* For bounded character boxes, for a given character having an
* ascender, ascender height and baseline offset are equal.
* @param ascender the ascender to set
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/OutlineFont.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/OutlineFont.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/OutlineFont.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/OutlineFont.java
Wed Jul 22 15:48:16 2009
@@ -87,8 +87,7 @@
* "x-height" (the height of the letter "x"), such as "d", "t", or "h".
Also
* used to denote the part of the letter extending above the x-height.
*
- * @param size
- * the point size
+ * @param size the font size (in mpt)
* @return the ascender for the given size
*/
public int getAscender(int size) {
@@ -98,8 +97,7 @@
/**
* Obtains the height of capital letters for the specified point size.
*
- * @param size
- * the point size
+ * @param size the font size (in mpt)
* @return the cap height for the given size
*/
public int getCapHeight(int size) {
@@ -111,8 +109,7 @@
* base line, such as "g", "j", or "p". Also used to denote the part of the
* letter extending below the base line.
*
- * @param size
- * the point size
+ * @param size the font size (in mpt)
* @return the descender for the given size
*/
public int getDescender(int size) {
@@ -122,8 +119,7 @@
/**
* The "x-height" (the height of the letter "x").
*
- * @param size
- * the point size
+ * @param size the font size (in mpt)
* @return the x height for the given size
*/
public int getXHeight(int size) {
@@ -133,7 +129,7 @@
/**
* Obtain the width of the character for the specified point size.
* @param character the character
- * @param size point size
+ * @param size the font size (in mpt)
* @return the width of the character for the specified point size
*/
public int getWidth(int character, int size) {
@@ -144,8 +140,7 @@
* Get the getWidth (in 1/1000ths of a point size) of all characters in
this
* character set.
*
- * @param size
- * the point size
+ * @param size the font size (in mpt)
* @return the widths of all characters
*/
public int[] getWidths(int size) {
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/RasterFont.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/RasterFont.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/RasterFont.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/fonts/RasterFont.java
Wed Jul 22 15:48:16 2009
@@ -19,10 +19,10 @@
package org.apache.fop.afp.fonts;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
-import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -163,26 +163,37 @@
}
+ private int metricsToAbsoluteSize(CharacterSet cs, int value, int
givenSize) {
+ int nominalVerticalSize = cs.getNominalVerticalSize();
+ if (nominalVerticalSize != 0) {
+ return value * nominalVerticalSize;
+ } else {
+ return value * givenSize;
+ }
+ }
+
/**
* The ascender is the part of a lowercase letter that extends above the
* "x-height" (the height of the letter "x"), such as "d", "t", or "h".
Also
* used to denote the part of the letter extending above the x-height.
*
- * @param size the point size (in mpt)
+ * @param size the font size (in mpt)
* @return the ascender for the given point size
*/
public int getAscender(int size) {
- return getCharacterSet(size).getAscender() * size;
+ CharacterSet cs = getCharacterSet(size);
+ return metricsToAbsoluteSize(cs, cs.getAscender(), size);
}
/**
* Obtains the height of capital letters for the specified point size.
*
- * @param size the point size (in mpt)
+ * @param size the font size (in mpt)
* @return the cap height for the specified point size
*/
public int getCapHeight(int size) {
- return getCharacterSet(size).getCapHeight() * size;
+ CharacterSet cs = getCharacterSet(size);
+ return metricsToAbsoluteSize(cs, cs.getCapHeight(), size);
}
/**
@@ -190,42 +201,50 @@
* base line, such as "g", "j", or "p". Also used to denote the part of the
* letter extending below the base line.
*
- * @param size the point size (in mpt)
+ * @param size the font size (in mpt)
* @return the descender for the specified point size
*/
public int getDescender(int size) {
- return getCharacterSet(size).getDescender() * size;
+ CharacterSet cs = getCharacterSet(size);
+ return metricsToAbsoluteSize(cs, cs.getDescender(), size);
}
/**
* The "x-height" (the height of the letter "x").
*
- * @param size the point size (in mpt)
+ * @param size the font size (in mpt)
* @return the x height for the given point size
*/
public int getXHeight(int size) {
- return getCharacterSet(size).getXHeight() * size;
+ CharacterSet cs = getCharacterSet(size);
+ return metricsToAbsoluteSize(cs, cs.getXHeight(), size);
}
/**
* Obtain the width of the character for the specified point size.
* @param character the character
- * @param size the point size (in mpt)
+ * @param size the font size (in mpt)
* @return the width for the given point size
*/
public int getWidth(int character, int size) {
- return getCharacterSet(size).getWidth(character) * size;
+ CharacterSet cs = getCharacterSet(size);
+ return metricsToAbsoluteSize(cs, cs.getWidth(character), size);
}
/**
* Get the getWidth (in 1/1000ths of a point size) of all characters in
this
* character set.
*
- * @param size the point size (in mpt)
+ * @param size the font size (in mpt)
* @return the widths of all characters
*/
public int[] getWidths(int size) {
- return getCharacterSet(size).getWidths();
+ CharacterSet cs = getCharacterSet(size);
+ int[] widths = cs.getWidths();
+ for (int i = 0, c = widths.length; i < c; i++) {
+ widths[i] = metricsToAbsoluteSize(cs, widths[i], size);
+ }
+ return widths;
}
/**
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/AbstractPageObject.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/AbstractPageObject.java
Wed Jul 22 15:48:16 2009
@@ -25,9 +25,9 @@
import java.util.List;
import org.apache.fop.afp.AFPLineDataInfo;
-import org.apache.fop.afp.AFPTextDataInfo;
import org.apache.fop.afp.Completable;
import org.apache.fop.afp.Factory;
+import org.apache.fop.afp.ptoca.PtocaProducer;
import org.apache.fop.afp.fonts.AFPFont;
/**
@@ -170,8 +170,10 @@
* the afp text data
* @throws UnsupportedEncodingException thrown if character encoding is
not supported
*/
- public void createText(AFPTextDataInfo textDataInfo) throws
UnsupportedEncodingException {
- getPresentationTextObject().createTextData(textDataInfo);
+ public void createText(PtocaProducer producer) throws
UnsupportedEncodingException {
+ //getPresentationTextObject().createTextData(textDataInfo);
+ getPresentationTextObject().createControlSequences(producer);
+
}
/**
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/MapCodedFont.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/MapCodedFont.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/MapCodedFont.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/MapCodedFont.java
Wed Jul 22 15:48:16 2009
@@ -206,7 +206,7 @@
// There are approximately 72 points to 1 inch or 20 1440ths
per point.
- fontDefinition.scale = ((size / 1000) * 20);
+ fontDefinition.scale = 20 * size / 1000;
fontDefinition.codePage = cs.getCodePage().getBytes(
AFPConstants.EBCIDIC_ENCODING);
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/TagLogicalElement.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/TagLogicalElement.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/TagLogicalElement.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/afp/modca/TagLogicalElement.java
Wed Jul 22 15:48:16 2009
@@ -64,7 +64,7 @@
/**
* Construct a tag logical element with the name and value specified.
- *
+ *
* @param name the name of the tag logical element
* @param value the value of the tag logical element
* @param tleID unique identifier for TLE within AFP stream
@@ -135,7 +135,7 @@
data[pos++] = tleByteValue[i];
}
// attribute qualifier
- data[pos++] = 0x10;
+ data[pos++] = 0x0A;
data[pos++] = (byte)0x80;
byte[] id = BinaryUtils.convert(tleID, 4);
for (int i = 0; i < id.length; i++) {
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/FObj.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/FObj.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/FObj.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/FObj.java
Wed Jul 22 15:48:16 2009
@@ -53,7 +53,7 @@
protected FONode firstChild;
/** The list of extension attachments, null if none */
- private List extensionAttachments = null;
+ private List/*<ExtensionAttachment>*/ extensionAttachments = null;
/** The map of foreign attributes, null if none */
private Map foreignAttributes = null;
@@ -554,7 +554,7 @@
"Parameter attachment must not be null");
}
if (extensionAttachments == null) {
- extensionAttachments = new java.util.ArrayList();
+ extensionAttachments = new
java.util.ArrayList/*<ExtensionAttachment>*/();
}
if (log.isDebugEnabled()) {
log.debug("ExtensionAttachment of category "
@@ -565,7 +565,7 @@
}
/** @return the extension attachments of this FObj. */
- public List getExtensionAttachments() {
+ public List/*<ExtensionAttachment>*/ getExtensionAttachments() {
if (extensionAttachments == null) {
return Collections.EMPTY_LIST;
} else {
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/flow/table/TablePart.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/flow/table/TablePart.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/flow/table/TablePart.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fo/flow/table/TablePart.java
Wed Jul 22 15:48:16 2009
@@ -110,13 +110,13 @@
pendingSpans = null;
columnNumberManager = null;
}
-
if (!(tableRowsFound || tableCellsFound)) {
missingChildElementError("marker* (table-row+|table-cell+)", true);
getParent().removeChild(this);
} else {
finishLastRowGroup();
}
+
}
/** {...@inheritdoc} */
@@ -204,6 +204,9 @@
//nop
}
}
+ //TODO: possible performance problems in case of large tables...
+ //If the number of children grows significantly large, the default
+ //implementation in FObj will get slower and slower...
super.addChildNode(child);
}
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
Wed Jul 22 15:48:16 2009
@@ -212,7 +212,8 @@
IOUtils.closeQuietly(in);
}
- List embedFontInfoList = new java.util.ArrayList();
//List<EmbedFontInfo>
+ List/*<EmbedFontInfo>*/ embedFontInfoList
+ = new java.util.ArrayList/*<EmbedFontInfo>*/();
// For each font name ...
//for (String fontName : ttcNames) {
Modified:
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=796775&r1=796774&r2=796775&view=diff
==============================================================================
---
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
(original)
+++
xmlgraphics/fop/branches/Temp_ChangingIPDHack/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
Wed Jul 22 15:48:16 2009
@@ -49,10 +49,10 @@
int footnoteLastListIndex;
int footnoteLastElementIndex;
- PageBreakPosition(LayoutManager lm, int iBreakIndex,
+ PageBreakPosition(LayoutManager lm, int breakIndex,
int ffli, int ffei, int flli, int flei,
double bpdA, int diff) {
- super(lm, iBreakIndex);
+ super(lm, breakIndex);
bpdAdjust = bpdA;
difference = diff;
footnoteFirstListIndex = ffli;
@@ -62,6 +62,30 @@
}
}
+ /**
+ * Helper method, mainly used to improve debug/trace output
+ * @param breakClassId the {...@link Constants} enum value.
+ * @return the break class name
+ */
+ static String getBreakClassName(int breakClassId) {
+ switch (breakClassId) {
+ case Constants.EN_ALL: return "ALL";
+ case Constants.EN_ANY: return "ANY";
+ case Constants.EN_AUTO: return "AUTO";
+ case Constants.EN_COLUMN: return "COLUMN";
+ case Constants.EN_EVEN_PAGE: return "EVEN PAGE";
+ case Constants.EN_LINE: return "LINE";
+ case Constants.EN_NONE: return "NONE";
+ case Constants.EN_ODD_PAGE: return "ODD PAGE";
+ case Constants.EN_PAGE: return "PAGE";
+ default: return "??? (" + String.valueOf(breakClassId) + ")";
+ }
+ }
+
+ /**
+ * Helper class, extending the functionality of the
+ * basic {...@link BlockKnuthSequence}.
+ */
public class BlockSequence extends BlockKnuthSequence {
/** Number of elements to ignore at the beginning of the list. */
@@ -82,19 +106,21 @@
/**
* Creates a new BlockSequence.
- * @param iStartOn the kind of page the sequence should start on. One
of EN_ANY, EN_COLUMN,
- * EN_ODD_PAGE, EN_EVEN_PAGE.
+ * @param startOn the kind of page the sequence should start on.
+ * One of {...@link Constants#EN_ANY}, {...@link
Constants#EN_COLUMN},
+ * {...@link Constants#EN_ODD_PAGE}, or {...@link
Constants#EN_EVEN_PAGE}.
* @param displayAlign the value for the display-align property
*/
- public BlockSequence(int iStartOn, int displayAlign) {
+ public BlockSequence(int startOn, int displayAlign) {
super();
- startOn = iStartOn;
+ this.startOn = startOn;
this.displayAlign = displayAlign;
}
/**
- * @return the kind of page the sequence should start on. One of
EN_ANY, EN_COLUMN,
- * EN_ODD_PAGE, EN_EVEN_PAGE.
+ * @return the kind of page the sequence should start on.
+ * One of {...@link Constants#EN_ANY}, {...@link
Constants#EN_COLUMN},
+ * {...@link Constants#EN_ODD_PAGE}, or {...@link
Constants#EN_EVEN_PAGE}.
*/
public int getStartOn() {
return this.startOn;
@@ -104,6 +130,7 @@
public int getDisplayAlign() {
return this.displayAlign;
}
+
/**
* Finalizes a Knuth sequence.
* @return a finalized sequence.
@@ -145,6 +172,12 @@
}
}
+ /**
+ * Finalizes a this {...@link BlockSequence}, adding a terminating
+ * penalty-glue-penalty sequence
+ * @param breakPosition a Position instance pointing to the last
penalty
+ * @return the finalized {...@link BlockSequence}
+ */
public BlockSequence endBlockSequence(Position breakPosition) {
KnuthSequence temp = endSequence(breakPosition);
if (temp != null) {
@@ -310,10 +343,7 @@
//debug code start
if (log.isDebugEnabled()) {
log.debug(" blockListIndex = " + blockListIndex);
- String pagina = (blockList.startOn == Constants.EN_ANY) ?
"any page"
- : (blockList.startOn == Constants.EN_ODD_PAGE) ?
"odd page"
- : "even page";
- log.debug(" sequence starts on " + pagina);
+ log.debug(" sequence starts on " +
getBreakClassName(blockList.startOn));
}
observeElementList(blockList);
//debug code end
@@ -502,7 +532,7 @@
log.debug("PLM> part: " + (p + 1)
+ ", start at pos " + startElementIndex
+ ", break at pos " + endElementIndex
- + ", break class = " + lastBreakClass);
+ + ", break class = " + getBreakClassName(lastBreakClass));
startPart(effectiveList, lastBreakClass);
@@ -529,17 +559,9 @@
// at the beginning of the line
effectiveListIterator = effectiveList
.listIterator(startElementIndex);
- KnuthElement firstElement;
while (effectiveListIterator.hasNext()
- && !(firstElement = (KnuthElement)
effectiveListIterator.next())
+ && !((KnuthElement) effectiveListIterator.next())
.isBox()) {
- /*
- if (firstElement.isGlue() && firstElement.getLayoutManager()
!= null) {
- // discard the space representd by the glue element
- ((BlockLevelLayoutManager) firstElement
- .getLayoutManager())
- .discardSpace((KnuthGlue) firstElement);
- }*/
startElementIndex++;
}
@@ -674,26 +696,23 @@
nextSequenceStartsOn = handleSpanChange(childLC,
nextSequenceStartsOn);
Position breakPosition = null;
- if (((KnuthElement)
ListUtil.getLast(returnedList)).isForcedBreak()) {
+ if (ElementListUtils.endsWithForcedBreak(returnedList)) {
KnuthPenalty breakPenalty = (KnuthPenalty) ListUtil
.removeLast(returnedList);
breakPosition = breakPenalty.getPosition();
+ log.debug("PLM> break - " +
getBreakClassName(breakPenalty.getBreakClass()));
switch (breakPenalty.getBreakClass()) {
case Constants.EN_PAGE:
- log.debug("PLM> break - PAGE");
nextSequenceStartsOn = Constants.EN_ANY;
break;
case Constants.EN_COLUMN:
- log.debug("PLM> break - COLUMN");
//TODO Fix this when implementing multi-column layout
nextSequenceStartsOn = Constants.EN_COLUMN;
break;
case Constants.EN_ODD_PAGE:
- log.debug("PLM> break - ODD PAGE");
nextSequenceStartsOn = Constants.EN_ODD_PAGE;
break;
case Constants.EN_EVEN_PAGE:
- log.debug("PLM> break - EVEN PAGE");
nextSequenceStartsOn = Constants.EN_EVEN_PAGE;
break;
default:
@@ -702,7 +721,7 @@
}
}
blockList.addAll(returnedList);
- BlockSequence seq = null;
+ BlockSequence seq;
seq = blockList.endBlockSequence(breakPosition);
if (seq != null) {
this.blockLists.add(seq);
@@ -714,8 +733,8 @@
/**
* Returns the average width of all the lines in the given range.
* @param effectiveList effective block list to work on
- * @param startElementIndex
- * @param endElementIndex
+ * @param startElementIndex index of the element starting the range
+ * @param endElementIndex index of the element ending the range
* @return the average line length, 0 if there's no content
*/
private int optimizeLineLength(KnuthSequence effectiveList, int
startElementIndex, int endElementIndex) {
@@ -966,29 +985,6 @@
log.debug("AdjustLineNumbers: difference " + difference + " / " +
total + " on " + lineList.size() + " elements");
}
-// int adjustedDiff = 0;
-// int partial = 0;
-// KnuthGlue prevLine = null;
-// KnuthGlue currLine = null;
-// ListIterator lineListIterator = lineList.listIterator();
-// while (lineListIterator.hasNext()) {
-// currLine = (KnuthGlue)lineListIterator.next();
-// if (prevLine != null
-// && prevLine.getLayoutManager() !=
currLine.getLayoutManager()) {
-// int newAdjust = ((BlockLevelLayoutManager)
prevLine.getLayoutManager())
-// .negotiateBPDAdjustment(((int) ((float)
partial * difference / total)) - adjustedDiff, prevLine);
-// adjustedDiff += newAdjust;
-// }
-// partial += (difference > 0 ? currLine.getY() :
currLine.getZ());
-// prevLine = currLine;
-// }
-// if (currLine != null) {
-// int newAdjust = ((BlockLevelLayoutManager)
currLine.getLayoutManager())
-// .negotiateBPDAdjustment(((int) ((float)
partial * difference / total)) - adjustedDiff, currLine);
-// adjustedDiff += newAdjust;
-// }
-// return adjustedDiff;
-
ListIterator lineListIterator = lineList.listIterator();
int adjustedDiff = 0;
int partial = 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]