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

(-)src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java (+574 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 * 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 * 
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
/* $Id: InlineContainerLayoutManager.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20
package org.apache.fop.layoutmgr.inline;
21
22
// Java
23
import java.util.LinkedList;
24
import java.util.List;
25
import java.util.ListIterator;
26
import java.awt.geom.Rectangle2D;
27
28
import org.apache.fop.area.Area;
29
import org.apache.fop.area.Block;
30
import org.apache.fop.area.Trait;
31
import org.apache.fop.area.CTM;
32
import org.apache.fop.area.inline.InlineArea;
33
import org.apache.fop.area.inline.InlineBlockParent;
34
import org.apache.fop.area.inline.Viewport;
35
import org.apache.fop.datatypes.FODimension;
36
import org.apache.fop.datatypes.Length;
37
import org.apache.fop.fo.flow.InlineContainer;
38
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
39
import org.apache.fop.fo.properties.SpaceProperty;
40
import org.apache.fop.fo.Constants;
41
import org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager.StackingIter;
42
import org.apache.fop.layoutmgr.AbstractBreaker;
43
import org.apache.fop.layoutmgr.ElementListObserver;
44
import org.apache.fop.layoutmgr.InlineKnuthSequence;
45
import org.apache.fop.layoutmgr.KnuthSequence;
46
import org.apache.fop.layoutmgr.LayoutContext;
47
import org.apache.fop.layoutmgr.LayoutManager;
48
import org.apache.fop.layoutmgr.LeafPosition;
49
import org.apache.fop.layoutmgr.ListElement;
50
import org.apache.fop.layoutmgr.NonLeafPosition;
51
import org.apache.fop.layoutmgr.PageBreakingAlgorithm;
52
import org.apache.fop.layoutmgr.Position;
53
import org.apache.fop.layoutmgr.PositionIterator;
54
import org.apache.fop.layoutmgr.SpaceResolver;
55
import org.apache.fop.layoutmgr.TraitSetter;
56
import org.apache.fop.traits.MinOptMax;
57
/**
58
 * This creates a single inline container area after
59
 * laying out the child block areas. All footnotes, floats
60
 * and id areas are maintained for later retrieval.
61
 */
62
public class InlineContainerLayoutManager extends LeafNodeLayoutManager {
63
64
    Viewport currentViewport;
65
    InlineArea referenceArea;
66
    Block baseBlockArea;
67
    
68
    /** The Common Border, Padding and Background properties */
69
    private CommonBorderPaddingBackground borderProps = null;
70
    /** The alignment adjust property */
71
    private Length alignmentAdjust;
72
    /** The alignment baseline property */
73
    private int alignmentBaseline = EN_BASELINE;
74
    /** The baseline shift property */
75
    private Length baselineShift;
76
    /** The dominant baseline property */
77
    private int dominantBaseline;
78
    /** The line height property */
79
    private SpaceProperty lineHeight;
80
81
    private Length height;
82
    private Length width;
83
    private boolean autoHeight;
84
    private boolean inlineElementList;
85
86
    private int contentAreaBPD;
87
    private int contentAreaIPD;
88
    private int viewportContentBPD;
89
    private int referenceIPD;
90
91
    private FODimension relDims;
92
    private CTM absoluteCTM;
93
94
    private LayoutManager lastChildLM = null;
95
    
96
97
    /**
98
     * Construct a new InlineContainerLayoutManager
99
     * for the the given {@link InlineContainer}
100
     *
101
     * @param node  the base {@link InlineContainer}
102
     */
103
    public InlineContainerLayoutManager(InlineContainer node) {
104
        super(node);
105
    }
106
    
107
    /** {@inheritDoc} */
108
    public void initialize() {
109
        InlineContainer node = (InlineContainer) fobj;
110
        
111
        borderProps = node.getCommonBorderPaddingBackground();
112
        
113
        alignmentAdjust = node.getAlignmentAdjust();
114
        alignmentBaseline = node.getAlignmentBaseline();
115
        baselineShift = node.getBaselineShift();
116
        dominantBaseline = node.getDominantBaseline();
117
        
118
        boolean rotated = (node.getReferenceOrientation() % 180 != 0);
119
        if (rotated) {
120
            height = node.getInlineProgressionDimension()
121
                            .getOptimum(this).getLength();
122
            width = node.getBlockProgressionDimension()
123
                            .getOptimum(this).getLength();
124
        } else {
125
            height = node.getBlockProgressionDimension()
126
                            .getOptimum(this).getLength();
127
            width = node.getInlineProgressionDimension()
128
                            .getOptimum(this).getLength();
129
        }
130
131
    }
132
    
133
    /** {@inheritDoc} */
134
    public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
135
136
        InlineContainer ic = (InlineContainer) fobj;
137
        boolean rotated = (ic.getReferenceOrientation() % 180 != 0);
138
        autoHeight = false;
139
        int maxbpd = context.getStackLimitBP().opt;
140
        int allocBPD;
141
        if (height.getEnum() == EN_AUTO
142
                || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) {
143
            //auto height when height="auto" or "if that dimension is not specified explicitly
144
            //(i.e., it depends on content's block-progression-dimension)" (XSL 1.0, 7.14.1)
145
            allocBPD = maxbpd;
146
            autoHeight = true;
147
            if (ic.getReferenceOrientation() == 0) {
148
                //Cannot easily inline element list when ref-or="180"
149
                inlineElementList = true;
150
            }
151
        } else {
152
            allocBPD = height.getValue(this); //this is the content-height
153
            allocBPD += borderProps.getBPPaddingAndBorder(false, this);
154
        }
155
        viewportContentBPD = allocBPD - borderProps.getBPPaddingAndBorder(false, this);
156
157
        referenceIPD = context.getRefIPD();
158
159
        double contentRectOffsetX = 0;
160
        //contentRectOffsetX += ic.getCommonMarginInline().spaceStart.getLength().getValue(this);
161
        double contentRectOffsetY = 0;
162
        contentRectOffsetY += borderProps.getBorderBeforeWidth(false);
163
        contentRectOffsetY += borderProps.getPaddingBefore(false, this);
164
165
        updateRelDims(contentRectOffsetX, contentRectOffsetY, autoHeight);
166
167
        if (getContentAreaIPD() > referenceIPD) {
168
            InlineLevelEventProducer eventProducer
169
                    = InlineLevelEventProducer.Provider.get(
170
                        ic.getUserAgent().getEventBroadcaster());
171
            eventProducer.lineOverflows(
172
                    this, 0,
173
                    (getContentAreaIPD() - referenceIPD), ic.getLocator());
174
        }
175
176
        LinkedList returnList = new LinkedList();
177
        KnuthSequence inlineSeq = new InlineKnuthSequence();
178
        
179
        addKnuthElementsForBorderPaddingStart(inlineSeq);
180
181
        MinOptMax refIPD = new MinOptMax(width.getValue(this));
182
        InlineContainerBreaker breaker = new InlineContainerBreaker(this, refIPD);
183
        breaker.doLayout(height.getValue(this), autoHeight);
184
185
        if (!breaker.isEmpty()) {
186
            if (autoHeight) {
187
                //Update content BPD now that it is known
188
                int newHeight = breaker.deferredAlg.getTotalWidth();
189
                if (rotated) {
190
                    setContentAreaIPD(newHeight);
191
                } else {
192
                    viewportContentBPD = newHeight;
193
                }
194
                updateRelDims(contentRectOffsetX, contentRectOffsetY, false);
195
            }
196
197
            Position icPosition = new InlineContainerPosition(this, breaker);
198
            inlineSeq.add(new KnuthInlineBox(refIPD.opt, makeAlignmentContext(context), notifyPos(icPosition), false));
199
        }
200
201
        addKnuthElementsForBorderPaddingEnd(inlineSeq);
202
203
        returnList.add(inlineSeq);
204
        
205
        setFinished(true);
206
        
207
        return returnList;
208
    }
209
210
    /** {@inheritDoc} */
211
    public void addChildArea(Area childArea) {
212
        baseBlockArea.addBlock((Block) childArea);
213
    }
214
215
    /** {@inheritDoc} */
216
    public void addAreas(PositionIterator posIter, LayoutContext context) {
217
218
        /* "Unwrap" the NonLeafPositions stored in parentIter and put
219
         * them in a new list.  Set lastLM to be the LayoutManager
220
         * which created the last Position: if the LAST_AREA flag is
221
         * set in the layout context, it must be also set in the
222
         * layout context given to lastLM, but must be cleared in the
223
         * layout context given to the other LMs. */
224
        LinkedList positionList = new LinkedList();
225
        Position pos;
226
        LayoutManager lastLM = null;// last child LM in this iterator
227
        Position lastPos = null;
228
        InlineContainerPosition icPos = null;
229
        while (posIter.hasNext()) {
230
            pos = (Position) posIter.next();
231
            if (pos instanceof InlineContainerPosition) {
232
                assert (icPos == null);
233
                icPos = (InlineContainerPosition)pos;
234
            }
235
            if (pos != null && pos.getPosition() != null) {
236
                positionList.add(pos.getPosition());
237
                lastLM = pos.getPosition().getLM();
238
                lastPos = pos;
239
            }
240
        }
241
242
        addId();
243
        addMarkersToPage(
244
                true, 
245
                true, 
246
                lastPos == null || isLast(lastPos));
247
248
        LayoutManager prevLM = null;
249
250
        if (icPos == null) {
251
            StackingIter childPosIter
252
                = new StackingIter(positionList.listIterator());
253
254
            LayoutManager childLM;
255
            while ((childLM = childPosIter.getNextChildLM()) != null) {
256
                context.setFlags(LayoutContext.LAST_AREA,
257
                                      context.isLastArea() && childLM == lastLM);
258
                childLM.addAreas(childPosIter, context);
259
                context.setLeadingSpace(context.getTrailingSpace());
260
                context.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
261
                prevLM = childLM;
262
            }
263
264
            currentViewport.setContent(referenceArea);;
265
            parentLM.addChildArea(currentViewport);
266
        } else {
267
            icPos.breaker.addContainedAreas();
268
        }
269
270
        addMarkersToPage(
271
                false, 
272
                true, 
273
                lastPos == null || isLast(lastPos));
274
        
275
        boolean isLast = (context.isLastArea() && prevLM == lastChildLM);
276
        context.setFlags(LayoutContext.LAST_AREA, isLast);
277
    }
278
279
    /** {@inheritDoc} */
280
    public int getContentAreaIPD() {
281
        return width.getEnum() == EN_AUTO
282
                ? contentAreaIPD
283
                    : width.getValue(this);
284
    }
285
286
    /**
287
     * Sets the IPD of the content area
288
     * @param contentAreaIPD the IPD of the content area
289
     */
290
    private void setContentAreaIPD(int contentAreaIPD) {
291
        this.contentAreaIPD = contentAreaIPD;
292
    }
293
294
    /** {@inheritDoc} */
295
    public int getContentAreaBPD() {
296
        return height.getEnum() == EN_AUTO
297
                ? contentAreaBPD 
298
                    : height.getValue(this);
299
    }
300
    
301
    /**
302
     * Get the parent area for children of this inline-container.
303
     * This returns the current inline-container area
304
     * and creates it if required.
305
     *
306
     * {@inheritDoc}
307
     */
308
    public Area getParentArea(Area childArea) {
309
        if (referenceArea == null) {
310
            currentViewport = new Viewport(childArea);
311
            currentViewport.addTrait(Trait.IS_VIEWPORT_AREA, Boolean.TRUE);
312
            currentViewport.setIPD(getContentAreaIPD());
313
            currentViewport.setBPD(this.viewportContentBPD);
314
            
315
            TraitSetter.setProducerID(currentViewport, fobj.getId());
316
            TraitSetter.addBorders(currentViewport, 
317
                    borderProps, 
318
                    false, false, false, false, this);
319
            TraitSetter.addPadding(currentViewport, 
320
                    borderProps, 
321
                    false, false, false, false, this);
322
            TraitSetter.addBackground(currentViewport, 
323
                    borderProps,
324
                    this);
325
            
326
            currentViewport.setContentPosition(
327
                    new java.awt.geom.Rectangle2D.Float(0, 0, getContentAreaIPD(), getContentAreaBPD()));
328
            referenceArea = new InlineBlockParent();
329
            referenceArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
330
            TraitSetter.setProducerID(referenceArea, fobj.getId());
331
            // Set up dimensions
332
            // Must get dimensions from parent area
333
            parentLM.getParentArea(referenceArea);
334
            referenceArea.setIPD(width.getValue(this));
335
            baseBlockArea = new Block();
336
            referenceArea.addChildArea(baseBlockArea);
337
            // Get reference IPD from parentArea
338
            setCurrentArea(currentViewport); // ??? for generic operations
339
        }
340
        return referenceArea;
341
    }
342
    
343
    private boolean needClip() {
344
        int overflow = ((InlineContainer) fobj).getOverflow();
345
        return (overflow == EN_HIDDEN || overflow == EN_ERROR_IF_OVERFLOW);
346
    }
347
    
348
    /**
349
     * {@inheritDoc}
350
     */
351
    protected AlignmentContext makeAlignmentContext(LayoutContext context) {
352
        return new AlignmentContext(
353
                viewportContentBPD
354
                , alignmentAdjust
355
                , alignmentBaseline
356
                , baselineShift
357
                , dominantBaseline
358
                , context.getAlignmentContext()
359
            );
360
    }
361
362
    /**
363
     * Get the allocation ipd of the inline area.
364
     * This method may be overridden to handle percentage values.
365
     * @param refIPD the ipd of the parent reference area
366
     * @return the min/opt/max ipd of the inline area
367
     */
368
    protected MinOptMax getAllocationIPD(int refIPD) {
369
        return new MinOptMax(curArea.getIPD());
370
    }
371
372
    /**
373
     * "wrap" the Position inside each element moving the elements from
374
     * SourceList to targetList
375
     * @param sourceList source list
376
     * @param targetList target list receiving the wrapped position elements
377
     */
378
    protected void wrapPositionElements(List sourceList, List targetList) {
379
        wrapPositionElements(sourceList, targetList, false);
380
    }
381
382
    /**
383
     * "wrap" the Position inside each element moving the elements from
384
     * SourceList to targetList
385
     * @param sourceList source list
386
     * @param targetList target list receiving the wrapped position elements
387
     * @param force if true, every Position is wrapped regardless of its LM of origin
388
     */
389
    protected void wrapPositionElements(List sourceList, List targetList, boolean force) {
390
391
        ListIterator listIter = sourceList.listIterator();
392
        Object tempElement;
393
        while (listIter.hasNext()) {
394
            tempElement = listIter.next();
395
            if (tempElement instanceof ListElement) {
396
                wrapPositionElement(
397
                        (ListElement) tempElement,
398
                        targetList,
399
                        force);
400
            } else if (tempElement instanceof List) {
401
                wrapPositionElements(
402
                        (List) tempElement,
403
                        targetList,
404
                        force);
405
            }
406
        }
407
    }
408
409
    /**
410
     * "wrap" the Position inside the given element and add it to the target list.
411
     * @param el the list element
412
     * @param targetList target list receiving the wrapped position elements
413
     * @param force if true, every Position is wrapped regardless of its LM of origin
414
     */
415
    protected void wrapPositionElement(ListElement el, List targetList, boolean force) {
416
        if (force || el.getLayoutManager() != this) {
417
            el.setPosition(notifyPos(new NonLeafPosition(this,
418
                    el.getPosition())));
419
        }
420
        targetList.add(el);
421
    }
422
423
    private void updateRelDims(double xOffset, double yOffset, boolean skipAutoHeight) {
424
        Rectangle2D rect = new Rectangle2D.Double(
425
                xOffset, yOffset,
426
                getContentAreaIPD(),
427
                this.viewportContentBPD);
428
        relDims = new FODimension(0, 0);
429
        absoluteCTM = CTM.getCTMandRelDims(
430
                ((InlineContainer) fobj).getReferenceOrientation(),
431
                ((InlineContainer) fobj).getWritingMode(),
432
                rect, relDims);
433
    }
434
435
    private class InlineContainerPosition extends LeafPosition {
436
437
        private InlineContainerBreaker breaker;
438
439
        public InlineContainerPosition(LayoutManager lm, InlineContainerBreaker breaker) {
440
            super(lm, 0);
441
            this.breaker = breaker;
442
        }
443
444
        public InlineContainerBreaker getBreaker() {
445
            return this.breaker;
446
        }
447
448
    }
449
450
    private class InlineContainerBreaker extends AbstractBreaker {
451
452
        private InlineContainerLayoutManager iclm;
453
        private MinOptMax ipd;
454
455
        //Info for deferred adding of areas
456
        private PageBreakingAlgorithm deferredAlg;
457
        private BlockSequence deferredOriginalList;
458
        private BlockSequence deferredEffectiveList;
459
460
        public InlineContainerBreaker(InlineContainerLayoutManager iclm, MinOptMax ipd) {
461
            this.iclm = iclm;
462
            this.ipd = ipd;
463
        }
464
465
        /** {@inheritDoc} */
466
        protected void observeElementList(List elementList) {
467
            ElementListObserver.observe(
468
                    elementList,
469
                    "inline-container",
470
                    iclm.fobj.getId());
471
        }
472
473
        /** {@inheritDoc} */
474
        protected boolean isPartOverflowRecoveryActivated() {
475
            return false;
476
        }
477
478
        /** {@inheritDoc} */
479
        protected boolean isSinglePartFavored() {
480
            return true;
481
        }
482
483
        public int getDifferenceOfFirstPart() {
484
            PageBreakPosition pbp = (PageBreakPosition)this.deferredAlg.getPageBreaks().getFirst();
485
            return pbp.getDifference();
486
        }
487
488
        public boolean isOverflow() {
489
            return !isEmpty()
490
                    && ((deferredAlg.getPageBreaks().size() > 1)
491
                        || (deferredAlg.getOverflowAmount() > 0));
492
        }
493
494
        public int getOverflowAmount() {
495
            return deferredAlg.getOverflowAmount();
496
        }
497
498
        protected LayoutManager getTopLevelLM() {
499
            return iclm;
500
        }
501
502
        protected LayoutContext createLayoutContext() {
503
            LayoutContext lc = super.createLayoutContext();
504
            lc.setRefIPD(ipd.opt);
505
            lc.setWritingMode(((InlineContainer) fobj).getWritingMode());
506
            return lc;
507
        }
508
509
        protected LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
510
            LayoutManager curLM; // currently active LM
511
            LinkedList returnList = new LinkedList();
512
513
            while ((curLM = getChildLM()) != null) {
514
                LayoutContext childLC = new LayoutContext(0);
515
                childLC.setStackLimitBP(context.getStackLimitBP());
516
                childLC.setRefIPD(context.getRefIPD());
517
                childLC.setWritingMode(((InlineContainer)fobj).getWritingMode());
518
519
                LinkedList returnedList = null;
520
                if (!curLM.isFinished()) {
521
                    returnedList = curLM.getNextKnuthElements(childLC, alignment);
522
                }
523
                if (returnedList != null) {
524
                    iclm.wrapPositionElements(returnedList, returnList);
525
                }
526
            }
527
            SpaceResolver.resolveElementList(returnList);
528
            setFinished(true);
529
            return returnList;
530
        }
531
532
        protected int getCurrentDisplayAlign() {
533
            //TODO: Implement me!
534
            return Constants.EN_AUTO;
535
        }
536
537
        protected boolean hasMoreContent() {
538
            return !isFinished();
539
        }
540
541
        protected void addAreas(PositionIterator posIter, LayoutContext context) {
542
            iclm.addAreas(posIter, context);
543
        }
544
545
        protected void doPhase3(PageBreakingAlgorithm alg, int partCount,
546
                BlockSequence originalList, BlockSequence effectiveList) {
547
            //Defer adding of areas until addAreas is called by the parent LM
548
            this.deferredAlg = alg;
549
            this.deferredOriginalList = originalList;
550
            this.deferredEffectiveList = effectiveList;
551
        }
552
553
        protected void finishPart(PageBreakingAlgorithm alg, PageBreakPosition pbp) {
554
            //nop for bclm
555
        }
556
557
        protected LayoutManager getCurrentChildLM() {
558
            return curChildLM;
559
        }
560
561
        public void addContainedAreas() {
562
            if (isEmpty()) {
563
                return;
564
            }
565
            //Rendering all parts (not just the first) at once for the case where the parts that
566
            //overflow should be visible.
567
            this.deferredAlg.removeAllPageBreaks();
568
            this.addAreas(this.deferredAlg,
569
                          this.deferredAlg.getPageBreaks().size(),
570
                          this.deferredOriginalList, this.deferredEffectiveList);
571
        }
572
573
    }
574
}
(-)src/java/org/apache/fop/layoutmgr/BreakingAlgorithm.java (-14 / +30 lines)
Lines 22-27 Link Here
22
import org.apache.commons.logging.Log;
22
import org.apache.commons.logging.Log;
23
import org.apache.commons.logging.LogFactory;
23
import org.apache.commons.logging.LogFactory;
24
24
25
import org.apache.fop.fo.Constants;
25
import org.apache.fop.fo.FONode;
26
import org.apache.fop.fo.FONode;
26
27
27
/**
28
/**
Lines 156-165 Link Here
156
    private KnuthNode lastRecovered;
157
    private KnuthNode lastRecovered;
157
158
158
    /**
159
    /**
159
     * Create a new instance.
160
     * Create a new BreakingAlgorithm instance.
160
     * @param align alignment of the paragraph/page. One of EN_START, EN_JUSTIFY, etc. For
161
     *
161
     * pages EN_BEFORE, EN_AFTER are mapped to the corresponding inline properties
162
     * @param align alignment of the paragraph/page. One of {@link Constants#EN_START},
162
     * (EN_START, EN_END)
163
     * {@link Constants#EN_JUSTIFY}, etc. <i>Note: For pages, {@link Constants#EN_BEFORE}
164
     * and {@link Constants#EN_AFTER} are mapped to the corresponding inline properties
165
     * {@link Constants#EN_START} and {@link Constants#EN_END})
163
     * @param alignLast alignment of the paragraph's last line
166
     * @param alignLast alignment of the paragraph's last line
164
     * @param first for the text-indent property (indent the first line of a paragraph)
167
     * @param first for the text-indent property (indent the first line of a paragraph)
165
     * @param partOverflowRecovery true if too long elements should be moved to the next line/part
168
     * @param partOverflowRecovery true if too long elements should be moved to the next line/part
Lines 404-416 Link Here
404
        return findBreakingPoints(par, 0, threshold, force, allowedBreaks);
407
        return findBreakingPoints(par, 0, threshold, force, allowedBreaks);
405
    }
408
    }
406
    
409
    
407
    /** Finds an optimal set of breakpoints for the given paragraph.
410
    /**
411
     * Finds an optimal set of breakpoints for the given paragraph.
412
     *
408
     * @param par the paragraph to break
413
     * @param par               the paragraph to break
409
     * @param startIndex index of the Knuth element at which the breaking must start
414
     * @param startIndex        index of the {@link KnuthElement} at which
415
     *                          the breaking must start
410
     * @param threshold upper bound of the adjustment ratio
416
     * @param threshold         upper bound of the adjustment ratio
411
     * @param force true if a set of breakpoints must be found even if there are no
417
     * @param force             true if a set of breakpoints must be found
412
     * feasible ones
418
     *                          even if there are no feasible ones
413
     * @param allowedBreaks one of ONLY_FORCED_BREAKS, NO_FLAGGED_PENALTIES, ALL_BREAKS
419
     * @param allowedBreaks     one of {@link #ONLY_FORCED_BREAKS},
420
     *                          {@link #NO_FLAGGED_PENALTIES},
421
     *                          {@link #ALL_BREAKS}
422
     * @return the index of the optimal set of breakpoints
414
     */
423
     */
415
    public int findBreakingPoints(KnuthSequence par, int startIndex,
424
    public int findBreakingPoints(KnuthSequence par, int startIndex,
416
                                  double threshold, boolean force,
425
                                  double threshold, boolean force,
Lines 477-487 Link Here
477
                // only if its penalty is not infinite;
486
                // only if its penalty is not infinite;
478
                // consider all penalties, non-flagged penalties or non-forcing penalties
487
                // consider all penalties, non-flagged penalties or non-forcing penalties
479
                // according to the value of allowedBreaks
488
                // according to the value of allowedBreaks
480
                if (((KnuthPenalty) thisElement).getP() < KnuthElement.INFINITE
489
                if ((thisElement).getP() < KnuthElement.INFINITE
481
                    && (!(allowedBreaks == NO_FLAGGED_PENALTIES) 
490
                    && (!(allowedBreaks == NO_FLAGGED_PENALTIES) 
482
                            || !(((KnuthPenalty) thisElement).isFlagged()))
491
                            || !(((KnuthPenalty) thisElement).isFlagged()))
483
                    && (!(allowedBreaks == ONLY_FORCED_BREAKS) 
492
                    && (!(allowedBreaks == ONLY_FORCED_BREAKS) 
484
                            || ((KnuthPenalty) thisElement).getP() == -KnuthElement.INFINITE)) {
493
                            || (thisElement).getP() == -KnuthElement.INFINITE)) {
485
                    considerLegalBreak(thisElement, i);
494
                    considerLegalBreak(thisElement, i);
486
                }
495
                }
487
                previousIsBox = false;
496
                previousIsBox = false;
Lines 1141-1144 Link Here
1141
        return this.alignmentLast;
1150
        return this.alignmentLast;
1142
    }
1151
    }
1143
1152
1144
}
1153
    public int getOverflowAmount() {
1154
        return (this.totalWidth - this.totalShrink) - this.lineWidth;
1155
    }
1156
    
1157
    public int getTotalWidth() {
1158
        return this.totalWidth;
1159
    }
1160
}
(-)src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (-1 / +10 lines)
Lines 56-62 Link Here
56
            footnoteLastListIndex = flli;
56
            footnoteLastListIndex = flli;
57
            footnoteLastElementIndex = flei;
57
            footnoteLastElementIndex = flei;
58
        }
58
        }
59
    }
59
60
        /**
61
         * Accessor for the difference member
62
         *
63
         * @return the difference
64
         */
65
        public int getDifference() {
66
            return difference;
67
        }
68
    }
60
69
61
    public class BlockSequence extends BlockKnuthSequence {
70
    public class BlockSequence extends BlockKnuthSequence {
62
71
(-)src/java/org/apache/fop/render/AbstractRenderer.java (-1 / +2 lines)
Lines 718-724 Link Here
718
        currentIPPosition += ibp.getBorderAndPaddingWidthStart();
718
        currentIPPosition += ibp.getBorderAndPaddingWidthStart();
719
        // For inline content the BP position is updated by the enclosing line area
719
        // For inline content the BP position is updated by the enclosing line area
720
        int saveBP = currentBPPosition;
720
        int saveBP = currentBPPosition;
721
        currentBPPosition += ibp.getOffset();
722
        renderBlock(ibp.getChildArea());
721
        renderBlock(ibp.getChildArea());
723
        currentBPPosition = saveBP;
722
        currentBPPosition = saveBP;
724
    }
723
    }
Lines 738-743 Link Here
738
            renderContainer((Container) content);
737
            renderContainer((Container) content);
739
        } else if (content instanceof ForeignObject) {
738
        } else if (content instanceof ForeignObject) {
740
            renderForeignObject((ForeignObject) content, contpos);
739
            renderForeignObject((ForeignObject) content, contpos);
740
        } else if (content instanceof InlineBlockParent) {
741
            renderInlineBlockParent((InlineBlockParent) content);
741
        }
742
        }
742
        currentIPPosition += viewport.getAllocIPD();
743
        currentIPPosition += viewport.getAllocIPD();
743
        currentBPPosition = saveBP;
744
        currentBPPosition = saveBP;
(-)src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java (-5 / +2 lines)
Lines 72-78 Link Here
72
import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
72
import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
73
import org.apache.fop.layoutmgr.inline.ExternalGraphicLayoutManager;
73
import org.apache.fop.layoutmgr.inline.ExternalGraphicLayoutManager;
74
import org.apache.fop.layoutmgr.inline.FootnoteLayoutManager;
74
import org.apache.fop.layoutmgr.inline.FootnoteLayoutManager;
75
import org.apache.fop.layoutmgr.inline.ICLayoutManager;
75
import org.apache.fop.layoutmgr.inline.InlineContainerLayoutManager;
76
import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
76
import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
77
import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
77
import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
78
import org.apache.fop.layoutmgr.inline.InstreamForeignObjectLM;
78
import org.apache.fop.layoutmgr.inline.InstreamForeignObjectLM;
Lines 218-224 Link Here
218
    public static class Maker {
218
    public static class Maker {
219
        public void make(FONode node, List lms) {
219
        public void make(FONode node, List lms) {
220
            // no layout manager
220
            // no layout manager
221
            return;
222
        }
221
        }
223
    }
222
    }
224
223
Lines 283-291 Link Here
283
282
284
    public static class InlineContainerLayoutManagerMaker extends Maker {
283
    public static class InlineContainerLayoutManagerMaker extends Maker {
285
        public void make(FONode node, List lms) {
284
        public void make(FONode node, List lms) {
286
            ArrayList childList = new ArrayList();
285
            lms.add(new InlineContainerLayoutManager((InlineContainer) node));
287
            super.make(node, childList);
288
            lms.add(new ICLayoutManager((InlineContainer) node, childList));
289
        }
286
        }
290
    }
287
    }
291
288
(-)src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (-2 / +2 lines)
Lines 31-37 Link Here
31
import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition;
31
import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition;
32
import org.apache.fop.traits.MinOptMax;
32
import org.apache.fop.traits.MinOptMax;
33
33
34
class PageBreakingAlgorithm extends BreakingAlgorithm {
34
public class PageBreakingAlgorithm extends BreakingAlgorithm {
35
35
36
    /** the logger for the class */
36
    /** the logger for the class */
37
    private static Log log = LogFactory.getLog(PageBreakingAlgorithm.class);
37
    private static Log log = LogFactory.getLog(PageBreakingAlgorithm.class);
Lines 313-319 Link Here
313
                                    int elementIndex) {
313
                                    int elementIndex) {
314
        KnuthPageNode pageNode = (KnuthPageNode) activeNode;
314
        KnuthPageNode pageNode = (KnuthPageNode) activeNode;
315
        int actualWidth = totalWidth - pageNode.totalWidth;
315
        int actualWidth = totalWidth - pageNode.totalWidth;
316
        int footnoteSplit;
316
        int footnoteSplit = 0;
317
        boolean canDeferOldFootnotes;
317
        boolean canDeferOldFootnotes;
318
        if (element.isPenalty()) {
318
        if (element.isPenalty()) {
319
            actualWidth += element.getW();
319
            actualWidth += element.getW();

Return to bug 44885