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.

InlineLayoutManager.java 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  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.inline;
  19. import java.util.LinkedList;
  20. import java.util.List;
  21. import java.util.ListIterator;
  22. import org.apache.commons.logging.Log;
  23. import org.apache.commons.logging.LogFactory;
  24. import org.apache.fop.area.Area;
  25. import org.apache.fop.area.inline.InlineArea;
  26. import org.apache.fop.area.inline.InlineBlockParent;
  27. import org.apache.fop.area.inline.InlineParent;
  28. import org.apache.fop.datatypes.Length;
  29. import org.apache.fop.fo.flow.Inline;
  30. import org.apache.fop.fo.flow.InlineLevel;
  31. import org.apache.fop.fo.flow.Leader;
  32. import org.apache.fop.fo.pagination.Title;
  33. import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
  34. import org.apache.fop.fo.properties.CommonMarginInline;
  35. import org.apache.fop.fo.properties.SpaceProperty;
  36. import org.apache.fop.fonts.Font;
  37. import org.apache.fop.fonts.FontInfo;
  38. import org.apache.fop.fonts.FontTriplet;
  39. import org.apache.fop.layoutmgr.BlockKnuthSequence;
  40. import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
  41. import org.apache.fop.layoutmgr.BreakElement;
  42. import org.apache.fop.layoutmgr.InlineKnuthSequence;
  43. import org.apache.fop.layoutmgr.KnuthBox;
  44. import org.apache.fop.layoutmgr.KnuthSequence;
  45. import org.apache.fop.layoutmgr.LayoutContext;
  46. import org.apache.fop.layoutmgr.LayoutManager;
  47. import org.apache.fop.layoutmgr.NonLeafPosition;
  48. import org.apache.fop.layoutmgr.Position;
  49. import org.apache.fop.layoutmgr.PositionIterator;
  50. import org.apache.fop.layoutmgr.SpaceSpecifier;
  51. import org.apache.fop.layoutmgr.TraitSetter;
  52. import org.apache.fop.traits.MinOptMax;
  53. import org.apache.fop.traits.SpaceVal;
  54. /**
  55. * LayoutManager for objects which stack children in the inline direction,
  56. * such as Inline or Line
  57. */
  58. public class InlineLayoutManager extends InlineStackingLayoutManager {
  59. /**
  60. * logging instance
  61. */
  62. private static Log log = LogFactory.getLog(InlineLayoutManager.class);
  63. private CommonMarginInline inlineProps = null;
  64. private CommonBorderPaddingBackground borderProps = null;
  65. private boolean areaCreated = false;
  66. private LayoutManager lastChildLM = null; // Set when return last breakposs;
  67. private Position auxiliaryPosition;
  68. private Font font;
  69. /** The alignment adjust property */
  70. protected Length alignmentAdjust;
  71. /** The alignment baseline property */
  72. protected int alignmentBaseline = EN_BASELINE;
  73. /** The baseline shift property */
  74. protected Length baselineShift;
  75. /** The dominant baseline property */
  76. protected int dominantBaseline;
  77. /** The line height property */
  78. protected SpaceProperty lineHeight;
  79. /** The keep-together property */
  80. //private KeepProperty keepTogether;
  81. private AlignmentContext alignmentContext = null;
  82. /**
  83. * Create an inline layout manager.
  84. * This is used for fo's that create areas that
  85. * contain inline areas.
  86. *
  87. * @param node the formatting object that creates the area
  88. */
  89. // The node should be FObjMixed
  90. public InlineLayoutManager(InlineLevel node) {
  91. super(node);
  92. }
  93. private Inline getInlineFO() {
  94. return (Inline) fobj;
  95. }
  96. /** {@inheritDoc} */
  97. public void initialize() {
  98. InlineLevel fobj = (InlineLevel) this.fobj;
  99. int padding = 0;
  100. FontInfo fi = fobj.getFOEventHandler().getFontInfo();
  101. FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi);
  102. font = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this));
  103. lineHeight = fobj.getLineHeight();
  104. borderProps = fobj.getCommonBorderPaddingBackground();
  105. inlineProps = fobj.getCommonMarginInline();
  106. if (fobj instanceof Inline) {
  107. alignmentAdjust = ((Inline)fobj).getAlignmentAdjust();
  108. alignmentBaseline = ((Inline)fobj).getAlignmentBaseline();
  109. baselineShift = ((Inline)fobj).getBaselineShift();
  110. dominantBaseline = ((Inline)fobj).getDominantBaseline();
  111. } else if (fobj instanceof Leader) {
  112. alignmentAdjust = ((Leader)fobj).getAlignmentAdjust();
  113. alignmentBaseline = ((Leader)fobj).getAlignmentBaseline();
  114. baselineShift = ((Leader)fobj).getBaselineShift();
  115. dominantBaseline = ((Leader)fobj).getDominantBaseline();
  116. }
  117. if (borderProps != null) {
  118. padding = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
  119. padding += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
  120. false);
  121. padding += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this);
  122. padding += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
  123. }
  124. extraBPD = new MinOptMax(padding);
  125. }
  126. /** {@inheritDoc} */
  127. protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) {
  128. int borderAndPadding = 0;
  129. if (borderProps != null) {
  130. borderAndPadding
  131. = borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this);
  132. borderAndPadding
  133. += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, isNotFirst);
  134. borderAndPadding
  135. += borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this);
  136. borderAndPadding
  137. += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast);
  138. }
  139. return new MinOptMax(borderAndPadding);
  140. }
  141. /** {@inheritDoc} */
  142. protected boolean hasLeadingFence(boolean isNotFirst) {
  143. return borderProps != null
  144. && (borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0
  145. || borderProps.getBorderWidth(CommonBorderPaddingBackground.START, isNotFirst) > 0
  146. );
  147. }
  148. /** {@inheritDoc} */
  149. protected boolean hasTrailingFence(boolean isNotLast) {
  150. return borderProps != null
  151. && (borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0
  152. || borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast) > 0
  153. );
  154. }
  155. /** {@inheritDoc} */
  156. protected SpaceProperty getSpaceStart() {
  157. return inlineProps != null ? inlineProps.spaceStart : null;
  158. }
  159. /** {@inheritDoc} */
  160. protected SpaceProperty getSpaceEnd() {
  161. return inlineProps != null ? inlineProps.spaceEnd : null;
  162. }
  163. /**
  164. * Create and initialize an <code>InlineArea</code>
  165. *
  166. * @param hasInlineParent true if the parent is an inline
  167. * @return the area
  168. */
  169. protected InlineArea createArea(boolean hasInlineParent) {
  170. InlineArea area;
  171. if (hasInlineParent) {
  172. area = new InlineParent();
  173. area.setOffset(0);
  174. } else {
  175. area = new InlineBlockParent();
  176. }
  177. if (fobj instanceof Inline) {
  178. TraitSetter.setProducerID(area, getInlineFO().getId());
  179. }
  180. return area;
  181. }
  182. /** {@inheritDoc} */
  183. protected void setTraits(boolean isNotFirst, boolean isNotLast) {
  184. if (borderProps != null) {
  185. // Add border and padding to current area and set flags (FIRST, LAST ...)
  186. TraitSetter.setBorderPaddingTraits(getCurrentArea(),
  187. borderProps, isNotFirst, isNotLast, this);
  188. TraitSetter.addBackground(getCurrentArea(), borderProps, this);
  189. }
  190. }
  191. /**
  192. * @return true if this element must be kept together
  193. */
  194. public boolean mustKeepTogether() {
  195. return mustKeepTogether(this.getParent());
  196. }
  197. private boolean mustKeepTogether(LayoutManager lm) {
  198. if (lm instanceof BlockLevelLayoutManager) {
  199. return ((BlockLevelLayoutManager) lm).mustKeepTogether();
  200. } else if (lm instanceof InlineLayoutManager) {
  201. return ((InlineLayoutManager) lm).mustKeepTogether();
  202. } else {
  203. return mustKeepTogether(lm.getParent());
  204. }
  205. }
  206. /** {@inheritDoc} */
  207. public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
  208. LayoutManager curLM;
  209. // the list returned by child LM
  210. LinkedList returnedList;
  211. // the list which will be returned to the parent LM
  212. LinkedList returnList = new LinkedList();
  213. KnuthSequence lastSequence = null;
  214. SpaceSpecifier leadingSpace = context.getLeadingSpace();
  215. if (fobj instanceof Title) {
  216. alignmentContext = new AlignmentContext(font,
  217. lineHeight.getOptimum(this).getLength().getValue(this),
  218. context.getWritingMode());
  219. } else {
  220. alignmentContext = new AlignmentContext(font
  221. , lineHeight.getOptimum(this).getLength().getValue(this)
  222. , alignmentAdjust
  223. , alignmentBaseline
  224. , baselineShift
  225. , dominantBaseline
  226. , context.getAlignmentContext());
  227. }
  228. childLC = new LayoutContext(context);
  229. childLC.setAlignmentContext(alignmentContext);
  230. if (context.startsNewArea()) {
  231. // First call to this LM in new parent "area", but this may
  232. // not be the first area created by this inline
  233. if (getSpaceStart() != null) {
  234. context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this));
  235. }
  236. // Check for "fence"
  237. if (hasLeadingFence(!context.isFirstArea())) {
  238. // Reset leading space sequence for child areas
  239. leadingSpace = new SpaceSpecifier(false);
  240. }
  241. // Reset state variables
  242. clearPrevIPD(); // Clear stored prev content dimensions
  243. }
  244. StringBuffer trace = new StringBuffer("InlineLM:");
  245. // We'll add the border to the first inline sequence created.
  246. // This flag makes sure we do it only once.
  247. boolean borderAdded = false;
  248. if (borderProps != null) {
  249. childLC.setLineStartBorderAndPaddingWidth(context.getLineStartBorderAndPaddingWidth()
  250. + borderProps.getPaddingStart(true, this)
  251. + borderProps.getBorderStartWidth(true)
  252. );
  253. childLC.setLineEndBorderAndPaddingWidth(context.getLineEndBorderAndPaddingWidth()
  254. + borderProps.getPaddingEnd(true, this)
  255. + borderProps.getBorderEndWidth(true)
  256. );
  257. }
  258. while ((curLM = getChildLM()) != null) {
  259. if (!(curLM instanceof InlineLevelLayoutManager)) {
  260. // A block LM
  261. // Leave room for start/end border and padding
  262. if (borderProps != null) {
  263. childLC.setRefIPD(childLC.getRefIPD()
  264. - borderProps.getPaddingStart(lastChildLM != null, this)
  265. - borderProps.getBorderStartWidth(lastChildLM != null)
  266. - borderProps.getPaddingEnd(hasNextChildLM(), this)
  267. - borderProps.getBorderEndWidth(hasNextChildLM()));
  268. }
  269. }
  270. // get KnuthElements from curLM
  271. returnedList = curLM.getNextKnuthElements(childLC, alignment);
  272. if (returnList.size() == 0 && childLC.isKeepWithPreviousPending()) {
  273. childLC.clearKeepWithPreviousPending();
  274. }
  275. if (returnedList == null
  276. || returnedList.size() == 0) {
  277. // curLM returned null or an empty list, because it finished;
  278. // just iterate once more to see if there is another child
  279. continue;
  280. }
  281. if (curLM instanceof InlineLevelLayoutManager) {
  282. context.clearKeepWithNextPending();
  283. // "wrap" the Position stored in each element of returnedList
  284. ListIterator seqIter = returnedList.listIterator();
  285. while (seqIter.hasNext()) {
  286. KnuthSequence sequence = (KnuthSequence) seqIter.next();
  287. sequence.wrapPositions(this);
  288. }
  289. if (lastSequence != null && lastSequence.appendSequenceOrClose
  290. ((KnuthSequence) returnedList.get(0))) {
  291. returnedList.remove(0);
  292. }
  293. // add border and padding to the first complete sequence of this LM
  294. if (!borderAdded && returnedList.size() != 0) {
  295. addKnuthElementsForBorderPaddingStart((KnuthSequence) returnedList.get(0));
  296. borderAdded = true;
  297. }
  298. returnList.addAll(returnedList);
  299. } else { // A block LM
  300. BlockKnuthSequence sequence = new BlockKnuthSequence(returnedList);
  301. sequence.wrapPositions(this);
  302. boolean appended = false;
  303. if (lastSequence != null) {
  304. if (lastSequence.canAppendSequence(sequence)) {
  305. BreakElement bk = new BreakElement(new Position(this), 0, context);
  306. boolean keepTogether = (mustKeepTogether()
  307. || context.isKeepWithNextPending()
  308. || childLC.isKeepWithPreviousPending());
  309. appended = lastSequence.appendSequenceOrClose(sequence, keepTogether, bk);
  310. } else {
  311. lastSequence.endSequence();
  312. }
  313. }
  314. if (!appended) {
  315. // add border and padding to the first complete sequence of this LM
  316. if (!borderAdded) {
  317. addKnuthElementsForBorderPaddingStart(sequence);
  318. borderAdded = true;
  319. }
  320. returnList.add(sequence);
  321. }
  322. // propagate and clear
  323. context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
  324. childLC.clearKeepsPending();
  325. }
  326. lastSequence = (KnuthSequence) returnList.getLast();
  327. lastChildLM = curLM;
  328. }
  329. if (lastSequence != null) {
  330. addKnuthElementsForBorderPaddingEnd(lastSequence);
  331. }
  332. setFinished(true);
  333. log.trace(trace);
  334. if (returnList.size() == 0) {
  335. /*
  336. * if the FO itself is empty, but has an id specified
  337. * or associated fo:markers, then we still need a dummy
  338. * sequence to register its position in the area tree
  339. */
  340. if (fobj.hasId() || fobj.hasMarkers()) {
  341. InlineKnuthSequence emptySeq = new InlineKnuthSequence();
  342. emptySeq.add(new KnuthInlineBox(
  343. 0,
  344. alignmentContext,
  345. notifyPos(getAuxiliaryPosition()),
  346. true));
  347. returnList.add(emptySeq);
  348. }
  349. }
  350. return returnList.size() == 0 ? null : returnList;
  351. }
  352. /**
  353. * Generate and add areas to parent area.
  354. * Set size of each area. This should only create and return one
  355. * inline area for any inline parent area.
  356. *
  357. * @param parentIter Iterator over Position information returned
  358. * by this LayoutManager.
  359. * @param context layout context.
  360. */
  361. public void addAreas(PositionIterator parentIter,
  362. LayoutContext context) {
  363. addId();
  364. setChildContext(new LayoutContext(context)); // Store current value
  365. // If this LM has fence, make a new leading space specifier.
  366. if (hasLeadingFence(areaCreated)) {
  367. getContext().setLeadingSpace(new SpaceSpecifier(false));
  368. getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
  369. } else {
  370. getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, false);
  371. }
  372. if (getSpaceStart() != null) {
  373. context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this));
  374. }
  375. // "Unwrap" the NonLeafPositions stored in parentIter and put
  376. // them in a new list. Set lastLM to be the LayoutManager
  377. // which created the last Position: if the LAST_AREA flag is
  378. // set in the layout context, it must be also set in the
  379. // layout context given to lastLM, but must be cleared in the
  380. // layout context given to the other LMs.
  381. LinkedList positionList = new LinkedList();
  382. NonLeafPosition pos;
  383. LayoutManager lastLM = null;// last child LM in this iterator
  384. Position lastPos = null;
  385. while (parentIter.hasNext()) {
  386. pos = (NonLeafPosition) parentIter.next();
  387. if (pos != null && pos.getPosition() != null) {
  388. positionList.add(pos.getPosition());
  389. lastLM = pos.getPosition().getLM();
  390. lastPos = pos;
  391. }
  392. }
  393. /*if (pos != null) {
  394. lastLM = pos.getPosition().getLM();
  395. }*/
  396. addMarkersToPage(
  397. true,
  398. !areaCreated,
  399. lastPos == null || isLast(lastPos));
  400. InlineArea parent = createArea(lastLM == null
  401. || lastLM instanceof InlineLevelLayoutManager);
  402. parent.setBPD(alignmentContext.getHeight());
  403. if (parent instanceof InlineParent) {
  404. parent.setOffset(alignmentContext.getOffset());
  405. } else if (parent instanceof InlineBlockParent) {
  406. // All inline elements are positioned by the renderers relative to
  407. // the before edge of their content rectangle
  408. if (borderProps != null) {
  409. parent.setOffset(borderProps.getPaddingBefore(false, this)
  410. + borderProps.getBorderBeforeWidth(false));
  411. }
  412. }
  413. setCurrentArea(parent);
  414. StackingIter childPosIter
  415. = new StackingIter(positionList.listIterator());
  416. LayoutManager prevLM = null;
  417. LayoutManager childLM;
  418. while ((childLM = childPosIter.getNextChildLM()) != null) {
  419. getContext().setFlags(LayoutContext.LAST_AREA,
  420. context.isLastArea() && childLM == lastLM);
  421. childLM.addAreas(childPosIter, getContext());
  422. getContext().setLeadingSpace(getContext().getTrailingSpace());
  423. getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
  424. prevLM = childLM;
  425. }
  426. /* If this LM has a trailing fence, resolve trailing space
  427. * specs from descendants. Otherwise, propagate any trailing
  428. * space specs to the parent LM via the layout context. If
  429. * the last child LM called returns LAST_AREA in the layout
  430. * context and it is the last child LM for this LM, then this
  431. * must be the last area for the current LM too.
  432. */
  433. boolean isLast = (getContext().isLastArea() && prevLM == lastChildLM);
  434. if (hasTrailingFence(isLast)) {
  435. addSpace(getCurrentArea(),
  436. getContext().getTrailingSpace().resolve(false),
  437. getContext().getSpaceAdjust());
  438. context.setTrailingSpace(new SpaceSpecifier(false));
  439. } else {
  440. // Propagate trailing space-spec sequence to parent LM in context.
  441. context.setTrailingSpace(getContext().getTrailingSpace());
  442. }
  443. // Add own trailing space to parent context (or set on area?)
  444. if (context.getTrailingSpace() != null && getSpaceEnd() != null) {
  445. context.getTrailingSpace().addSpace(new SpaceVal(getSpaceEnd(), this));
  446. }
  447. // Not sure if lastPos can legally be null or if that masks a different problem.
  448. // But it seems to fix bug 38053.
  449. setTraits(areaCreated, lastPos == null || !isLast(lastPos));
  450. parentLM.addChildArea(getCurrentArea());
  451. addMarkersToPage(
  452. false,
  453. !areaCreated,
  454. lastPos == null || isLast(lastPos));
  455. context.setFlags(LayoutContext.LAST_AREA, isLast);
  456. areaCreated = true;
  457. }
  458. /** {@inheritDoc} */
  459. public void addChildArea(Area childArea) {
  460. Area parent = getCurrentArea();
  461. if (getContext().resolveLeadingSpace()) {
  462. addSpace(parent,
  463. getContext().getLeadingSpace().resolve(false),
  464. getContext().getSpaceAdjust());
  465. }
  466. parent.addChildArea(childArea);
  467. }
  468. /** {@inheritDoc} */
  469. public LinkedList getChangedKnuthElements(List oldList, int alignment) {
  470. LinkedList returnedList = new LinkedList();
  471. addKnuthElementsForBorderPaddingStart(returnedList);
  472. returnedList.addAll(super.getChangedKnuthElements(oldList, alignment));
  473. addKnuthElementsForBorderPaddingEnd(returnedList);
  474. return returnedList;
  475. }
  476. /**
  477. * Creates Knuth elements for start border padding and adds them to the return list.
  478. * @param returnList return list to add the additional elements to
  479. */
  480. protected void addKnuthElementsForBorderPaddingStart(List returnList) {
  481. //Border and Padding (start)
  482. /**
  483. * If the returnlist is a BlockKnuthSequence, the border and padding should be added
  484. * to the first paragraph inside it, but it is too late to do that now.
  485. * At least, avoid adding it to the bpd sequence.
  486. */
  487. if (returnList instanceof BlockKnuthSequence) {
  488. return;
  489. }
  490. CommonBorderPaddingBackground borderAndPadding =
  491. ((InlineLevel)fobj).getCommonBorderPaddingBackground();
  492. if (borderAndPadding != null) {
  493. int ipStart = borderAndPadding.getBorderStartWidth(false)
  494. + borderAndPadding.getPaddingStart(false, this);
  495. if (ipStart > 0) {
  496. returnList.add(0,new KnuthBox(ipStart, getAuxiliaryPosition(), true));
  497. }
  498. }
  499. }
  500. /**
  501. * Creates Knuth elements for end border padding and adds them to the return list.
  502. * @param returnList return list to add the additional elements to
  503. */
  504. protected void addKnuthElementsForBorderPaddingEnd(List returnList) {
  505. //Border and Padding (after)
  506. /**
  507. * If the returnlist is a BlockKnuthSequence, the border and padding should be added
  508. * to the last paragraph inside it, but it is too late to do that now.
  509. * At least, avoid adding it to the bpd sequence.
  510. */
  511. if (returnList instanceof BlockKnuthSequence) {
  512. return;
  513. }
  514. CommonBorderPaddingBackground borderAndPadding =
  515. ((InlineLevel)fobj).getCommonBorderPaddingBackground();
  516. if (borderAndPadding != null) {
  517. int ipEnd = borderAndPadding.getBorderEndWidth(false)
  518. + borderAndPadding.getPaddingEnd(false, this);
  519. if (ipEnd > 0) {
  520. returnList.add(new KnuthBox(ipEnd, getAuxiliaryPosition(), true));
  521. }
  522. }
  523. }
  524. /** @return a cached auxiliary Position instance used for things like spaces. */
  525. protected Position getAuxiliaryPosition() {
  526. //if (this.auxiliaryPosition == null) {
  527. //this.auxiliaryPosition = new NonLeafPosition(this, new LeafPosition(this, -1));
  528. this.auxiliaryPosition = new NonLeafPosition(this, null);
  529. //}
  530. return this.auxiliaryPosition;
  531. }
  532. }