/** * @param file the CssFile * */ public CssStateController(ICssFile file) { this.css = file; utils = CssUtils.GetInstance(); buffer = new StringBuilder(); commentStart = new CommentStart(this); commentEnd = new CommentEnd(this); commentInside = new CommentInside(this); unknown = new Unknown(this); properties = new Properties(this); rule = new Rule(this); current = unknown; }
/** * Constructs a new CssFilesImpl. */ public CssFilesImpl() { this.files = new List<ICssFile>(); this.utils = CssUtils.GetInstance(); this.select = new CssSelector(); }
virtual public void SetUp() { LoggerFactory.GetInstance().SetLogger(new SysoLogger(3)); css = CssUtils.GetInstance(); str = " een twee drie vier een twee drie vier"; }
/** * Construct a new StyleAttrCSSResolver with the given {@link CssFiles} and {@link CssUtils}. * * @param rules the {@link CssInheritanceRules} to use. * @param cssFiles a {@link CssFiles} implementation. * @param utils the CssUtils to use. * @param fileRetrieve the {@link FileRetrieve} implementation */ public StyleAttrCSSResolver(ICssInheritanceRules rules, ICssFiles cssFiles, CssUtils utils, IFileRetrieve fileRetrieve) { this.utils = utils; this.cssFiles = cssFiles; this.inherit = rules; this.retrieve = fileRetrieve; }
/** * Construct a new StyleAttrCSSResolver with the given {@link CssFiles} and {@link CssUtils} and the * {@link DefaultCssInheritanceRules}. * * @param cssFiles a {@link CssFiles} implementation. * @param utils the CssUtils to use. */ public StyleAttrCSSResolver(ICssFiles cssFiles, CssUtils utils) : this(new DefaultCssInheritanceRules(), cssFiles, utils) { }
/** * @return Singleton instance of CssUtils. */ public static CssUtils GetInstance() { if (myself != null) return myself; lock (syncroot) { if (null == myself) { myself = new CssUtils(); } return myself; } }
/** * Construct a new StyleAttrCSSResolver with the given {@link CssFiles} and {@link CssUtils}. * * @param rules the {@link CssInheritanceRules} to use. * @param cssFiles a {@link CssFiles} implementation. * @param utils the CssUtils to use. */ public StyleAttrCSSResolver(ICssInheritanceRules rules, ICssFiles cssFiles, CssUtils utils) : this(rules, cssFiles, utils, new FileRetrieveImpl()) { }
/** * Validates a given textHeight based on the content of a tag against the css styles "min-height" and "max-height" of the tag if present. * * @param css the styles of a tag * @param textHeight the current textHeight based on the content of a tag * @return the text height of an element. */ virtual public float ValidateTextHeight(IDictionary<String, String> css, float textHeight) { if (css.ContainsKey("min-height") && textHeight < new CssUtils().ParsePxInCmMmPcToPt(css["min-height"])) { textHeight = new CssUtils().ParsePxInCmMmPcToPt(css["min-height"]); } else if (css.ContainsKey("max-height") && textHeight > new CssUtils().ParsePxInCmMmPcToPt(css["max-height"])) { textHeight = new CssUtils().ParsePxInCmMmPcToPt(css["max-height"]); } return textHeight; }
/** * */ public CssSelector() { this.utils = CssUtils.GetInstance(); }
/** * Constructs a new CssFilesImpl. */ public CssFilesImpl() { this.files = new List <ICssFile>(); this.utils = CssUtils.GetInstance(); }
virtual public void PopulateOneCss(IDictionary <String, String> aggregatedProps, IDictionary <String, String> cssDeclaration) { IDictionary <String, String> css = new Dictionary <String, String>(); foreach (KeyValuePair <String, String> e in cssDeclaration) { String key = utils.StripDoubleSpacesTrimAndToLowerCase(e.Key); String value = utils.StripDoubleSpacesAndTrim(e.Value); if (Util.EqualsIgnoreCase(CSS.Property.BORDER, key)) { CssUtils.MapPutAll(css, utils.ParseBorder(value)); } else if (Util.EqualsIgnoreCase(CSS.Property.MARGIN, key)) { IDictionary <String, String> margins = utils.ParseBoxValues(value, "margin-", ""); foreach (String marginKey in margins.Keys) { if (!css.ContainsKey(marginKey)) { css.Add(marginKey, margins[marginKey]); } } } else if (Util.EqualsIgnoreCase(CSS.Property.BORDER_WIDTH, key)) { CssUtils.MapPutAll(css, utils.ParseBoxValues(value, "border-", "-width")); } else if (Util.EqualsIgnoreCase(CSS.Property.BORDER_STYLE, key)) { CssUtils.MapPutAll(css, utils.ParseBoxValues(value, "border-", "-style")); } else if (Util.EqualsIgnoreCase(CSS.Property.BORDER_COLOR, key)) { CssUtils.MapPutAll(css, utils.ParseBoxValues(value, "border-", "-color")); } else if (Util.EqualsIgnoreCase(CSS.Property.PADDING, key)) { IDictionary <String, String> paddings = utils.ParseBoxValues(value, "padding-", ""); foreach (String paddingKey in paddings.Keys) { if (!css.ContainsKey(paddingKey)) { css.Add(paddingKey, paddings[paddingKey]); } } //CssUtils.MapPutAll(css, utils.ParseBoxValues(value, "padding-", "")); } else if (Util.EqualsIgnoreCase(CSS.Property.FONT, key)) { CssUtils.MapPutAll(css, utils.ProcessFont(value)); } else if (Util.EqualsIgnoreCase(CSS.Property.LIST_STYLE, key)) { CssUtils.MapPutAll(css, utils.ProcessListStyle(value)); } else if (Util.EqualsIgnoreCase(CSS.Property.BACKGROUND, key)) { IDictionary <String, String> backgroundStyles = utils.ProcessBackground(value); foreach (String backgroundKey in backgroundStyles.Keys) { if (!css.ContainsKey(backgroundKey)) { css.Add(backgroundKey, backgroundStyles[backgroundKey]); } } } else { css[key] = value; } } CssUtils.MapPutAll(aggregatedProps, css); }
/** * Construct a new StyleAttrCSSResolver with the given {@link CssFiles} and {@link CssUtils}. * * @param rules the {@link CssInheritanceRules} to use. * @param cssFiles a {@link CssFiles} implementation. * @param utils the CssUtils to use. * @param fileRetrieve the {@link FileRetrieve} implementation */ public StyleAttrSvgCSSResolver(ICssInheritanceRules rules, ICssFiles cssFiles, CssUtils utils, IFileRetrieve fileRetrieve) { this.utils = utils; this.cssFiles = cssFiles; this.inherit = rules; this.retrieve = fileRetrieve; this.attributes = SVGAttributes.GetSVGAttributesList(); }