public virtual void ListStyleTest03() { String shorthandExpression = "inherit"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("list-style-type: inherit" , "list-style-position: inherit", "list-style-image: inherit")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.LIST_STYLE); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BorderColorTest02() { String shorthandExpression = "red"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-color: red" , "border-right-color: red", "border-bottom-color: red", "border-left-color: red")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_COLOR); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void OutlineTest01() { String shorthandExpression = "#00ff00 dashed medium"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("outline-color: #00ff00" , "outline-style: dashed", "outline-width: medium")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.OUTLINE); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BorderStyleTest01() { String shorthandExpression = "dotted solid double dashed"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-style: dotted" , "border-right-style: solid", "border-bottom-style: double", "border-left-style: dashed")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_STYLE); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BorderRightTest01() { String shorthandExpression = "10px double rgb(12,220,100)"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-right-width: 10px" , "border-right-style: double", "border-right-color: rgb(12,220,100)")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_RIGHT); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BorderTopTest01() { String shorthandExpression = "10px hidden rgba(12,225,100,0.7)"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-width: 10px" , "border-top-style: hidden", "border-top-color: rgba(12,225,100,0.7)")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_TOP); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BorderBottomTest01() { String shorthandExpression = "15px dotted blue"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-bottom-width: 15px" , "border-bottom-style: dotted", "border-bottom-color: blue")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_BOTTOM); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BorderLeftTest01() { String shorthandExpression = "10px solid #ff0000"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-left-width: 10px" , "border-left-style: solid", "border-left-color: #ff0000")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_LEFT); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void PaddingTest03() { String shorthandExpression = "inherit"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("padding-top: inherit" , "padding-right: inherit", "padding-bottom: inherit", "padding-left: inherit")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.PADDING); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void MarginTest02() { String shorthandExpression = "2cm auto 4cm"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("margin-top: 2cm" , "margin-right: auto", "margin-bottom: 4cm", "margin-left: auto")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.MARGIN); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BorderWidthTest01() { String shorthandExpression = "thin medium thick 10px"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("border-top-width: thin" , "border-right-width: medium", "border-bottom-width: thick", "border-left-width: 10px")); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BORDER_WIDTH); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void FontTest09() { String shorthandExpression = "Georgia , 'Times New Roman', serif"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("font-style: initial" , "font-variant: initial", "font-weight: initial", "font-size: initial", "line-height: initial", "font-family: georgia,'Times New Roman',serif" )); IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.FONT); NUnit.Framework.Assert.IsNotNull(resolver); IList <CssDeclaration> resolvedShorthandProps = resolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BackgroundTest06() { String shorthandExpression = "DarkOliveGreen fixed center"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("background-color: darkolivegreen" , "background-image: initial", "background-position: center", "background-size: initial", "background-repeat: initial" , "background-origin: initial", "background-clip: initial", "background-attachment: fixed")); IShorthandResolver backgroundResolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BACKGROUND ); NUnit.Framework.Assert.IsNotNull(backgroundResolver); IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BackgroundTest05() { String shorthandExpression = "rgdbq(150,90,60) url'smiley.gif') repeat-x scroll 20 60%"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("background-color: initial" , "background-image: initial", "background-position: 20 60%", "background-size: initial", "background-repeat: repeat-x" , "background-origin: initial", "background-clip: initial", "background-attachment: scroll")); IShorthandResolver backgroundResolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BACKGROUND ); NUnit.Framework.Assert.IsNotNull(backgroundResolver); IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
public virtual void BackgroundTest03() { String shorthandExpression = "url('img.gif') 25%/50px 150px fixed border-box"; ICollection <String> expectedResolvedProperties = new HashSet <String>(JavaUtil.ArraysAsList("background-color: initial" , "background-image: url('img.gif')", "background-position: 25%", "background-size: 50px 150px", "background-repeat: initial" , "background-origin: border-box", "background-clip: initial", "background-attachment: fixed")); IShorthandResolver backgroundResolver = ShorthandResolverFactory.GetShorthandResolver(CssConstants.BACKGROUND ); NUnit.Framework.Assert.IsNotNull(backgroundResolver); IList <CssDeclaration> resolvedShorthandProps = backgroundResolver.ResolveShorthand(shorthandExpression); CompareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); }
/// <summary>Populates the CSS declarations map.</summary> /// <param name="declarations">the declarations</param> /// <param name="map">the map</param> private static void PopulateDeclarationsMap(IList <CssDeclaration> declarations, IDictionary <String, CssDeclaration > map) { foreach (CssDeclaration declaration in declarations) { IShorthandResolver shorthandResolver = ShorthandResolverFactory.GetShorthandResolver(declaration.GetProperty ()); if (shorthandResolver == null) { PutDeclarationInMapIfValid(map, declaration); } else { IList <CssDeclaration> resolvedShorthandProps = shorthandResolver.ResolveShorthand(declaration.GetExpression ()); PopulateDeclarationsMap(resolvedShorthandProps, map); } } }
/* (non-Javadoc) * @see com.itextpdf.styledxmlparser.css.resolve.shorthand.impl.AbstractBorderShorthandResolver#resolveShorthand(java.lang.String) */ public override IList <CssDeclaration> ResolveShorthand(String shorthandExpression) { IList <CssDeclaration> preResolvedProps = base.ResolveShorthand(shorthandExpression); IList <CssDeclaration> resolvedProps = new List <CssDeclaration>(); foreach (CssDeclaration prop in preResolvedProps) { IShorthandResolver shorthandResolver = ShorthandResolverFactory.GetShorthandResolver(prop.GetProperty()); if (shorthandResolver != null) { resolvedProps.AddAll(shorthandResolver.ResolveShorthand(prop.GetExpression())); } else { ILog logger = LogManager.GetLogger(typeof(BorderShorthandResolver)); logger.Error(MessageFormatUtil.Format("Cannot find a shorthand resolver for the \"{0}\" property. " + "Expected border-width, border-style or border-color properties." , prop.GetProperty())); } } return(resolvedProps); }
private static bool CheckProperties(IDictionary <CssBackgroundUtils.BackgroundPropertyType, String> resolvedProps ) { foreach (KeyValuePair <CssBackgroundUtils.BackgroundPropertyType, String> property in resolvedProps) { if (!CssDeclarationValidationMaster.CheckDeclaration(new CssDeclaration(CssBackgroundUtils.GetBackgroundPropertyNameFromType (property.Key), property.Value))) { LOGGER.Error(MessageFormatUtil.Format(iText.StyledXmlParser.LogMessageConstant.INVALID_CSS_PROPERTY_DECLARATION , property.Value)); return(false); } IShorthandResolver resolver = ShorthandResolverFactory.GetShorthandResolver(CssBackgroundUtils.GetBackgroundPropertyNameFromType (property.Key)); if (resolver != null && resolver.ResolveShorthand(property.Value).IsEmpty()) { return(false); } } return(true); }