View | Details | Raw Unified | Return to bug 47530
Collapse All | Expand All

(-)src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java (-3 / +34 lines)
Lines 24-33 Link Here
24
import org.apache.fop.fo.flow.Wrapper;
24
import org.apache.fop.fo.flow.Wrapper;
25
import org.apache.fop.layoutmgr.BlockLayoutManager;
25
import org.apache.fop.layoutmgr.BlockLayoutManager;
26
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
26
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
27
import org.apache.fop.layoutmgr.KnuthBox;
28
import org.apache.fop.layoutmgr.KnuthSequence;
27
import org.apache.fop.layoutmgr.LayoutContext;
29
import org.apache.fop.layoutmgr.LayoutContext;
30
import org.apache.fop.layoutmgr.ListElement;
28
import org.apache.fop.layoutmgr.PositionIterator;
31
import org.apache.fop.layoutmgr.PositionIterator;
29
import org.apache.fop.layoutmgr.TraitSetter;
32
import org.apache.fop.layoutmgr.TraitSetter;
30
33
34
import java.util.LinkedList;
35
import java.util.List;
36
31
/**
37
/**
32
 * This is the layout manager for the fo:wrapper formatting object.
38
 * This is the layout manager for the fo:wrapper formatting object.
33
 */
39
 */
Lines 54-67 Link Here
54
        return area;
60
        return area;
55
    }
61
    }
56
62
63
57
    /**
64
    /**
65
     * Overridden to generate a proper {@link ListElement}, if the parent
66
     * requires it (i.e. is a block-container, list-item-body...)
67
     * If the parent is a block, the line LM will take care of properly
68
     * wrapping the sequence in a line box.
69
     * {@inheritDoc}
70
     */
71
    @Override
72
    public List getNextKnuthElements(LayoutContext context, int alignment) {
73
        List returnList = super.getNextKnuthElements(context, alignment);
74
        KnuthSequence seq = (KnuthSequence) returnList.get(0);
75
        ListElement tempElement = (ListElement) seq.get(0);
76
        if (parentLayoutManager instanceof BlockStackingLayoutManager
77
                && !(parentLayoutManager instanceof BlockLayoutManager)) {
78
            // replace inline box with a block box
79
            returnList = new LinkedList();
80
            KnuthBox auxiliaryBox = new KnuthBox(0, tempElement.getPosition(), true);
81
            returnList.add(auxiliaryBox);
82
        } else {
83
            // make sure the inline box is an auxiliary one
84
            seq.set(0, new KnuthInlineBox(0, null, tempElement.getPosition(), true));
85
        }
86
        return returnList;
87
    }
88
89
    /**
58
     * Add the area for this layout manager.
90
     * Add the area for this layout manager.
59
     * This adds the dummy area to the parent, *if* it has an id
91
     * This adds the dummy area to the parent, *if* it has an id
60
     * - otherwise it serves no purpose.
92
     * - otherwise it serves no purpose.
61
     *
93
     * {@inheritDoc}
62
     * @param posIter the position iterator
63
     * @param context the layout context for adding the area
64
     */
94
     */
95
    @Override
65
    public void addAreas(PositionIterator posIter, LayoutContext context) {
96
    public void addAreas(PositionIterator posIter, LayoutContext context) {
66
        if (fobj.hasId()) {
97
        if (fobj.hasId()) {
67
            addId();
98
            addId();
(-)test/layoutengine/standard-testcases/wrapper_block.xml (-11 / +82 lines)
Lines 23-29 Link Here
23
    </p>
23
    </p>
24
  </info>
24
  </info>
25
  <fo>
25
  <fo>
26
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
26
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
27
      <fo:layout-master-set>
27
      <fo:layout-master-set>
28
        <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
28
        <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
29
          <fo:region-body/>
29
          <fo:region-body/>
Lines 31-51 Link Here
31
      </fo:layout-master-set>
31
      </fo:layout-master-set>
32
      <fo:page-sequence master-reference="normal">
32
      <fo:page-sequence master-reference="normal">
33
        <fo:flow flow-name="xsl-region-body">
33
        <fo:flow flow-name="xsl-region-body">
34
          <fo:wrapper color="red">
34
          <fo:wrapper color="red" font-size="8pt">
35
            <fo:block>block content.</fo:block>
35
            <fo:block>w-1</fo:block>
36
          </fo:wrapper>
36
          </fo:wrapper>
37
          <fo:block>
38
            <!-- triggers creation of a blank lineArea; bug? -->
39
            <fo:wrapper color="green" font-size="9pt">
40
              <fo:block>w-2</fo:block>
41
            </fo:wrapper>
42
          </fo:block>
43
          <fo:block-container>
44
            <fo:wrapper color="blue" font-size="10pt">
45
              <fo:block>w-3</fo:block>
46
            </fo:wrapper>
47
          </fo:block-container>
48
          <fo:list-block>
49
            <fo:list-item>
50
              <fo:list-item-label end-indent="label-end()">
51
                <!-- does not work; causes the list content to be dropped... -->
52
                <!--fo:wrapper color="red" font-size="8pt"-->
53
                  <fo:block>w-4</fo:block>
54
                <!--/fo:wrapper-->
55
              </fo:list-item-label>
56
              <fo:list-item-body start-indent="body-start() + 5pt">
57
                <fo:wrapper color="green" font-size="9pt">
58
                  <fo:block>w-5</fo:block>
59
                  <fo:block>w-5</fo:block>
60
                  <fo:block>w-5</fo:block>
61
                </fo:wrapper>
62
              </fo:list-item-body>
63
            </fo:list-item>
64
          </fo:list-block>
65
          <fo:table>
66
            <fo:table-column />
67
            <fo:table-body>
68
              <fo:table-cell starts-row="true" ends-row="true">
69
                <fo:wrapper color="blue" font-size="10pt">
70
                  <fo:block>w-6</fo:block>
71
                  <fo:block>w-6</fo:block>
72
                </fo:wrapper>
73
              </fo:table-cell>
74
            </fo:table-body>
75
          </fo:table>
37
        </fo:flow>
76
        </fo:flow>
38
      </fo:page-sequence>
77
      </fo:page-sequence>
39
    </fo:root>
78
    </fo:root>
40
  </fo>
79
  </fo>
41
  <checks>
80
  <checks>
42
    <!-- Just check if this really results in 1 line. -->
81
    <!-- Check the amount of lines, inherited property values and content -->
43
    <element-list category="breaker">
82
    <!-- wrapper as child of flow -->
44
      <skip>2</skip>
83
    <eval expected="1" xpath="count(//lineArea//word[.='w-1'])"/>
45
      <box w="14400"/>
84
    <eval expected="#ff0000" xpath="(//flow[1]//lineArea)[1]/text[1]/@color"/>
46
      <skip>3</skip>
85
    <eval expected="8000" xpath="(//flow[1]//lineArea)[1]/text[1]/@font-size"/>
47
    </element-list>
86
    <eval expected="w-1" xpath="(//flow[1]//lineArea)[1]//word" />
48
    <eval expected="1" xpath="count(//lineArea)"/>
87
    <!-- wrapper as child of block; generates an extra line area? -->
49
    <eval expected="#ff0000" xpath="//flow/block/lineArea[1]/text[1]/@color"/>
88
    <eval expected="1" xpath="count(//lineArea//word[.='w-2'])"/>
89
    <eval expected="#008000" xpath="(//flow[1]//lineArea)[3]/text[1]/@color"/>
90
    <eval expected="9000" xpath="(//flow[1]//lineArea)[3]/text[1]/@font-size"/>
91
    <eval expected="w-2" xpath="(//flow[1]//lineArea)[3]//word" />
92
    <!-- wrapper as child of block-container -->
93
    <eval expected="1" xpath="count(//lineArea//word[.='w-3'])"/>
94
    <eval expected="#0000ff" xpath="(//flow[1]//lineArea)[4]/text[1]/@color"/>
95
    <eval expected="10000" xpath="(//flow[1]//lineArea)[4]/text[1]/@font-size"/>
96
    <eval expected="w-3" xpath="(//flow[1]//lineArea)[4]//word" />
97
    <!-- wrapper as child of list-item-label -->
98
    <!--eval expected="1" xpath="count(//lineArea//word[.='w-4'])"/>
99
    <eval expected="#ff0000" xpath="(//flow[1]//lineArea)[5]/text[1]/@color"/>
100
    <eval expected="8000" xpath="(//flow[1]//lineArea)[5]/text[1]/@font-size"/>
101
    <eval expected="w-4" xpath="(//flow[1]//lineArea)[5]//word" /-->
102
    <!-- wrapper as child of list-item-body -->
103
    <eval expected="3" xpath="count(//lineArea//word[.='w-5'])"/>
104
    <eval expected="#008000" xpath="(//flow[1]//lineArea)[6]/text[1]/@color"/>
105
    <eval expected="9000" xpath="(//flow[1]//lineArea)[6]/text[1]/@font-size"/>
106
    <eval expected="w-5" xpath="(//flow[1]//lineArea)[6]//word" />
107
    <eval expected="#008000" xpath="(//flow[1]//lineArea)[7]/text[1]/@color"/>
108
    <eval expected="9000" xpath="(//flow[1]//lineArea)[7]/text[1]/@font-size"/>
109
    <eval expected="w-5" xpath="(//flow[1]//lineArea)[7]//word" />
110
    <eval expected="#008000" xpath="(//flow[1]//lineArea)[8]/text[1]/@color"/>
111
    <eval expected="9000" xpath="(//flow[1]//lineArea)[8]/text[1]/@font-size"/>
112
    <eval expected="w-5" xpath="(//flow[1]//lineArea)[8]//word" />
113
    <!-- wrapper as child of table-cell -->
114
    <eval expected="2" xpath="count(//lineArea//word[.='w-6'])"/>
115
    <eval expected="#0000ff" xpath="(//flow[1]//lineArea)[9]/text[1]/@color"/>
116
    <eval expected="10000" xpath="(//flow[1]//lineArea)[9]/text[1]/@font-size"/>
117
    <eval expected="w-6" xpath="(//flow[1]//lineArea)[9]//word" />
118
    <eval expected="#0000ff" xpath="(//flow[1]//lineArea)[10]/text[1]/@color"/>
119
    <eval expected="10000" xpath="(//flow[1]//lineArea)[10]/text[1]/@font-size"/>
120
    <eval expected="w-6" xpath="(//flow[1]//lineArea)[10]//word" />
50
  </checks>
121
  </checks>
51
</testcase>
122
</testcase>

Return to bug 47530