private Renderer rendererOverride = null;
private FOEventHandler foEventHandlerOverride = null;
private boolean locatorEnabled = true; // true by default (for error messages).
+ private boolean conserveMemoryPolicy = false;
private EventBroadcaster eventBroadcaster = new FOPEventBroadcaster();
/** Producer: Metadata element for the system/software that produces
}
+ /**
+ * Check whether memory-conservation is enabled.
+ *
+ * @return true if FOP is to conserve as much as possible
+ */
+ public boolean isConserveMemoryPolicyEnabled() {
+ return this.conserveMemoryPolicy;
+ }
+
+ /**
+ * Control whether memory-conservation should be enabled
+ *
+ * @param conserveMemoryPolicy the cachingEnabled to set
+ */
+ public void setConserveMemoryPolicy(boolean conserveMemoryPolicy) {
+ this.conserveMemoryPolicy = conserveMemoryPolicy;
+ }
+
}
*/
protected void setupModel(FOUserAgent userAgent, String outputFormat,
OutputStream stream) throws FOPException {
- this.model = new RenderPagesModel(userAgent, outputFormat, fontInfo, stream);
+ if (userAgent.isConserveMemoryPolicyEnabled()) {
+ this.model = new CachedRenderPagesModel(userAgent, outputFormat, fontInfo, stream);
+ } else {
+ this.model = new RenderPagesModel(userAgent, outputFormat, fontInfo, stream);
+ }
}
/**
/**
* Default constructor
- * @param areaTreeHandler area tree handler
*/
protected Statistics() {
this.runtime = Runtime.getRuntime();
try {
// save page to cache
ObjectOutputStream tempstream;
- String fname = "fop-page-" + page.toString() + ".ser";
+ String fname = "fop-page-" + page.getPageIndex() + ".ser";
File tempFile = new File(baseDir, fname);
tempFile.deleteOnExit();
tempstream = new ObjectOutputStream(new BufferedOutputStream(
package org.apache.fop.area.inline;
+import java.io.Serializable;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.LineArea;
import org.apache.fop.area.Trait;
* that can be used in order to re-compute adjustments when a
* page-number or a page-number-citation is resolved
*/
- protected class InlineAdjustingInfo {
+ protected class InlineAdjustingInfo implements Serializable {
/** stretch of the inline area */
protected int availableStretch;
/** shrink of the inline area */
private Map renderingOptions = new java.util.HashMap();
/* target resolution (for the user agent) */
private int targetResolution = 0;
+ /* control memory-conservation policy */
+ private boolean conserveMemoryPolicy = false;
private FopFactory factory = FopFactory.newInstance();
private FOUserAgent foUserAgent;
}
addXSLTParameter("fop-output-format", getOutputFormat());
addXSLTParameter("fop-version", Version.getVersion());
+ foUserAgent.setConserveMemoryPolicy(conserveMemoryPolicy);
} else {
return false;
}
setLogOption("debug", "debug");
} else if (args[i].equals("-r")) {
factory.setStrictValidation(false);
+ } else if (args[i].equals("-conserve")) {
+ conserveMemoryPolicy = true;
} else if (args[i].equals("-dpi")) {
i = i + parseResolution(args, i);
} else if (args[i].equals("-q") || args[i].equals("--quiet")) {
+ " -noannotations PDF file will be encrypted without edit annotation permission\n"
+ " -pdfprofile prof PDF file will be generated with the specified profile\n"
+ " (Examples for prof: PDF/A-1b or PDF/X-3:2003)\n\n"
+ + " -conserve Enable memory-conservation policy (trades memory-consumption for disk I/O)"
+ + " (Note: currently only influences whether the area tree is serialized.)"
+ " [INPUT] \n"
+ " infile xsl:fo input file (the same as the next) \n"
+ " (use '-' for infile to pipe input from stdin)\n"
addChildToArea(childArea, getCurrentArea());
}
+ /** {@inheritDoc} */
+ protected void notifyEndOfLayout() {
+ super.notifyEndOfLayout();
+ // Free memory of the area tree
+ //this.parentArea = null;
+ }
+
/**
* Force current area to be added to parent area.
*/
// ? "penalty" : (lastElement.isGlue() ? "glue" : "box" )));
/*LF*/ //log.debug(" position e' " + lastElement.getPosition().getClass().getName());
/*LF*/ //log.debug(" " + (bpUnit > 0 ? "unit" : ""));
- Position innerPosition = ((NonLeafPosition) lastElement.getPosition()).getPosition();
+ Position innerPosition = lastElement.getPosition().getPosition();
if (innerPosition == null && lastElement.isGlue()) {
// this adjustment applies to space-before or space-after of this block
/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> chiamata passata");
return ((BlockLevelLayoutManager)storedPenalty.getLayoutManager())
.negotiateBPDAdjustment(storedPenalty.getW(),
- (KnuthElement)storedPenalty);
+ storedPenalty);
} else {
// the original penalty has width = 0
// the adjustment involves only the spaces before and after
returnList.add(new KnuthGlue(0, 0, 0,
SPACE_AFTER_ADJUSTMENT,
new NonLeafPosition(this, null),
- (!spaceAfterIsConditional) ? false : true));
+ spaceAfterIsConditional));
} else {
returnList.add(new KnuthGlue(adjustedSpaceAfter, 0, 0,
SPACE_AFTER_ADJUSTMENT,
new NonLeafPosition(this, null),
- (!spaceAfterIsConditional) ? false : true));
+ spaceAfterIsConditional));
}
if (!spaceAfterIsConditional) {
returnList.add(new KnuthBox(0,
totalLength.add(new MinOptMax(element.getW()));
//log.debug("box " + element.getW());
} else if (element.isGlue()) {
- totalLength.min -= ((KnuthGlue) element).getZ();
- totalLength.max += ((KnuthGlue) element).getY();
+ totalLength.min -= element.getZ();
+ totalLength.max += element.getY();
//leafValue = ((LeafPosition) element.getPosition()).getLeafPos();
//log.debug("glue " + element.getW() + " + "
// + ((KnuthGlue) element).getY() + " - " + ((KnuthGlue) element).getZ());
lengthAfterBreak.subtract(new MinOptMax(element.getW()));
bPrevIsBox = true;
} else if (element.isGlue()) {
- lengthBeforeBreak.min -= ((KnuthGlue) element).getZ();
- lengthAfterBreak.min += ((KnuthGlue) element).getZ();
- lengthBeforeBreak.max += ((KnuthGlue) element).getY();
- lengthAfterBreak.max -= ((KnuthGlue) element).getY();
+ lengthBeforeBreak.min -= element.getZ();
+ lengthAfterBreak.min += element.getZ();
+ lengthBeforeBreak.max += element.getY();
+ lengthAfterBreak.max -= element.getY();
bPrevIsBox = false;
} else {
lengthBeforeBreak.add(new MinOptMax(element.getW()));
}
// create the new elements
- if (element.isPenalty() && ((KnuthPenalty) element).getP() < KnuthElement.INFINITE
+ if (element.isPenalty() && element.getP() < KnuthElement.INFINITE
|| element.isGlue() && bPrevIsBox
|| !oldListIterator.hasNext()) {
// suppress elements after the breaking point
iStepsForward++;
if (el.isGlue()) {
// suppressed glue
- lengthAfterBreak.min += ((KnuthGlue) el).getZ();
- lengthAfterBreak.max -= ((KnuthGlue) el).getY();
+ lengthAfterBreak.min += el.getZ();
+ lengthAfterBreak.max -= el.getY();
} else if (el.isPenalty()) {
// suppressed penalty, do nothing
} else {
for (int i = 0; i < iStepsForward; i++) {
KnuthElement el = (KnuthElement) oldListIterator.previous();
if (el.isGlue()) {
- lengthAfterBreak.min -= ((KnuthGlue) el).getZ();
- lengthAfterBreak.max += ((KnuthGlue) el).getY();
+ lengthAfterBreak.min -= el.getZ();
+ lengthAfterBreak.max += el.getY();
}
}
p.setP(0);
}
- notifyEndOfLayout();
-
setFinished(true);
return returnList;
}
flush();
curBlockArea = null;
+
+ notifyEndOfLayout();
}
/** Adds background areas for the column, body and row, if any. */
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Code" dev="AD" type="add" fixes-bug="46828" due-to="Dario Laera">
+ Added the possibility to use CachedRenderPagesModel, to conserve memory in case
+ of large documents with a lot of cross-references (area tree will be serialized to
+ disk to avoid keeping it entirely in memory).
+ </action>
<action context="Fonts" dev="JM" type="add">
- AFP Fonts: Added support for full URI resolution on configured AFP fonts.
+ AFP Fonts: Added support for full URI resolution on configured AFP fonts.
</action>
<action context="Renderers" dev="JM" type="add">
AFP Output: Tag Logical Element (TLE) is now also allowed on fo:page-sequence
- (page group level).
+ (page group level).
</action>
<action context="Layout" dev="JM" type="fix">
Fixed BPD trait and border painting for leaders with leader-pattern="space"
- (and similar cases).
+ (and similar cases).
</action>
<action context="Renderers" dev="JM" type="add">
- AFP Output: Added support for Invoke Medium Map (IMM).
+ AFP Output: Added support for Invoke Medium Map (IMM).
</action>
<action context="Renderers" dev="JM" type="add">
Introduced a new, additional intermediate format optimized for performance. Please see
code.
</action>
<action context="Code" dev="VH" type="fix" fixes-bug="46638">
- MinOptMaxUtil.toMinOptMax was converting LengthRangeProperty objects into illegal MinOptMax
+ MinOptMaxUtil.toMinOptMax was converting LengthRangeProperty objects into illegal MinOptMax
objects (in some cases opt could be inferior to min).
</action>
<action context="Layout" dev="VH" type="add" fixes-bug="46315" due-to="Georg Datterl">
- Added extension to disable column balancing before blocks spanning the whole page, in
+ Added extension to disable column balancing before blocks spanning the whole page, in
multiple-column documents.
</action>
<action context="Renderers" dev="JM" type="add">