diff options
author | Simon Pepping <spepping@apache.org> | 2010-12-18 11:36:28 +0000 |
---|---|---|
committer | Simon Pepping <spepping@apache.org> | 2010-12-18 11:36:28 +0000 |
commit | e914537cba3c39675b04de25c292b1f51d46e3e0 (patch) | |
tree | d401e72b84f51bb254f058387c2cc3d3ab6242ff | |
parent | c4aab2f512ffa516e3ebfcf7566ebff4998afa2b (diff) | |
parent | d4ec49dd8f220752be8a5ab0cf6d6f4e30a1e685 (diff) | |
download | xmlgraphics-fop-e914537cba3c39675b04de25c292b1f51d46e3e0.tar.gz xmlgraphics-fop-e914537cba3c39675b04de25c292b1f51d46e3e0.zip |
Merge from trunk
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ComplexScripts@1050618 13f79535-47bb-0310-9956-ffa450edef68
11 files changed, 252 insertions, 18 deletions
diff --git a/src/java/org/apache/fop/afp/AFPStreamer.java b/src/java/org/apache/fop/afp/AFPStreamer.java index 154ca4cc9..65686b92a 100644 --- a/src/java/org/apache/fop/afp/AFPStreamer.java +++ b/src/java/org/apache/fop/afp/AFPStreamer.java @@ -174,6 +174,14 @@ public class AFPStreamer implements Streamable { outputStream.close(); + + if (documentOutputStream != null) { + documentOutputStream.close(); + } + + if (documentFile != null) { + documentFile.close(); + } // delete temporary file tempFile.delete(); } @@ -213,4 +221,4 @@ public class AFPStreamer implements Streamable { // long end = System.currentTimeMillis(); // log.debug("writing time " + (end - start) + "ms"); } -}
\ No newline at end of file +} diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index b4aabeea1..bca42186e 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -19,13 +19,13 @@ package org.apache.fop.area; -import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.fo.Constants; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.fo.Constants; + /** * The line area. * This is a line area that contains inline areas. @@ -59,6 +59,15 @@ public class LineArea extends Area { variationFactor = 1.0; bAddedToAreaTree = false; } + + /** {@inheritDoc} */ + public String toString() { + return getClass().getSimpleName() + + ": diff=" + difference + + ", variation=" + variationFactor + + ", stretch=" + availableStretch + + ", shrink=" + availableShrink; + } } private LineAdjustingInfo adjustingInfo = null; @@ -208,6 +217,9 @@ public class LineArea extends Area { */ public void finish() { if (adjustingInfo.lineAlignment == Constants.EN_JUSTIFY) { + if (log.isTraceEnabled()) { + log.trace("Applying variation factor to justified line: " + adjustingInfo); + } // justified line: apply the variation factor boolean bUnresolvedAreasPresent = false; // recursively apply variation factor to descendant areas diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index 7463cab50..874ab0903 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.java @@ -245,6 +245,11 @@ public class InlineArea extends Area { * @param ipdVariation the variation */ public void handleIPDVariation(int ipdVariation) { + if (log.isTraceEnabled()) { + log.trace("Handling IPD variation for " + getClass().getSimpleName() + + ": increase by " + ipdVariation + " mpt."); + } + increaseIPD(ipdVariation); notifyIPDVariation(ipdVariation); } diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index 786170186..9e69e00a7 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.java @@ -19,11 +19,10 @@ package org.apache.fop.area.inline; -import org.apache.fop.area.Area; - -import java.util.ArrayList; -import java.util.Iterator; import java.util.List; +import java.util.Iterator; + +import org.apache.fop.area.Area; /** * Inline parent area. @@ -36,7 +35,7 @@ public class InlineParent extends InlineArea { /** * The list of inline areas added to this inline parent. */ - protected List inlines = new ArrayList(); + protected List<InlineArea> inlines = new java.util.ArrayList<InlineArea>(); /** Controls whether the IPD is automatically adjusted based on the area's children. */ protected transient boolean autoSize; @@ -52,13 +51,14 @@ public class InlineParent extends InlineArea { * * @param childArea the child area to add */ + @Override public void addChildArea(Area childArea) { if (inlines.size() == 0) { autoSize = (getIPD() == 0); } if (childArea instanceof InlineArea) { InlineArea inlineChildArea = (InlineArea) childArea; - inlines.add(childArea); + inlines.add(inlineChildArea); // set the parent area for the child area inlineChildArea.setParentArea(this); if (autoSize) { @@ -73,7 +73,7 @@ public class InlineParent extends InlineArea { * * @return the list of child areas */ - public List getChildAreas() { + public List<InlineArea> getChildAreas() { return inlines; } @@ -84,14 +84,20 @@ public class InlineParent extends InlineArea { * @param lineShrink the total shrink of the line * @return true if there is an UnresolvedArea descendant */ + @Override public boolean applyVariationFactor(double variationFactor, int lineStretch, int lineShrink) { boolean bUnresolvedAreasPresent = false; + int cumulativeIPD = 0; // recursively apply variation factor to descendant areas for (int i = 0, len = inlines.size(); i < len; i++) { - bUnresolvedAreasPresent |= ((InlineArea)inlines.get(i)) - .applyVariationFactor(variationFactor, lineStretch, lineShrink); + InlineArea inline = inlines.get(i); + bUnresolvedAreasPresent |= inline.applyVariationFactor( + variationFactor, lineStretch, lineShrink); + cumulativeIPD += inline.getIPD(); //Update this area's IPD based on changes to children } + setIPD(cumulativeIPD); + return bUnresolvedAreasPresent; } diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index ee010efe5..877da13dd 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -323,7 +323,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager } if (ElementListUtils.endsWithForcedBreak(returnedList)) { // a descendant of this block has break-after - if (curLM.isFinished()) { + if (curLM.isFinished() && !hasNextChildLM()) { // there is no other content in this block; // it's useless to add space after before a page break setFinished(true); diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java index 4a6a59615..8d8de3d22 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java @@ -285,8 +285,9 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager KnuthElement oldElement; while (oldListIterator.hasNext()) { oldElement = (KnuthElement) oldListIterator.next(); - oldElement.setPosition - (oldElement.getPosition().getPosition()); + if (oldElement.getPosition() != null) { + oldElement.setPosition(oldElement.getPosition().getPosition()); + } } // reset the iterator oldListIterator = oldList.listIterator(); @@ -338,8 +339,11 @@ public abstract class InlineStackingLayoutManager extends AbstractLayoutManager oldListIterator = oldList.listIterator(); while (oldListIterator.hasNext()) { oldElement = (KnuthElement) oldListIterator.next(); - oldElement.setPosition - (notifyPos(new NonLeafPosition(this, oldElement.getPosition()))); + NonLeafPosition newPos = new NonLeafPosition(this, oldElement.getPosition()); + if (newPos.generatesAreas()) { + notifyPos(newPos); + } + oldElement.setPosition(newPos); } return bSomethingChanged; } diff --git a/status.xml b/status.xml index d933ef686..2f2608cfd 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,12 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> <release version="FOP Trunk" date="TBD"> + <action context="Layout" dev="VH" type="fix" fixes-bug="50089"> + Bugfix: content after forced break in block-container is not rendered. + </action> + <action context="Layout" dev="JM" type="fix" fixes-bug="42034"> + Fixed adjustment of inline parent area for justified text containing a forward page reference. + </action> <action context="Layout" dev="AD" type="fix" fixes-bug="38264"> Fixed behavior when combining hyphenation with preserved linefeeds or whitespace. </action> diff --git a/test/layoutengine/standard-testcases/basic-link_for_toc.xml b/test/layoutengine/standard-testcases/basic-link_for_toc.xml new file mode 100644 index 000000000..9966c54b1 --- /dev/null +++ b/test/layoutengine/standard-testcases/basic-link_for_toc.xml @@ -0,0 +1,53 @@ +<?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 fo:basic-link in conjunction with text-align="justify" and an + fo:page-number-citation. + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in"> + <fo:region-body/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="normal"> + <fo:flow flow-name="xsl-region-body"> + <fo:block text-align="justify"> + You can read about Apache FOP in + <fo:basic-link external-destination="http://xmlgraphics.apache.org/fop/" + >chapter 1 on page <fo:page-number-citation ref-id="1"/></fo:basic-link>. + Apache FOP is open source, BTW. + </fo:block> + <fo:block id="1"/> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="http://xmlgraphics.apache.org/fop/" xpath="substring-after(//flow/block[1]/lineArea/inlineparent/@external-link,'dest=')"/> + <eval expected="360000" xpath="//flow/block[1]/lineArea/@ipd"/> + <eval expected="104440" xpath="//flow/block[1]/lineArea/inlineparent/text[1]/@ipd"/> + <eval expected="6672" xpath="//flow/block[1]/lineArea/inlineparent/text[2]/@ipd"/> + <eval expected="111112" xpath="//flow/block[1]/lineArea/inlineparent/@ipd"/> + </checks> +</testcase> diff --git a/test/layoutengine/standard-testcases/block-container_break.xml b/test/layoutengine/standard-testcases/block-container_break.xml new file mode 100644 index 000000000..352f755f0 --- /dev/null +++ b/test/layoutengine/standard-testcases/block-container_break.xml @@ -0,0 +1,47 @@ +<?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 that a forced break on a child element of an fo:block-container is honored. + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="page" + page-height="420pt" page-width="320pt" margin="10pt"> + <fo:region-body/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="page"> + <fo:flow flow-name="xsl-region-body"> + <fo:block-container> + <fo:block id="before-break" break-after="page">Before the break.</fo:block> + <fo:block id="after-break">After the break.</fo:block> + </fo:block-container> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="2" xpath="count(//pageViewport)"/> + <eval expected="After the break." xpath="//pageViewport[2]//flow/block/block/block//text"/> + </checks> +</testcase> diff --git a/test/layoutengine/standard-testcases/inline_hyphenation_border.xml b/test/layoutengine/standard-testcases/inline_hyphenation_border.xml new file mode 100644 index 000000000..f3c133e6e --- /dev/null +++ b/test/layoutengine/standard-testcases/inline_hyphenation_border.xml @@ -0,0 +1,49 @@ +<?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 whether the border is properly rendered with + hyphenation. I effectively checks whether + InlineStackingLM.applyChanges rewraps the positions properly. + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="normal" page-width="210mm" page-height="297mm"> + <fo:region-body/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="normal"> + <fo:flow flow-name="xsl-region-body"> + <fo:block hyphenate="true" language="en"> + <fo:inline border-color="#000000" border-style="solid" border-width="1pt">Test</fo:inline> + </fo:block> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="(solid,#000000,1000)" xpath="//flow/block[1]/lineArea/inlineparent/@border-start"/> + <eval expected="(solid,#000000,1000)" xpath="//flow/block[1]/lineArea/inlineparent/@border-end"/> + <eval expected="(solid,#000000,1000)" xpath="//flow/block[1]/lineArea/inlineparent/@border-before"/> + <eval expected="(solid,#000000,1000)" xpath="//flow/block[1]/lineArea/inlineparent/@border-after"/> + </checks> +</testcase> diff --git a/test/layoutengine/standard-testcases/knuth_element-null_position.xml b/test/layoutengine/standard-testcases/knuth_element-null_position.xml new file mode 100644 index 000000000..cf964fdf5 --- /dev/null +++ b/test/layoutengine/standard-testcases/knuth_element-null_position.xml @@ -0,0 +1,44 @@ +<?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 check tests that Knuth elements with a null position do +not cause a NPE (in InlineStackingLM.applyChanges)</p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" hyphenate="true" language="de"> + <fo:layout-master-set> + <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm"> + <fo:region-body/> + </fo:simple-page-master> + </fo:layout-master-set> + + <fo:page-sequence master-reference="A4"> + + <fo:flow flow-name="xsl-region-body"> + <fo:block><fo:inline padding-left="1cm"><fo:basic-link internal-destination="N1003F">Abluftanlage</fo:basic-link></fo:inline></fo:block> + <fo:block id="N1003F"/> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="Abluftanlage" xpath="//flow/block/lineArea/inlineparent/inlineparent/text/word"/> + </checks> +</testcase> |