1 17 18 19 20 package org.apache.fop.fo.properties; 21 22 import org.apache.fop.apps.FOPException; 23 import org.apache.fop.fo.FObj; 24 import org.apache.fop.fo.PropertyList; 25 import org.apache.fop.fo.expr.PropertyException; 26 27 29 public class CorrespondingPropertyMaker { 30 protected PropertyMaker baseMaker; 31 protected int lr_tb; 32 protected int rl_tb; 33 protected int tb_rl; 34 protected boolean useParent; 35 private boolean relative; 36 37 public CorrespondingPropertyMaker(PropertyMaker baseMaker) { 38 this.baseMaker = baseMaker; 39 baseMaker.setCorresponding(this); 40 } 41 42 43 public void setCorresponding(int lr_tb, int rl_tb, int tb_rl) { 44 this.lr_tb = lr_tb; 45 this.rl_tb = rl_tb; 46 this.tb_rl = tb_rl; 47 } 48 49 public void setUseParent(boolean useParent) { 50 this.useParent = useParent; 51 } 52 53 public void setRelative(boolean relative) { 54 this.relative = relative; 55 } 56 57 73 public boolean isCorrespondingForced(PropertyList propertyList) { 74 75 if (!relative) { 76 return false; 77 } 78 79 PropertyList pList = getWMPropertyList(propertyList); 80 if (pList != null) { 81 int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl); 82 83 if (pList.getExplicit(correspondingId) != null) { 84 return true; 85 } 86 } 87 return false; 88 } 89 90 100 public Property compute(PropertyList propertyList) throws PropertyException { 101 PropertyList pList = getWMPropertyList(propertyList); 102 if (pList == null) { 103 return null; 104 } 105 int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl); 106 107 Property p = propertyList.getExplicitOrShorthand(correspondingId); 108 if (p != null) { 109 FObj parentFO = propertyList.getParentFObj(); 110 p = baseMaker.convertProperty(p, propertyList, parentFO); 111 } 112 return p; 113 } 114 115 119 protected PropertyList getWMPropertyList(PropertyList pList) { 120 if (useParent) { 121 return pList.getParentPropertyList(); 122 } else { 123 return pList; 124 } 125 } 126 } 127 128 | Popular Tags |