- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 23 Aug 2005 16:25:04 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/paged In directory hutz:/tmp/cvs-serv7360/properties/paged Added Files: Css2Style.java Makefile Marks.java Orphans.java OrphansATSC.java Page.java PageATSC.java PageBreakAfter.java PageBreakAfterATSC.java PageBreakBefore.java PageBreakBeforeATSC.java PageBreakInside.java PageBreakInsideATSC.java PagedDefault.properties PagedProperties.java PagedProperty.java Size.java Widows.java WidowsATSC.java Log Message: Patch by Jean-Guilhem Rouel Better handling of media and properties files Major reorganization of those properties files --- NEW FILE: Css2Style.java --- // // $Id: Css2Style.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssPrinterStyle; /** * @version $Revision: 1.1 $ */ public class Css2Style extends org.w3c.css.properties.css2.user.Css2Style { Size size; Marks marks; PageBreakBefore pageBreakBefore; PageBreakBeforeATSC pageBreakBeforeATSC; PageBreakAfter pageBreakAfter; PageBreakAfterATSC pageBreakAfterATSC; PageBreakInside pageBreakInside; PageBreakInsideATSC pageBreakInsideATSC; Page page; PageATSC pageATSC; Orphans orphans; OrphansATSC orphansATSC; Widows widows; WidowsATSC widowsATSC; /** * Get the size property */ public final Size getSize() { if (size == null) { size = (Size) style.CascadingOrder(new Size(), style, selector); } return size; } /** * Get the marks property */ public final Marks getMarks() { if (marks == null) { marks = (Marks) style.CascadingOrder(new Marks(), style, selector); } return marks; } /** * Get the page-break-before property */ public final PageBreakBefore getPageBreakBefore() { if (pageBreakBefore == null) { pageBreakBefore = (PageBreakBefore) style.CascadingOrder(new PageBreakBefore(), style, selector); } return pageBreakBefore; } public final PageBreakBeforeATSC getPageBreakBeforeATSC() { if (pageBreakBeforeATSC == null) { pageBreakBeforeATSC = (PageBreakBeforeATSC) style.CascadingOrder(new PageBreakBeforeATSC(), style, selector); } return pageBreakBeforeATSC; } /** * Get the page-break-after property */ public final PageBreakAfter getPageBreakAfter() { if (pageBreakAfter == null) { pageBreakAfter = (PageBreakAfter) style.CascadingOrder(new PageBreakAfter(), style, selector); } return pageBreakAfter; } public final PageBreakAfterATSC getPageBreakAfterATSC() { if (pageBreakAfterATSC == null) { pageBreakAfterATSC = (PageBreakAfterATSC) style.CascadingOrder(new PageBreakAfterATSC(), style, selector); } return pageBreakAfterATSC; } /** * Get the page-break-inside property */ public final PageBreakInside getPageBreakInside() { if (pageBreakInside == null) { pageBreakInside = (PageBreakInside) style.CascadingOrder(new PageBreakInside(), style, selector); } return pageBreakInside; } public final PageBreakInsideATSC getPageBreakInsideATSC() { if (pageBreakInsideATSC == null) { pageBreakInsideATSC = (PageBreakInsideATSC) style.CascadingOrder(new PageBreakInsideATSC(), style, selector); } return pageBreakInsideATSC; } /** * Get the page property */ public final Page getPage() { if (page == null) { page = (Page) style.CascadingOrder(new Page(), style, selector); } return page; } public final PageATSC getPageATSC() { if (pageATSC == null) { pageATSC = (PageATSC) style.CascadingOrder(new PageATSC(), style, selector); } return pageATSC; } /** * Get the orphans property */ public final Orphans getOrphans() { if (orphans == null) { orphans = (Orphans) style.CascadingOrder(new Orphans(), style, selector); } return orphans; } public final OrphansATSC getOrphansATSC() { if (orphansATSC == null) { orphansATSC = (OrphansATSC) style.CascadingOrder(new OrphansATSC(), style, selector); } return orphansATSC; } /** * Get the widows property */ public final Widows getWidows() { if (widows == null) { widows = (Widows) style.CascadingOrder(new Widows(), style, selector); } return widows; } public final WidowsATSC getWidowsATSC() { if (widowsATSC == null) { widowsATSC = (WidowsATSC) style.CascadingOrder(new WidowsATSC(), style, selector); } return widowsATSC; } /** * Print this style. * * @param printer The printer interface. */ public void print(CssPrinterStyle printer) { super.print(printer); if (size != null) { size.print(printer); } if (marks != null) { marks.print(printer); } if (pageBreakBefore != null) { pageBreakBefore.print(printer); } if (pageBreakBeforeATSC != null) { pageBreakBeforeATSC.print(printer); } if (pageBreakAfter != null) { pageBreakAfter.print(printer); } if (pageBreakAfterATSC != null) { pageBreakAfterATSC.print(printer); } if (pageBreakInside != null) { pageBreakInside.print(printer); } if (pageBreakInsideATSC != null) { pageBreakInsideATSC.print(printer); } if (page != null) { page.print(printer); } if (pageATSC != null) { pageATSC.print(printer); } if (orphans != null) { orphans.print(printer); } if (orphansATSC != null) { orphansATSC.print(printer); } if (widows != null) { widows.print(printer); } if (widowsATSC != null) { widowsATSC.print(printer); } } } --- NEW FILE: WidowsATSC.java --- // // $Id: WidowsATSC.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssValue; /** */ public class WidowsATSC extends PagedProperty { CssValue value; /** * Create a new WidowsATSC */ public WidowsATSC() { value = new CssNumber(null, 2); } /** * Creates a new CssWidowsATSC * * @param expression the expression of the size * @exception InvalidParamException The expression is incorrect */ public WidowsATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val.equals(inherit)) { value = inherit; expression.next(); return; } else if (val instanceof CssNumber) { if (((CssNumber) val).isInteger()) { value = val; expression.next(); return; } else { throw new InvalidParamException("integer", val.toString(), getPropertyName(), ac); } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public WidowsATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the current value */ public Object get() { return value; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == inherit; } /** * Returns a string representation of the object. */ public String toString() { return value.toString(); } /** * Returns the name of this property */ public String getPropertyName() { return "widows"; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.widowsATSC != null) { style.addRedefinitionWarning(ac, this); } style0.widowsATSC = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getWidowsATSC(); } else { return ((Css2Style) style).widowsATSC; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { if (value == null) { return (property instanceof WidowsATSC && ((WidowsATSC) property).value == value); } else { return (property instanceof WidowsATSC && ((WidowsATSC) property).value.equals(value)); } } } --- NEW FILE: Marks.java --- // // $Id: Marks.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class Marks extends CssProperty implements CssOperator { CssValue l1, l2; private static CssIdent none = new CssIdent("none"); private static CssIdent crop = new CssIdent("crop"); private static CssIdent cross = new CssIdent("cross"); /** * Create a new CssMarks */ public Marks() { l1 = none; } /** * Create a new CssMarks * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public Marks(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); char op = expression.getOperator(); setByUser(); if (val.equals(inherit)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } l1 = inherit; expression.next(); return; } else if (val.equals(none)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } l1 = none; expression.next(); return; } else if (val.equals(crop)) { l1 = crop; expression.next(); if (!expression.end()) { val = expression.getValue(); if ((op == SPACE) && (val.equals(cross))) { l2 = cross; expression.next(); return; } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } return; } else if (val.equals(cross)) { l1 = cross; expression.next(); if (!expression.end()) { val = expression.getValue(); if ((op == SPACE) && (val.equals(crop))) { l2 = crop; expression.next(); return; } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } return; } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public Marks(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "marks"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return l1 == inherit; } /** * Returns a string representation of the object. */ public String toString() { if (l2 != null) { return l1.toString() + " " + l2.toString(); } else { return l1.toString(); } } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.marks != null) style0.addRedefinitionWarning(ac, this); style0.marks = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getMarks(); } else { return ((Css2Style) style).marks; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof Marks && l1.equals(((Marks) property).l1) || l2.equals(((Marks) property).l2)); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return l1 == none; } CssLength getLength(CssValue val) throws InvalidParamException { if (val instanceof CssLength) { return (CssLength) val; } else if (val instanceof CssNumber) { return ((CssNumber) val).getLength(); } else { return null; } } } --- NEW FILE: PageBreakBefore.java --- // // $Id: PageBreakBefore.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class PageBreakBefore extends CssProperty implements CssOperator { int value; private static String PAGEBREAKBEFORE[] = { "auto", "always", "avoid", "left", "right", "inherit" }; private static int[] hash_values; /** * Create a new CssPageBreakBefore */ public PageBreakBefore() { value = 0; } /** * Create a new CssPageBreakBefore * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public PageBreakBefore(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); // char op = expression.getOperator(); setByUser(); if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < PAGEBREAKBEFORE.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public PageBreakBefore(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "page-break-before"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == PAGEBREAKBEFORE.length - 1; } /** * Returns a string representation of the object. */ public String toString() { return PAGEBREAKBEFORE[value]; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.pageBreakBefore != null) style0.addRedefinitionWarning(ac, this); style0.pageBreakBefore = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getPageBreakBefore(); } else { return ((Css2Style) style).pageBreakBefore; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof PageBreakBefore && value == ((PageBreakBefore) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[PAGEBREAKBEFORE.length]; for (int i=0; i<PAGEBREAKBEFORE.length; i++) hash_values[i] = PAGEBREAKBEFORE[i].hashCode(); } } --- NEW FILE: Size.java --- // // $Id: Size.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class Size extends CssProperty implements CssOperator { CssValue l1, l2; private static CssIdent auto = new CssIdent("auto"); private static CssIdent portrait = new CssIdent("portrait"); private static CssIdent landscape = new CssIdent("landscape"); /** * Create a new CssSize */ public Size() { l1 = auto; } /** * Create a new CssSize * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public Size(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); char op = expression.getOperator(); setByUser(); if (val.equals(inherit)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } l1 = inherit; expression.next(); return; } else if (val.equals(auto)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } l1 = auto; expression.next(); return; } else if (val.equals(portrait)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } l1 = portrait; expression.next(); return; } else if (val.equals(landscape)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } l1 = landscape; expression.next(); return; } val = getLength(val); if (val != null) { l1 = val; expression.next(); if (!expression.end()) { if(expression.getValue().equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } val = getLength(expression.getValue()); if ((val == null) || (op != SPACE)) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } else { l2 = val; expression.next(); return; } } else { expression.next(); return; } } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } public Size(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "size"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return l1 == inherit; } /** * Returns a string representation of the object. */ public String toString() { if (l2 != null) { return l1.toString() + " " + l2.toString(); } else { return l1.toString(); } } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.size != null) style0.addRedefinitionWarning(ac, this); style0.size = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getSize(); } else { return ((Css2Style) style).size; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof Size && l1.equals(((Size) property).l1) && ((l2 == null) || l2.equals(((Size) property).l2))); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return l1 == auto; } CssLength getLength(CssValue val) throws InvalidParamException { if (val instanceof CssLength) { return (CssLength) val; } else if (val instanceof CssNumber) { return ((CssNumber) val).getLength(); } else { return null; } } } --- NEW FILE: PageBreakAfter.java --- // // $Id: PageBreakAfter.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class PageBreakAfter extends CssProperty implements CssOperator { int value; private static String PAGEBREAKAFTER[] = { "auto", "always", "avoid", "left", "right", "inherit" }; private static int[] hash_values; /** * Create a new CssPageBreakAfter */ public PageBreakAfter() { value = 0; } /** * Create a new CssPageBreakAfter * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public PageBreakAfter(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); // char op = expression.getOperator(); setByUser(); if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < PAGEBREAKAFTER.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public PageBreakAfter(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "page-break-after"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == PAGEBREAKAFTER.length - 1; } /** * Returns a string representation of the object. */ public String toString() { return PAGEBREAKAFTER[value]; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.pageBreakAfter != null) style0.addRedefinitionWarning(ac, this); style0.pageBreakAfter = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getPageBreakAfter(); } else { return ((Css2Style) style).pageBreakAfter; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof PageBreakAfter && value == ((PageBreakAfter) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[PAGEBREAKAFTER.length]; for (int i=0; i<PAGEBREAKAFTER.length; i++) hash_values[i] = PAGEBREAKAFTER[i].hashCode(); } } --- NEW FILE: PagedDefault.properties --- size.inherited: false marks.inherited: false page-break-before.inherited: true page-break-after.inherited: true page-break-inside.inherited: true --- NEW FILE: Page.java --- // // $Id: Page.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class Page extends CssProperty implements CssOperator { CssValue value; CssValue pseudo; private static CssIdent auto = new CssIdent("auto"); /** * Create a new CssPage */ public Page() { value = auto; } /** * Create a new CssPage * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public Page(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); char op = expression.getOperator(); setByUser(); if (val.equals(auto)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } value = val; expression.next(); } else if (val instanceof CssIdent) { value = val; expression.next(); if (!expression.end()) { val = expression.getValue(); if ((op == SPACE) && (val instanceof CssIdent)) { pseudo = val; expression.next(); return; } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } public Page(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "page"; } /** * Returns a string representation of the object. */ public String toString() { if (pseudo != null) { return value + " " + pseudo; } else { return value.toString(); } } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.page != null) style0.addRedefinitionWarning(ac, this); style0.page = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getPage(); } else { return ((Css2Style) style).page; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof Page && value == ((Page) property).value && ((pseudo == null) || pseudo.equals(((Page) property).pseudo))); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == auto; } } --- NEW FILE: PageATSC.java --- // // $Id: PageATSC.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class PageATSC extends CssProperty implements CssOperator { CssValue value; CssValue pseudo; private static CssIdent auto = new CssIdent("auto"); /** * Create a new CssPageATSC */ public PageATSC() { value = auto; } /** * Create a new CssPageATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public PageATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); char op = expression.getOperator(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val.equals(auto)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } value = val; expression.next(); } else if (val instanceof CssIdent) { value = val; expression.next(); if (!expression.end()) { val = expression.getValue(); if ((op == SPACE) && (val instanceof CssIdent)) { pseudo = val; expression.next(); return; } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } } else { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } public PageATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "page"; } /** * Returns a string representation of the object. */ public String toString() { if (pseudo != null) { return value + " " + pseudo; } else { return value.toString(); } } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.pageATSC != null) style0.addRedefinitionWarning(ac, this); style0.pageATSC = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getPageATSC(); } else { return ((Css2Style) style).pageATSC; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof PageATSC && value == ((PageATSC) property).value && ((pseudo == null) || pseudo.equals(((PageATSC) property).pseudo))); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == auto; } } --- NEW FILE: PagedProperty.java --- // // $Id: PagedProperty.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.properties.css1.CssProperty; /** * @version $Revision: 1.1 $ */ public abstract class PagedProperty extends CssProperty { /** * Returns true if the property is inherited */ public boolean Inherited() { return PagedProperties.getInheritance(this); } } --- NEW FILE: Orphans.java --- // // $Id: Orphans.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssValue; /** */ public class Orphans extends PagedProperty { CssValue value; /** * Create a new Orphans */ public Orphans() { value = new CssNumber(null, 2); } /** * Creates a new CssOrphans * * @param expression the expression of the size * @exception InvalidParamException The expression is incorrect */ public Orphans(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); if (val.equals(inherit)) { value = inherit; expression.next(); return; } else if (val instanceof CssNumber) { if (((CssNumber) val).isInteger()) { value = val; expression.next(); return; } else { throw new InvalidParamException("integer", val.toString(), getPropertyName(), ac); } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public Orphans(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the current value */ public Object get() { return value; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == inherit; } /** * Returns a string representation of the object. */ public String toString() { return value.toString(); } /** * Returns the name of this property */ public String getPropertyName() { return "orphans"; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.orphans != null) { style.addRedefinitionWarning(ac, this); } style0.orphans = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOrphans(); } else { return ((Css2Style) style).orphans; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { if (value == null) { return (property instanceof Orphans && ((Orphans) property).value == value); } else { return (property instanceof Orphans && ((Orphans) property).value.equals(value)); } } } --- NEW FILE: PageBreakAfterATSC.java --- // // $Id: PageBreakAfterATSC.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class PageBreakAfterATSC extends CssProperty implements CssOperator { int value; private static String PAGEBREAKAFTER[] = { "auto", "always", "avoid", "left", "right", "inherit" }; private static int[] hash_values; /** * Create a new CssPageBreakAfterATSC */ public PageBreakAfterATSC() { value = 0; } /** * Create a new CssPageBreakAfterATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public PageBreakAfterATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); // char op = expression.getOperator(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < PAGEBREAKAFTER.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public PageBreakAfterATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "page-break-after"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == PAGEBREAKAFTER.length - 1; } /** * Returns a string representation of the object. */ public String toString() { return PAGEBREAKAFTER[value]; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.pageBreakAfterATSC != null) style0.addRedefinitionWarning(ac, this); style0.pageBreakAfterATSC = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getPageBreakAfterATSC(); } else { return ((Css2Style) style).pageBreakAfterATSC; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof PageBreakAfterATSC && value == ((PageBreakAfterATSC) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[PAGEBREAKAFTER.length]; for (int i=0; i<PAGEBREAKAFTER.length; i++) hash_values[i] = PAGEBREAKAFTER[i].hashCode(); } } --- NEW FILE: PageBreakInside.java --- // // $Id: PageBreakInside.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class PageBreakInside extends CssProperty implements CssOperator { int value; private static String PAGEBREAKINSIDE[] = { "auto", "avoid", "inherit" }; private static int[] hash_values; /** * Create a new CssPageBreakInside */ public PageBreakInside() { value = 0; } /** * Create a new CssPageBreakInside * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public PageBreakInside(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); // char op = expression.getOperator(); setByUser(); if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < PAGEBREAKINSIDE.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public PageBreakInside(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "page-break-inside"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == PAGEBREAKINSIDE.length - 1; } /** * Returns a string representation of the object. */ public String toString() { return PAGEBREAKINSIDE[value]; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.pageBreakInside != null) style0.addRedefinitionWarning(ac, this); style0.pageBreakInside = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getPageBreakInside(); } else { return ((Css2Style) style).pageBreakInside; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof PageBreakInside && value == ((PageBreakInside) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[PAGEBREAKINSIDE.length]; for (int i=0; i<PAGEBREAKINSIDE.length; i++) hash_values[i] = PAGEBREAKINSIDE[i].hashCode(); } } --- NEW FILE: Makefile --- SRCS = Css2Properties.java Css2Property.java Css2Style.java OBJS = $(SRCS:.java=.class) PACKAGE = org.w3c.css.properties2 JAVAC = /usr/local/java11/bin/javac JAVADOC = javadoc JAVADOCFLAGS = -version -d docs -protected JAVACFLAGS = MAKEDEPEND = jmakedepend .SUFFIXES: .class .java .java.class:; $(JAVAC) $(JAVACFLAGS) $< all: $(OBJS) javadoc:; $(JAVADOC) $(JAVADOCFLAGS) $(PACKAGE) clean:; -rm -f $(OBJS) *~ core depend:; $(MAKEDEPEND) $(SRCS) # DO NOT DELETE THIS LINE -- make depend depends on it. Css2Style.class:: Css2Style.java\ /usr/local/java11/lib/classes.zip\ /u/www43/0/w3c/plehegar/Work/Java/org.w3c.css.util/Warnings.class\ /u/www43/0/w3c/plehegar/Work/Java/org.w3c.css.parser/CssPrinterStyle.class\ /u/www43/0/w3c/plehegar/Work/Java/org.w3c.css.aural/ACssStyle.class Css2Properties.class:: Css2Properties.java\ /usr/local/java11/lib/classes.zip\ /u/www43/0/w3c/plehegar/Work/Java/org.w3c.css.properties/CssProperty.class Css2Property.class:: Css2Property.java\ /u/www43/0/w3c/plehegar/Work/Java/org.w3c.css.aural/ACssProperty.class --- NEW FILE: OrphansATSC.java --- // // $Id: OrphansATSC.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssValue; /** */ public class OrphansATSC extends PagedProperty { CssValue value; /** * Create a new OrphansATSC */ public OrphansATSC() { value = new CssNumber(null, 2); } /** * Creates a new CssOrphansATSC * * @param expression the expression of the size * @exception InvalidParamException The expression is incorrect */ public OrphansATSC(ApplContext ac, CssExpression expression,boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val.equals(inherit)) { value = inherit; expression.next(); return; } else if (val instanceof CssNumber) { if (((CssNumber) val).isInteger()) { value = val; expression.next(); return; } else { throw new InvalidParamException("integer", val.toString(), getPropertyName(), ac); } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public OrphansATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the current value */ public Object get() { return value; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == inherit; } /** * Returns a string representation of the object. */ public String toString() { return value.toString(); } /** * Returns the name of this property */ public String getPropertyName() { return "orphans"; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.orphansATSC != null) { style.addRedefinitionWarning(ac, this); } style0.orphansATSC = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOrphansATSC(); } else { return ((Css2Style) style).orphansATSC; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { if (value == null) { return (property instanceof OrphansATSC && ((OrphansATSC) property).value == value); } else { return (property instanceof OrphansATSC && ((OrphansATSC) property).value.equals(value)); } } } --- NEW FILE: PagedProperties.java --- // // $Id: PagedProperties.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.paged; import java.net.URL; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.Utf8Properties; /** * @version $Revision: 1.1 $ */ public class PagedProperties { public static Utf8Properties properties; public static String getString(CssProperty property, String prop) { return properties.getProperty(property.getPropertyName() + "." + prop); } public static boolean getInheritance(CssProperty property) { return getString(property, "inherited").equals("true"); } static { Utf8Properties properties = new Utf8Properties(); try { URL url = PagedProperties.class .getResource("PagedDefault.properties"); properties.load(url.openStream()); } catch (Exception e) { System.err .println("org.w3c.css.properties.paged.PagedProperties: couldn't load properties "); System.err.println(" " + e.toString()); } } } --- NEW FILE: Widows.java --- // // $Id: Widows.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssValue; /** */ public class Widows extends PagedProperty { CssValue value; /** * Create a new Widows */ public Widows() { value = new CssNumber(null, 2); } /** * Creates a new CssWidows * * @param expression the expression of the size * @exception InvalidParamException The expression is incorrect */ public Widows(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); if (val.equals(inherit)) { value = inherit; expression.next(); return; } else if (val instanceof CssNumber) { if (((CssNumber) val).isInteger()) { value = val; expression.next(); return; } else { throw new InvalidParamException("integer", val.toString(), getPropertyName(), ac); } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public Widows(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the current value */ public Object get() { return value; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == inherit; } /** * Returns a string representation of the object. */ public String toString() { return value.toString(); } /** * Returns the name of this property */ public String getPropertyName() { return "widows"; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.widows != null) { style.addRedefinitionWarning(ac, this); } style0.widows = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getWidows(); } else { return ((Css2Style) style).widows; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { if (value == null) { return (property instanceof Widows && ((Widows) property).value == value); } else { return (property instanceof Widows && ((Widows) property).value.equals(value)); } } } --- NEW FILE: PageBreakInsideATSC.java --- // // $Id: PageBreakInsideATSC.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class PageBreakInsideATSC extends CssProperty implements CssOperator { int value; private static String PAGEBREAKINSIDE[] = { "auto", "avoid", "inherit" }; private static int[] hash_values; /** * Create a new CssPageBreakInsideATSC */ public PageBreakInsideATSC() { value = 0; } /** * Create a new CssPageBreakInsideATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public PageBreakInsideATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); //char op = expression.getOperator(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < PAGEBREAKINSIDE.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public PageBreakInsideATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "page-break-inside"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == PAGEBREAKINSIDE.length - 1; } /** * Returns a string representation of the object. */ public String toString() { return PAGEBREAKINSIDE[value]; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.pageBreakInsideATSC != null) style0.addRedefinitionWarning(ac, this); style0.pageBreakInsideATSC = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getPageBreakInsideATSC(); } else { return ((Css2Style) style).pageBreakInsideATSC; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof PageBreakInsideATSC && value == ((PageBreakInsideATSC) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[PAGEBREAKINSIDE.length]; for (int i=0; i<PAGEBREAKINSIDE.length; i++) hash_values[i] = PAGEBREAKINSIDE[i].hashCode(); } } --- NEW FILE: PageBreakBeforeATSC.java --- // // $Id: PageBreakBeforeATSC.java,v 1.1 2005/08/23 16:25:02 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.paged; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class PageBreakBeforeATSC extends CssProperty implements CssOperator { int value; private static String PAGEBREAKBEFORE[] = { "auto", "always", "avoid", "left", "right", "inherit" }; private static int[] hash_values; /** * Create a new CssPageBreakBeforeATSC */ public PageBreakBeforeATSC() { value = 0; } /** * Create a new CssPageBreakBeforeATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public PageBreakBeforeATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); // char op = expression.getOperator(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < PAGEBREAKBEFORE.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public PageBreakBeforeATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "page-break-before"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == PAGEBREAKBEFORE.length - 1; } /** * Returns a string representation of the object. */ public String toString() { return PAGEBREAKBEFORE[value]; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.pageBreakBeforeATSC != null) style0.addRedefinitionWarning(ac, this); style0.pageBreakBeforeATSC = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getPageBreakBeforeATSC(); } else { return ((Css2Style) style).pageBreakBeforeATSC; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof PageBreakBeforeATSC && value == ((PageBreakBeforeATSC) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[PAGEBREAKBEFORE.length]; for (int i=0; i<PAGEBREAKBEFORE.length; i++) hash_values[i] = PAGEBREAKBEFORE[i].hashCode(); } }
Received on Tuesday, 23 August 2005 16:25:26 UTC