Skip to content

Commit

Permalink
updated for Apache FOP 2.10, #301
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelligent2013 committed Nov 18, 2024
1 parent 338c521 commit 055f5f6
Show file tree
Hide file tree
Showing 18 changed files with 164 additions and 73 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SHELL ?= /bin/bash
endif

#JAR_VERSION := $(shell mvn -q -Dexec.executable="echo" -Dexec.args='$${project.version}' --non-recursive exec:exec -DforceStdout)
JAR_VERSION := 2.09
JAR_VERSION := 2.10
JAR_FILE := mn2pdf-$(JAR_VERSION).jar

all: target/$(JAR_FILE)
Expand Down
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ You will need the Java Development Kit (JDK) version 8, Update 241 (8u241) or hi

[source,sh]
----
java -Xss5m -Xmx2048m -jar target/mn2pdf-2.09.jar --xml-file <XML-FileName> --xsl-file <XSLT-FileName> --pdf-file <Output-PDF-FileName> [--syntax-highlight]
java -Xss5m -Xmx2048m -jar target/mn2pdf-2.10.jar --xml-file <XML-FileName> --xsl-file <XSLT-FileName> --pdf-file <Output-PDF-FileName> [--syntax-highlight]
----

e.g.

[source,sh]
----
java -Xss5m -Xmx2048m -jar target/mn2pdf-2.09.jar --xml-file tests/G.191.xml --xsl-file tests/itu.recommendation.xsl --pdf-file tests/G.191.pdf
java -Xss5m -Xmx2048m -jar target/mn2pdf-2.10.jar --xml-file tests/G.191.xml --xsl-file tests/itu.recommendation.xsl --pdf-file tests/G.191.pdf
----

=== PDF encryption features
Expand Down Expand Up @@ -100,7 +100,7 @@ Update version in `pom.xml`, e.g.:
----
<groupId>org.metanorma.fop</groupId>
<artifactId>mn2pdf</artifactId>
<version>2.09</version>
<version>2.10</version>
<name>Metanorma XML to PDF converter</name>
----

Expand All @@ -111,8 +111,8 @@ Tag the same version in Git:

[source,xml]
----
git tag v2.09
git push origin v2.09
git tag v2.10
git push origin v2.10
----

Then the corresponding GitHub release will be automatically created at:
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.metanorma.fop</groupId>
<artifactId>mn2pdf</artifactId>
<version>2.09</version>
<version>2.10</version>
<name>Metanorma XML to PDF converter</name>
<packaging>jar</packaging>
<url>https://www.metanorma.org</url>
Expand Down Expand Up @@ -150,12 +150,12 @@
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>2.9</version>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop-pdf-images</artifactId>
<version>2.9</version>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
Expand Down Expand Up @@ -190,7 +190,7 @@
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>xmlgraphics-commons</artifactId>
<version>2.8</version>
<version>2.10</version> <!-- 2.8 -->
</dependency>
<dependency>
<groupId>xalan</groupId>
Expand All @@ -217,7 +217,7 @@
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-all</artifactId>
<version>1.16</version><!-- 1.9.1 -->
<version>1.18</version><!-- 1.9.1 1.16 -->
<exclusions>
<exclusion>
<groupId>org.python</groupId>
Expand Down Expand Up @@ -249,7 +249,7 @@
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.24</version>
<version>2.0.27</version> <!-- 2.0.24 -->
<!-- <scope>test</scope> -->
</dependency>
<dependency>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/org/apache/fop/apps/FopConfParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class FopConfParser {
private static final String TABLE_BORDER_OVERPAINT = "table-border-overpaint";
private static final String SIMPLE_LINE_BREAKING = "simple-line-breaking";
private static final String SKIP_PAGE_POSITION_ONLY_ALLOWED = "skip-page-position-only-allowed";
private static final String LEGACY_SKIP_PAGE_POSITION_ONLY = "legacy-skip-page-position-only";
private static final String LEGACY_LAST_PAGE_CHANGE_IPD = "legacy-last-page-change-ipd";

private final Log log = LogFactory.getLog(FopConfParser.class);

Expand Down Expand Up @@ -299,6 +301,22 @@ private void configure(final URI baseURI, final ResourceResolver resourceResolve
LogUtil.handleException(log, e, false);
}
}
if (cfg.getChild(LEGACY_SKIP_PAGE_POSITION_ONLY, false) != null) {
try {
fopFactoryBuilder.setLegacySkipPagePositionOnly(
cfg.getChild(LEGACY_SKIP_PAGE_POSITION_ONLY).getValueAsBoolean());
} catch (ConfigurationException e) {
LogUtil.handleException(log, e, false);
}
}
if (cfg.getChild(LEGACY_LAST_PAGE_CHANGE_IPD, false) != null) {
try {
fopFactoryBuilder.setLegacyLastPageChangeIPD(
cfg.getChild(LEGACY_LAST_PAGE_CHANGE_IPD).getValueAsBoolean());
} catch (ConfigurationException e) {
LogUtil.handleException(log, e, false);
}
}

// configure font manager
new FontManagerConfigurator(cfg, baseURI, fopFactoryBuilder.getBaseURI(), resourceResolver)
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/apache/fop/events/EventFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

import org.apache.fop.events.model.EventSeverity;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.util.XMLResourceBundle;
import org.apache.fop.util.text.AdvancedMessageFormat;
import org.apache.fop.util.text.AdvancedMessageFormat.Part;
import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory;
import org.apache.fop.utils.XMLResourceBundle;
import org.apache.fop.utils.text.AdvancedMessageFormat;
import org.apache.fop.utils.text.AdvancedMessageFormat.Part;
import org.apache.fop.utils.text.AdvancedMessageFormat.PartFactory;

/**
* Converts events into human-readable, localized messages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public int getContentAreaBPD() {

/** {@inheritDoc} */
@Override
public List getNextKnuthElements(LayoutContext context, int alignment) {
public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
return getNextKnuthElements(context, alignment, null, null, null);
}

Expand All @@ -208,7 +208,7 @@ protected LayoutContext makeChildLayoutContext(LayoutContext context) {

/** {@inheritDoc} */
@Override
public List getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment, Stack lmStack,
Position restartPosition, LayoutManager restartAtLM) {

resetSpaces();
Expand Down Expand Up @@ -674,14 +674,14 @@ protected LayoutContext createLayoutContext() {
return lc;
}

protected List getNextKnuthElements(LayoutContext context, int alignment) {
protected List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
LayoutManager curLM; // currently active LM
List<ListElement> returnList = new LinkedList<ListElement>();

while ((curLM = getChildLM()) != null) {
LayoutContext childLC = makeChildLayoutContext(context);

List returnedList = null;
List<ListElement> returnedList = null;
if (!curLM.isFinished()) {
returnedList = curLM.getNextKnuthElements(childLC, alignment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ protected int updateContentAreaIPDwithOverconstrainedAdjust(int contentIPD) {

/** {@inheritDoc} */
@Override
public List getNextKnuthElements(LayoutContext context, int alignment) {
public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
return getNextKnuthElements(context, alignment, null, null, null);
}

/** {@inheritDoc} */
@Override
public List getNextKnuthElements(LayoutContext context, int alignment,
public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment,
Stack lmStack, Position restartPosition, LayoutManager restartAtLM) {
isRestartAtLM = restartAtLM != null;
referenceIPD = context.getRefIPD();
Expand Down Expand Up @@ -670,12 +670,12 @@ public void discardSpace(KnuthGlue spaceGlue) {

/** {@inheritDoc} */
@Override
public List getChangedKnuthElements(List oldList, int alignment) {
public List<ListElement> getChangedKnuthElements(List oldList, int alignment) {
ListIterator<KnuthElement> oldListIterator = oldList.listIterator();
KnuthElement currElement = null;
KnuthElement prevElement = null;
List<KnuthElement> returnedList = new LinkedList<KnuthElement>();
List<KnuthElement> returnList = new LinkedList<KnuthElement>();
List<ListElement> returnList = new LinkedList<>();
int fromIndex = 0;

// "unwrap" the Positions stored in the elements
Expand Down Expand Up @@ -992,7 +992,7 @@ protected SpaceProperty getSpaceAfterProperty() {
* @param isFirst true if this is the first time a layout manager instance needs to generate
* border and padding
*/
protected void addKnuthElementsForBorderPaddingBefore(List returnList, boolean isFirst) {
protected void addKnuthElementsForBorderPaddingBefore(List<ListElement> returnList, boolean isFirst) {
//Border and Padding (before)
CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground();
if (borderAndPadding != null) {
Expand All @@ -1019,7 +1019,7 @@ protected void addKnuthElementsForBorderPaddingBefore(List returnList, boolean i
* @param isLast true if this is the last time a layout manager instance needs to generate
* border and padding
*/
protected void addKnuthElementsForBorderPaddingAfter(List returnList, boolean isLast) {
protected void addKnuthElementsForBorderPaddingAfter(List<ListElement> returnList, boolean isLast) {
//Border and Padding (after)
CommonBorderPaddingBackground borderAndPadding = getBorderPaddingBackground();
if (borderAndPadding != null) {
Expand Down Expand Up @@ -1165,7 +1165,7 @@ public int getLastIndex() {
* @param sourceList source list
* @param targetList target list receiving the wrapped position elements
*/
protected void wrapPositionElements(List sourceList, List targetList) {
protected void wrapPositionElements(List sourceList, List<ListElement> targetList) {
wrapPositionElements(sourceList, targetList, false);
}

Expand All @@ -1176,7 +1176,7 @@ protected void wrapPositionElements(List sourceList, List targetList) {
* @param targetList target list receiving the wrapped position elements
* @param force if true, every Position is wrapped regardless of its LM of origin
*/
protected void wrapPositionElements(List sourceList, List targetList, boolean force) {
protected void wrapPositionElements(List sourceList, List<ListElement> targetList, boolean force) {

ListIterator listIter = sourceList.listIterator();
Object tempElement;
Expand All @@ -1202,7 +1202,7 @@ protected void wrapPositionElements(List sourceList, List targetList, boolean fo
* @param targetList target list receiving the wrapped position elements
* @param force if true, every Position is wrapped regardless of its LM of origin
*/
protected void wrapPositionElement(ListElement el, List targetList, boolean force) {
protected void wrapPositionElement(ListElement el, List<ListElement> targetList, boolean force) {
if (force || el.getLayoutManager() != this) {
el.setPosition(notifyPos(new NonLeafPosition(this, el.getPosition())));
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public FlowLayoutManager(PageSequenceLayoutManager pslm, Flow node) {

/** {@inheritDoc} */
@Override
public List getNextKnuthElements(LayoutContext context, int alignment) {
public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
return getNextKnuthElements(context, alignment, null, null);
}

Expand All @@ -80,7 +80,7 @@ public List getNextKnuthElements(LayoutContext context, int alignment) {
* @return the list of KnuthElements
* @see LayoutManager#getNextKnuthElements(LayoutContext,int)
*/
List getNextKnuthElements(LayoutContext context, int alignment,
List<ListElement> getNextKnuthElements(LayoutContext context, int alignment,
Position restartPosition, LayoutManager restartLM) {

List<ListElement> elements = new LinkedList<ListElement>();
Expand Down Expand Up @@ -290,11 +290,11 @@ public Keep getKeepWithPrevious() {

/** {@inheritDoc} */
@Override
public List<KnuthElement> getChangedKnuthElements(List oldList, int alignment) {
public List<ListElement> getChangedKnuthElements(List oldList, int alignment) {
ListIterator<KnuthElement> oldListIterator = oldList.listIterator();
KnuthElement returnedElement;
List<KnuthElement> returnedList = new LinkedList<KnuthElement>();
List<KnuthElement> returnList = new LinkedList<KnuthElement>();
List<ListElement> returnList = new LinkedList<>();
KnuthElement prevElement = null;
KnuthElement currElement = null;
int fromIndex = 0;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/apache/fop/layoutmgr/LayoutContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ public final class LayoutContext {
* A list of pending marks (border and padding) on the after edge when a page break occurs.
* May be null.
*/
private List pendingAfterMarks;
private List<ListElement> pendingAfterMarks;

/**
* A list of pending marks (border and padding) on the before edge when a page break occurs.
* May be null.
*/
private List pendingBeforeMarks;
private List<ListElement> pendingBeforeMarks;

/** Current hyphenation context. May be null. */
private HyphContext hyphContext;
Expand Down Expand Up @@ -178,10 +178,10 @@ private LayoutContext(int flags) {
/** @param source from which pending marks are copied */
public void copyPendingMarksFrom(LayoutContext source) {
if (source.pendingAfterMarks != null) {
this.pendingAfterMarks = new java.util.ArrayList(source.pendingAfterMarks);
this.pendingAfterMarks = new java.util.ArrayList<>(source.pendingAfterMarks);
}
if (source.pendingBeforeMarks != null) {
this.pendingBeforeMarks = new java.util.ArrayList(source.pendingBeforeMarks);
this.pendingBeforeMarks = new java.util.ArrayList<>(source.pendingBeforeMarks);
}
}

Expand Down Expand Up @@ -335,7 +335,7 @@ public SpaceSpecifier getTrailingSpace() {
*/
public void addPendingAfterMark(UnresolvedListElementWithLength element) {
if (this.pendingAfterMarks == null) {
this.pendingAfterMarks = new java.util.ArrayList();
this.pendingAfterMarks = new java.util.ArrayList<>();
}
this.pendingAfterMarks.add(element);
}
Expand All @@ -344,7 +344,7 @@ public void addPendingAfterMark(UnresolvedListElementWithLength element) {
* @return the pending border and padding elements at the after edge
* @see #addPendingAfterMark(UnresolvedListElementWithLength)
*/
public List getPendingAfterMarks() {
public List<ListElement> getPendingAfterMarks() {
if (this.pendingAfterMarks != null) {
return Collections.unmodifiableList(this.pendingAfterMarks);
} else {
Expand All @@ -368,7 +368,7 @@ public void clearPendingMarks() {
*/
public void addPendingBeforeMark(UnresolvedListElementWithLength element) {
if (this.pendingBeforeMarks == null) {
this.pendingBeforeMarks = new java.util.ArrayList();
this.pendingBeforeMarks = new java.util.ArrayList<>();
}
this.pendingBeforeMarks.add(element);
}
Expand All @@ -377,7 +377,7 @@ public void addPendingBeforeMark(UnresolvedListElementWithLength element) {
* @return the pending border and padding elements at the before edge
* @see #addPendingBeforeMark(UnresolvedListElementWithLength)
*/
public List getPendingBeforeMarks() {
public List<ListElement> getPendingBeforeMarks() {
if (this.pendingBeforeMarks != null) {
return Collections.unmodifiableList(this.pendingBeforeMarks);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public StaticContentLayoutManager(PageSequenceLayoutManager pslm,
}

/** {@inheritDoc} */
public List getNextKnuthElements(LayoutContext context, int alignment) {
public List<ListElement> getNextKnuthElements(LayoutContext context, int alignment) {
throw new IllegalStateException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ public boolean handleOverflow(int milliPoints) {
return true;
}

public List addALetterSpaceTo(List oldList) {
public List<ListElement> addALetterSpaceTo(List<ListElement> oldList) {
return oldList;
}

public List addALetterSpaceTo(List oldList, int depth) {
public List<ListElement> addALetterSpaceTo(List<ListElement> oldList, int depth) {
return oldList;
}

Expand All @@ -314,15 +314,15 @@ public String getWordChars(Position pos) {
public void hyphenate(Position pos, HyphContext hyphContext) {
}

public boolean applyChanges(List oldList) {
public boolean applyChanges(List<ListElement> oldList) {
return false;
}

public boolean applyChanges(List oldList, int depth) {
public boolean applyChanges(List<ListElement> oldList, int depth) {
return false;
}

public List getChangedKnuthElements(List oldList, int alignment, int depth) {
public List<ListElement> getChangedKnuthElements(List<ListElement> oldList, int alignment, int depth) {
return oldList;
}

Expand Down
Loading

0 comments on commit 055f5f6

Please sign in to comment.