Browse Source

Bugzilla 42748: Added support for ids on empty fo:inlines



git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@591437 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_95beta
Andreas L. Delmelle 16 years ago
parent
commit
4368d83184

+ 1
- 3
src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java View File

@@ -270,9 +270,7 @@ public class LayoutManagerMapping implements LayoutManagerMaker {

public static class InlineLayoutManagerMaker extends Maker {
public void make(FONode node, List lms) {
if (node.getChildNodes() != null) {
lms.add(new InlineLayoutManager((InlineLevel) node));
}
lms.add(new InlineLayoutManager((InlineLevel) node));
}
}


+ 26
- 9
src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java View File

@@ -30,7 +30,6 @@ import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.InlineBlockParent;
import org.apache.fop.area.inline.InlineParent;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.InlineLevel;
import org.apache.fop.fo.flow.Leader;
@@ -44,6 +43,7 @@ import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.layoutmgr.BlockKnuthSequence;
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.InlineKnuthSequence;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
@@ -108,7 +108,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
}
private Inline getInlineFO() {
return (Inline)fobj;
return (Inline) fobj;
}
/** {@inheritDoc} */
@@ -379,6 +379,24 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {

setFinished(true);
log.trace(trace);
if (returnList.size() == 0) {
/*
* if the FO itself is empty, but has an id specified
* or associated fo:markers, then we still need a dummy
* sequence to register its position in the area tree
*/
if (fobj.hasId() || fobj.hasMarkers()) {
InlineKnuthSequence emptySeq = new InlineKnuthSequence();
emptySeq.add(new KnuthInlineBox(
0,
alignmentContext,
notifyPos(getAuxiliaryPosition()),
true));
returnList.add(emptySeq);
}
}
return returnList.size() == 0 ? null : returnList;
}

@@ -394,8 +412,6 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
public void addAreas(PositionIterator parentIter,
LayoutContext context) {
Position lastPos = null;
addId();

setChildContext(new LayoutContext(context)); // Store current value
@@ -420,7 +436,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
// layout context given to the other LMs.
LinkedList positionList = new LinkedList();
NonLeafPosition pos = null;
LayoutManager lastLM = null; // last child LM in this iterator
LayoutManager lastLM = null;// last child LM in this iterator
Position lastPos = null;
while (parentIter.hasNext()) {
pos = (NonLeafPosition) parentIter.next();
if (pos != null && pos.getPosition() != null) {
@@ -556,10 +573,10 @@ public class InlineLayoutManager extends InlineStackingLayoutManager {
/** {@inheritDoc} */
protected void addId() {
if (fobj instanceof Inline) {
getPSLM().addIDToPage(getInlineFO().getId());
}
getPSLM().addIDToPage(fobj.getId());
}
public String toString() {
return (this.getClass().getName() + "[fobj=" + fobj.toString() + "]");
}
}


+ 50
- 0
test/layoutengine/standard-testcases/page-number-citation_empty-inline.xml View File

@@ -0,0 +1,50 @@
<?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 a page-number-citation for an empty fo:inline (see Bugzilla 42748).
</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="20in"
margin="20pt">
<fo:region-body background-color="yellow"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence id="page-sequence1" master-reference="normal" white-space-collapse="true">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:block>text<fo:inline id="empty-inline1" />text</fo:block>
</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="normal">
<fo:flow flow-name="xsl-region-body" font-size="8pt">
<fo:block><fo:page-number-citation ref-id="empty-inline1" /></fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</fo>
<checks>
<true fail-msg="no ID for empty inline" xpath="'1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]"/>
</checks>
</testcase>

Loading…
Cancel
Save