diff options
79 files changed, 2506 insertions, 566 deletions
diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 000000000..6fc292f6d --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,40 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Publish Snapshot + +on: + push: + branches: ["main"] + +jobs: + build: + name: Publish Snapshot with Java ${{ matrix.jdk }} ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + jdk: ['8'] + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.jdk }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jdk }} + distribution: 'temurin' + cache: maven + server-id: apache.snapshots.https + server-username: NEXUS_USER + server-password: NEXUS_PW + - name: Deploy + run: mvn -B deploy -DskipTests + env: + NEXUS_USER: ${{ secrets.NEXUS_USER }} + NEXUS_PW: ${{ secrets.NEXUS_PW }} diff --git a/fop-core/src/main/codegen/unicode/java/org/apache/fop/hyphenation/UnicodeClasses.java b/fop-core/src/main/codegen/unicode/java/org/apache/fop/hyphenation/UnicodeClasses.java index df25831ea..7550bbabc 100644 --- a/fop-core/src/main/codegen/unicode/java/org/apache/fop/hyphenation/UnicodeClasses.java +++ b/fop-core/src/main/codegen/unicode/java/org/apache/fop/hyphenation/UnicodeClasses.java @@ -87,7 +87,7 @@ public final class UnicodeClasses { } f.createNewFile(); FileOutputStream fw = new FileOutputStream(f); - OutputStreamWriter ow = new OutputStreamWriter(fw, "utf-8"); + OutputStreamWriter ow = new OutputStreamWriter(fw, StandardCharsets.UTF_8); int maxChar; maxChar = Character.MAX_VALUE; @@ -189,7 +189,7 @@ public final class UnicodeClasses { } f.createNewFile(); FileOutputStream fw = new FileOutputStream(f); - OutputStreamWriter ow = new OutputStreamWriter(fw, "utf-8"); + OutputStreamWriter ow = new OutputStreamWriter(fw, StandardCharsets.UTF_8); URI inuri = unidata.resolve("Blocks.txt"); InputStream inis = null; @@ -199,7 +199,7 @@ public final class UnicodeClasses { } else if (scheme.equals("http")) { inis = inuri.toURL().openStream(); } - InputStreamReader insr = new InputStreamReader(inis, "utf-8"); + InputStreamReader insr = new InputStreamReader(inis, StandardCharsets.UTF_8); BufferedReader inbr = new BufferedReader(insr); Map blocks = new HashMap(); for (String line = inbr.readLine(); line != null; line = inbr.readLine()) { @@ -221,7 +221,7 @@ public final class UnicodeClasses { } else if (scheme.equals("http")) { inis = inuri.toURL().openStream(); } - insr = new InputStreamReader(inis, "utf-8"); + insr = new InputStreamReader(inis, StandardCharsets.UTF_8); inbr = new BufferedReader(insr); int maxChar; maxChar = Character.MAX_VALUE; @@ -306,10 +306,10 @@ public final class UnicodeClasses { } f.createNewFile(); FileOutputStream fw = new FileOutputStream(f); - OutputStreamWriter ow = new OutputStreamWriter(fw, "utf-8"); + OutputStreamWriter ow = new OutputStreamWriter(fw, StandardCharsets.UTF_8); FileInputStream inis = new FileInputStream(in); - InputStreamReader insr = new InputStreamReader(inis, "utf-8"); + InputStreamReader insr = new InputStreamReader(inis, StandardCharsets.UTF_8); BufferedReader inbr = new BufferedReader(insr); ow.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); diff --git a/fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java b/fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java index d20e4d37a..3ba4babb7 100644 --- a/fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java +++ b/fop-core/src/main/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverter.java @@ -54,6 +54,7 @@ import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; +import org.apache.fop.fo.flow.table.TableCaption; import org.apache.fop.fo.flow.table.TableCell; import org.apache.fop.fo.flow.table.TableColumn; import org.apache.fop.fo.flow.table.TableFooter; @@ -358,6 +359,24 @@ public class FO2StructureTreeConverter extends DelegatingFOEventHandler { super.endTable(tbl); } + public void startTableCaption(final TableCaption tableCaption) { + startContent(new Event(this) { + public void run() { + eventHandler.startTableCaption(tableCaption); + } + }, true); + super.startTableCaption(tableCaption); + } + + public void endTableCaption(final TableCaption tableCaption) { + endContent(new Event(this) { + public void run() { + eventHandler.endTableCaption(tableCaption); + } + }); + super.endTableCaption(tableCaption); + } + @Override public void startColumn(final TableColumn tc) { startContent(new Event(this) { diff --git a/fop-core/src/main/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java b/fop-core/src/main/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java index 8def8a4d4..160a0236e 100644 --- a/fop-core/src/main/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java +++ b/fop-core/src/main/java/org/apache/fop/accessibility/fo/StructureTreeEventTrigger.java @@ -58,6 +58,7 @@ import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; +import org.apache.fop.fo.flow.table.TableCaption; import org.apache.fop.fo.flow.table.TableCell; import org.apache.fop.fo.flow.table.TableFooter; import org.apache.fop.fo.flow.table.TableHeader; @@ -258,6 +259,14 @@ class StructureTreeEventTrigger extends FOEventHandler { tables.pop(); } + public void startTableCaption(TableCaption tableCaption) { + startElement(tableCaption); + } + + public void endTableCaption(TableCaption tableCaption) { + endElement(tableCaption); + } + @Override public void startHeader(TableHeader header) { inTableHeader.push(Boolean.TRUE); diff --git a/fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java b/fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java index 4174f31d8..4c4db49b5 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java +++ b/fop-core/src/main/java/org/apache/fop/afp/fonts/CharacterSetBuilder.java @@ -621,7 +621,7 @@ public abstract class CharacterSetBuilder { } } - private class FontControl { + private static class FontControl { private int dpi; private int unitsPerEm; diff --git a/fop-core/src/main/java/org/apache/fop/afp/modca/Registry.java b/fop-core/src/main/java/org/apache/fop/afp/modca/Registry.java index fe0a42790..45cd85284 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/modca/Registry.java +++ b/fop-core/src/main/java/org/apache/fop/afp/modca/Registry.java @@ -209,7 +209,7 @@ public final class Registry { /** * Encapsulates a MOD:CA Registry Object Type entry */ - public class ObjectType { + public static class ObjectType { private final byte componentId; private final byte[] oid; private final String name; diff --git a/fop-core/src/main/java/org/apache/fop/area/LineArea.java b/fop-core/src/main/java/org/apache/fop/area/LineArea.java index f659c2d78..3c1ae5217 100644 --- a/fop-core/src/main/java/org/apache/fop/area/LineArea.java +++ b/fop-core/src/main/java/org/apache/fop/area/LineArea.java @@ -44,7 +44,7 @@ public class LineArea extends Area { * page-number or a page-number-citation is resolved */ // @SuppressFBWarnings("SE_INNER_CLASS") - private final class LineAdjustingInfo implements Serializable { + private static final class LineAdjustingInfo implements Serializable { private static final long serialVersionUID = -6103629976229458273L; diff --git a/fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java b/fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java index b82dbee97..3e56bdd13 100644 --- a/fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java +++ b/fop-core/src/main/java/org/apache/fop/datatypes/URISpecification.java @@ -19,7 +19,7 @@ package org.apache.fop.datatypes; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; /** @@ -130,13 +130,9 @@ public final class URISpecification { //Note: this may not be accurate for some very special cases. sb.append(ch); } else { - try { - byte[] utf8 = Character.toString(ch).getBytes("UTF-8"); - for (byte anUtf8 : utf8) { - appendEscape(sb, anUtf8); - } - } catch (UnsupportedEncodingException e) { - throw new Error("Incompatible JVM. UTF-8 not supported."); + byte[] utf8 = Character.toString(ch).getBytes(StandardCharsets.UTF_8); + for (byte anUtf8 : utf8) { + appendEscape(sb, anUtf8); } } } diff --git a/fop-core/src/main/java/org/apache/fop/fo/DelegatingFOEventHandler.java b/fop-core/src/main/java/org/apache/fop/fo/DelegatingFOEventHandler.java index 4cf6ddd15..2e240fe35 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/DelegatingFOEventHandler.java +++ b/fop-core/src/main/java/org/apache/fop/fo/DelegatingFOEventHandler.java @@ -46,6 +46,7 @@ import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; +import org.apache.fop.fo.flow.table.TableCaption; import org.apache.fop.fo.flow.table.TableCell; import org.apache.fop.fo.flow.table.TableColumn; import org.apache.fop.fo.flow.table.TableFooter; @@ -204,6 +205,14 @@ public abstract class DelegatingFOEventHandler extends FOEventHandler { delegate.endTable(tbl); } + public void startTableCaption(TableCaption tableCaption) { + delegate.startTableCaption(tableCaption); + } + + public void endTableCaption(TableCaption tableCaption) { + delegate.endTableCaption(tableCaption); + } + @Override public void startColumn(TableColumn tc) { delegate.startColumn(tc); diff --git a/fop-core/src/main/java/org/apache/fop/fo/FOEventHandler.java b/fop-core/src/main/java/org/apache/fop/fo/FOEventHandler.java index 0be90dd04..1f1611fb4 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/FOEventHandler.java +++ b/fop-core/src/main/java/org/apache/fop/fo/FOEventHandler.java @@ -46,6 +46,7 @@ import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; +import org.apache.fop.fo.flow.table.TableCaption; import org.apache.fop.fo.flow.table.TableCell; import org.apache.fop.fo.flow.table.TableColumn; import org.apache.fop.fo.flow.table.TableFooter; @@ -283,6 +284,12 @@ public abstract class FOEventHandler { public void endTable(Table tbl) { } + public void startTableCaption(TableCaption tableCaption) { + } + + public void endTableCaption(TableCaption tableCaption) { + } + /** * * @param tc TableColumn that is starting; diff --git a/fop-core/src/main/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java b/fop-core/src/main/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java index 8bd28caf5..4b3b14dcf 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java +++ b/fop-core/src/main/java/org/apache/fop/fo/XMLWhiteSpaceHandler.java @@ -439,7 +439,7 @@ public class XMLWhiteSpaceHandler { * with an iterator that starts at the first white-space * character in the sequence of trailing white-space */ - private class PendingInline { + private static class PendingInline { protected CharIterator firstTrailingWhiteSpace; PendingInline(CharIterator firstTrailingWhiteSpace) { diff --git a/fop-core/src/main/java/org/apache/fop/fo/extensions/xmp/XMPContentHandlerFactory.java b/fop-core/src/main/java/org/apache/fop/fo/extensions/xmp/XMPContentHandlerFactory.java index fd64f1a98..9021945c3 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/extensions/xmp/XMPContentHandlerFactory.java +++ b/fop-core/src/main/java/org/apache/fop/fo/extensions/xmp/XMPContentHandlerFactory.java @@ -48,7 +48,7 @@ public class XMPContentHandlerFactory implements ContentHandlerFactory { /** * Local subclass of XMPHandler that implements ObjectSource for FOP integration. */ - private class FOPXMPHandler extends XMPHandler implements ObjectSource { + private static class FOPXMPHandler extends XMPHandler implements ObjectSource { private ObjectBuiltListener obListener; diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/Character.java b/fop-core/src/main/java/org/apache/fop/fo/flow/Character.java index c075d8b7e..3a3a0f830 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/Character.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/Character.java @@ -249,7 +249,7 @@ public class Character extends FObj implements StructureTreeElementHolder { return ranges; } - private class FOCharIterator extends CharIterator { + private static class FOCharIterator extends CharIterator { private boolean bFirst = true; private Character foChar; diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/Marker.java b/fop-core/src/main/java/org/apache/fop/fo/flow/Marker.java index 1233da615..01e52337e 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/Marker.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/Marker.java @@ -156,7 +156,7 @@ public class Marker extends FObjMixed { * specified properties/attributes as bundles of name-value-namespace * strings */ - protected class MarkerPropertyList extends PropertyList + protected static class MarkerPropertyList extends PropertyList implements Attributes { /** the array of attributes **/ diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/table/TableAndCaption.java b/fop-core/src/main/java/org/apache/fop/fo/flow/table/TableAndCaption.java index b7c7adc91..35ec4c617 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/table/TableAndCaption.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/table/TableAndCaption.java @@ -19,7 +19,6 @@ package org.apache.fop.fo.flow.table; -// XML import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; @@ -29,6 +28,8 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAccessibilityHolder; +import org.apache.fop.fo.properties.CommonBorderPaddingBackground; +import org.apache.fop.fo.properties.KeepProperty; /** * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-and-caption"> @@ -37,25 +38,13 @@ import org.apache.fop.fo.properties.CommonAccessibilityHolder; */ public class TableAndCaption extends FObj implements CommonAccessibilityHolder { + private static final String TABLE_CAPTION = "fo:table-caption"; + private static final String TABLE = "fo:table"; private CommonAccessibility commonAccessibility; - - // The value of properties relevant for fo:table-and-caption. - // Unused but valid items, commented out for performance: - // private CommonAural commonAural; - // private CommonBorderPaddingBackground commonBorderPaddingBackground; - // private CommonMarginBlock commonMarginBlock; - // private CommonRelativePosition commonRelativePosition; - // private int breakAfter; - // private int breakBefore; - // private int captionSide; - // private int intrusionDisplace; - // private KeepProperty keepTogether; - // private KeepProperty keepWithNext; - // private KeepProperty keepWithPrevious; - // private int textAlign; - // End of property values - - static boolean notImplementedWarningGiven; + private CommonBorderPaddingBackground commonBorderPaddingBackground; + private KeepProperty keepTogether; + private KeepProperty keepWithNext; + private KeepProperty keepWithPrevious; /** used for FO validation */ private boolean tableCaptionFound; @@ -68,19 +57,16 @@ public class TableAndCaption extends FObj implements CommonAccessibilityHolder { */ public TableAndCaption(FONode parent) { super(parent); - - if (!notImplementedWarningGiven) { - getFOValidationEventProducer().unimplementedFeature(this, getName(), - "fo:table-and-caption", getLocator()); - // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") - notImplementedWarningGiven = true; - } } @Override public void bind(PropertyList pList) throws FOPException { super.bind(pList); commonAccessibility = CommonAccessibility.getInstance(pList); + keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep(); + keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep(); + keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep(); + commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); } /** @@ -104,21 +90,21 @@ public class TableAndCaption extends FObj implements CommonAccessibilityHolder { if (FO_URI.equals(nsURI)) { if (localName.equals("marker")) { if (tableCaptionFound) { - nodesOutOfOrderError(loc, "fo:marker", "fo:table-caption"); + nodesOutOfOrderError(loc, "fo:marker", TABLE_CAPTION); } else if (tableFound) { - nodesOutOfOrderError(loc, "fo:marker", "fo:table"); + nodesOutOfOrderError(loc, "fo:marker", TABLE); } } else if (localName.equals("table-caption")) { if (tableCaptionFound) { - tooManyNodesError(loc, "fo:table-caption"); + tooManyNodesError(loc, TABLE_CAPTION); } else if (tableFound) { - nodesOutOfOrderError(loc, "fo:table-caption", "fo:table"); + nodesOutOfOrderError(loc, TABLE_CAPTION, TABLE); } else { tableCaptionFound = true; } } else if (localName.equals("table")) { if (tableFound) { - tooManyNodesError(loc, "fo:table"); + tooManyNodesError(loc, TABLE); } else { tableFound = true; } @@ -146,5 +132,20 @@ public class TableAndCaption extends FObj implements CommonAccessibilityHolder { return commonAccessibility; } + public KeepProperty getKeepTogether() { + return keepTogether; + } + + public KeepProperty getKeepWithNext() { + return keepWithNext; + } + + public KeepProperty getKeepWithPrevious() { + return keepWithPrevious; + } + + public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { + return commonBorderPaddingBackground; + } } diff --git a/fop-core/src/main/java/org/apache/fop/fo/flow/table/TableCaption.java b/fop-core/src/main/java/org/apache/fop/fo/flow/table/TableCaption.java index 5ecce65af..5ca8c51de 100644 --- a/fop-core/src/main/java/org/apache/fop/fo/flow/table/TableCaption.java +++ b/fop-core/src/main/java/org/apache/fop/fo/flow/table/TableCaption.java @@ -19,17 +19,19 @@ package org.apache.fop.fo.flow.table; -// XML import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAccessibilityHolder; - +import org.apache.fop.fo.properties.EnumProperty; +import org.apache.fop.fo.properties.KeepProperty; +import org.apache.fop.fo.properties.Property; /** * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-caption"> @@ -38,24 +40,13 @@ import org.apache.fop.fo.properties.CommonAccessibilityHolder; public class TableCaption extends FObj implements CommonAccessibilityHolder { private CommonAccessibility commonAccessibility; - - // The value of properties relevant for fo:table-caption. - // Unused but valid items, commented out for performance: - // private CommonAural commonAural; - // private CommonRelativePosition commonRelativePosition; - // private LengthRangeProperty blockProgressionDimension; - // private Length height; - // private LengthRangeProperty inlineProgressionDimension; - // private int intrusionDisplace; - // private KeepProperty keepTogether; - // private Length width; - // End of property values + private KeepProperty keepTogether; + private KeepProperty keepWithNext; + private KeepProperty keepWithPrevious; /** used for FO validation */ private boolean blockItemFound; - static boolean notImplementedWarningGiven; - /** * Create a TableCaption instance with the given {@link FONode} * as parent. @@ -63,19 +54,25 @@ public class TableCaption extends FObj implements CommonAccessibilityHolder { */ public TableCaption(FONode parent) { super(parent); - - if (!notImplementedWarningGiven) { - getFOValidationEventProducer().unimplementedFeature(this, getName(), - "fo:table-caption", getLocator()); - // @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") - notImplementedWarningGiven = true; - } } /** {@inheritDoc} */ public void bind(PropertyList pList) throws FOPException { super.bind(pList); commonAccessibility = CommonAccessibility.getInstance(pList); + keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep(); + Property keepWithNextProp = pList.get(PR_KEEP_WITH_NEXT); + if (keepWithNextProp instanceof KeepProperty) { + ((KeepProperty)keepWithNextProp).setWithinPage( + EnumProperty.getInstance(Constants.EN_ALWAYS, "ALWAYS"), true); + } + keepWithNext = keepWithNextProp.getKeep(); + keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep(); + } + + public void startOfNode() throws FOPException { + super.startOfNode(); + getFOEventHandler().startTableCaption(this); } /** {@inheritDoc} */ @@ -83,6 +80,7 @@ public class TableCaption extends FObj implements CommonAccessibilityHolder { if (firstChild == null) { missingChildElementError("marker* (%block;)"); } + getFOEventHandler().endTableCaption(this); } /** @@ -122,5 +120,16 @@ public class TableCaption extends FObj implements CommonAccessibilityHolder { return commonAccessibility; } + public KeepProperty getKeepTogether() { + return keepTogether; + } + + public KeepProperty getKeepWithNext() { + return keepWithNext; + } + + public KeepProperty getKeepWithPrevious() { + return keepWithPrevious; + } } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontFileFinder.java b/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontFileFinder.java index e7902e993..3095d4910 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontFileFinder.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/autodetect/FontFileFinder.java @@ -172,7 +172,11 @@ public class FontFileFinder extends DirectoryWalker implements FontFinder { public List<URL> find(File directory) throws IOException { List<URL> results = new java.util.ArrayList<>(); if (!directory.isDirectory()) { - eventListener.fontDirectoryNotFound(this, directory.getAbsolutePath()); + if (eventListener != null) { + eventListener.fontDirectoryNotFound(this, directory.getAbsolutePath()); + } else { + log.warn("Font directory not found: " + directory.getAbsolutePath()); + } } else { walkDirectory(directory, results); } diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/FontFileReader.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/FontFileReader.java index 790e885bc..5e85e926a 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/FontFileReader.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/FontFileReader.java @@ -21,6 +21,7 @@ package org.apache.fop.fonts.truetype; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; @@ -292,9 +293,8 @@ public class FontFileReader { byte[] tmp = new byte[len]; System.arraycopy(file, current, tmp, 0, len); current += len; - final String encoding; - encoding = "UTF-16BE"; //Use this for all known encoding IDs for now - return new String(tmp, encoding); + //Use this for all known encoding IDs for now + return new String(tmp, StandardCharsets.UTF_16BE); } /** diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java index befbb9453..dd548ff56 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java @@ -20,6 +20,7 @@ package org.apache.fop.fonts.truetype; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import org.apache.fontbox.cff.CFFFont; @@ -131,7 +132,7 @@ public class OTFFile extends OpenFont { input.readShort(); //rangeShift for (int q = 0; q < numTables; q++) { - String tagName = new String(input.readBytes(4)); + String tagName = new String(input.readBytes(4), StandardCharsets.UTF_8); readLong(input); //Checksum long offset = readLong(input); long length = readLong(input); diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java index 2ea2ed823..40185abed 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java @@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -203,7 +204,7 @@ public class OTFSubSetFile extends OTFSubSetWriter { writeBytes(cffReader.getHeader()); //Name Index - writeIndex(Arrays.asList(embedFontName.getBytes("UTF-8"))); + writeIndex(Arrays.asList(embedFontName.getBytes(StandardCharsets.UTF_8))); Offsets offsets = new Offsets(); @@ -355,7 +356,7 @@ public class OTFSubSetFile extends OTFSubSetWriter { int sidAStringIndex = stringIndexData.size() + 390; int sidB = dictEntry.getOperands().get(1).intValue(); if (sidB > 390) { - stringIndexData.add("Identity".getBytes("UTF-8")); + stringIndexData.add("Identity".getBytes(StandardCharsets.UTF_8)); } int sidBStringIndex = stringIndexData.size() + 390; byte[] cidEntryByteData = dictEntry.getByteData(); @@ -407,7 +408,7 @@ public class OTFSubSetFile extends OTFSubSetWriter { if (index < cffReader.getStringIndex().getNumObjects()) { byte[] value = cffReader.getStringIndex().getValue(index); if (mbFont != null) { - mbFont.mapUsedGlyphName(v, new String(value, "UTF-8")); + mbFont.mapUsedGlyphName(v, new String(value, StandardCharsets.UTF_8)); } gidToSID.put(v, stringIndexData.size() + 391); stringIndexData.add(value); diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/SVGGlyphData.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/SVGGlyphData.java index d018f5bf2..9bc248331 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/SVGGlyphData.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/SVGGlyphData.java @@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -54,7 +55,8 @@ public class SVGGlyphData { public String getDataURL(int height) { try { String modifiedSVG = updateTransform(svg, height); - return DataURLUtil.createDataURL(new ByteArrayInputStream(modifiedSVG.getBytes("UTF-8")), "image/svg"); + return DataURLUtil.createDataURL( + new ByteArrayInputStream(modifiedSVG.getBytes(StandardCharsets.UTF_8)), "image/svg"); } catch (IOException | TransformerException | SAXException | ParserConfigurationException e) { throw new RuntimeException(e); } diff --git a/fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java b/fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java index 6bf3391e6..4a8a30086 100644 --- a/fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java +++ b/fop-core/src/main/java/org/apache/fop/hyphenation/PatternParser.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import javax.xml.parsers.SAXParserFactory; @@ -489,7 +490,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer { PrintStream p = null; if (args.length > 1) { FileOutputStream f = new FileOutputStream(args[1]); - p = new PrintStream(f, false, "utf-8"); + p = new PrintStream(f, false, StandardCharsets.UTF_8.name()); pp.setTestOut(p); } pp.parse(args[0]); diff --git a/fop-core/src/main/java/org/apache/fop/hyphenation/SerializeHyphPattern.java b/fop-core/src/main/java/org/apache/fop/hyphenation/SerializeHyphPattern.java index 8d51edf25..e3cd7bbed 100644 --- a/fop-core/src/main/java/org/apache/fop/hyphenation/SerializeHyphPattern.java +++ b/fop-core/src/main/java/org/apache/fop/hyphenation/SerializeHyphPattern.java @@ -74,13 +74,10 @@ public class SerializeHyphPattern { if (startProcess) { HyphenationTree hTree = buildPatternFile(infile); // serialize class - try { - // @SuppressFBWarnings("OS_OPEN_STREAM_EXCEPTION_PATH") - ObjectOutputStream out = new ObjectOutputStream( + try (ObjectOutputStream out = new ObjectOutputStream( new java.io.BufferedOutputStream( - new java.io.FileOutputStream(outfile))); + new java.io.FileOutputStream(outfile)))) { out.writeObject(hTree); - out.close(); } catch (IOException ioe) { System.err.println("Can't write compiled pattern file: " + outfile); diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index 7fc5c09c0..6e9293579 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -581,7 +581,7 @@ public class BlockContainerLayoutManager extends SpacedBorderedPaddedBlockLayout rect, relDims); } - private class BlockContainerPosition extends NonLeafPosition { + private static class BlockContainerPosition extends NonLeafPosition { private BlockContainerBreaker breaker; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java index 8be8b5803..d4feedf82 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java @@ -62,7 +62,9 @@ import org.apache.fop.fo.flow.RetrieveMarker; import org.apache.fop.fo.flow.RetrieveTableMarker; import org.apache.fop.fo.flow.Wrapper; import org.apache.fop.fo.flow.table.Table; +import org.apache.fop.fo.flow.table.TableAndCaption; import org.apache.fop.fo.flow.table.TableBody; +import org.apache.fop.fo.flow.table.TableCaption; import org.apache.fop.fo.flow.table.TableCell; import org.apache.fop.fo.flow.table.TableColumn; import org.apache.fop.fo.flow.table.TableFooter; @@ -91,6 +93,8 @@ import org.apache.fop.layoutmgr.inline.TextLayoutManager; import org.apache.fop.layoutmgr.inline.WrapperLayoutManager; import org.apache.fop.layoutmgr.list.ListBlockLayoutManager; import org.apache.fop.layoutmgr.list.ListItemLayoutManager; +import org.apache.fop.layoutmgr.table.TableAndCaptionLayoutManager; +import org.apache.fop.layoutmgr.table.TableCaptionLayoutManager; import org.apache.fop.layoutmgr.table.TableLayoutManager; import org.apache.fop.util.CharUtilities; @@ -143,6 +147,8 @@ public class LayoutManagerMapping implements LayoutManagerMaker { new PageNumberCitationLayoutManagerMaker()); registerMaker(PageNumberCitationLast.class, new PageNumberCitationLastLayoutManagerMaker()); + registerMaker(TableAndCaption.class, new TableAndCaptionManagerMaker()); + registerMaker(TableCaption.class, new TableCaptionManagerMaker()); registerMaker(Table.class, new TableLayoutManagerMaker()); registerMaker(TableBody.class, new Maker()); registerMaker(TableColumn.class, new Maker()); @@ -458,6 +464,18 @@ public class LayoutManagerMapping implements LayoutManagerMaker { } } + public class TableAndCaptionManagerMaker extends Maker { + public void make(FONode node, List layoutManagers, FOUserAgent userAgent) { + layoutManagers.add(new TableAndCaptionLayoutManager((TableAndCaption)node)); + } + } + + public class TableCaptionManagerMaker extends Maker { + public void make(FONode node, List layoutManagers, FOUserAgent userAgent) { + layoutManagers.add(new TableCaptionLayoutManager((TableCaption)node)); + } + } + public class MultiSwitchLayoutManagerMaker extends Maker { @Override diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java index ae1825dd4..fc6e05835 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/PageBreaker.java @@ -475,11 +475,16 @@ public class PageBreaker extends AbstractBreaker { //Replace last page pslm.setCurrentPage(pageProvider.getPage(false, currentPageNum)); } else { - setLastPageIndex(currentPageNum + 1); + if (optimalPageCount > pslm.getCurrentPV().getBodyRegion().getMainReference().getColumnCount()) { + setLastPageIndex(currentPageNum + 2); + } else { + setLastPageIndex(currentPageNum + 1); + } //Last page-master cannot hold the content. //Add areas now... addAreas(alg, restartPoint, partCount - restartPoint, originalList, effectiveList); if (!ipdChange && pslm.currentPageNum == currentPageNum) { + setLastPageIndex(currentPageNum + 1); //...and add a blank last page pslm.setCurrentPage(pslm.makeNewPage(true)); } diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java index ce35a38ee..0c728517c 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java @@ -73,7 +73,7 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager /** * Store information about the inline area */ - protected class AreaInfo { + protected static class AreaInfo { /** letter space count */ protected short letterSpaces; /** ipd of area */ diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 25b68842c..66f92a7f4 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -182,7 +182,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager * which was the first element in the paragraph * returned by each LM. */ - private final class Update { + private static final class Update { private final InlineLevelLayoutManager inlineLM; private final int firstIndex; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java index 75aa3467a..5f0373629 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java @@ -32,7 +32,7 @@ public class LineLayoutPossibilities { /** logger instance */ private static final Log LOG = LogFactory.getLog(LineLayoutPossibilities.class); - private final class Possibility { + private static final class Possibility { private int lineCount; private double demerits; private List<LineLayoutManager.LineBreakPosition> breakPositions; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index a96e5706e..6fdc69749 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -69,7 +69,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { /** * this class stores information about changes in vecAreaInfo which are not yet applied */ - private final class PendingChange { + private static final class PendingChange { private final GlyphMapping mapping; private final int index; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index bc54fa1da..49e2d7562 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -85,7 +85,7 @@ public class ListItemLayoutManager extends SpacedBorderedPaddedBlockLayoutManage private Keep keepWithNextPendingOnLabel; private Keep keepWithNextPendingOnBody; - public class ListItemPosition extends Position { + public static class ListItemPosition extends Position { private int labelFirstIndex; private int labelLastIndex; private int bodyFirstIndex; diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java index 1d8cb890c..2f974c2ac 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableAndCaptionLayoutManager.java @@ -19,13 +19,33 @@ package org.apache.fop.layoutmgr.table; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.Stack; + import org.apache.fop.area.Area; import org.apache.fop.area.Block; +import org.apache.fop.area.LineArea; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.flow.table.TableAndCaption; -import org.apache.fop.layoutmgr.BlockStackingLayoutManager; -import org.apache.fop.layoutmgr.Keep; +import org.apache.fop.fo.properties.CommonBorderPaddingBackground; +import org.apache.fop.fo.properties.KeepProperty; +import org.apache.fop.layoutmgr.BreakOpportunity; +import org.apache.fop.layoutmgr.KnuthElement; +import org.apache.fop.layoutmgr.KnuthPossPosIter; +import org.apache.fop.layoutmgr.LMiter; import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.ListElement; +import org.apache.fop.layoutmgr.NonLeafPosition; +import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.SpacedBorderedPaddedBlockLayoutManager; +import org.apache.fop.layoutmgr.TraitSetter; +import org.apache.fop.traits.MinOptMax; /** * LayoutManager for a table-and-caption FO. @@ -35,130 +55,255 @@ import org.apache.fop.layoutmgr.PositionIterator; * The caption blocks have an implicit keep with the table. * TODO Implement getNextKnuthElements() */ -public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { - +public class TableAndCaptionLayoutManager extends SpacedBorderedPaddedBlockLayoutManager implements BreakOpportunity { private Block curBlockArea; + /** Iterator over the child layout managers. */ + private ProxyLMiter proxyLMiter; + /** * Create a new table and caption layout manager. - * @param node table-and-caption FO + * @param tableAndCaption the block FO object to create the layout manager for. */ - public TableAndCaptionLayoutManager(TableAndCaption node) { - super(node); + public TableAndCaptionLayoutManager(TableAndCaption tableAndCaption) { + super(tableAndCaption); + proxyLMiter = new ProxyLMiter(); } - /** - * Returns the table-and-caption formatting object. - * @return the table-and-caption formatting object - */ - public TableAndCaption getTableAndCaptionFO() { - return (TableAndCaption)this.fobj; + @Override + protected CommonBorderPaddingBackground getCommonBorderPaddingBackground() { + return getTableAndCaptionFO().getCommonBorderPaddingBackground(); + } + + public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) { + return getNextKnuthElements(context, alignment, null, null, null); + } + + public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack, + Position restartPosition, LayoutManager restartAtLM) { + resetSpaces(); + return super.getNextKnuthElements(context, alignment, lmStack, restartPosition, restartAtLM); + } + + private void resetSpaces() { + this.discardBorderBefore = false; + this.discardBorderAfter = false; + this.discardPaddingBefore = false; + this.discardPaddingAfter = false; + this.effSpaceBefore = null; + this.effSpaceAfter = null; } /** - * Get the next break possibility. - * - * @param context the layout context for getting breaks - * @return the next break possibility + * Proxy iterator for Block LM. + * This iterator creates and holds the complete list + * of child LMs. + * It uses fobjIter as its base iterator. + * Block LM's createNextChildLMs uses this iterator + * as its base iterator. */ - /* - public BreakPoss getNextBreakPoss(LayoutContext context) { - LayoutManager curLM; // currently active LM - - MinOptMax stackSize = new MinOptMax(); - // if starting add space before - // stackSize.add(spaceBefore); - BreakPoss lastPos = null; - - // if there is a caption then get the side and work out when - // to handle it - - while ((curLM = getChildLM()) != null) { - // Make break positions and return blocks! - // Set up a LayoutContext - int ipd = context.getRefIPD(); - BreakPoss bp; - - LayoutContext childLC = LayoutContext.newInstance(); - // if line layout manager then set stack limit to ipd - // line LM actually generates a LineArea which is a block - childLC.setStackLimit( - MinOptMax.subtract(context.getStackLimit(), - stackSize)); - childLC.setRefIPD(ipd); - - boolean over = false; - while (!curLM.isFinished()) { - if ((bp = curLM.getNextBreakPoss(childLC)) != null) { - if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) { - // reset to last break - if (lastPos != null) { - LayoutManager lm = lastPos.getLayoutManager(); - lm.resetPosition(lastPos.getPosition()); - if (lm != curLM) { - curLM.resetPosition(null); - } - } else { - curLM.resetPosition(null); - } - over = true; - break; - } - stackSize.add(bp.getStackingSize()); - lastPos = bp; - childBreaks.add(bp); - - if (bp.nextBreakOverflows()) { - over = true; - break; - } - - childLC.setStackLimit(MinOptMax.subtract( - context.getStackLimit(), stackSize)); - } + protected class ProxyLMiter extends LMiter { + + /** + * Constructs a proxy iterator for Block LM. + */ + public ProxyLMiter() { + super(TableAndCaptionLayoutManager.this); + listLMs = new ArrayList<>(10); + } + + /** + * @return true if there are more child lms + */ + public boolean hasNext() { + return (curPos < listLMs.size()) || createNextChildLMs(curPos); + } + + /** + * @param pos ... + * @return true if new child lms were added + */ + protected boolean createNextChildLMs(int pos) { + List<LayoutManager> newLMs = createChildLMs(pos + 1 - listLMs.size()); + if (newLMs != null) { + listLMs.addAll(newLMs); } - BreakPoss breakPoss = new BreakPoss( - new LeafPosition(this, childBreaks.size() - 1)); - if (over) { - breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true); + return pos < listLMs.size(); + } + } + + public boolean createNextChildLMs(int pos) { + while (proxyLMiter.hasNext()) { + LayoutManager lm = proxyLMiter.next(); + addChildLM(lm); + if (pos < childLMs.size()) { + return true; } - breakPoss.setStackingSize(stackSize); - return breakPoss; } - setFinished(true); - return null; - }*/ + return false; + } - /** - * Add the areas. - * - * @param parentIter the position iterator - * @param layoutContext the layout context for adding areas - */ - public void addAreas(PositionIterator parentIter, - LayoutContext layoutContext) { + public KeepProperty getKeepTogetherProperty() { + return getTableAndCaptionFO().getKeepTogether(); + } + + public KeepProperty getKeepWithPreviousProperty() { + return getTableAndCaptionFO().getKeepWithPrevious(); + } + + public KeepProperty getKeepWithNextProperty() { + return getTableAndCaptionFO().getKeepWithNext(); + } + + public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - addId(); - /* TODO: Reimplement using Knuth approach + // if this will create the first block area in a page + // and display-align is after or center, add space before + if (layoutContext.getSpaceBefore() > 0) { + addBlockSpacing(0.0, MinOptMax.getInstance(layoutContext.getSpaceBefore())); + } + LayoutManager childLM; - int iStartPos = 0; - LayoutContext lc = LayoutContext.newInstance(); + LayoutManager lastLM = null; + LayoutContext lc = LayoutContext.offspringOf(layoutContext); + lc.setSpaceAdjust(layoutContext.getSpaceAdjust()); + // set space after in the LayoutContext for children + if (layoutContext.getSpaceAfter() > 0) { + lc.setSpaceAfter(layoutContext.getSpaceAfter()); + } + PositionIterator childPosIter; + + // "unwrap" the NonLeafPositions stored in parentIter + // and put them in a new list; + LinkedList<Position> positionList = new LinkedList<>(); + Position pos; + boolean spaceBefore = false; + boolean spaceAfter = false; + Position firstPos = null; + Position lastPos = null; while (parentIter.hasNext()) { - LeafPosition lfp = (LeafPosition) parentIter.next(); - // Add the block areas to Area - PositionIterator breakPosIter = new BreakPossPosIter( - childBreaks, iStartPos, lfp.getLeafPos() + 1); - iStartPos = lfp.getLeafPos() + 1; - while ((childLM = breakPosIter.getNextChildLM()) != null) { - childLM.addAreas(breakPosIter, lc); + pos = parentIter.next(); + if (pos.getIndex() >= 0) { + if (firstPos == null) { + firstPos = pos; + } + lastPos = pos; + } + Position innerPosition = pos; + if (pos instanceof NonLeafPosition) { + //Not all elements are wrapped + innerPosition = pos.getPosition(); + } + if (innerPosition == null) { + // pos was created by this BlockLM and was inside an element + // representing space before or after + // this means the space was not discarded + if (positionList.isEmpty()) { + // pos was in the element representing space-before + spaceBefore = true; + } else { + // pos was in the element representing space-after + spaceAfter = true; + } + } else if (innerPosition.getLM() == this + && !(innerPosition instanceof MappingPosition)) { + // pos was created by this BlockLM and was inside a penalty + // allowing or forbidding a page break + // nothing to do + } else { + // innerPosition was created by another LM + positionList.add(innerPosition); + lastLM = innerPosition.getLM(); + } + } + + addId(); + + registerMarkers(true, isFirst(firstPos), isLast(lastPos)); + + if (bpUnit == 0) { + // the Positions in positionList were inside the elements + // created by the LineLM + childPosIter = new StackingIter(positionList.listIterator()); + } else { + // the Positions in positionList were inside the elements + // created by the BlockLM in the createUnitElements() method + LinkedList<KnuthElement> splitList = new LinkedList<>(); + int splitLength = 0; + int iFirst = ((MappingPosition) positionList.getFirst()).getFirstIndex(); + int iLast = ((MappingPosition) positionList.getLast()).getLastIndex(); + // copy from storedList to splitList all the elements from + // iFirst to iLast + ListIterator<KnuthElement> storedListIterator = storedList.listIterator(iFirst); + while (storedListIterator.nextIndex() <= iLast) { + KnuthElement element = storedListIterator.next(); + // some elements in storedList (i.e. penalty items) were created + // by this BlockLM, and must be ignored + if (element.getLayoutManager() != this) { + splitList.add(element); + splitLength += element.getWidth(); + lastLM = element.getLayoutManager(); + } } - }*/ + // add space before and / or after the paragraph + // to reach a multiple of bpUnit + if (spaceBefore && spaceAfter) { + adjustedSpaceBefore = (neededUnits(splitLength + + foSpaceBefore.getMin() + + foSpaceAfter.getMin()) + * bpUnit - splitLength) / 2; + adjustedSpaceAfter = neededUnits(splitLength + + foSpaceBefore.getMin() + + foSpaceAfter.getMin()) + * bpUnit - splitLength - adjustedSpaceBefore; + } else if (spaceBefore) { + adjustedSpaceBefore = neededUnits(splitLength + + foSpaceBefore.getMin()) + * bpUnit - splitLength; + } else { + adjustedSpaceAfter = neededUnits(splitLength + + foSpaceAfter.getMin()) + * bpUnit - splitLength; + } + childPosIter = new KnuthPossPosIter(splitList, 0, splitList + .size()); + } + while ((childLM = childPosIter.getNextChildLM()) != null) { + // set last area flag + lc.setFlags(LayoutContext.LAST_AREA, + (layoutContext.isLastArea() && childLM == lastLM)); + lc.setStackLimitBP(layoutContext.getStackLimitBP()); + // Add the line areas to Area + childLM.addAreas(childPosIter, lc); + } + + registerMarkers(false, isFirst(firstPos), isLast(lastPos)); + + TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), + effSpaceBefore, effSpaceAfter); flush(); - //childBreaks.clear(); curBlockArea = null; + resetSpaces(); + + //Notify end of block layout manager to the PSLM + checkEndOfLayout(lastPos); + } + + private static class StackingIter extends PositionIterator { + public StackingIter(Iterator parentIter) { + super(parentIter); + } + + protected LayoutManager getLM(Object nextObj) { + return ((Position) nextObj).getLM(); + } + + protected Position getPos(Object nextObj) { + return ((Position) nextObj); + } } /** @@ -170,54 +315,98 @@ public class TableAndCaptionLayoutManager extends BlockStackingLayoutManager { * Finally, based on the dimensions of the parent area, it initializes * its own area. This includes setting the content IPD and the maximum * BPD. - * - * @param childArea the child area to locate the parent - * @return the area for this table and caption + * @param childArea area to get the parent area for + * @return the parent area */ public Area getParentArea(Area childArea) { if (curBlockArea == null) { curBlockArea = new Block(); - curBlockArea.setChangeBarList(getChangeBarList()); - // Set up dimensions + curBlockArea.setIPD(super.getContentAreaIPD()); + + curBlockArea.setBidiLevel(getTableAndCaptionFO().getBidiLevelRecursive()); + // Must get dimensions from parent area - Area parentArea = parentLayoutManager.getParentArea(curBlockArea); - int referenceIPD = parentArea.getIPD(); - curBlockArea.setIPD(referenceIPD); - curBlockArea.setBidiLevel(getTableAndCaptionFO().getBidiLevel()); - // Get reference IPD from parentArea + //Don't optimize this line away. It can have ugly side-effects. + parentLayoutManager.getParentArea(curBlockArea); + + // set traits + TraitSetter.setProducerID(curBlockArea, getTableAndCaptionFO().getId()); + TraitSetter.addBorders(curBlockArea, + getCommonBorderPaddingBackground(), + discardBorderBefore, discardBorderAfter, false, false, this); + TraitSetter.addPadding(curBlockArea, + getCommonBorderPaddingBackground(), + discardPaddingBefore, discardPaddingAfter, false, false, this); + TraitSetter.addMargins(curBlockArea, + getCommonBorderPaddingBackground(), + startIndent, endIndent, + this); + TraitSetter.setLayer(curBlockArea, getTableAndCaptionFO().getLayer()); + curBlockArea.setLocation(FONode.getLocatorString(getTableAndCaptionFO().getLocator())); setCurrentArea(curBlockArea); // ??? for generic operations } return curBlockArea; } + public void addChildArea(Area childArea) { + if (curBlockArea != null) { + if (childArea instanceof LineArea) { + curBlockArea.addLineArea((LineArea) childArea); + } else { + curBlockArea.addBlock((Block) childArea); + } + } + } + /** - * Add the child to the current area. - * - * @param childArea the area to add + * Force current area to be added to parent area. + * {@inheritDoc} */ - public void addChildArea(Area childArea) { + protected void flush() { + if (curBlockArea != null) { + TraitSetter.addBackground(curBlockArea, getTableAndCaptionFO().getCommonBorderPaddingBackground(), this); + super.flush(); + } + } + + /** + * Returns the table-and-caption formatting object. + * @return the table-and-caption formatting object + */ + protected TableAndCaption getTableAndCaptionFO() { + return (TableAndCaption) fobj; + } + + // --------- Property Resolution related functions --------- // + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { if (curBlockArea != null) { - curBlockArea.addBlock((Block) childArea); + return curBlockArea.getIPD(); } + return super.getContentAreaIPD(); } - /** {@inheritDoc} */ - public Keep getKeepWithNext() { - return Keep.KEEP_AUTO; - /* TODO Complete me! - return KeepUtil.getCombinedBlockLevelKeepStrength( - getTableAndCaptionFO().getKeepWithNext()); - */ + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + if (curBlockArea != null) { + return curBlockArea.getBPD(); + } + return -1; } - /** {@inheritDoc} */ - public Keep getKeepWithPrevious() { - return Keep.KEEP_AUTO; - /* TODO Complete me! - return KeepUtil.getCombinedBlockLevelKeepStrength( - getTableAndCaptionFO().getKeepWithPrevious()); - */ + public boolean getGeneratesBlockArea() { + return true; } + public boolean isRestartable() { + return true; + } } diff --git a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java index a89519425..fc19f6d87 100644 --- a/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java +++ b/fop-core/src/main/java/org/apache/fop/layoutmgr/table/TableCaptionLayoutManager.java @@ -19,142 +19,265 @@ package org.apache.fop.layoutmgr.table; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; + import org.apache.fop.area.Area; import org.apache.fop.area.Block; +import org.apache.fop.area.LineArea; +import org.apache.fop.fo.FONode; import org.apache.fop.fo.flow.table.TableCaption; +import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.layoutmgr.BlockStackingLayoutManager; -import org.apache.fop.layoutmgr.Keep; +import org.apache.fop.layoutmgr.BreakOpportunity; +import org.apache.fop.layoutmgr.KnuthElement; +import org.apache.fop.layoutmgr.KnuthPossPosIter; +import org.apache.fop.layoutmgr.LMiter; import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.ListElement; +import org.apache.fop.layoutmgr.NonLeafPosition; +import org.apache.fop.layoutmgr.Position; import org.apache.fop.layoutmgr.PositionIterator; +import org.apache.fop.layoutmgr.TraitSetter; +import org.apache.fop.traits.MinOptMax; /** * LayoutManager for a table-caption FO. - * The table caption contains blocks that are placed beside the - * table. + * A table caption consists of a table caption. + * The caption contains blocks that are positioned next to the + * table on the caption side. + * The caption blocks have an implicit keep with the table. * TODO Implement getNextKnuthElements() */ -public class TableCaptionLayoutManager extends BlockStackingLayoutManager { - +public class TableCaptionLayoutManager extends BlockStackingLayoutManager implements BreakOpportunity { private Block curBlockArea; + /** Iterator over the child layout managers. */ + private ProxyLMiter proxyLMiter; + /** - * Create a new Caption layout manager. - * @param node table-caption FO + * Create a new table caption layout manager. + * @param tableCaption the block FO object to create the layout manager for. */ - public TableCaptionLayoutManager(TableCaption node) { - super(node); + public TableCaptionLayoutManager(TableCaption tableCaption) { + super(tableCaption); + proxyLMiter = new ProxyLMiter(); } - /** @return the table-caption FO */ - public TableCaption getTableCaptionFO() { - return (TableCaption)this.fobj; + public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) { + return getNextKnuthElements(context, alignment, null, null, null); } /** - * Get the next break position for the caption. - * - * @param context the layout context for finding breaks - * @return the next break possibility + * Proxy iterator for Block LM. + * This iterator creates and holds the complete list + * of child LMs. + * It uses fobjIter as its base iterator. + * Block LM's createNextChildLMs uses this iterator + * as its base iterator. */ - /* - public BreakPoss getNextBreakPoss(LayoutContext context) { - LayoutManager curLM; // currently active LM - - MinOptMax stackSize = new MinOptMax(); - // if starting add space before - // stackSize.add(spaceBefore); - BreakPoss lastPos = null; - - // if there is a caption then get the side and work out when - // to handle it - - while ((curLM = getChildLM()) != null) { - // Make break positions and return blocks! - // Set up a LayoutContext - int ipd = context.getRefIPD(); - BreakPoss bp; - - LayoutContext childLC = LayoutContext.newInstance(); - // if line layout manager then set stack limit to ipd - // line LM actually generates a LineArea which is a block - childLC.setStackLimit( - MinOptMax.subtract(context.getStackLimit(), - stackSize)); - childLC.setRefIPD(ipd); - - boolean over = false; - - while (!curLM.isFinished()) { - if ((bp = curLM.getNextBreakPoss(childLC)) != null) { - if (stackSize.opt + bp.getStackingSize().opt > context.getStackLimit().max) { - // reset to last break - if (lastPos != null) { - LayoutManager lm = lastPos.getLayoutManager(); - lm.resetPosition(lastPos.getPosition()); - if (lm != curLM) { - curLM.resetPosition(null); - } - } else { - curLM.resetPosition(null); - } - over = true; - break; - } - stackSize.add(bp.getStackingSize()); - lastPos = bp; - childBreaks.add(bp); - - if (bp.nextBreakOverflows()) { - over = true; - break; - } - - childLC.setStackLimit(MinOptMax.subtract( - context.getStackLimit(), stackSize)); - } + protected class ProxyLMiter extends LMiter { + + /** + * Constructs a proxy iterator for Block LM. + */ + public ProxyLMiter() { + super(TableCaptionLayoutManager.this); + listLMs = new ArrayList<>(10); + } + + /** + * @return true if there are more child lms + */ + public boolean hasNext() { + return (curPos < listLMs.size()) || createNextChildLMs(curPos); + } + + /** + * @param pos ... + * @return true if new child lms were added + */ + protected boolean createNextChildLMs(int pos) { + List<LayoutManager> newLMs = createChildLMs(pos + 1 - listLMs.size()); + if (newLMs != null) { + listLMs.addAll(newLMs); } - BreakPoss breakPoss = new BreakPoss( - new LeafPosition(this, childBreaks.size() - 1)); - if (over) { - breakPoss.setFlag(BreakPoss.NEXT_OVERFLOWS, true); + return pos < listLMs.size(); + } + } + + public boolean createNextChildLMs(int pos) { + while (proxyLMiter.hasNext()) { + LayoutManager lm = proxyLMiter.next(); + addChildLM(lm); + if (pos < childLMs.size()) { + return true; } - breakPoss.setStackingSize(stackSize); - return breakPoss; } - setFinished(true); - return null; - }*/ + return false; + } - /** - * Add the areas to the parent. - * - * @param parentIter the position iterator of the breaks - * @param layoutContext the layout context for adding areas - */ - public void addAreas(PositionIterator parentIter, - LayoutContext layoutContext) { + public KeepProperty getKeepTogetherProperty() { + return getTableCaptionFO().getKeepTogether(); + } + + public KeepProperty getKeepWithPreviousProperty() { + return getTableCaptionFO().getKeepWithPrevious(); + } + + public KeepProperty getKeepWithNextProperty() { + return getTableCaptionFO().getKeepWithNext(); + } + + public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { getParentArea(null); - addId(); - /* TODO: Reimplement using Knuth approach + // if this will create the first block area in a page + // and display-align is after or center, add space before + if (layoutContext.getSpaceBefore() > 0) { + addBlockSpacing(0.0, MinOptMax.getInstance(layoutContext.getSpaceBefore())); + } + LayoutManager childLM; - int iStartPos = 0; - LayoutContext lc = LayoutContext.newInstance(); + LayoutManager lastLM = null; + LayoutContext lc = LayoutContext.offspringOf(layoutContext); + lc.setSpaceAdjust(layoutContext.getSpaceAdjust()); + // set space after in the LayoutContext for children + if (layoutContext.getSpaceAfter() > 0) { + lc.setSpaceAfter(layoutContext.getSpaceAfter()); + } + PositionIterator childPosIter; + + // "unwrap" the NonLeafPositions stored in parentIter + // and put them in a new list; + LinkedList<Position> positionList = new LinkedList<>(); + Position pos; + boolean spaceBefore = false; + boolean spaceAfter = false; + Position firstPos = null; + Position lastPos = null; while (parentIter.hasNext()) { - LeafPosition lfp = (LeafPosition) parentIter.next(); - // Add the block areas to Area - PositionIterator breakPosIter = new BreakPossPosIter( - childBreaks, iStartPos, lfp.getLeafPos() + 1); - iStartPos = lfp.getLeafPos() + 1; - while ((childLM = breakPosIter.getNextChildLM()) != null) { - childLM.addAreas(breakPosIter, lc); + pos = parentIter.next(); + if (pos.getIndex() >= 0) { + if (firstPos == null) { + firstPos = pos; + } + lastPos = pos; + } + Position innerPosition = pos; + if (pos instanceof NonLeafPosition) { + //Not all elements are wrapped + innerPosition = pos.getPosition(); + } + if (innerPosition == null) { + // pos was created by this BlockLM and was inside an element + // representing space before or after + // this means the space was not discarded + if (positionList.isEmpty()) { + // pos was in the element representing space-before + spaceBefore = true; + } else { + // pos was in the element representing space-after + spaceAfter = true; + } + } else if (innerPosition.getLM() == this + && !(innerPosition instanceof MappingPosition)) { + // pos was created by this BlockLM and was inside a penalty + // allowing or forbidding a page break + // nothing to do + } else { + // innerPosition was created by another LM + positionList.add(innerPosition); + lastLM = innerPosition.getLM(); + } + } + + addId(); + + registerMarkers(true, isFirst(firstPos), isLast(lastPos)); + + if (bpUnit == 0) { + // the Positions in positionList were inside the elements + // created by the LineLM + childPosIter = new StackingIter(positionList.listIterator()); + } else { + // the Positions in positionList were inside the elements + // created by the BlockLM in the createUnitElements() method + LinkedList<KnuthElement> splitList = new LinkedList<>(); + int splitLength = 0; + int iFirst = ((MappingPosition) positionList.getFirst()).getFirstIndex(); + int iLast = ((MappingPosition) positionList.getLast()).getLastIndex(); + // copy from storedList to splitList all the elements from + // iFirst to iLast + ListIterator<KnuthElement> storedListIterator = storedList.listIterator(iFirst); + while (storedListIterator.nextIndex() <= iLast) { + KnuthElement element = storedListIterator.next(); + // some elements in storedList (i.e. penalty items) were created + // by this BlockLM, and must be ignored + if (element.getLayoutManager() != this) { + splitList.add(element); + splitLength += element.getWidth(); + lastLM = element.getLayoutManager(); + } + } + // add space before and / or after the paragraph + // to reach a multiple of bpUnit + if (spaceBefore && spaceAfter) { + adjustedSpaceBefore = (neededUnits(splitLength + + foSpaceBefore.getMin() + + foSpaceAfter.getMin()) + * bpUnit - splitLength) / 2; + adjustedSpaceAfter = neededUnits(splitLength + + foSpaceBefore.getMin() + + foSpaceAfter.getMin()) + * bpUnit - splitLength - adjustedSpaceBefore; + } else if (spaceBefore) { + adjustedSpaceBefore = neededUnits(splitLength + + foSpaceBefore.getMin()) + * bpUnit - splitLength; + } else { + adjustedSpaceAfter = neededUnits(splitLength + + foSpaceAfter.getMin()) + * bpUnit - splitLength; } - }*/ + childPosIter = new KnuthPossPosIter(splitList, 0, splitList + .size()); + } + + while ((childLM = childPosIter.getNextChildLM()) != null) { + // set last area flag + lc.setFlags(LayoutContext.LAST_AREA, + (layoutContext.isLastArea() && childLM == lastLM)); + lc.setStackLimitBP(layoutContext.getStackLimitBP()); + // Add the line areas to Area + childLM.addAreas(childPosIter, lc); + } + registerMarkers(false, isFirst(firstPos), isLast(lastPos)); flush(); - //childBreaks.clear(); curBlockArea = null; + + //Notify end of block layout manager to the PSLM + checkEndOfLayout(lastPos); + } + + private static class StackingIter extends PositionIterator { + public StackingIter(Iterator parentIter) { + super(parentIter); + } + + protected LayoutManager getLM(Object nextObj) { + return ((Position) nextObj).getLM(); + } + + protected Position getPos(Object nextObj) { + return ((Position) nextObj); + } } /** @@ -166,55 +289,77 @@ public class TableCaptionLayoutManager extends BlockStackingLayoutManager { * Finally, based on the dimensions of the parent area, it initializes * its own area. This includes setting the content IPD and the maximum * BPD. - * - * @param childArea the child area - * @return the parent area from this caption + * @param childArea area to get the parent area for + * @return the parent area */ public Area getParentArea(Area childArea) { if (curBlockArea == null) { curBlockArea = new Block(); - curBlockArea.setChangeBarList(getChangeBarList()); - // Set up dimensions + curBlockArea.setIPD(super.getContentAreaIPD()); + + curBlockArea.setBidiLevel(getTableCaptionFO().getBidiLevelRecursive()); + // Must get dimensions from parent area - Area parentArea = parentLayoutManager.getParentArea(curBlockArea); - int referenceIPD = parentArea.getIPD(); - curBlockArea.setIPD(referenceIPD); - curBlockArea.setBidiLevel(getTableCaptionFO().getBidiLevel()); - // Get reference IPD from parentArea + //Don't optimize this line away. It can have ugly side-effects. + parentLayoutManager.getParentArea(curBlockArea); + + // set traits + TraitSetter.setProducerID(curBlockArea, getTableCaptionFO().getId()); + TraitSetter.setLayer(curBlockArea, getTableCaptionFO().getLayer()); + curBlockArea.setLocation(FONode.getLocatorString(getTableCaptionFO().getLocator())); setCurrentArea(curBlockArea); // ??? for generic operations } return curBlockArea; } - /** - * Add the child to the caption area. - * - * @param childArea the child area to add - */ public void addChildArea(Area childArea) { if (curBlockArea != null) { + if (childArea instanceof LineArea) { + curBlockArea.addLineArea((LineArea) childArea); + } else { curBlockArea.addBlock((Block) childArea); + } } } - /** {@inheritDoc} */ - public Keep getKeepWithNext() { - return Keep.KEEP_AUTO; - /* TODO Complete me! - return KeepUtil.getCombinedBlockLevelKeepStrength( - getTableCaptionFO().getKeepWithNext()); - */ + /** + * Returns the table-caption formatting object. + * @return the table-caption formatting object + */ + protected TableCaption getTableCaptionFO() { + return (TableCaption) fobj; } - /** {@inheritDoc} */ - public Keep getKeepWithPrevious() { - return Keep.KEEP_AUTO; - /* TODO Complete me! - return KeepUtil.getCombinedBlockLevelKeepStrength( - getTableCaptionFO().getKeepWithPrevious()); - */ + // --------- Property Resolution related functions --------- // + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + if (curBlockArea != null) { + return curBlockArea.getIPD(); + } + return super.getContentAreaIPD(); } -} + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + if (curBlockArea != null) { + return curBlockArea.getBPD(); + } + return -1; + } + public boolean getGeneratesBlockArea() { + return true; + } + + public boolean isRestartable() { + return true; + } +} diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java index 7ebb0ffd6..c2080f0d0 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java @@ -23,6 +23,7 @@ package org.apache.fop.pdf; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; @@ -847,13 +848,13 @@ public class PDFDocument { } try { MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] thedigest = md.digest(key.getBytes("UTF-8")); + byte[] thedigest = md.digest(key.getBytes(StandardCharsets.UTF_8)); StringBuilder hex = new StringBuilder(); for (byte b : thedigest) { hex.append(String.format("%02x", b)); } return hex.toString(); - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFEncoding.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFEncoding.java index 64fd6f866..4bd1ac57e 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFEncoding.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFEncoding.java @@ -146,7 +146,7 @@ public class PDFEncoding extends PDFDictionary { /** * Builder class for constructing the Differences array. */ - public class DifferencesBuilder { + public static class DifferencesBuilder { private int currentCode = -1; diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFEncryptionJCE.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFEncryptionJCE.java index edebbb23a..7517646e5 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFEncryptionJCE.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFEncryptionJCE.java @@ -21,7 +21,7 @@ package org.apache.fop.pdf; import java.io.IOException; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.MessageDigest; @@ -332,19 +332,15 @@ public final class PDFEncryptionJCE extends PDFObject implements PDFEncryption { protected byte[] preparePassword(String password) { int finalLength = 32; byte[] preparedPassword = new byte[finalLength]; - try { - byte[] passwordBytes = password.getBytes("UTF-8"); - if (passwordBytes.length >= finalLength) { - System.arraycopy(passwordBytes, 0, preparedPassword, 0, finalLength); - } else { - System.arraycopy(passwordBytes, 0, preparedPassword, 0, passwordBytes.length); - System.arraycopy(padding, 0, preparedPassword, passwordBytes.length, finalLength - - passwordBytes.length); - } - return preparedPassword; - } catch (UnsupportedEncodingException e) { - throw new UnsupportedOperationException(e); + byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8); + if (passwordBytes.length >= finalLength) { + System.arraycopy(passwordBytes, 0, preparedPassword, 0, finalLength); + } else { + System.arraycopy(passwordBytes, 0, preparedPassword, 0, passwordBytes.length); + System.arraycopy(padding, 0, preparedPassword, passwordBytes.length, finalLength + - passwordBytes.length); } + return preparedPassword; } void run() { @@ -548,20 +544,16 @@ public final class PDFEncryptionJCE extends PDFObject implements PDFEncryption { protected byte[] preparePassword(String password) { byte[] passwordBytes; byte[] preparedPassword; - try { - // the password needs to be normalized first but we are bypassing that step for now - passwordBytes = password.getBytes("UTF-8"); - if (passwordBytes.length > 127) { - preparedPassword = new byte[127]; - System.arraycopy(passwordBytes, 0, preparedPassword, 0, 127); - } else { - preparedPassword = new byte[passwordBytes.length]; - System.arraycopy(passwordBytes, 0, preparedPassword, 0, passwordBytes.length); - } - return preparedPassword; - } catch (UnsupportedEncodingException e) { - throw new UnsupportedOperationException(e.getMessage()); + // the password needs to be normalized first but we are bypassing that step for now + passwordBytes = password.getBytes(StandardCharsets.UTF_8); + if (passwordBytes.length > 127) { + preparedPassword = new byte[127]; + System.arraycopy(passwordBytes, 0, preparedPassword, 0, 127); + } else { + preparedPassword = new byte[passwordBytes.length]; + System.arraycopy(passwordBytes, 0, preparedPassword, 0, passwordBytes.length); } + return preparedPassword; } /** diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFLinearization.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFLinearization.java index f071c6250..dc294b307 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFLinearization.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFLinearization.java @@ -21,6 +21,7 @@ package org.apache.fop.pdf; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -312,7 +313,7 @@ public class PDFLinearization { private static void writePadding(int padding, OutputStream stream) throws IOException { for (int i = 0; i < padding; i++) { - stream.write(" ".getBytes("UTF-8")); + stream.write(" ".getBytes(StandardCharsets.UTF_8)); } } diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFLink.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFLink.java index e0426a454..766520632 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFLink.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFLink.java @@ -21,6 +21,7 @@ package org.apache.fop.pdf; // Java import java.awt.geom.Rectangle2D; +import java.nio.charset.StandardCharsets; import java.util.Set; /** @@ -103,7 +104,12 @@ public class PDFLink extends PDFObject { if (action instanceof PDFUri) { String altText = ((PDFUri) action).getAltText(); if (altText != null && !altText.isEmpty()) { - dict += "/Contents " + PDFText.escapeText(altText) + "\n"; + if (getDocumentSafely().isEncryptionActive()) { + altText = new String(encodeText(altText), StandardCharsets.ISO_8859_1); + } else { + altText = PDFText.escapeText(altText); + } + dict += "/Contents " + altText + "\n"; } } dict += fFlag + "\n>>"; diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFSignature.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFSignature.java index f5384be53..bdcc07bc0 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFSignature.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFSignature.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.PrivateKey; @@ -208,8 +209,8 @@ public class PDFSignature { .replace("\0", " "); try (OutputStream editedPDF = getTempOS()) { IOUtils.copyLarge(pdfIS, editedPDF, 0, startOfContents); - editedPDF.write(byteRange.getBytes("UTF-8")); - editedPDF.write(byteRangePadding.getBytes("UTF-8")); + editedPDF.write(byteRange.getBytes(StandardCharsets.UTF_8)); + editedPDF.write(byteRangePadding.getBytes(StandardCharsets.UTF_8)); IOUtils.copyLarge(pdfIS, editedPDF, offsetToPDFEnd - startOfContents, Long.MAX_VALUE); } pdfIS.reset(); @@ -219,10 +220,10 @@ public class PDFSignature { String signedHexPadding = new String(new char[SIZE_OF_CONTENTS - (signed.length * 2)]) .replace("\0", "0"); String signedHex = "<" + PDFText.toHex(signed, false) + signedHexPadding + ">"; - os.write(signedHex.getBytes("UTF-8")); + os.write(signedHex.getBytes(StandardCharsets.UTF_8)); } - os.write(byteRange.getBytes("UTF-8")); - os.write(byteRangePadding.getBytes("UTF-8")); + os.write(byteRange.getBytes(StandardCharsets.UTF_8)); + os.write(byteRangePadding.getBytes(StandardCharsets.UTF_8)); IOUtils.copyLarge(pdfIS, os, offsetToPDFEnd - startOfContents, Long.MAX_VALUE); } } diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFText.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFText.java index 749bf5a30..d088f355f 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFText.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFText.java @@ -21,6 +21,7 @@ package org.apache.fop.pdf; import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; import java.util.Locale; import org.apache.fop.util.CharUtilities; @@ -99,12 +100,7 @@ public class PDFText extends PDFObject { } if (hexMode) { - final byte[] uniBytes; - try { - uniBytes = text.getBytes("UTF-16"); - } catch (java.io.UnsupportedEncodingException uee) { - throw new RuntimeException("Incompatible VM", uee); - } + final byte[] uniBytes = text.getBytes(StandardCharsets.UTF_16); return toHex(uniBytes); } else { final StringBuffer result = new StringBuffer(text.length() * 2); @@ -192,13 +188,8 @@ public class PDFText extends PDFObject { */ public static final String toUnicodeHex(char c) { final StringBuffer buf = new StringBuffer(4); - final byte[] uniBytes; - try { - final char[] a = {c}; - uniBytes = new String(a).getBytes("UTF-16BE"); - } catch (java.io.UnsupportedEncodingException uee) { - throw new RuntimeException("Incompatible VM", uee); - } + final char[] a = {c}; + final byte[] uniBytes = new String(a).getBytes(StandardCharsets.UTF_16BE); for (byte uniByte : uniBytes) { buf.append(DIGITS[(uniByte >>> 4) & 0x0F]); diff --git a/fop-core/src/main/java/org/apache/fop/render/awt/viewer/PreviewPanel.java b/fop-core/src/main/java/org/apache/fop/render/awt/viewer/PreviewPanel.java index 93cc29e4f..97abb9565 100644 --- a/fop-core/src/main/java/org/apache/fop/render/awt/viewer/PreviewPanel.java +++ b/fop-core/src/main/java/org/apache/fop/render/awt/viewer/PreviewPanel.java @@ -279,7 +279,7 @@ public class PreviewPanel extends JPanel { /** * Allows any mouse drag on the page area to scroll the display window. */ - private class ViewportScroller implements MouseListener, MouseMotionListener { + private static class ViewportScroller implements MouseListener, MouseMotionListener { /** The viewport to be scrolled */ private final JViewport viewport; /** Starting position of a mouse drag - X co-ordinate */ diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java index 9a4960bb9..db920cc7c 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java @@ -19,6 +19,10 @@ package org.apache.fop.render.intermediate.extensions; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; @@ -47,7 +51,23 @@ public class URIAction extends AbstractAction implements DocumentNavigationExten this.uri = uri; this.newWindow = newWindow; this.altText = altText; - setID(getIDPrefix() + (uri + newWindow).hashCode()); + setID(createID(getIDPrefix(), uri + newWindow)); + } + + private String createID(String idPrefix, String url) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] thedigest = md.digest(url.getBytes(StandardCharsets.UTF_8)); + + StringBuilder hex = new StringBuilder(); + for (byte b : thedigest) { + hex.append(String.format("%02x", b)); + } + + return idPrefix + hex; + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException("MD5 algorithm not found", e); + } } /** diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java b/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java index 8a4258bfc..8704c5e5d 100644 --- a/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java +++ b/fop-core/src/main/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java @@ -118,11 +118,12 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter { // here we need to inflate the PNG pixel data, which includes alpha, separate the alpha channel
// and then deflate it back again
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- BufferedOutputStream dos = new BufferedOutputStream(new DeflaterOutputStream(baos, new Deflater()));
- InputStream in = ((ImageRawStream) image).createInputStream();
- try {
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ InputStream in = null;
+ DataInputStream dataStream = null;
+ try (BufferedOutputStream dos = new BufferedOutputStream(
+ new DeflaterOutputStream(baos, new Deflater()))) {
+ in = ((ImageRawStream) image).createInputStream();
+ dataStream = new DataInputStream(new InflaterInputStream(in, new Inflater()));
// offset is the byte offset of the alpha component
int offset = numberOfInterleavedComponents - 1; // 1 for GA, 3 for RGBA
int numColumns = image.getSize().getWidthPx();
@@ -139,11 +140,11 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter { }
offset = numberOfInterleavedComponents - 1;
}
- dos.close();
} catch (IOException e) {
- throw new RuntimeException("Error processing transparency channel:", e);
+ throw new RuntimeException("Error processing transparency channel: " + getKey(), e);
} finally {
IOUtils.closeQuietly(in);
+ IOUtils.closeQuietly(dataStream);
}
// set up alpha channel compression
FlateFilter transFlate;
@@ -211,6 +212,7 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter { public void outputContents(OutputStream out) throws IOException {
InputStream in = ((ImageRawStream) image).createInputStream();
+ DataInputStream dataStream = null;
try {
if (numberOfInterleavedComponents == 1 || numberOfInterleavedComponents == 3) {
// means we have Gray, RGB, or Palette
@@ -220,8 +222,8 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter { // TODO: since we have alpha here do this when the alpha channel is extracted
int numBytes = numberOfInterleavedComponents - 1; // 1 for Gray, 3 for RGB
int numColumns = image.getSize().getWidthPx();
- InflaterInputStream infStream = new InflaterInputStream(in, new Inflater());
- DataInputStream dataStream = new DataInputStream(infStream);
+ dataStream = new DataInputStream(new InflaterInputStream(in, new Inflater()));
+
int offset = 0;
int bytesPerRow = numberOfInterleavedComponents * numColumns;
int filter;
@@ -242,6 +244,7 @@ public class ImageRawPNGAdapter extends AbstractImageAdapter { }
} finally {
IOUtils.closeQuietly(in);
+ IOUtils.closeQuietly(dataStream);
}
}
diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSBatikFlowTextElementBridge.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSBatikFlowTextElementBridge.java index a09f55bec..41467a975 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSBatikFlowTextElementBridge.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSBatikFlowTextElementBridge.java @@ -64,7 +64,7 @@ public class PSBatikFlowTextElementBridge extends BatikFlowTextElementBridge { return this.textPainter; } - private class PSFlowExtTextPainter extends PSTextPainter { + private static class PSFlowExtTextPainter extends PSTextPainter { /** * Main constructor diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSSVGFlowRootElementBridge.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSSVGFlowRootElementBridge.java index df9e22053..3e33183a0 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSSVGFlowRootElementBridge.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSSVGFlowRootElementBridge.java @@ -64,7 +64,7 @@ public class PSSVGFlowRootElementBridge extends SVGFlowRootElementBridge { return this.textPainter; } - private class PSFlowTextPainter extends PSTextPainter { + private static class PSFlowTextPainter extends PSTextPainter { /** * Main constructor diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java b/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java index 3a2d80d5e..08960172a 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/RTFHandler.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.Iterator; import java.util.Map; @@ -186,7 +187,7 @@ public class RTFHandler extends FOEventHandler { public void startDocument() throws SAXException { // TODO sections should be created try { - rtfFile = new RtfFile(new OutputStreamWriter(os)); + rtfFile = new RtfFile(new OutputStreamWriter(os, StandardCharsets.UTF_8)); docArea = rtfFile.startDocumentArea(); } catch (IOException ioe) { // TODO could we throw Exception in all FOEventHandler events? @@ -1002,7 +1003,7 @@ public class RTFHandler extends FOEventHandler { RtfListItem item = (RtfListItem)builderContext.getContainer(RtfListItem.class, true, this); - RtfListItemLabel label = item.new RtfListItemLabel(item); + RtfListItemLabel label = new RtfListItem.RtfListItemLabel(item); builderContext.pushContainer(label); } catch (IOException ioe) { handleIOTrouble(ioe); diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java index 2c4e0807a..3c9906f73 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java @@ -27,10 +27,11 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; */ import java.io.BufferedWriter; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.charset.StandardCharsets; import org.apache.fop.render.rtf.rtflib.exceptions.RtfStructureException; @@ -234,10 +235,10 @@ extends RtfContainer { if (args.length != 0) { final String outFile = args[0]; System.err.println("Outputting RTF to file '" + outFile + "'"); - w = new BufferedWriter(new FileWriter(outFile)); + w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), StandardCharsets.UTF_8)); } else { System.err.println("Outputting RTF code to standard output"); - w = new BufferedWriter(new OutputStreamWriter(System.out)); + w = new BufferedWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8)); } final RtfFile f = new RtfFile(w); diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListItem.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListItem.java index 0b365bb15..23f9f4a1f 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListItem.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfListItem.java @@ -64,7 +64,7 @@ public class RtfListItem extends RtfContainer /** * special RtfTextrun that is used as list item label */ - public class RtfListItemLabel extends RtfTextrun implements IRtfTextrunContainer { + public static class RtfListItemLabel extends RtfTextrun implements IRtfTextrunContainer { private RtfListItem rtfListItem; diff --git a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java index 9758ab0b4..d034cabd8 100644 --- a/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java +++ b/fop-core/src/main/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java @@ -61,7 +61,7 @@ public class RtfTextrun extends RtfContainer { private RtfSpaceManager rtfSpaceManager = new RtfSpaceManager(); /** Class which represents the opening of a RTF group mark.*/ - private class RtfOpenGroupMark extends RtfElement { + private static class RtfOpenGroupMark extends RtfElement { RtfOpenGroupMark(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException { @@ -86,7 +86,7 @@ public class RtfTextrun extends RtfContainer { } /** Class which represents the closing of a RTF group mark.*/ - private class RtfCloseGroupMark extends RtfElement { + private static class RtfCloseGroupMark extends RtfElement { private int breakType = BREAK_NONE; RtfCloseGroupMark(RtfContainer parent, Writer w, int breakType) diff --git a/fop-core/src/main/java/org/apache/fop/render/txt/TXTStream.java b/fop-core/src/main/java/org/apache/fop/render/txt/TXTStream.java index 44a237b34..85639e29c 100644 --- a/fop-core/src/main/java/org/apache/fop/render/txt/TXTStream.java +++ b/fop-core/src/main/java/org/apache/fop/render/txt/TXTStream.java @@ -21,13 +21,14 @@ package org.apache.fop.render.txt; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; /** * Helper class for text streams. */ public class TXTStream { - private static final String DEFAULT_ENCODING = "UTF-8"; + private static final String DEFAULT_ENCODING = StandardCharsets.UTF_8.name(); private OutputStream out; private boolean doOutput = true; @@ -68,7 +69,7 @@ public class TXTStream { /** * Set the encoding for the text stream. - * @param encoding the encoding, if null, "UTF-8" is chosen as default + * @param encoding the encoding, if null, StandardCharsets.UTF_8 is chosen as default */ public void setEncoding(String encoding) { if (encoding != null) { diff --git a/fop-core/src/main/java/org/apache/fop/render/txt/TxtRendererConfig.java b/fop-core/src/main/java/org/apache/fop/render/txt/TxtRendererConfig.java index 76128d42b..a8afffc06 100644 --- a/fop-core/src/main/java/org/apache/fop/render/txt/TxtRendererConfig.java +++ b/fop-core/src/main/java/org/apache/fop/render/txt/TxtRendererConfig.java @@ -19,6 +19,7 @@ package org.apache.fop.render.txt; +import java.nio.charset.StandardCharsets; import java.util.EnumMap; import org.apache.fop.apps.FOPException; @@ -37,7 +38,7 @@ import org.apache.fop.render.RendererConfigOption; public final class TxtRendererConfig implements RendererConfig { public enum TxtRendererOption implements RendererConfigOption { - ENCODING("encoding", "UTF-8"); + ENCODING("encoding", StandardCharsets.UTF_8.name()); private final String name; private final Object defaultValue; diff --git a/fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java b/fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java index 931f02819..c27b4d087 100644 --- a/fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java +++ b/fop-core/src/main/java/org/apache/fop/tools/anttasks/FileCompare.java @@ -21,8 +21,11 @@ package org.apache.fop.tools.anttasks; import java.io.BufferedInputStream; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.util.Date; import java.util.List; @@ -170,8 +173,8 @@ public class FileCompare { File oldFile; File newFile; try { - PrintWriter results - = new PrintWriter(new java.io.FileWriter("results.html"), true); + PrintWriter results = new PrintWriter(new OutputStreamWriter(new FileOutputStream("results.html"), + StandardCharsets.UTF_8)); this.writeHeader(results); for (String aFilenameList : filenameList) { oldFile = new File(referenceDirectory + aFilenameList); diff --git a/fop-core/src/main/java/org/apache/fop/util/AbstractPaintingState.java b/fop-core/src/main/java/org/apache/fop/util/AbstractPaintingState.java index 8368383ba..b2d9f92de 100644 --- a/fop-core/src/main/java/org/apache/fop/util/AbstractPaintingState.java +++ b/fop-core/src/main/java/org/apache/fop/util/AbstractPaintingState.java @@ -385,7 +385,7 @@ public abstract class AbstractPaintingState implements Cloneable, Serializable { * A stack implementation which holds state objects */ // @SuppressFBWarnings("SE_INNER_CLASS") - public class StateStack<E> extends java.util.Stack<E> { + public static class StateStack<E> extends java.util.Stack<E> { private static final long serialVersionUID = 4897178211223823041L; diff --git a/fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java b/fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java index 57443e15d..e604e5619 100644 --- a/fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -183,7 +184,8 @@ public class FO2StructureTreeConverterTestCase { @Test public void testRemoveTableHeader() throws Exception { keepEmptyTags = false; - String fo = IOUtils.toString(getResource("table-artifact.fo"), "utf8").replace("role=\"artifact\"", ""); + String fo = IOUtils.toString(getResource("table-artifact.fo"), StandardCharsets.UTF_8) + .replace("role=\"artifact\"", ""); compare(fo, "<structure-tree-sequence>\n" + "<structure-tree xmlns=\"http://xmlgraphics.apache.org/fop/intermediate\" " + "xmlns:foi=\"http://xmlgraphics.apache.org/fop/internal\" " diff --git a/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java b/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java index f4c64d9f0..3c696164f 100644 --- a/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java @@ -18,6 +18,8 @@ /* $Id$ */ package org.apache.fop.afp.fonts; +import java.nio.charset.StandardCharsets; + import org.junit.Assert; import org.junit.Test; @@ -33,7 +35,8 @@ public class OutlineFontTestCase { } public static CharacterSet getCharacterSet() { - CharacterSet characterSet = new CharacterSet("00000000", "utf-8", CharacterSetType.SINGLE_BYTE, "", null, null); + CharacterSet characterSet = new CharacterSet("00000000", StandardCharsets.UTF_8.name(), + CharacterSetType.SINGLE_BYTE, "", null, null); characterSet.addCharacterSetOrientation(new CharacterSetOrientation(0, 0, 0, 0)); return characterSet; } diff --git a/fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java b/fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java index e99a83260..c337aa715 100644 --- a/fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java +++ b/fop-core/src/test/java/org/apache/fop/apps/FopConfBuilder.java @@ -24,8 +24,8 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; import java.lang.reflect.InvocationTargetException; +import java.nio.charset.StandardCharsets; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -309,13 +309,11 @@ public class FopConfBuilder implements FontConfigurator<FopConfBuilder> { transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.name()); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); try { transformer.transform(new DOMSource(fopConfDOM), - new StreamResult(new OutputStreamWriter(out, "UTF-8"))); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); + new StreamResult(new OutputStreamWriter(out, StandardCharsets.UTF_8))); } catch (TransformerException e) { throw new RuntimeException(e); } diff --git a/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java b/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java index 9c2cd78e0..837ad8025 100644 --- a/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java +++ b/fop-core/src/test/java/org/apache/fop/complexscripts/scripts/arabic/GenerateArabicTestData.java @@ -28,7 +28,7 @@ import java.io.InputStreamReader; import java.io.LineNumberReader; import java.io.ObjectOutputStream; import java.nio.IntBuffer; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -104,7 +104,7 @@ public final class GenerateArabicTestData implements ArabicWordFormsConstants { FileInputStream fis = null; try { fis = new FileInputStream(spn); - LineNumberReader lr = new LineNumberReader(new InputStreamReader(fis, Charset.forName("UTF-8"))); + LineNumberReader lr = new LineNumberReader(new InputStreamReader(fis, StandardCharsets.UTF_8)); String wf; while ((wf = lr.readLine()) != null) { GlyphSequence igs = tf.mapCharsToGlyphs(wf); diff --git a/fop-core/src/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java b/fop-core/src/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java deleted file mode 100644 index 1a5e38291..000000000 --- a/fop-core/src/test/java/org/apache/fop/fo/flow/table/UnimplementedWarningNeutralizer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.fo.flow.table; - -/** - * This class aims at easing testing, by preventing the event notification system from - * getting in the way just to issue an Unimplemented Feature warning. - */ -public final class UnimplementedWarningNeutralizer { - - private UnimplementedWarningNeutralizer() { } - - /** - * Neutralizes Unimplemented Feature events from the {@link TableAndCaption} and - * {@link TableCaption} classes. - */ - public static void neutralizeUnimplementedWarning() { - TableAndCaption.notImplementedWarningGiven = true; - TableCaption.notImplementedWarningGiven = true; - } -} diff --git a/fop-core/src/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java b/fop-core/src/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java index 81ebc2f41..008ab0580 100644 --- a/fop-core/src/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fo/properties/CommonAccessibilityHolderTestCase.java @@ -34,7 +34,6 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FONodeMocks; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; -import org.apache.fop.fo.flow.table.UnimplementedWarningNeutralizer; /** * This tests that all the FONodes that implement CommonAccessibilityHolder correctly configure @@ -50,10 +49,6 @@ public class CommonAccessibilityHolderTestCase { private final String sourceDocument = "source document"; static { - /* This triggers 'unimplemented feature' FO validation events so that the event system is - * not triggered when testing, avoiding extra convoluted dependency stubbing. */ - UnimplementedWarningNeutralizer.neutralizeUnimplementedWarning(); - IMPLEMENTATIONS.add(org.apache.fop.fo.flow.BasicLink.class); IMPLEMENTATIONS.add(org.apache.fop.fo.flow.Block.class); IMPLEMENTATIONS.add(org.apache.fop.fo.pagination.bookmarks.Bookmark.class); diff --git a/fop-core/src/test/java/org/apache/fop/fonts/autodetect/FontFileFinderTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/autodetect/FontFileFinderTestCase.java index b9782e672..ab9e587d2 100644 --- a/fop-core/src/test/java/org/apache/fop/fonts/autodetect/FontFileFinderTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fonts/autodetect/FontFileFinderTestCase.java @@ -29,12 +29,15 @@ import java.nio.file.spi.FileSystemProvider; import org.junit.Test; +import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.apache.fop.fonts.FontEventListener; + public class FontFileFinderTestCase { @Test @@ -63,6 +66,26 @@ public class FontFileFinderTestCase { verify(linkDirectory.toPath(), times(2)).toRealPath(); } + @Test + public void testNullEventListener() throws IOException { + FontFileFinder finder = new FontFileFinder(null); + try { + finder.find(new File("")); + } catch (NullPointerException e) { + fail("Should not throw NullPointerException when event listener is null"); + } + } + + @Test + public void testValidEventListener() throws IOException { + FontEventListener mockListener = mock(FontEventListener.class); + FontFileFinder finder = new FontFileFinder(mockListener); + + finder.find(new File("")); + + verify(mockListener, times(1)).fontDirectoryNotFound(any(), any()); + } + private File createMockDirectory(String path) throws IOException { Path mockRealPath = mock(Path.class); when(mockRealPath.toString()).thenReturn(path); diff --git a/fop-core/src/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java b/fop-core/src/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java index 18d15c384..d3345a893 100644 --- a/fop-core/src/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java +++ b/fop-core/src/test/java/org/apache/fop/pdf/PDFEncryptionJCETestCase.java @@ -22,6 +22,7 @@ package org.apache.fop.pdf; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.MessageDigest; @@ -460,7 +461,7 @@ public class PDFEncryptionJCETestCase { IllegalBlockSizeException, BadPaddingException { MessageDigest sha256 = MessageDigest.getInstance("SHA-256"); String dataText = "Test data to encrypt."; - byte[] data = dataText.getBytes("UTF-8"); + byte[] data = dataText.getBytes(StandardCharsets.UTF_8); PDFEncryptionParams params = new PDFEncryptionParams(); params.setEncryptionLengthInBits(256); params.setUserPassword("userpassword"); @@ -486,7 +487,7 @@ public class PDFEncryptionJCETestCase { byte[] userKeySalt = new byte[8]; System.arraycopy(u, 32, userValSalt, 0, 8); System.arraycopy(u, 40, userKeySalt, 0, 8); - byte[] uPassBytes = params.getUserPassword().getBytes("UTF-8"); + byte[] uPassBytes = params.getUserPassword().getBytes(StandardCharsets.UTF_8); byte[] testUPass = new byte[uPassBytes.length + 8]; System.arraycopy(uPassBytes, 0, testUPass, 0, uPassBytes.length); System.arraycopy(userValSalt, 0, testUPass, uPassBytes.length, 8); @@ -501,7 +502,7 @@ public class PDFEncryptionJCETestCase { byte[] ownerKeySalt = new byte[8]; System.arraycopy(o, 32, ownerValSalt, 0, 8); System.arraycopy(o, 40, ownerKeySalt, 0, 8); - byte[] oPassBytes = params.getOwnerPassword().getBytes("UTF-8"); + byte[] oPassBytes = params.getOwnerPassword().getBytes(StandardCharsets.UTF_8); byte[] testOPass = new byte[oPassBytes.length + 8 + 48]; System.arraycopy(oPassBytes, 0, testOPass, 0, oPassBytes.length); System.arraycopy(ownerValSalt, 0, testOPass, oPassBytes.length, 8); diff --git a/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java b/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java index 9aeef7807..baa39d830 100644 --- a/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java @@ -27,9 +27,11 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.nio.charset.StandardCharsets; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -283,14 +285,69 @@ public class PDFFactoryTestCase { } @Test - public void testLinkAltText() throws IOException { + public void testNullLinkAltText() throws IOException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + defaultLinkAltText(bos, false, null); + + assertFalse("If the alt text is null, it should not be added to the dictionary", + bos.toString().contains("/Contents")); + + defaultLinkAltText(bos, false, null); + assertFalse("If the alt text is null, it should not be added to the dictionary", + bos.toString().contains("/Contents")); + } + + @Test + public void testEmptyLinkAltText() throws IOException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + defaultLinkAltText(bos, false, ""); + + assertFalse("If the alt text is empty, it should not be added to the dictionary", + bos.toString().contains("/Contents")); + + defaultLinkAltText(bos, false, ""); + assertFalse("If the alt text is empty, it should not be added to the dictionary", + bos.toString().contains("/Contents")); + } + + @Test + public void testValidLinkAltText() throws IOException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + String altText = defaultLinkAltText(bos, false, "b"); + assertTrue("Alt Text must not use the encryption", + bos.toString().contains("/Contents (" + altText + ")")); + + String encryptedAltText = defaultLinkAltText(bos, true, "b"); + assertTrue("Alt Text must use the encryption", + bos.toString().contains("/Contents " + encryptedAltText)); + } + + private String defaultLinkAltText(ByteArrayOutputStream bos, boolean useEncryption, String originalAltText) + throws IOException { PDFDocument doc = new PDFDocument(""); + if (useEncryption) { + doc.setEncryption(new PDFEncryptionParams("", "", true, true, true, true, true)); + } + PDFFactory pdfFactory = new PDFFactory(doc); - PDFAction action = pdfFactory.getExternalAction("a", false, "b"); + PDFAction action = pdfFactory.getExternalAction("a", false, originalAltText); + action.setObjectNumber(1); + action.setDocument(doc); + PDFLink link = pdfFactory.makeLink(new Rectangle(), "a", 0, 0); link.setAction(action); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + link.output(bos); - assertTrue(bos.toString().contains("/Contents (b)")); + if (useEncryption && originalAltText != null && !originalAltText.isEmpty()) { + ByteArrayOutputStream encryptedAltTextBos = new ByteArrayOutputStream(); + String encryptedAltText = new String(link.encodeText(((PDFUri) action).getAltText()), + StandardCharsets.ISO_8859_1); + encryptedAltTextBos.write(PDFDocument.encode(encryptedAltText)); + + return encryptedAltTextBos.toString(); + } else { + return originalAltText; + } } } diff --git a/fop-core/src/test/java/org/apache/fop/pdf/PDFStructureTreeTestCase.java b/fop-core/src/test/java/org/apache/fop/pdf/PDFStructureTreeTestCase.java index d66159fd2..27b0bea12 100644 --- a/fop-core/src/test/java/org/apache/fop/pdf/PDFStructureTreeTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/pdf/PDFStructureTreeTestCase.java @@ -21,7 +21,7 @@ package org.apache.fop.pdf; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.IOException; +import java.nio.charset.StandardCharsets; import javax.xml.transform.Result; import javax.xml.transform.Source; @@ -79,14 +79,14 @@ public class PDFStructureTreeTestCase { } private ByteArrayOutputStream foToOutput(String fo) - throws IOException, SAXException, TransformerException { + throws SAXException, TransformerException { FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); FOUserAgent userAgent = fopFactory.newFOUserAgent(); userAgent.setAccessibility(true); ByteArrayOutputStream bos = new ByteArrayOutputStream(); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, bos); Transformer transformer = TransformerFactory.newInstance().newTransformer(); - Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes("UTF-8"))); + Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes(StandardCharsets.UTF_8))); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); return bos; diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/AFPParser.java b/fop-core/src/test/java/org/apache/fop/render/afp/AFPParser.java index e3705271a..747a88ea5 100644 --- a/fop-core/src/test/java/org/apache/fop/render/afp/AFPParser.java +++ b/fop-core/src/test/java/org/apache/fop/render/afp/AFPParser.java @@ -21,6 +21,7 @@ package org.apache.fop.render.afp; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -90,7 +91,7 @@ public class AFPParser { } else if ("TRN".equals(PTOCA_MAP.get(functionType))) { byte[] data = new byte[len - 2]; bis.read(data); - sb.append(" " + new String(data, "UTF-16BE")); + sb.append(" " + new String(data, StandardCharsets.UTF_16BE)); } else { bis.skip(len - 2); } diff --git a/fop-core/src/test/java/org/apache/fop/render/intermediate/URIActionTestCase.java b/fop-core/src/test/java/org/apache/fop/render/intermediate/URIActionTestCase.java index 42675f8a0..44eff68a5 100644 --- a/fop-core/src/test/java/org/apache/fop/render/intermediate/URIActionTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/intermediate/URIActionTestCase.java @@ -32,4 +32,12 @@ public class URIActionTestCase { Assert.assertEquals(action.getID(), action2.getID()); Assert.assertFalse(action.getID().equals(action3.getID())); } + + @Test + public void testIdEdgeCase() { + URIAction action = new URIAction("19", true, null); + URIAction action2 = new URIAction("0X", true, null); + Assert.assertNotEquals("We can't use the hashcode for the ids as some strings have the same hashcode", + action.getID(), action2.getID()); + } } diff --git a/fop-core/src/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java b/fop-core/src/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java index c8baf8ad7..b702e1264 100644 --- a/fop-core/src/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/ps/ImageHandlingTestCase.java @@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import org.junit.Test; @@ -184,7 +185,7 @@ public class ImageHandlingTestCase extends AbstractPostScriptTest { + "rotate=\"30 30 0 15\">Hello SVG with FOP</text>\n" + "</svg>"; SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(null); - Document doc = factory.createDocument(null, IOUtils.toInputStream(svg, "utf-8")); + Document doc = factory.createDocument(null, IOUtils.toInputStream(svg, StandardCharsets.UTF_8)); ByteArrayOutputStream bos = new ByteArrayOutputStream(); new PSImageHandlerSVG().handleImage( new PSRenderingContext(ua, new PSGenerator(bos), new FontInfo()), diff --git a/fop-core/src/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java b/fop-core/src/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java index 80e40dbfd..1b7ad1962 100644 --- a/fop-core/src/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/ps/svg/GradientTestCase.java @@ -22,6 +22,7 @@ package org.apache.fop.render.ps.svg; import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.junit.Test; @@ -68,7 +69,8 @@ public class GradientTestCase { svgGraphics2D.setGraphicContext(new GraphicContext()); svgGraphics2D.translate(100, 100); svgGraphics2D.applyPaint(gradient, true); - String expected = IOUtils.toString(getClass().getResourceAsStream(expectedResourceName), "utf-8"); + String expected = IOUtils.toString( + getClass().getResourceAsStream(expectedResourceName), StandardCharsets.UTF_8); assertEquals(expected.replace("\r", ""), out.toString()); } diff --git a/fop-core/src/tools/resources/findbugs/exclusions.xml b/fop-core/src/tools/resources/findbugs/exclusions.xml index a0ff65e68..fb801d102 100644 --- a/fop-core/src/tools/resources/findbugs/exclusions.xml +++ b/fop-core/src/tools/resources/findbugs/exclusions.xml @@ -163,14 +163,6 @@ </Or> </Match> <Match> - <!-- class only used when building? --> - <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/> - <And> - <Class name="org.apache.fop.hyphenation.SerializeHyphPattern"/> - <Method name="serializeFile"/> - </And> - </Match> - <Match> <Bug pattern="DM_EXIT"/> <Or> <And> @@ -240,14 +232,6 @@ </Or> </Match> <Match> - <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/> - <!-- TODO - fix potential file descriptor leak --> - <And> - <Class name="org.apache.fop.hyphenation.SerializeHyphPattern"/> - <Method name="serializeFile"/> - </And> - </Match> - <Match> <Bug pattern="SE_INNER_CLASS"/> <Or> <Class name="org.apache.fop.afp.AFPPaintingState$AFPData"/> @@ -301,17 +285,6 @@ <!-- Properties not yet implemented --> <Class name="org.apache.fop.fo.properties.CommonAural"/> </Match> - <Match> - <Class name="org.apache.fop.render.pdf.ImageRawPNGAdapter"/> - <Or> - <Method name="outputContents"/> - <Method name="setup"/> - </Or> - <Or> - <Bug pattern="OS_OPEN_STREAM"/> - <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/> - </Or> - </Match> <!-- END - APPROVED EXCLUSIONS --> <!-- START - TEMPORARY (UNAPPROVED) EXCLUSIONS --> @@ -332,18 +305,6 @@ <Bug pattern="DM_CONVERT_CASE"/> </Match> <Match> - <!-- 17 warnings --> - <Bug pattern="DM_DEFAULT_ENCODING"/> - </Match> - <Match> - <!-- 20 warnings --> - <Bug pattern="DM_FP_NUMBER_CTOR"/> - </Match> - <Match> - <!-- 88 warnings --> - <Bug pattern="DM_NUMBER_CTOR"/> - </Match> - <Match> <!-- 84 warnings --> <Bug pattern="EI_EXPOSE_REP"/> </Match> @@ -388,10 +349,6 @@ <Bug pattern="SE_BAD_FIELD"/> </Match> <Match> - <!-- 21 warnings --> - <Bug pattern="SIC_INNER_SHOULD_BE_STATIC"/> - </Match> - <Match> <!-- 20 warnings --> <Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/> </Match> diff --git a/fop-sandbox/src/main/java/org/apache/fop/render/mif/MIFElement.java b/fop-sandbox/src/main/java/org/apache/fop/render/mif/MIFElement.java index 93f7c1d8d..08a1b664f 100644 --- a/fop-sandbox/src/main/java/org/apache/fop/render/mif/MIFElement.java +++ b/fop-sandbox/src/main/java/org/apache/fop/render/mif/MIFElement.java @@ -22,6 +22,7 @@ package org.apache.fop.render.mif; // Java import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.Iterator; import java.util.List; @@ -89,9 +90,9 @@ public class MIFElement { } String indentStr = sb.toString(); if (!started) { - os.write((indentStr + "<" + name).getBytes()); + os.write((indentStr + "<" + name).getBytes(StandardCharsets.UTF_8)); if (valueElements != null) { - os.write(("\n").getBytes()); + os.write(("\n").getBytes(StandardCharsets.UTF_8)); } started = true; } @@ -110,9 +111,9 @@ public class MIFElement { if (!finish || !done) { return false; } - os.write((indentStr + "> # end of " + name + "\n").getBytes()); + os.write((indentStr + "> # end of " + name + "\n").getBytes(StandardCharsets.UTF_8)); } else { - os.write((" " + valueStr + ">\n").getBytes()); + os.write((" " + valueStr + ">\n").getBytes(StandardCharsets.UTF_8)); } finished = true; return true; diff --git a/fop-sandbox/src/main/java/org/apache/fop/render/mif/MIFFile.java b/fop-sandbox/src/main/java/org/apache/fop/render/mif/MIFFile.java index c727b2998..1a2b3e599 100644 --- a/fop-sandbox/src/main/java/org/apache/fop/render/mif/MIFFile.java +++ b/fop-sandbox/src/main/java/org/apache/fop/render/mif/MIFFile.java @@ -22,6 +22,7 @@ package org.apache.fop.render.mif; // Java import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.Iterator; import java.util.List; @@ -130,7 +131,7 @@ public class MIFFile extends MIFElement { } if (!started) { - os.write(("<MIFFile 5.00> # Generated by FOP\n"/* + getVersion()*/).getBytes()); + os.write(("<MIFFile 5.00> # Generated by FOP\n"/* + getVersion()*/).getBytes(StandardCharsets.UTF_8)); started = true; } boolean done = true; @@ -146,7 +147,7 @@ public class MIFFile extends MIFElement { } } if (done && finish) { - os.write(("# end of MIFFile").getBytes()); + os.write(("# end of MIFFile").getBytes(StandardCharsets.UTF_8)); } } diff --git a/fop-sandbox/src/main/java/org/apache/fop/render/svg/SVGRenderer.java b/fop-sandbox/src/main/java/org/apache/fop/render/svg/SVGRenderer.java index 9cbc1662d..9800eb766 100644 --- a/fop-sandbox/src/main/java/org/apache/fop/render/svg/SVGRenderer.java +++ b/fop-sandbox/src/main/java/org/apache/fop/render/svg/SVGRenderer.java @@ -25,6 +25,7 @@ import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.OutputStream; import java.io.Writer; +import java.nio.charset.StandardCharsets; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; @@ -148,7 +149,7 @@ public class SVGRenderer extends Java2DRenderer { return; } try { - Writer writer = new java.io.OutputStreamWriter(out, "UTF-8"); + Writer writer = new java.io.OutputStreamWriter(out, StandardCharsets.UTF_8.name()); this.svgGenerator.stream(writer, useCSS); } finally { if (out != this.firstOutputStream) { diff --git a/fop-sandbox/src/tools/resources/findbugs/exclusions.xml b/fop-sandbox/src/tools/resources/findbugs/exclusions.xml index 325065e13..a7a45b4cd 100644 --- a/fop-sandbox/src/tools/resources/findbugs/exclusions.xml +++ b/fop-sandbox/src/tools/resources/findbugs/exclusions.xml @@ -73,12 +73,6 @@ <Bug pattern="DM_CONVERT_CASE"/> </Match> <Match> - <Bug pattern="DM_FP_NUMBER_CTOR"/> - </Match> - <Match> - <Bug pattern="DM_NUMBER_CTOR"/> - </Match> - <Match> <Bug pattern="EI_EXPOSE_REP2"/> </Match> <Match> diff --git a/fop-transcoder-allinone/src/tools/resources/assembly/assembly.xml b/fop-transcoder-allinone/src/tools/resources/assembly/assembly.xml index 13d8ce403..7edc187dd 100644 --- a/fop-transcoder-allinone/src/tools/resources/assembly/assembly.xml +++ b/fop-transcoder-allinone/src/tools/resources/assembly/assembly.xml @@ -22,11 +22,7 @@ <unpack>true</unpack> <unpackOptions> <includes> - <include>org/apache/commons/io/*.class</include> - <include>org/apache/commons/io/filefilter/*.class</include> - <include>org/apache/commons/io/output/*.class</include> - <include>org/apache/commons/io/input/*.class</include> - <include>org/apache/commons/io/function/*.class</include> + <include>org/apache/commons/io/**</include> <include>org/apache/commons/logging/**</include> <include>org/apache/fop/Version.class</include> <include>org/apache/fop/accessibility/StructureTreeElement.class</include> diff --git a/fop/test/layoutengine/standard-testcases/page-sequence_two-column_last-page_7.xml b/fop/test/layoutengine/standard-testcases/page-sequence_two-column_last-page_7.xml index c3365fd8e..ca07447b9 100644 --- a/fop/test/layoutengine/standard-testcases/page-sequence_two-column_last-page_7.xml +++ b/fop/test/layoutengine/standard-testcases/page-sequence_two-column_last-page_7.xml @@ -1457,5 +1457,9 @@ <eval expected="(2)" xpath="//pageViewport[2]//word"/> <eval expected="(Enter" xpath="//pageViewport[3]//word"/> <eval expected="Loss" xpath="//pageViewport[4]//word"/> + <eval expected="PageFirst" xpath="//pageViewport[1]/@simple-page-master-name"/> + <eval expected="PageRestEven" xpath="//pageViewport[2]/@simple-page-master-name"/> + <eval expected="PageRestOdd" xpath="//pageViewport[3]/@simple-page-master-name"/> + <eval expected="PageLastEven" xpath="//pageViewport[4]/@simple-page-master-name"/> </checks> </testcase> diff --git a/fop/test/layoutengine/standard-testcases/page-sequence_two-column_last-page_9.xml b/fop/test/layoutengine/standard-testcases/page-sequence_two-column_last-page_9.xml new file mode 100644 index 000000000..aa4ab9f56 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/page-sequence_two-column_last-page_9.xml @@ -0,0 +1,1187 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- $Id$ --> +<testcase> + <info> + <p> + Test case: last content spans all columns and does not fit on last page, and there is not even + space left to fit any part of it after switching to last-page master. + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> + <fo:layout-master-set> + <fo:simple-page-master margin-right="0.5in" margin-left="0.5in" margin-top="0.35in" margin-bottom="0.25in" master-name="PageFirst" page-width="8.5in" page-height="11in"> + <fo:region-body margin-top="0.85in" column-count="2" column-gap="0.3in" margin-bottom="1in" region-name="PageBody" background-color="red"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="PageRestEven" margin-right="0.5in" margin-left="0.5in" margin-top="0.35in" margin-bottom="0.25in" page-width="8.5in" page-height="11in"> + <fo:region-body margin-top="0.5in" column-gap="0.3in" column-count="2" margin-bottom="1in" region-name="PageBody" background-color="yellow"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="PageRestOdd" margin-right="0.5in" margin-left="0.5in" margin-top="0.35in" margin-bottom="0.25in" page-width="8.5in" page-height="11in"> + <fo:region-body margin-top="0.5in" column-gap="0.3in" column-count="2" margin-bottom="1in" region-name="PageBody" background-color="green"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="PageLastEven" page-width="8.5in" page-height="11in" margin-bottom="0.25in" margin-right="0.5in" margin-top="0.35in" margin-left="0.5in"> + <fo:region-body column-count="2" margin-top="0.5in" column-gap="0.3in" margin-bottom="2.5in" region-name="PageBody" background-color="orange"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="PageLastOdd" page-width="8.5in" page-height="11in" margin-bottom="0.25in" margin-right="0.5in" margin-top="0.35in" margin-left="0.5in"> + <fo:region-body margin-top="0.5in" column-gap="0.3in" column-count="2" margin-bottom="2.5in" region-name="PageBody" background-color="pink"/> + </fo:simple-page-master> + <fo:page-sequence-master master-name="LetterPages"> + <fo:repeatable-page-master-alternatives> + <fo:conditional-page-master-reference page-position="first" master-reference="PageFirst"/> + <fo:conditional-page-master-reference odd-or-even="odd" page-position="rest" master-reference="PageRestOdd"/> + <fo:conditional-page-master-reference odd-or-even="even" page-position="rest" master-reference="PageRestEven"/> + <fo:conditional-page-master-reference odd-or-even="even" page-position="last" master-reference="PageLastEven"/> + <fo:conditional-page-master-reference odd-or-even="odd" page-position="last" master-reference="PageLastOdd"/> + </fo:repeatable-page-master-alternatives> + </fo:page-sequence-master> + </fo:layout-master-set> + <fo:page-sequence format="1" id="th_default_sequence1" initial-page-number="auto" force-page-count="auto" master-reference="LetterPages"> + <fo:flow flow-name="PageBody"> + <fo:block-container> + <fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>A.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>When this endorsement is attached to the Standard Property Policy <fo:inline>CP 00 99,</fo:inline> the term Coverage Part in this endorsement is replaced by the term Policy. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>B.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>Nothing in this endorsement increases the applicable Limit of Insurance. We will not pay any Loss Payee more than their financial interest in the Covered Property, and we will not pay more than the applicable Limit of Insurance on the Covered Property.</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>C.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>The following is added to the<fo:inline> Loss Payment</fo:inline> Loss Condition, as indicated in the Declarations or in the Schedule:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>1.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="0.5in">For Covered Property in which both you and a Loss Payee shown in the Schedule or in the Declarations have an insurable interest, we will: </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>Adjust losses with you; and</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>Pay any claim for loss or damage jointly to you and the Loss Payee, as<fo:inline> </fo:inline>interests may appear</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>2.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Lender's Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is a creditor, including a mortgageholder or trustee, whose interest in Covered Property is established by such written instruments as<fo:inline>:</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Warehouse receipts; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>A contract for deed;</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(3)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Bills of lading; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(4)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Financing statements; or </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(5)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Mortgages, deeds of trust, or security agreements. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>For Covered Property in which both you and a Loss Payee have an insurable interest<fo:inline>:</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>We will pay for covered loss or damage to each Loss Payee in their order of precedence, as interests may appear. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>The Loss Payee has the right to receive loss payment even if the Loss Payee has started foreclosure or similar action on the Covered Property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(3)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>If we deny your claim because of your acts or because you have failed to comply with the terms of the Coverage Part, the Loss Payee will still have the right to receive loss payment if the Loss Payee:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(a)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Pays any premium due under this Coverage Part at our request if you have failed to do so; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(b)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Submits a signed, sworn proof of loss within 60 days after receiving notice from us of your failure to do so; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(c)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Has notified us of any change in ownership, occupancy or substantial change in risk known to the Loss Payee. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="1in">All of the terms of this Coverage Part will then apply directly to the Loss Payee. </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(4)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>If we pay the Loss Payee for any loss or damage and deny payment to you because of your acts or because you have failed to comply with the terms of this Coverage Part:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(a)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>The Loss Payee's rights will be transferred to us to the extent of the amount we pay; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(b)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>The Loss Payee's rights to recover the full amount of the Loss Payee's claim will not be impaired. At our option, we may pay to the Loss Payee the whole principal on the debt plus any accrued interest. In this event, you will pay your remaining debt to us. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>If we cancel this policy, we will give written notice to the Loss Payee at least: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>10 days before the effective date of cancellation if we cancel for your nonpayment of premium; or </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>30 days before the effective date of cancellation if we cancel for any other reason. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>d.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>If we elect not to renew this policy, we will give written notice to the Loss Payee at least 10 days before the expiration date of this policy. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>3.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Contract Of Sale Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is a person or organization you have entered into a contract with for the sale of Covered Property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>For Covered Property in which both you and the Loss Payee have an insurable interest, we will: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Adjust losses with you; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Pay any claim for loss or damage jointly to you and the Loss Payee, as interests may appear.</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The following is added to the <fo:inline>Other Insurance</fo:inline> Condition: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="0.5in" fox:tab-stops="end space 24pt start space 30pt" text-align="left">For Covered Property that is the subject of a contract of sale, the word "you" includes the Loss Payee.</fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>4.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Building Owner Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is the owner of the described building in which you are a tenant. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>We will adjust losses to the described building with the Loss Payee. Any loss payment made to the Loss Payee will satisfy your claims against us for the owner's property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>We will adjust losses to tenants' improvements and betterments with you, unless the lease provides otherwise.</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="11pt"> + <fo:leader/> + </fo:block> + </fo:block> + </fo:block-container> + <fo:block-container span="all"> + <fo:block> + <fo:block font-size="10pt" line-height="11pt"> + <fo:leader/> + </fo:block> + <fo:table border-collapse="separate" table-layout="fixed" width="100%"> + <fo:table-column column-width="proportional-column-width(100)" column-number="1"/> + <fo:table-body> + <fo:table-row> + <fo:table-cell padding-top="2pt" padding-left="2pt" white-space="normal" border-collapse="collapse" white-space-collapse="false" padding="5px"> + <fo:block> + <fo:block text-align="center"> + <fo:inline>SCHEDULE</fo:inline> + </fo:block> + </fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + <fo:block font-size="10pt" line-height="11pt"> + <fo:leader/> + </fo:block> + <fo:table border-collapse="separate" table-layout="fixed" width="100%"> + <fo:table-column column-width="proportional-column-width(100)" column-number="1"/> + <fo:table-body> + <fo:table-row> + <fo:table-cell padding-top="2pt" padding-left="2pt" white-space="normal" border-collapse="collapse" white-space-collapse="false" padding="5px" border-right-style="solid" border-bottom-color="black" border-top-width="1pt" border-left-style="solid" border-right-width="1pt" border-bottom-width="1pt" border-left-color="black" border-top-color="black" border-bottom-style="solid" border-right-color="black" border-left-width="1pt" border-top-style="solid"> + <fo:block> + <fo:block font-size="10pt" line-height="11pt">Information required to complete this Schedule, if not shown above, will be shown in the Declarations.</fo:block> + </fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>A.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>When this endorsement is attached to the Standard Property Policy <fo:inline>CP 00 99,</fo:inline> the term Coverage Part in this endorsement is replaced by the term Policy. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>B.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>Nothing in this endorsement increases the applicable Limit of Insurance. We will not pay any Loss Payee more than their financial interest in the Covered Property, and we will not pay more than the applicable Limit of Insurance on the Covered Property.</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>C.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>The following is added to the<fo:inline> Loss Payment</fo:inline> Loss Condition, as indicated in the Declarations or in the Schedule:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>1.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="0.5in">For Covered Property in which both you and a Loss Payee shown in the Schedule or in the Declarations have an insurable interest, we will: </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>Adjust losses with you; and</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>Pay any claim for loss or damage jointly to you and the Loss Payee, as<fo:inline> </fo:inline>interests may appear</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>2.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Lender's Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is a creditor, including a mortgageholder or trustee, whose interest in Covered Property is established by such written instruments as<fo:inline>:</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Warehouse receipts; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>A contract for deed;</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(3)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Bills of lading; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(4)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Financing statements; or </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(5)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Mortgages, deeds of trust, or security agreements. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>For Covered Property in which both you and a Loss Payee have an insurable interest<fo:inline>:</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>We will pay for covered loss or damage to each Loss Payee in their order of precedence, as interests may appear. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>The Loss Payee has the right to receive loss payment even if the Loss Payee has started foreclosure or similar action on the Covered Property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(3)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>If we deny your claim because of your acts or because you have failed to comply with the terms of the Coverage Part, the Loss Payee will still have the right to receive loss payment if the Loss Payee:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(a)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Pays any premium due under this Coverage Part at our request if you have failed to do so; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(b)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Submits a signed, sworn proof of loss within 60 days after receiving notice from us of your failure to do so; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(c)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Has notified us of any change in ownership, occupancy or substantial change in risk known to the Loss Payee. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="1in">All of the terms of this Coverage Part will then apply directly to the Loss Payee. </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(4)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>If we pay the Loss Payee for any loss or damage and deny payment to you because of your acts or because you have failed to comply with the terms of this Coverage Part:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(a)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>The Loss Payee's rights will be transferred to us to the extent of the amount we pay; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(b)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>The Loss Payee's rights to recover the full amount of the Loss Payee's claim will not be impaired. At our option, we may pay to the Loss Payee the whole principal on the debt plus any accrued interest. In this event, you will pay your remaining debt to us. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>If we cancel this policy, we will give written notice to the Loss Payee at least: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>10 days before the effective date of cancellation if we cancel for your nonpayment of premium; or </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>30 days before the effective date of cancellation if we cancel for any other reason. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>d.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>If we elect not to renew this policy, we will give written notice to the Loss Payee at least 10 days before the expiration date of this policy. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>3.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Contract Of Sale Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is a person or organization you have entered into a contract with for the sale of Covered Property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>For Covered Property in which both you and the Loss Payee have an insurable interest, we will: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Adjust losses with you; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Pay any claim for loss or damage jointly to you and the Loss Payee, as interests may appear.</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The following is added to the <fo:inline>Other Insurance</fo:inline> Condition: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="0.5in" fox:tab-stops="end space 24pt start space 30pt" text-align="left">For Covered Property that is the subject of a contract of sale, the word "you" includes the Loss Payee</fo:block> + <fo:block font-size="10pt" line-height="10pt" margin-left="0.5in" fox:tab-stops="end space 24pt start space 30pt"> + <fo:leader/> + </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>4.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Building Owner Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is the owner of the described building in which you are a tenant. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>We will adjust losses to the described building with the Loss Payee. Any loss payment made to the Loss Payee will satisfy your claims against us for the owner's property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>We will adjust losses to tenants' improvements and betterments with you, unless the lease provides otherwise.</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="11pt"> + <fo:leader/> + </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>A.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>When this endorsement is attached to the Standard Property Policy <fo:inline>CP 00 99,</fo:inline> the term Coverage Part in this endorsement is replaced by the term Policy. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>B.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>Nothing in this endorsement increases the applicable Limit of Insurance. We will not pay any Loss Payee more than their financial interest in the Covered Property, and we will not pay more than the applicable Limit of Insurance on the Covered Property.</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt"> + <fo:block>C.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.25in" space-after="4pt"> + <fo:block>The following is added to the<fo:inline> Loss Payment</fo:inline> Loss Condition, as indicated in the Declarations or in the Schedule:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>1.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="0.5in">For Covered Property in which both you and a Loss Payee shown in the Schedule or in the Declarations have an insurable interest, we will: </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>Adjust losses with you; and</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>Pay any claim for loss or damage jointly to you and the Loss Payee, as<fo:inline> </fo:inline>interests may appear</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>2.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Lender's Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is a creditor, including a mortgageholder or trustee, whose interest in Covered Property is established by such written instruments as<fo:inline>:</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Warehouse receipts; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>A contract for deed;</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(3)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Bills of lading; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(4)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Financing statements; or </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(5)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Mortgages, deeds of trust, or security agreements. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>For Covered Property in which both you and a Loss Payee have an insurable interest<fo:inline>:</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>We will pay for covered loss or damage to each Loss Payee in their order of precedence, as interests may appear. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>The Loss Payee has the right to receive loss payment even if the Loss Payee has started foreclosure or similar action on the Covered Property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(3)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>If we deny your claim because of your acts or because you have failed to comply with the terms of the Coverage Part, the Loss Payee will still have the right to receive loss payment if the Loss Payee:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(a)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Pays any premium due under this Coverage Part at our request if you have failed to do so; </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(b)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Submits a signed, sworn proof of loss within 60 days after receiving notice from us of your failure to do so; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(c)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>Has notified us of any change in ownership, occupancy or substantial change in risk known to the Loss Payee. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="1in">All of the terms of this Coverage Part will then apply directly to the Loss Payee. </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(4)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>If we pay the Loss Payee for any loss or damage and deny payment to you because of your acts or because you have failed to comply with the terms of this Coverage Part:</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(a)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>The Loss Payee's rights will be transferred to us to the extent of the amount we pay; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>(b)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1.25in"> + <fo:block>The Loss Payee's rights to recover the full amount of the Loss Payee's claim will not be impaired. At our option, we may pay to the Loss Payee the whole principal on the debt plus any accrued interest. In this event, you will pay your remaining debt to us. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>If we cancel this policy, we will give written notice to the Loss Payee at least: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>10 days before the effective date of cancellation if we cancel for your nonpayment of premium; or </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>30 days before the effective date of cancellation if we cancel for any other reason. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>d.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>If we elect not to renew this policy, we will give written notice to the Loss Payee at least 10 days before the expiration date of this policy. </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>3.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Contract Of Sale Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is a person or organization you have entered into a contract with for the sale of Covered Property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>For Covered Property in which both you and the Loss Payee have an insurable interest, we will: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(1)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Adjust losses with you; and </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>(2)</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="1in"> + <fo:block>Pay any claim for loss or damage jointly to you and the Loss Payee, as interests may appear.</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The following is added to the <fo:inline>Other Insurance</fo:inline> Condition: </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:block font-size="10pt" line-height="10pt" margin-left="0.5in" fox:tab-stops="end space 24pt start space 30pt" text-align="left">For Covered Property that is the subject of a contract of sale, the word "you" includes the Loss Payee</fo:block> + <fo:block font-size="10pt" line-height="10pt" margin-left="0.5in" fox:tab-stops="end space 24pt start space 30pt"> + <fo:leader/> + </fo:block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.25in"> + <fo:block>4.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block> + <fo:inline>Building Owner Loss Payable Clause</fo:inline> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + <fo:list-block font-size="10pt" line-height="11pt"> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>a.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>The Loss Payee shown in the Schedule or in the Declarations is the owner of the described building in which you are a tenant. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>b.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>We will adjust losses to the described building with the Loss Payee. Any loss payment made to the Loss Payee will satisfy your claims against us for the owner's property. </fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>c.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>We will adjust losses to tenants' improvements and betterments with you, unless the lease provides otherwise.</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>d.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>abc</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item space-before="4pt" space-after="4pt"> + <fo:list-item-label font-size="10pt" space-before="4pt" start-indent="0.5in"> + <fo:block>e.</fo:block> + </fo:list-item-label> + <fo:list-item-body font-size="10pt" space-before="4pt" start-indent="0.75in"> + <fo:block>abad</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + </fo:block> + </fo:block-container> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="5" xpath="count(//pageViewport)"/> + <eval expected="A." xpath="//pageViewport[1]//word"/> + <eval expected="c." xpath="//pageViewport[2]//word"/> + <eval expected="(a)" xpath="//pageViewport[3]//word"/> + <eval expected="(1)" xpath="//pageViewport[4]//word"/> + <eval expected="PageFirst" xpath="//pageViewport[1]/@simple-page-master-name"/> + <eval expected="PageRestEven" xpath="//pageViewport[2]/@simple-page-master-name"/> + <eval expected="PageRestOdd" xpath="//pageViewport[3]/@simple-page-master-name"/> + <eval expected="PageRestEven" xpath="//pageViewport[4]/@simple-page-master-name"/> + <eval expected="PageLastOdd" xpath="//pageViewport[5]/@simple-page-master-name"/> + </checks> +</testcase> diff --git a/fop/test/layoutengine/standard-testcases/table_and_caption.xml b/fop/test/layoutengine/standard-testcases/table_and_caption.xml new file mode 100644 index 000000000..e5bdf1e50 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/table_and_caption.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- $Id$ --> +<testcase> + <info> + <p> + This test checks table with a caption + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="simple" page-height="27.9cm" page-width="21.6cm"> + <fo:region-body margin="1cm"/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="simple"> + <fo:flow flow-name="xsl-region-body"> + <fo:table-and-caption border="solid 0.5mm black"> + <fo:table-caption> + <fo:block text-align="center">test</fo:block> + </fo:table-caption> + <fo:table table-layout="fixed" width="100%"> + <fo:table-column column-width="proportional-column-width(50)"/> + <fo:table-column column-width="proportional-column-width(50)"/> + <fo:table-header> + <fo:table-row> + <fo:table-cell> + <fo:block>header1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>header2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-body> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:table-and-caption> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="test" xpath="//block/block[1]//word"/> + <eval expected="header1" xpath="//block/block[2]/block[1]/block//word"/> + <eval expected="header2" xpath="//block/block[2]/block[2]/block//word"/> + <eval expected="cell1" xpath="//block/block[2]/block[3]/block//word"/> + <eval expected="cell2" xpath="//block/block[2]/block[4]/block//word"/> + <eval expected="(solid,#000000,1417)" xpath="//block/@border-start"/> + </checks> +</testcase> diff --git a/fop/test/layoutengine/standard-testcases/table_and_caption_multicolumn.xml b/fop/test/layoutengine/standard-testcases/table_and_caption_multicolumn.xml new file mode 100644 index 000000000..fecebe494 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/table_and_caption_multicolumn.xml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- $Id$ --> +<testcase> + <info> + <p> + This test checks table with a caption + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> + <fo:layout-master-set> + <fo:simple-page-master master-name="simple" page-height="10cm" page-width="21.6cm"> + <fo:region-body margin="1cm" column-count="2"/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="simple"> + <fo:flow flow-name="xsl-region-body"> + <fo:block font-size="40pt">test test test test test test test test test test test test </fo:block> + <fo:table-and-caption border="solid 0.5mm black" font-size="35pt"> + <fo:table-caption> + <fo:block text-align="center">caption</fo:block> + </fo:table-caption> + <fo:table table-layout="fixed" width="100%"> + <fo:table-column column-width="proportional-column-width(50)"/> + <fo:table-column column-width="proportional-column-width(50)"/> + <fo:table-header> + <fo:table-row> + <fo:table-cell> + <fo:block>header1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>header2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-body> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:table-and-caption> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="2" xpath="count(//pageViewport)"/> + <eval expected="test" xpath="//pageViewport[1]//flow[1]//word"/> + <eval expected="caption" xpath="//pageViewport[1]//flow[2]//word"/> + <eval expected="header1" xpath="//pageViewport[2]//word"/> + </checks> +</testcase> diff --git a/fop/test/layoutengine/standard-testcases/table_and_caption_multipage.xml b/fop/test/layoutengine/standard-testcases/table_and_caption_multipage.xml new file mode 100644 index 000000000..c4552bcc6 --- /dev/null +++ b/fop/test/layoutengine/standard-testcases/table_and_caption_multipage.xml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!-- $Id$ --> +<testcase> + <info> + <p> + This test checks table with a caption + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> + <fo:layout-master-set> + <fo:simple-page-master master-name="simple" page-height="10cm" page-width="21.6cm"> + <fo:region-body margin="1cm"/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="simple"> + <fo:flow flow-name="xsl-region-body"> + <fo:block font-size="40pt">test test test test test test test test test test test test </fo:block> + <fo:table-and-caption border="solid 0.5mm black" font-size="40pt"> + <fo:table-caption> + <fo:block text-align="center">caption</fo:block> + </fo:table-caption> + <fo:table table-layout="fixed" width="100%"> + <fo:table-column column-width="proportional-column-width(50)"/> + <fo:table-column column-width="proportional-column-width(50)"/> + <fo:table-header> + <fo:table-row> + <fo:table-cell> + <fo:block>header1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>header2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-header> + <fo:table-body> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + <fo:table-row> + <fo:table-cell> + <fo:block>cell1</fo:block> + </fo:table-cell> + <fo:table-cell> + <fo:block>cell2</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:table-and-caption> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="3" xpath="count(//pageViewport)"/> + <eval expected="test" xpath="//pageViewport[1]//word"/> + <eval expected="caption" xpath="//pageViewport[2]//word"/> + <eval expected="header1" xpath="//pageViewport[3]//word"/> + </checks> +</testcase> @@ -183,10 +183,10 @@ </repositories> <distributionManagement> - <site> - <id>${project.artifactId}-site</id> - <url>${project.baseUri}</url> - </site> + <snapshotRepository> + <id>apache.snapshots.https</id> + <url>https://repository.apache.org/content/repositories/snapshots</url> + </snapshotRepository> </distributionManagement> </project> |