aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/layoutmgr/AbstractBPLayoutManager.java
blob: 9a0218f74c68b2969bb316791db45a68e7b1bb9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * $Id$
 * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
 * For details on use and redistribution please refer to the
 * LICENSE file included with these sources.
 */

package org.apache.fop.layoutmgr;

import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyManager;
import org.apache.fop.fo.FONode;
import org.apache.fop.area.Area;

import java.util.ListIterator;
import java.util.ArrayList;

/**
 * The base class for all BPLayoutManagers.
 */
public abstract class AbstractBPLayoutManager extends AbstractLayoutManager
    implements BPLayoutManager {


    /** True if this LayoutManager has handled all of its content. */
    private boolean m_bFinished = false;


    public AbstractBPLayoutManager(FObj fobj) {
	super(fobj);
    }


    /**
     * This method provides a hook for a LayoutManager to intialize traits
     * for the areas it will create, based on Properties set on its FO.
     */
    protected final void initProperties() {
 	if (fobj != null) {
	    initProperties(fobj.getPropertyManager());
 	}
    }


    /**
     * This method provides a hook for a LayoutManager to intialize traits
     * for the areas it will create, based on Properties set on its FO.
     */
    protected void initProperties(PropertyManager pm) {
	System.err.println("AbstractBPLayoutManager.initProperties");
    }


    /**
     * Tell whether this LayoutManager has handled all of its content.
     * @return True if there are no more break possibilities,
     * ie. the last one returned represents the end of the content.
     */
    public boolean isFinished() {
	return m_bFinished;
    }

    public void setFinished(boolean bFinished) {
	m_bFinished = bFinished;
    }


//     /**
//      * Get the BreakPoss at the start of the next "area".
//      * @param lc The LayoutContext for this LayoutManager.
//      * @param bpPrevEnd The Position returned by the previous call
//      * to getNextBreakPoss, or null if none.
//      */
//     public BreakPoss getStartBreakPoss(LayoutContext lc,
// 				       BreakPoss.Position bpPrevEnd) {
// 	return null;
//     }


    /**
     * Generate and return the next break possibility.
     * Each layout manager must implement this.
     * TODO: should this be abstract or is there some reasonable
     * default implementation?
     */
    public BreakPoss getNextBreakPoss(LayoutContext context) {
	return getNextBreakPoss(context, null);
    }


    public BreakPoss getNextBreakPoss(LayoutContext context,
				      BreakPoss.Position prevBreakPoss) {
	return null;
    }

    /**
     * Return value indicating whether the next area to be generated could
     * start a new line or flow area.
     * In general, if can't break at the current level, delegate to
     * the first child LM.
     * NOTE: should only be called if the START_AREA flag is set in context,
     * since the previous sibling LM must have returned a BreakPoss which
     * does not allow break-after.
     * QUESTION: in block-stacked areas, does this mean some kind of keep
     * condition, or is it only used for inline-stacked areas?
     * Default implementation always returns true.
     */
    public boolean canBreakBefore(LayoutContext context) {
	return true;
    }


    public void addAreas(PositionIterator parentIter) {
    }

    /* ---------------------------------------------------------
     * PROVIDE NULL IMPLEMENTATIONS OF METHODS from LayoutManager
     * interface which are declared abstract in AbstractLayoutManager.
     * ---------------------------------------------------------*/
    public Area getParentArea(Area childArea) {
	return null;
    }

    protected boolean flush() {
	return false;
    }



    public boolean addChild(Area childArea) {
        return false;
    }
}