1 17 18 19 20 package org.apache.fop.fo.properties; 21 22 import org.apache.fop.fo.Constants; 23 import org.apache.fop.fo.FObj; 24 import org.apache.fop.fo.PropertyList; 25 import org.apache.fop.fo.expr.PropertyException; 26 import org.apache.fop.fo.properties.LengthProperty; 27 28 32 public class PageDimensionMaker extends LengthProperty.Maker { 33 34 39 public PageDimensionMaker(int propId) { 40 super(propId); 41 } 42 43 50 public Property get(int subpropId, PropertyList propertyList, 51 boolean tryInherit, boolean tryDefault) 52 throws PropertyException { 53 54 Property p = super.get(0, propertyList, tryInherit, tryDefault); 55 FObj fo = propertyList.getFObj(); 56 String fallbackValue = (propId == Constants.PR_PAGE_HEIGHT) 57 ? fo.getFOEventHandler().getUserAgent().getPageHeight() 58 : fo.getFOEventHandler().getUserAgent().getPageWidth(); 59 60 if (p.getEnum() == Constants.EN_INDEFINITE) { 61 int otherId = (propId == Constants.PR_PAGE_HEIGHT) 62 ? Constants.PR_PAGE_WIDTH : Constants.PR_PAGE_HEIGHT; 63 int writingMode = propertyList.get(Constants.PR_WRITING_MODE).getEnum(); 64 int refOrientation = propertyList.get(Constants.PR_REFERENCE_ORIENTATION) 65 .getNumeric().getValue(); 66 if (propertyList.getExplicit(otherId) != null 67 && propertyList.getExplicit(otherId).getEnum() == Constants.EN_INDEFINITE) { 68 if ((writingMode != Constants.EN_TB_RL 73 && (refOrientation == 0 74 || refOrientation == 180 75 || refOrientation == -180)) 76 || (writingMode == Constants.EN_TB_RL 77 && (refOrientation == 90 78 || refOrientation == 270 79 || refOrientation == -270))) { 80 if (propId == Constants.PR_PAGE_WIDTH) { 82 fo.getLogger().warn("Both page-width and page-height set to " 83 + "\"indefinite\". Forcing page-width to \"auto\""); 84 return make(propertyList, fallbackValue, fo); 85 } 86 } else { 87 fo.getLogger().warn("Both page-width and page-height set to " 89 + "\"indefinite\". Forcing page-height to \"auto\""); 90 if (propId == Constants.PR_PAGE_HEIGHT) { 91 return make(propertyList, fallbackValue, fo); 92 } 93 } 94 } 95 } else if (p.isAuto()) { 96 return make(propertyList, fallbackValue, fo); 97 } 98 99 return p; 100 } 101 } 102 | Popular Tags |