// helper methods /** * Generates a key for an tag/id/class combination and adds the style * attributes to the stylecache. * * @param attributes * a Properties object with the tagname and the attributes of the * tag. * @return a key */ private string GetKey(Properties attributes) { String tag = attributes[MarkupTags.ITEXT_TAG]; String id = attributes[MarkupTags.HTML_ATTR_CSS_ID]; String cl = attributes[MarkupTags.HTML_ATTR_CSS_CLASS]; if (id == null) { id = ""; } else { id = "#" + id; } if (cl == null) { cl = ""; } else { cl = "." + cl; } String key = tag + id + cl; if (!stylecache.ContainsKey(key) && key.Length > 0) { Properties props = new Properties(); Properties tagprops = (Properties)this[tag]; Properties idprops = (Properties)this[id]; Properties clprops = (Properties)this[cl]; Properties tagidprops = (Properties)this[tag + id]; Properties tagclprops = (Properties)this[tag + cl]; if (tagprops != null) { props.AddAll(tagprops); } if (idprops != null) { props.AddAll(idprops); } if (clprops != null) { props.AddAll(clprops); } if (tagidprops != null) { props.AddAll(tagidprops); } if (tagclprops != null) { props.AddAll(tagclprops); } stylecache[key] = props; } return(key); }
public static Properties <string, string> ConcatProperties(params Properties <string, string>[] propsArray) { Properties <string, string> result = null; if (propsArray != null) { result = new Properties <string, string>(); foreach (Properties <string, string> props in propsArray) { result.AddAll(props); } } return(result); }
public static void InitConfig(Properties <string, string> config, string cacheXml, bool PdxReadSerialized) { string gfcppPropsFile = Util.AssemblyDir + "/gfcpp.properties"; if (File.Exists(gfcppPropsFile)) { Properties <string, string> newConfig = new Properties <string, string>(); newConfig.Load(gfcppPropsFile); if (config != null) { newConfig.AddAll(config); } config = newConfig; } //ConnectConfig(dsName, config); if (m_cache == null || m_cache.IsClosed) { try { CacheHelper <TKey, TVal> .m_doDisconnect = false; CacheFactory cf = CacheFactory.CreateCacheFactory(config); if (cacheXml != null && cacheXml.Length > 0) { FwkInfo("seting cache-xml-file {0}", cacheXml); cf = cf.Set("cache-xml-file", cacheXml); } if (PdxReadSerialized) { FwkInfo("seting PdxReadSerialized {0}", PdxReadSerialized); cf = CacheFactory.CreateCacheFactory(config) .SetPdxReadSerialized(PdxReadSerialized); } m_cache = cf.Create(); } catch (CacheExistsException) { m_cache = CacheFactory.GetAnyInstance(); } } m_dsys = m_cache.DistributedSystem; }
/// <summary> Gets the list of attributes of the peer. </summary> public virtual Properties GetAttributes(Hashtable attrs) { Properties attributes = new Properties(); attributes.AddAll(attributeValues); if (defaultContent != null) { attributes.Add(ElementTags.ITEXT, defaultContent); } if (attrs != null) { foreach (string key in attrs.Keys) { attributes.Add(GetName(key), (string)attrs[key]); } } return(attributes); }
/// <summary> /// @see com.lowagie.text.xml.XmlPeer#getAttributes(org.xml.sax.Attributes) /// </summary> public override Properties GetAttributes(Hashtable attrs) { Properties attributes = new Properties(); attributes.AddAll(AttributeValues); if (DefaultContent != null) { attributes[ElementTags.ITEXT] = DefaultContent; } if (attrs != null) { foreach (string key in attrs.Keys) { attributes.Add(GetName(key).ToLower(CultureInfo.InvariantCulture), (string)attrs[key]); } } return(attributes); }
public static void InitConfig(Properties <string, string> config, string cacheXml, bool PdxReadSerialized) { string geodeNativePropsFile = Util.AssemblyDir + "/geode.properties"; if (File.Exists(geodeNativePropsFile)) { Properties <string, string> newConfig = new Properties <string, string>(); newConfig.Load(geodeNativePropsFile); if (config != null) { newConfig.AddAll(config); } config = newConfig; } //ConnectConfig(dsName, config); if (m_cache == null || m_cache.IsClosed) { try { CacheFactory cf = new CacheFactory(config); if (cacheXml != null && cacheXml.Length > 0) { FwkInfo("seting cache-xml-file {0}", cacheXml); cf = cf.Set("cache-xml-file", cacheXml); } if (PdxReadSerialized) { FwkInfo("seting PdxReadSerialized {0}", PdxReadSerialized); cf = new CacheFactory(config) .SetPdxReadSerialized(PdxReadSerialized); } m_cache = cf.Create(); } catch (CacheExistsException) { m_cache = new CacheFactory(config).Create(); } } }
/** * A <CODE>Chunk</CODE> copy constructor. * @param ck the <CODE>Chunk</CODE> to be copied */ public Chunk(Chunk ck) { if (ck.content != null) { content = new StringBuilder(ck.content.ToString()); } if (ck.font != null) { font = new Font(ck.font); } if (ck.attributes != null) { attributes = new Hashtable(ck.attributes); } if (ck.markupAttributes != null) { markupAttributes = new Properties(); markupAttributes.AddAll(ck.markupAttributes); } }
/** * This method gets called when a start tag is encountered. * * @param uri the Uniform Resource Identifier * @param lname the local name (without prefix), or the empty string if Namespace processing is not being performed. * @param name the name of the tag that is encountered * @param attrs the list of attributes */ public override void StartElement(String uri, String lname, String name, Hashtable attrs) { //System.err.Println("Start: " + name); // super.handleStartingTags is replaced with handleStartingTags // suggestion by Vu Ngoc Tan/Hop name = name.ToLower(CultureInfo.InvariantCulture); if (HtmlTagMap.IsHtml(name)) { // we do nothing return; } if (HtmlTagMap.IsHead(name)) { // we do nothing return; } if (HtmlTagMap.IsTitle(name)) { // we do nothing return; } if (HtmlTagMap.IsMeta(name)) { // we look if we can change the body attributes String meta = null; String content = null; if (attrs != null) { foreach (String attribute in attrs.Keys) { if (Util.EqualsIgnoreCase(attribute, HtmlTags.CONTENT)) { content = (String)attrs[attribute]; } else if (Util.EqualsIgnoreCase(attribute, HtmlTags.NAME)) { meta = (String)attrs[attribute]; } } } if (meta != null && content != null) { bodyAttributes.Add(meta, content); } return; } if (HtmlTagMap.IsLink(name)) { // we do nothing for the moment, in a later version we could extract the style sheet return; } if (HtmlTagMap.IsBody(name)) { // maybe we could extract some info about the document: color, margins,... // but that's for a later version... XmlPeer peer = new XmlPeer(ElementTags.ITEXT, name); peer.AddAlias(ElementTags.TOP, HtmlTags.TOPMARGIN); peer.AddAlias(ElementTags.BOTTOM, HtmlTags.BOTTOMMARGIN); peer.AddAlias(ElementTags.RIGHT, HtmlTags.RIGHTMARGIN); peer.AddAlias(ElementTags.LEFT, HtmlTags.LEFTMARGIN); bodyAttributes.AddAll(peer.GetAttributes(attrs)); HandleStartingTags(peer.Tag, bodyAttributes); return; } if (myTags.ContainsKey(name)) { XmlPeer peer = (XmlPeer)myTags[name]; if (ElementTags.TABLE.Equals(peer.Tag) || ElementTags.CELL.Equals(peer.Tag)) { Properties p = peer.GetAttributes(attrs); String value; if (ElementTags.TABLE.Equals(peer.Tag) && (value = p[ElementTags.BORDERWIDTH]) != null) { if (float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo) > 0) { tableBorder = true; } } if (tableBorder) { p.Add(ElementTags.LEFT, "true"); p.Add(ElementTags.RIGHT, "true"); p.Add(ElementTags.TOP, "true"); p.Add(ElementTags.BOTTOM, "true"); } HandleStartingTags(peer.Tag, p); return; } HandleStartingTags(peer.Tag, peer.GetAttributes(attrs)); return; } Properties attributes = new Properties(); if (attrs != null) { foreach (String attribute in attrs.Keys) { attributes.Add(attribute.ToLower(CultureInfo.InvariantCulture), ((String)attrs[attribute]).ToLower(CultureInfo.InvariantCulture)); } } HandleStartingTags(name, attributes); }
/// <summary> /// Constructs a Font-object. /// </summary> /// <param name="attributes">the attributes of a Font object</param> /// <returns>a Font object</returns> public Font GetFont(Properties attributes) { lock (_syncLock) { string fontname = null; var encoding = DefaultEncoding; var embedded = DefaultEmbedding; float size = Font.UNDEFINED; var style = Font.NORMAL; BaseColor color = null; var value = attributes[Markup.HTML_ATTR_STYLE]; if (!string.IsNullOrEmpty(value)) { var styleAttributes = Markup.ParseAttributes(value); if (styleAttributes.Count == 0) { attributes.Add(Markup.HTML_ATTR_STYLE, value); } else { fontname = styleAttributes[Markup.CSS_KEY_FONTFAMILY]; if (fontname != null) { string tmp; while (fontname.IndexOf(",", StringComparison.Ordinal) != -1) { tmp = fontname.Substring(0, fontname.IndexOf(",", StringComparison.Ordinal)); if (IsRegistered(tmp)) { fontname = tmp; } else { fontname = fontname.Substring(fontname.IndexOf(",", StringComparison.Ordinal) + 1); } } } if ((value = styleAttributes[Markup.CSS_KEY_FONTSIZE]) != null) { size = Markup.ParseLength(value); } if ((value = styleAttributes[Markup.CSS_KEY_FONTWEIGHT]) != null) { style |= Font.GetStyleValue(value); } if ((value = styleAttributes[Markup.CSS_KEY_FONTSTYLE]) != null) { style |= Font.GetStyleValue(value); } if ((value = styleAttributes[Markup.CSS_KEY_COLOR]) != null) { color = Markup.DecodeColor(value); } attributes.AddAll(styleAttributes); } } if ((value = attributes[ElementTags.ENCODING]) != null) { encoding = value; } if ("true".Equals(attributes[ElementTags.EMBEDDED])) { embedded = true; } if ((value = attributes[ElementTags.FONT]) != null) { fontname = value; } if ((value = attributes[ElementTags.SIZE]) != null) { size = float.Parse(value, NumberFormatInfo.InvariantInfo); } if ((value = attributes[Markup.HTML_ATTR_STYLE]) != null) { style |= Font.GetStyleValue(value); } if ((value = attributes[ElementTags.STYLE]) != null) { style |= Font.GetStyleValue(value); } var r = attributes[ElementTags.RED]; var g = attributes[ElementTags.GREEN]; var b = attributes[ElementTags.BLUE]; if (r != null || g != null || b != null) { var red = 0; var green = 0; var blue = 0; if (r != null) { red = int.Parse(r); } if (g != null) { green = int.Parse(g); } if (b != null) { blue = int.Parse(b); } color = new BaseColor(red, green, blue); } else if ((value = attributes[ElementTags.COLOR]) != null) { color = Markup.DecodeColor(value); } if (fontname == null) { return(GetFont(null, encoding, embedded, size, style, color)); } return(GetFont(fontname, encoding, embedded, size, style, color)); } }
/// <summary> /// Constructs a Font-object. /// </summary> /// <param name="attributes">the attributes of a Font object</param> /// <returns>a Font object</returns> public virtual Font GetFont(Properties attributes) { string fontname = null; string encoding = defaultEncoding; bool embedded = defaultEmbedding; float size = Font.UNDEFINED; int style = Font.NORMAL; Color color = null; string value = attributes[Markup.HTML_ATTR_STYLE]; if (value != null && value.Length > 0) { Properties styleAttributes = Markup.ParseAttributes(value); if (styleAttributes.Count == 0) { attributes.Add(Markup.HTML_ATTR_STYLE, value); } else { fontname = styleAttributes[Markup.CSS_KEY_FONTFAMILY]; if (fontname != null) { string tmp; while (fontname.IndexOf(',') != -1) { tmp = fontname.Substring(0, fontname.IndexOf(',')); if (IsRegistered(tmp)) { fontname = tmp; } else { fontname = fontname.Substring(fontname.IndexOf(',') + 1); } } } if ((value = styleAttributes[Markup.CSS_KEY_FONTSIZE]) != null) { size = Markup.ParseLength(value); } if ((value = styleAttributes[Markup.CSS_KEY_FONTWEIGHT]) != null) { style |= Font.GetStyleValue(value); } if ((value = styleAttributes[Markup.CSS_KEY_FONTSTYLE]) != null) { style |= Font.GetStyleValue(value); } if ((value = styleAttributes[Markup.CSS_KEY_COLOR]) != null) { color = Markup.DecodeColor(value); } attributes.AddAll(styleAttributes); } } if ((value = attributes[ElementTags.ENCODING]) != null) { encoding = value; } if ("true".Equals(attributes[ElementTags.EMBEDDED])) { embedded = true; } if ((value = attributes[ElementTags.FONT]) != null) { fontname = value; } if ((value = attributes[ElementTags.SIZE]) != null) { size = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo); } if ((value = attributes[Markup.HTML_ATTR_STYLE]) != null) { style |= Font.GetStyleValue(value); } if ((value = attributes[ElementTags.STYLE]) != null) { style |= Font.GetStyleValue(value); } string r = attributes[ElementTags.RED]; string g = attributes[ElementTags.GREEN]; string b = attributes[ElementTags.BLUE]; if (r != null || g != null || b != null) { int red = 0; int green = 0; int blue = 0; if (r != null) { red = int.Parse(r); } if (g != null) { green = int.Parse(g); } if (b != null) { blue = int.Parse(b); } color = new Color(red, green, blue); } else if ((value = attributes[ElementTags.COLOR]) != null) { color = Markup.DecodeColor(value); } if (fontname == null) { return(GetFont(null, encoding, embedded, size, style, color)); } return(GetFont(fontname, encoding, embedded, size, style, color)); }
public GroupContent AddProperties(Dictionary <string, string> properties) { Properties.AddAll(properties); return(this); }
/// <summary> /// Constructs a Font-object. /// </summary> /// <param name="attributes">the attributes of a Font object</param> /// <returns>a Font object</returns> public static Font getFont(Properties attributes) { string fontname = null; string encoding = defaultEncoding; bool embedded = defaultEmbedding; float size = Font.UNDEFINED; int style = Font.NORMAL; Color color = null; string value = attributes.Remove(MarkupTags.STYLE); if (value != null && value.Length > 0) { Properties styleAttributes = MarkupParser.parseAttributes(value); if (styleAttributes.Count == 0) { attributes.Add(MarkupTags.STYLE, value); } else { fontname = (string)styleAttributes.Remove(MarkupTags.CSS_FONTFAMILY); if (fontname != null) { string tmp; while (fontname.IndexOf(",") != -1) { tmp = fontname.Substring(0, fontname.IndexOf(",")); if (isRegistered(tmp)) { fontname = tmp; } else { fontname = fontname.Substring(fontname.IndexOf(",") + 1); } } } if ((value = (string)styleAttributes.Remove(MarkupTags.CSS_FONTSIZE)) != null) { size = MarkupParser.parseLength(value); } if ((value = (string)styleAttributes.Remove(MarkupTags.CSS_FONTWEIGHT)) != null) { style |= Font.getStyleValue(value); } if ((value = (string)styleAttributes.Remove(MarkupTags.CSS_FONTSTYLE)) != null) { style |= Font.getStyleValue(value); } if ((value = (string)styleAttributes.Remove(MarkupTags.CSS_COLOR)) != null) { color = MarkupParser.decodeColor(value); } attributes.AddAll(styleAttributes); } } if ((value = attributes.Remove(ElementTags.ENCODING)) != null) { encoding = value; } if ("false".Equals(attributes.Remove(ElementTags.EMBEDDED))) { embedded = false; } if ((value = attributes.Remove(ElementTags.FONT)) != null) { fontname = value; } if ((value = attributes.Remove(ElementTags.SIZE)) != null) { size = float.Parse(value); } if ((value = attributes.Remove(MarkupTags.STYLE)) != null) { style |= Font.getStyleValue(value); } if ((value = attributes.Remove(ElementTags.STYLE)) != null) { style |= Font.getStyleValue(value); } string r = attributes.Remove(ElementTags.RED); string g = attributes.Remove(ElementTags.GREEN); string b = attributes.Remove(ElementTags.BLUE); if (r != null || g != null || b != null) { int red = 0; int green = 0; int blue = 0; if (r != null) { red = int.Parse(r); } if (g != null) { green = int.Parse(g); } if (b != null) { blue = int.Parse(b); } color = new Color(red, green, blue); } else if ((value = attributes.Remove(ElementTags.COLOR)) != null) { color = MarkupParser.decodeColor(value); } if (fontname == null) { return(getFont(null, encoding, embedded, size, style, color)); } return(getFont(fontname, encoding, embedded, size, style, color)); }