1 17 18 19 20 package org.apache.fop.render.rtf.rtflib.rtfdoc; 21 22 import java.util.Iterator ; 23 import java.util.LinkedList ; 24 25 30 public class RtfSpaceManager { 31 32 private LinkedList blockAttributes = new LinkedList (); 33 34 35 private LinkedList inlineAttributes = new LinkedList (); 36 37 43 private int accumulatedSpace = 0; 44 45 48 public RtfSpaceManager() { 49 } 50 51 56 public void stopUpdatingSpaceBefore() { 57 for (Iterator it = blockAttributes.iterator(); it.hasNext();) { 58 RtfSpaceSplitter splitter = (RtfSpaceSplitter) it.next(); 59 if (splitter.isBeforeCadidateSet()) { 60 splitter.stopUpdatingSpaceBefore(); 61 } 62 } 63 } 64 65 70 public void setCandidate(RtfAttributes attrs) { 71 for (Iterator it = blockAttributes.iterator(); it.hasNext();) { 72 RtfSpaceSplitter splitter = (RtfSpaceSplitter) it.next(); 73 splitter.setSpaceBeforeCandidate(attrs); 74 splitter.setSpaceAfterCandidate(attrs); 75 } 76 } 77 78 85 public RtfSpaceSplitter pushRtfSpaceSplitter(RtfAttributes attrs) { 86 RtfSpaceSplitter splitter; 87 splitter = new RtfSpaceSplitter(attrs, accumulatedSpace); 88 accumulatedSpace = 0; 91 blockAttributes.addLast(splitter); 92 return splitter; 93 } 94 95 98 public void popRtfSpaceSplitter() { 99 if (!blockAttributes.isEmpty()) { 100 RtfSpaceSplitter splitter; 101 splitter = (RtfSpaceSplitter) blockAttributes.removeLast(); 102 accumulatedSpace += splitter.flush(); 103 } 104 } 105 106 111 public void pushInlineAttributes(RtfAttributes attrs) { 112 inlineAttributes.addLast(attrs); 113 } 114 115 118 public void popInlineAttributes() { 119 if (!inlineAttributes.isEmpty()) { 120 inlineAttributes.removeLast(); 121 } 122 } 123 124 129 public RtfAttributes getLastInlineAttribute() { 130 return (RtfAttributes) inlineAttributes.getLast(); 131 } 132 } 133 | Popular Tags |