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: BlockLevelEventProducer.java 1733431 2016-03-03 09:40:50Z gadams $ */
19 
20 package org.apache.fop.layoutmgr;
21 
22 import org.xml.sax.Locator;
23 
24 import org.apache.fop.events.EventBroadcaster;
25 import org.apache.fop.events.EventProducer;
26 import org.apache.fop.fo.pagination.PageProductionException;
27 
28 /**
29  * Event producer interface for block-level layout managers.
30  */
31 public interface BlockLevelEventProducer extends EventProducer {
32 
33     /**
34      * Provider class for the event producer.
35      */
36     final class Provider {
37 
Provider()38         private Provider() { }
39 
40         /**
41          * Returns an event producer.
42          * @param broadcaster the event broadcaster to use
43          * @return the event producer
44          */
get(EventBroadcaster broadcaster)45         public static BlockLevelEventProducer get(EventBroadcaster broadcaster) {
46             return broadcaster.getEventProducerFor(BlockLevelEventProducer.class);
47         }
48     }
49 
50     /**
51      * The contents of a table-row are too big to fit in the constraints.
52      * @param source the event source
53      * @param row the row number
54      * @param effCellBPD the effective extent in block-progression direction of the cell
55      * @param maxCellBPD the maximum extent in block-progression direction of the cell
56      * @param loc the location of the error or null
57      * @event.severity WARN
58      */
rowTooTall(Object source, int row, int effCellBPD, int maxCellBPD, Locator loc)59     void rowTooTall(Object source, int row, int effCellBPD, int maxCellBPD, Locator loc);
60 
61     /**
62      * Auto-table layout is not supported, yet.
63      * @param source the event source
64      * @param loc the location of the error or null
65      * @event.severity INFO
66      */
tableFixedAutoWidthNotSupported(Object source, Locator loc)67     void tableFixedAutoWidthNotSupported(Object source, Locator loc);
68 
69     /**
70      * An formatting object is too wide.
71      * @param source the event source
72      * @param elementName the formatting object
73      * @param effIPD the effective extent in inline-progression direction of the table contents
74      * @param maxIPD the maximum extent in inline-progression direction available
75      * @param loc the location of the error or null
76      * @event.severity WARN
77      */
objectTooWide(Object source, String elementName, int effIPD, int maxIPD, Locator loc)78     void objectTooWide(Object source, String elementName, int effIPD, int maxIPD, Locator loc);
79 
80     /**
81      * An overconstrained geometry adjustment rule was triggered (5.3.4, XSL 1.0).
82      * @param source the event source
83      * @param elementName the formatting object
84      * @param amount the amount of the adjustment (in mpt)
85      * @param loc the location of the error or null
86      * @event.severity INFO
87      */
overconstrainedAdjustEndIndent(Object source, String elementName, int amount, Locator loc)88     void overconstrainedAdjustEndIndent(Object source, String elementName, int amount, Locator loc);
89 
90     /**
91      * Contents IPD overflow a viewport.
92      * @param source the event source
93      * @param elementName the formatting object
94      * @param amount the amount by which the contents overflow (in mpt)
95      * @param clip true if the content will be clipped
96      * @param canRecover indicates whether FOP can recover from this problem and continue working
97      * @param loc the location of the error or null
98      * @event.severity ERROR
99      */
viewportIPDOverflow(Object source, String elementName, int amount, boolean clip, boolean canRecover, Locator loc)100     void viewportIPDOverflow(Object source, String elementName, int amount, boolean clip,
101             boolean canRecover, Locator loc);
102 
103     /**
104      * Contents BPD overflow a viewport.
105      * @param source the event source
106      * @param elementName the formatting object
107      * @param amount the amount by which the contents overflow (in mpt)
108      * @param clip true if the content will be clipped
109      * @param canRecover indicates whether FOP can recover from this problem and continue working
110      * @param loc the location of the error or null
111      * @event.severity ERROR
112      */
viewportBPDOverflow(Object source, String elementName, int amount, boolean clip, boolean canRecover, Locator loc)113     void viewportBPDOverflow(Object source, String elementName, int amount, boolean clip,
114             boolean canRecover, Locator loc);
115 
116     /**
117      * Contents overflow a region viewport.
118      * @param source the event source
119      * @param elementName the formatting object
120      * @param page the page number/name where the overflow happened
121      * @param amount the amount by which the contents overflow (in mpt)
122      * @param clip true if the content will be clipped
123      * @param canRecover indicates whether FOP can recover from this problem and continue working
124      * @param loc the location of the error or null
125      * @throws LayoutException the layout error provoked by the method call
126      * @event.severity FATAL
127      */
regionOverflow(Object source, String elementName, String page, int amount, boolean clip, boolean canRecover, Locator loc)128     void regionOverflow(Object source, String elementName,
129             String page,
130             int amount, boolean clip, boolean canRecover,
131             Locator loc) throws LayoutException;
132 
133     /**
134      * Contents overflow a static region viewport.
135      * @param source the event source
136      * @param elementName the formatting object
137      * @param page the page number/name where the overflow happened
138      * @param amount the amount by which the contents overflow (in mpt)
139      * @param clip true if the content will be clipped
140      * @param canRecover indicates whether FOP can recover from this problem and continue working
141      * @param loc the location of the error or null
142      * @throws LayoutException the layout error provoked by the method call
143      * @event.severity FATAL
144      */
staticRegionOverflow(Object source, String elementName, String page, int amount, boolean clip, boolean canRecover, Locator loc)145     void staticRegionOverflow(Object source, String elementName,
146             String page,
147             int amount, boolean clip, boolean canRecover,
148             Locator loc) throws LayoutException;
149 
150     /**
151      * Indicates that FOP doesn't support flows that are not mapped to region-body, yet.
152      * @param source the event source
153      * @param flowName the flow name
154      * @param masterName the page master name
155      * @param loc the location of the error or null
156      * @throws UnsupportedOperationException the layout error provoked by the method call
157      * @event.severity FATAL
158      */
flowNotMappingToRegionBody(Object source, String flowName, String masterName, Locator loc)159     void flowNotMappingToRegionBody(Object source, String flowName, String masterName,
160             Locator loc) throws UnsupportedOperationException;
161 
162     /**
163      * A page sequence master is exhausted.
164      * @param source the event source
165      * @param pageSequenceMasterName the name of the page sequence master
166      * @param canRecover indicates whether FOP can recover from this problem and continue working
167      * @param loc the location of the error or null
168      * @throws PageProductionException the error provoked by the method call
169      * @event.severity FATAL
170      */
pageSequenceMasterExhausted(Object source, String pageSequenceMasterName, boolean canRecover, Locator loc)171     void pageSequenceMasterExhausted(Object source, String pageSequenceMasterName,
172             boolean canRecover, Locator loc) throws PageProductionException;
173 
174     /**
175      * No subsequences in page sequence master.
176      * @param source the event source
177      * @param pageSequenceMasterName the name of the page sequence master
178      * @param loc the location of the error or null
179      * @throws PageProductionException the error provoked by the method call
180      * @event.severity FATAL
181      */
missingSubsequencesInPageSequenceMaster(Object source, String pageSequenceMasterName, Locator loc)182     void missingSubsequencesInPageSequenceMaster(Object source, String pageSequenceMasterName,
183             Locator loc) throws PageProductionException;
184 
185     /**
186      * No single-page-master matching in page sequence master.
187      * @param source the event source
188      * @param pageSequenceMasterName the name of the page sequence master
189      * @param pageMasterName the name of the page master not matching
190      * @param loc the location of the error or null
191      * @throws PageProductionException the error provoked by the method call
192      * @event.severity FATAL
193      */
noMatchingPageMaster(Object source, String pageSequenceMasterName, String pageMasterName, Locator loc)194     void noMatchingPageMaster(Object source, String pageSequenceMasterName,
195             String pageMasterName, Locator loc) throws PageProductionException;
196 
197     /**
198      * An element that cannot handle changing IPD (list, table) is flowing to a narrower
199      * page. Some content may be lost.
200      *
201      * @param source the event source
202      * @event.severity WARN
203      */
nonRestartableContentFlowingToNarrowerPage(Object source)204     void nonRestartableContentFlowingToNarrowerPage(Object source);
205 
206     /**
207      * A feasible layout has reached the given number of parts (columns or pages).
208      *
209      * @param source the event source
210      * @param partCount the number of parts that the layout has reached
211      * @event.severity INFO
212      */
layoutHasReachedParts(Object source, int partCount)213     void layoutHasReachedParts(Object source, int partCount);
214 
215     /**
216      * Last page master reference missing.
217      *
218      * @param source the event source
219      * @event.severity WARN
220      */
lastPageMasterReferenceMissing(Object source, Locator loc)221     void lastPageMasterReferenceMissing(Object source, Locator loc);
222 }
223