You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TableLayoutManager.java 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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. /* $Id$ */
  18. package org.apache.fop.layoutmgr.table;
  19. import java.util.ArrayList;
  20. import java.util.Collections;
  21. import java.util.LinkedList;
  22. import java.util.List;
  23. import java.util.Map;
  24. import org.apache.commons.logging.Log;
  25. import org.apache.commons.logging.LogFactory;
  26. import org.apache.fop.area.Area;
  27. import org.apache.fop.area.Block;
  28. import org.apache.fop.datatypes.LengthBase;
  29. import org.apache.fop.fo.Constants;
  30. import org.apache.fop.fo.FONode;
  31. import org.apache.fop.fo.FObj;
  32. import org.apache.fop.fo.flow.Marker;
  33. import org.apache.fop.fo.flow.Markers;
  34. import org.apache.fop.fo.flow.RetrieveTableMarker;
  35. import org.apache.fop.fo.flow.table.Table;
  36. import org.apache.fop.fo.flow.table.TableColumn;
  37. import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
  38. import org.apache.fop.fo.properties.KeepProperty;
  39. import org.apache.fop.layoutmgr.BlockLevelEventProducer;
  40. import org.apache.fop.layoutmgr.BreakElement;
  41. import org.apache.fop.layoutmgr.BreakOpportunity;
  42. import org.apache.fop.layoutmgr.KnuthElement;
  43. import org.apache.fop.layoutmgr.KnuthGlue;
  44. import org.apache.fop.layoutmgr.LayoutContext;
  45. import org.apache.fop.layoutmgr.LeafPosition;
  46. import org.apache.fop.layoutmgr.ListElement;
  47. import org.apache.fop.layoutmgr.Position;
  48. import org.apache.fop.layoutmgr.PositionIterator;
  49. import org.apache.fop.layoutmgr.SpacedBorderedPaddedBlockLayoutManager;
  50. import org.apache.fop.layoutmgr.TraitSetter;
  51. import org.apache.fop.traits.MinOptMax;
  52. import org.apache.fop.traits.SpaceVal;
  53. import org.apache.fop.util.BreakUtil;
  54. /**
  55. * LayoutManager for a table FO.
  56. * A table consists of columns, table header, table footer and multiple
  57. * table bodies.
  58. * The header, footer and body add the areas created from the table cells.
  59. * The table then creates areas for the columns, bodies and rows
  60. * the render background.
  61. */
  62. public class TableLayoutManager extends SpacedBorderedPaddedBlockLayoutManager
  63. implements BreakOpportunity {
  64. /**
  65. * logging instance
  66. */
  67. private static Log log = LogFactory.getLog(TableLayoutManager.class);
  68. private TableContentLayoutManager contentLM;
  69. private ColumnSetup columns;
  70. private Block curBlockArea;
  71. private double tableUnit;
  72. private boolean autoLayout = true;
  73. private int halfBorderSeparationBPD;
  74. private int halfBorderSeparationIPD;
  75. /** See {@link TableLayoutManager#registerColumnBackgroundArea(TableColumn, Block, int)}. */
  76. private List columnBackgroundAreas;
  77. private Position auxiliaryPosition;
  78. // this holds a possible list of TCLMs that needed to have their addAreas() repeated
  79. private List<TableCellLayoutManager> savedTCLMs;
  80. private boolean areAllTCLMsSaved;
  81. private Markers tableMarkers;
  82. private Markers tableFragmentMarkers;
  83. private boolean hasRetrieveTableMarker;
  84. private boolean repeatedHeader;
  85. private List<List<KnuthElement>> headerFootnotes = Collections.emptyList();
  86. private List<List<KnuthElement>> footerFootnotes = Collections.emptyList();
  87. /**
  88. * Temporary holder of column background informations for a table-cell's area.
  89. *
  90. * @see TableLayoutManager#registerColumnBackgroundArea(TableColumn, Block, int)
  91. */
  92. private static final class ColumnBackgroundInfo {
  93. private TableColumn column;
  94. private Block backgroundArea;
  95. private int xShift;
  96. private ColumnBackgroundInfo(TableColumn column, Block backgroundArea, int xShift) {
  97. this.column = column;
  98. this.backgroundArea = backgroundArea;
  99. this.xShift = xShift;
  100. }
  101. }
  102. /**
  103. * Create a new table layout manager.
  104. * @param node the table FO
  105. */
  106. public TableLayoutManager(Table node) {
  107. super(node);
  108. this.columns = new ColumnSetup(node);
  109. }
  110. @Override
  111. protected CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
  112. return getTable().getCommonBorderPaddingBackground();
  113. }
  114. /** @return the table FO */
  115. public Table getTable() {
  116. return (Table)this.fobj;
  117. }
  118. /**
  119. * @return the column setup for this table.
  120. */
  121. public ColumnSetup getColumns() {
  122. return this.columns;
  123. }
  124. /** {@inheritDoc} */
  125. public void initialize() {
  126. foSpaceBefore = new SpaceVal(
  127. getTable().getCommonMarginBlock().spaceBefore, this).getSpace();
  128. foSpaceAfter = new SpaceVal(
  129. getTable().getCommonMarginBlock().spaceAfter, this).getSpace();
  130. startIndent = getTable().getCommonMarginBlock().startIndent.getValue(this);
  131. endIndent = getTable().getCommonMarginBlock().endIndent.getValue(this);
  132. if (getTable().isSeparateBorderModel()) {
  133. this.halfBorderSeparationBPD = getTable().getBorderSeparation().getBPD().getLength()
  134. .getValue(this) / 2;
  135. this.halfBorderSeparationIPD = getTable().getBorderSeparation().getIPD().getLength()
  136. .getValue(this) / 2;
  137. } else {
  138. this.halfBorderSeparationBPD = 0;
  139. this.halfBorderSeparationIPD = 0;
  140. }
  141. if (!getTable().isAutoLayout()
  142. && getTable().getInlineProgressionDimension().getOptimum(this).getEnum()
  143. != EN_AUTO) {
  144. autoLayout = false;
  145. }
  146. }
  147. private void resetSpaces() {
  148. this.discardBorderBefore = false;
  149. this.discardBorderAfter = false;
  150. this.discardPaddingBefore = false;
  151. this.discardPaddingAfter = false;
  152. this.effSpaceBefore = null;
  153. this.effSpaceAfter = null;
  154. }
  155. /**
  156. * @return half the value of border-separation.block-progression-dimension, or 0 if
  157. * border-collapse="collapse".
  158. */
  159. public int getHalfBorderSeparationBPD() {
  160. return halfBorderSeparationBPD;
  161. }
  162. /**
  163. * @return half the value of border-separation.inline-progression-dimension, or 0 if
  164. * border-collapse="collapse".
  165. */
  166. public int getHalfBorderSeparationIPD() {
  167. return halfBorderSeparationIPD;
  168. }
  169. /** {@inheritDoc} */
  170. public List getNextKnuthElements(LayoutContext context, int alignment) {
  171. List returnList = new LinkedList();
  172. /*
  173. * Compute the IPD and adjust it if necessary (overconstrained)
  174. */
  175. referenceIPD = context.getRefIPD();
  176. if (getTable().getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) {
  177. int contentIPD = getTable().getInlineProgressionDimension().getOptimum(this)
  178. .getLength().getValue(this);
  179. updateContentAreaIPDwithOverconstrainedAdjust(contentIPD);
  180. } else {
  181. if (!getTable().isAutoLayout()) {
  182. BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
  183. getTable().getUserAgent().getEventBroadcaster());
  184. eventProducer.tableFixedAutoWidthNotSupported(this, getTable().getLocator());
  185. }
  186. updateContentAreaIPDwithOverconstrainedAdjust();
  187. }
  188. int sumOfColumns = columns.getSumOfColumnWidths(this);
  189. if (!autoLayout && sumOfColumns > getContentAreaIPD()) {
  190. log.debug(FONode.decorateWithContextInfo(
  191. "The sum of all column widths is larger than the specified table width.",
  192. getTable()));
  193. updateContentAreaIPDwithOverconstrainedAdjust(sumOfColumns);
  194. }
  195. int availableIPD = referenceIPD - getIPIndents();
  196. if (getContentAreaIPD() > availableIPD) {
  197. BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
  198. getTable().getUserAgent().getEventBroadcaster());
  199. eventProducer.objectTooWide(this, getTable().getName(),
  200. getContentAreaIPD(), context.getRefIPD(),
  201. getTable().getLocator());
  202. }
  203. /* initialize unit to determine computed values
  204. * for proportional-column-width()
  205. */
  206. if (tableUnit == 0.0) {
  207. this.tableUnit = columns.computeTableUnit(this);
  208. }
  209. if (!firstVisibleMarkServed) {
  210. addKnuthElementsForSpaceBefore(returnList, alignment);
  211. }
  212. if (getTable().isSeparateBorderModel()) {
  213. addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
  214. firstVisibleMarkServed = true;
  215. // Border and padding to be repeated at each break
  216. // This must be done only in the separate-border model, as in collapsing
  217. // tables have no padding and borders are determined at the cell level
  218. addPendingMarks(context);
  219. }
  220. // Elements for the table-header/footer/body
  221. List contentKnuthElements;
  222. contentLM = new TableContentLayoutManager(this);
  223. LayoutContext childLC = LayoutContext.newInstance();
  224. /*
  225. childLC.setStackLimit(
  226. MinOptMax.subtract(context.getStackLimit(),
  227. stackSize));*/
  228. childLC.setRefIPD(context.getRefIPD());
  229. childLC.copyPendingMarksFrom(context);
  230. contentKnuthElements = contentLM.getNextKnuthElements(childLC, alignment);
  231. //Set index values on elements coming from the content LM
  232. for (Object contentKnuthElement : contentKnuthElements) {
  233. ListElement el = (ListElement) contentKnuthElement;
  234. notifyPos(el.getPosition());
  235. }
  236. log.debug(contentKnuthElements);
  237. wrapPositionElements(contentKnuthElements, returnList);
  238. context.updateKeepWithPreviousPending(getKeepWithPrevious());
  239. context.updateKeepWithPreviousPending(childLC.getKeepWithPreviousPending());
  240. context.updateKeepWithNextPending(getKeepWithNext());
  241. context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
  242. if (getTable().isSeparateBorderModel()) {
  243. addKnuthElementsForBorderPaddingAfter(returnList, true);
  244. }
  245. addKnuthElementsForSpaceAfter(returnList, alignment);
  246. if (!context.suppressBreakBefore()) {
  247. //addKnuthElementsForBreakBefore(returnList, context);
  248. int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(),
  249. childLC.getBreakBefore());
  250. if (breakBefore != Constants.EN_AUTO) {
  251. returnList.add(0, new BreakElement(new LeafPosition(getParent(), 0), 0,
  252. -KnuthElement.INFINITE, breakBefore, context));
  253. }
  254. }
  255. //addKnuthElementsForBreakAfter(returnList, context);
  256. int breakAfter = BreakUtil.compareBreakClasses(getTable().getBreakAfter(),
  257. childLC.getBreakAfter());
  258. if (breakAfter != Constants.EN_AUTO) {
  259. returnList.add(new BreakElement(new LeafPosition(getParent(), 0),
  260. 0, -KnuthElement.INFINITE, breakAfter, context));
  261. }
  262. setFinished(true);
  263. resetSpaces();
  264. return returnList;
  265. }
  266. /** {@inheritDoc} */
  267. public Position getAuxiliaryPosition() {
  268. /*
  269. * Redefined to return a LeafPosition instead of a NonLeafPosition. The
  270. * SpaceResolver.SpaceHandlingBreakPosition constructors unwraps all
  271. * NonLeafPositions, which can lead to a NPE when a break in a table occurs at a
  272. * page with different ipd.
  273. */
  274. if (auxiliaryPosition == null) {
  275. auxiliaryPosition = new LeafPosition(this, 0);
  276. }
  277. return auxiliaryPosition;
  278. }
  279. /**
  280. * Registers the given area, that will be used to render the part of column background
  281. * covered by a table-cell. If percentages are used to place the background image, the
  282. * final bpd of the (fraction of) table that will be rendered on the current page must
  283. * be known. The traits can't then be set when the areas for the cell are created
  284. * since at that moment this bpd is yet unknown. So they will instead be set in
  285. * TableLM's {@link #addAreas(PositionIterator, LayoutContext)} method.
  286. *
  287. * @param column the table-column element from which the cell gets background
  288. * informations
  289. * @param backgroundArea the block of the cell's dimensions that will hold the column
  290. * background
  291. * @param xShift additional amount by which the image must be shifted to be correctly
  292. * placed (to counterbalance the cell's start border)
  293. */
  294. void registerColumnBackgroundArea(TableColumn column, Block backgroundArea, int xShift) {
  295. addBackgroundArea(backgroundArea);
  296. if (columnBackgroundAreas == null) {
  297. columnBackgroundAreas = new ArrayList();
  298. }
  299. columnBackgroundAreas.add(new ColumnBackgroundInfo(column, backgroundArea, xShift));
  300. }
  301. /**
  302. * The table area is a reference area that contains areas for
  303. * columns, bodies, rows and the contents are in cells.
  304. *
  305. * @param parentIter the position iterator
  306. * @param layoutContext the layout context for adding areas
  307. */
  308. public void addAreas(PositionIterator parentIter,
  309. LayoutContext layoutContext) {
  310. getParentArea(null);
  311. addId();
  312. // add space before, in order to implement display-align = "center" or "after"
  313. if (layoutContext.getSpaceBefore() != 0) {
  314. addBlockSpacing(0.0, MinOptMax.getInstance(layoutContext.getSpaceBefore()));
  315. }
  316. int startXOffset = getTable().getCommonMarginBlock().startIndent.getValue(this);
  317. // add column, body then row areas
  318. // BPD of the table, i.e., height of its content; table's borders and paddings not counted
  319. int tableHeight = 0;
  320. //Body childLM;
  321. LayoutContext lc = LayoutContext.offspringOf(layoutContext);
  322. lc.setRefIPD(getContentAreaIPD());
  323. contentLM.setStartXOffset(startXOffset);
  324. contentLM.addAreas(parentIter, lc);
  325. tableHeight += contentLM.getUsedBPD();
  326. curBlockArea.setBPD(tableHeight);
  327. if (columnBackgroundAreas != null) {
  328. for (Object columnBackgroundArea : columnBackgroundAreas) {
  329. ColumnBackgroundInfo b = (ColumnBackgroundInfo) columnBackgroundArea;
  330. TraitSetter.addBackground(b.backgroundArea,
  331. b.column.getCommonBorderPaddingBackground(), this,
  332. b.xShift, -b.backgroundArea.getYOffset(),
  333. b.column.getColumnWidth().getValue(this), tableHeight);
  334. }
  335. columnBackgroundAreas.clear();
  336. }
  337. if (getTable().isSeparateBorderModel()) {
  338. TraitSetter.addBorders(curBlockArea,
  339. getTable().getCommonBorderPaddingBackground(),
  340. discardBorderBefore, discardBorderAfter, false, false, this);
  341. TraitSetter.addPadding(curBlockArea,
  342. getTable().getCommonBorderPaddingBackground(),
  343. discardPaddingBefore, discardPaddingAfter, false, false, this);
  344. }
  345. TraitSetter.addBackground(curBlockArea,
  346. getTable().getCommonBorderPaddingBackground(),
  347. this);
  348. TraitSetter.addMargins(curBlockArea,
  349. getTable().getCommonBorderPaddingBackground(),
  350. startIndent, endIndent,
  351. this);
  352. TraitSetter.addBreaks(curBlockArea,
  353. getTable().getBreakBefore(), getTable().getBreakAfter());
  354. TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(),
  355. effSpaceBefore, effSpaceAfter);
  356. flush();
  357. resetSpaces();
  358. curBlockArea = null;
  359. notifyEndOfLayout();
  360. }
  361. /**
  362. * Return an Area which can contain the passed childArea. The childArea
  363. * may not yet have any content, but it has essential traits set.
  364. * In general, if the LayoutManager already has an Area it simply returns
  365. * it. Otherwise, it makes a new Area of the appropriate class.
  366. * It gets a parent area for its area by calling its parent LM.
  367. * Finally, based on the dimensions of the parent area, it initializes
  368. * its own area. This includes setting the content IPD and the maximum
  369. * BPD.
  370. *
  371. * @param childArea the child area
  372. * @return the parent area of the child
  373. */
  374. public Area getParentArea(Area childArea) {
  375. if (curBlockArea == null) {
  376. curBlockArea = new Block();
  377. curBlockArea.setChangeBarList(getChangeBarList());
  378. // Set up dimensions
  379. // Must get dimensions from parent area
  380. /*Area parentArea =*/ parentLayoutManager.getParentArea(curBlockArea);
  381. TraitSetter.setProducerID(curBlockArea, getTable().getId());
  382. curBlockArea.setIPD(getContentAreaIPD());
  383. setCurrentArea(curBlockArea);
  384. }
  385. return curBlockArea;
  386. }
  387. /**
  388. * Add the child area to this layout manager.
  389. *
  390. * @param childArea the child area to add
  391. */
  392. public void addChildArea(Area childArea) {
  393. if (curBlockArea != null) {
  394. curBlockArea.addBlock((Block) childArea);
  395. }
  396. }
  397. /**
  398. * Adds the given area to this layout manager's area, without updating the used bpd.
  399. *
  400. * @param background an area
  401. */
  402. void addBackgroundArea(Block background) {
  403. curBlockArea.addChildArea(background);
  404. }
  405. /** {@inheritDoc} */
  406. public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
  407. // TODO Auto-generated method stub
  408. return 0;
  409. }
  410. /** {@inheritDoc} */
  411. public void discardSpace(KnuthGlue spaceGlue) {
  412. // TODO Auto-generated method stub
  413. }
  414. /** {@inheritDoc} */
  415. public KeepProperty getKeepTogetherProperty() {
  416. return getTable().getKeepTogether();
  417. }
  418. /** {@inheritDoc} */
  419. public KeepProperty getKeepWithPreviousProperty() {
  420. return getTable().getKeepWithPrevious();
  421. }
  422. /** {@inheritDoc} */
  423. public KeepProperty getKeepWithNextProperty() {
  424. return getTable().getKeepWithNext();
  425. }
  426. // --------- Property Resolution related functions --------- //
  427. /**
  428. * {@inheritDoc}
  429. */
  430. public int getBaseLength(int lengthBase, FObj fobj) {
  431. // Special handler for TableColumn width specifications
  432. if (fobj instanceof TableColumn && fobj.getParent() == getFObj()) {
  433. switch (lengthBase) {
  434. case LengthBase.CONTAINING_BLOCK_WIDTH:
  435. return getContentAreaIPD();
  436. case LengthBase.TABLE_UNITS:
  437. return (int) this.tableUnit;
  438. default:
  439. log.error("Unknown base type for LengthBase.");
  440. return 0;
  441. }
  442. } else {
  443. switch (lengthBase) {
  444. case LengthBase.TABLE_UNITS:
  445. return (int) this.tableUnit;
  446. default:
  447. return super.getBaseLength(lengthBase, fobj);
  448. }
  449. }
  450. }
  451. /** {@inheritDoc} */
  452. public void reset() {
  453. super.reset();
  454. curBlockArea = null;
  455. tableUnit = 0.0;
  456. }
  457. /**
  458. * Saves a TableCellLayoutManager for later use.
  459. *
  460. * @param tclm a TableCellLayoutManager that has a RetrieveTableMarker
  461. */
  462. protected void saveTableHeaderTableCellLayoutManagers(TableCellLayoutManager tclm) {
  463. if (savedTCLMs == null) {
  464. savedTCLMs = new ArrayList<TableCellLayoutManager>();
  465. }
  466. if (!areAllTCLMsSaved) {
  467. savedTCLMs.add(tclm);
  468. }
  469. }
  470. /**
  471. * Calls addAreas() for each of the saved TableCellLayoutManagers.
  472. */
  473. protected void repeatAddAreasForSavedTableHeaderTableCellLayoutManagers() {
  474. if (savedTCLMs == null) {
  475. return;
  476. }
  477. // if we get to this stage then we are at the footer of the table fragment; this means that no more
  478. // different TCLM need to be saved (we already have all); we flag the list as being complete then
  479. areAllTCLMsSaved = true;
  480. for (TableCellLayoutManager tclm : savedTCLMs) {
  481. if (this.repeatedHeader) {
  482. tclm.setHasRepeatedHeader(true);
  483. }
  484. tclm.repeatAddAreas();
  485. }
  486. }
  487. /**
  488. * Resolves a RetrieveTableMarker by finding a qualifying Marker to which it is bound to.
  489. * @param rtm the RetrieveTableMarker to be resolved
  490. * @return a bound RetrieveTableMarker instance or null if no qualifying Marker found
  491. */
  492. public RetrieveTableMarker resolveRetrieveTableMarker(RetrieveTableMarker rtm) {
  493. String name = rtm.getRetrieveClassName();
  494. int originalPosition = rtm.getPosition();
  495. boolean changedPosition = false;
  496. Marker mark = null;
  497. // try the primary retrieve scope area, which is the same as table-fragment
  498. mark = (tableFragmentMarkers == null) ? null : tableFragmentMarkers.resolve(rtm);
  499. if (mark == null && rtm.getBoundary() != Constants.EN_TABLE_FRAGMENT) {
  500. rtm.changePositionTo(Constants.EN_LAST_ENDING);
  501. changedPosition = true;
  502. // try the page scope area
  503. mark = getCurrentPV().resolveMarker(rtm);
  504. if (mark == null && rtm.getBoundary() != Constants.EN_PAGE) {
  505. // try the table scope area
  506. mark = (tableMarkers == null) ? null : tableMarkers.resolve(rtm);
  507. }
  508. }
  509. if (changedPosition) {
  510. // so that the next time it is called looks unchanged
  511. rtm.changePositionTo(originalPosition);
  512. }
  513. if (mark == null) {
  514. log.debug("found no marker with name: " + name);
  515. return null;
  516. } else {
  517. rtm.bindMarker(mark);
  518. return rtm;
  519. }
  520. }
  521. /**
  522. * Register the markers for this table.
  523. *
  524. * @param marks the map of markers to add
  525. * @param starting if the area being added is starting or ending
  526. * @param isfirst if the area being added has is-first trait
  527. * @param islast if the area being added has is-last trait
  528. */
  529. public void registerMarkers(Map<String, Marker> marks, boolean starting, boolean isfirst,
  530. boolean islast) {
  531. if (tableMarkers == null) {
  532. tableMarkers = new Markers();
  533. }
  534. tableMarkers.register(marks, starting, isfirst, islast);
  535. if (tableFragmentMarkers == null) {
  536. tableFragmentMarkers = new Markers();
  537. }
  538. tableFragmentMarkers.register(marks, starting, isfirst, islast);
  539. }
  540. /**
  541. * Clears the list of markers in the current table fragment. Should be called just before starting a new
  542. * header (that belongs to the next table fragment).
  543. */
  544. protected void clearTableFragmentMarkers() {
  545. tableFragmentMarkers = null;
  546. }
  547. public void flagAsHavingRetrieveTableMarker() {
  548. hasRetrieveTableMarker = true;
  549. }
  550. protected void possiblyRegisterMarkersForTables(Map<String, Marker> markers, boolean isStarting,
  551. boolean isFirst, boolean isLast) {
  552. // note: if we allow table-footer after a table-body this check should not be made and the markers
  553. // should be registered regardless because the retrieval may be done only in the footer
  554. if (hasRetrieveTableMarker) {
  555. registerMarkers(markers, isStarting, isFirst, isLast);
  556. }
  557. super.possiblyRegisterMarkersForTables(markers, isStarting, isFirst, isLast);
  558. }
  559. void setHeaderFootnotes(List<List<KnuthElement>> footnotes) {
  560. this.headerFootnotes = footnotes;
  561. }
  562. List<List<KnuthElement>> getHeaderFootnotes() {
  563. return headerFootnotes;
  564. }
  565. void setFooterFootnotes(List<List<KnuthElement>> footnotes) {
  566. this.footerFootnotes = footnotes;
  567. }
  568. public void setRepeateHeader(boolean repeateHeader) {
  569. this.repeatedHeader = repeateHeader;
  570. }
  571. List<List<KnuthElement>> getFooterFootnotes() {
  572. return footerFootnotes;
  573. }
  574. }