public void SetClassAttrib() { _classAttrib = new ClassAttrib(); string className = "testa"; ArrayList attribute = new ArrayList(); attribute.Add("eng"); attribute.Add("US1"); _classAttrib.SetClassAttrib(className, attribute); Assert.AreEqual(className, _classAttrib.ClassName, "SetClassAttrib test Failed"); Assert.AreEqual(attribute, _classAttrib.Attribute, "SetClassAttrib test Failed"); }
protected ClassAttrib GetParentPrecede() { ClassAttrib result = new ClassAttrib(); if (_allStyleInfo != null && _allStyleInfo.Count > 0) { ClassInfo classInfo = new ClassInfo(); classInfo = _allStyleInfo.Peek(); result.SetClassAttrib(classInfo.Precede.ClassName, classInfo.Precede.Attribute); } return(result); }
protected ClassAttrib GetPreced() { ClassAttrib result = new ClassAttrib(); if (_allStyleInfo != null && _allStyleInfo.Count > 0) { ClassInfo result1 = new ClassInfo(); result1 = _allStyleInfo.Pop(); result.SetClassAttrib(result1.CoreClass.ClassName, result1.CoreClass.Attribute); } return(result); }
public new void Precede() { _classInfo = new ClassInfo(); ClassAttrib _expectedClassAttrib = new ClassAttrib(); ClassAttrib _outputClassAttrib = new ClassAttrib(); string className = "testa"; ArrayList attribute = new ArrayList(); attribute.Add("eng"); attribute.Add("US1"); _expectedClassAttrib.SetClassAttrib(className, attribute); _classInfo.Precede = _expectedClassAttrib; _outputClassAttrib = _classInfo.Precede; Assert.AreEqual(_outputClassAttrib.ClassName, _expectedClassAttrib.ClassName, "CoreClass test Failed"); Assert.AreEqual(_outputClassAttrib.Attribute, _expectedClassAttrib.Attribute, "CoreClass test Failed"); }
protected ClassAttrib GetParentPrecede() { ClassAttrib result = new ClassAttrib(); if (_allStyleInfo != null && _allStyleInfo.Count > 0) { ClassInfo classInfo = new ClassInfo(); classInfo = _allStyleInfo.Peek(); result.SetClassAttrib(classInfo.Precede.ClassName, classInfo.Precede.Attribute); } return result; }
protected ClassAttrib GetPreced() { ClassAttrib result = new ClassAttrib(); if (_allStyleInfo != null && _allStyleInfo.Count > 0) { ClassInfo result1 = new ClassInfo(); result1 = _allStyleInfo.Pop(); result.SetClassAttrib(result1.CoreClass.ClassName, result1.CoreClass.Attribute); } return result; }
private ClassAttrib ClassNode(TreeNode classNode) { ClassAttrib clsAtt = new ClassAttrib(); ArrayList clsAttrib = new ArrayList(); ClassAttribute classAttribute; ArrayList classCollection = new ArrayList(); string className = GetFirstChild(classNode); if (OutputType == Common.OutputType.XELATEX) { className = Common.ReplaceCSSClassName(className); } _baseClassName = className; foreach (TreeNode node in classNode.Nodes) { if (node.Text == "ATTRIB") { classAttribute = GetAttribValue(node); classCollection.Add(classAttribute); } } foreach (ClassAttribute classAttrib in classCollection) { if (string.Compare(classAttrib.AttributeSeperator, "HASVALUE") == 0) { if (OutputType != Common.OutputType.EPUB) { classAttrib.AttributeValue = classAttrib.AttributeValue.Replace("-", ""); classAttrib.AttributeValue = classAttrib.AttributeValue.Replace("_", ""); } className = className + Common.SepAncestor + classAttrib.AttributeValue; _baseClassName = _baseClassName + Common.Space + classAttrib.AttributeValue; _baseClassName = Common.SortMutiClass(_baseClassName); _specificityWeightage += 10; } else if (string.Compare(classAttrib.AttributeSeperator, "ATTRIBEQUAL") == 0) { string attribute; classAttrib.AttributeValue = classAttrib.AttributeValue.Replace("\"", ""); if (classAttrib.Name == "lang") { attribute = classAttrib.AttributeValue; // remove string "lang" } else if (classAttrib.Name == "src") { attribute = "src"; className = classAttrib.AttributeValue; } else { attribute = classAttrib.Name + classAttrib.AttributeValue; } className = className + Common.SepAttrib + attribute; clsAttrib.Add(attribute); _specificityWeightage += 10; } else if (classAttrib.AttributeSeperator.Length == 0) { className = className + Common.SepAttrib + classAttrib.Name; clsAttrib.Add(classAttrib.Name); _specificityWeightage += 10; } } clsAtt.SetClassAttrib(className, clsAttrib); return clsAtt; }
protected void StartElementBase(bool isHeadword) { string[] divTypeList = new[] { "div", "ol", "ul", "li", "p", "body", "h1", "h2", "h3", "h4", "h5", "h6", "table", "tr", "td", "th" }; _divType = new List <string>(divTypeList); ClassInfo classInfo = new ClassInfo(); _classNameWithLang = GetTagInfo(); if (_outputType == Common.OutputType.XELATEX) { _classNameWithLang = Common.ReplaceCSSClassName(_classNameWithLang); } _xhtmlClassAttrib.SetClassAttrib(_className, _xhtmlAttribute); classInfo.CoreClass = _xhtmlClassAttrib; classInfo.Precede = _precedeClassAttrib; BlockInline(); _childName = FindStyleName(); GetHeadwordStyles(isHeadword); _allStyleInfo.Push(classInfo); if (_divType.Contains(_tagType)) { _paragraphName = _childName; _allParagraph.Push(_paragraphName); _isNewParagraph = true; if (_tagType == "ol" || _tagType == "ul") { } else if (_tagType == "li") { } CreateSectionClass(_paragraphName); } else if (_tagType == "span" || _tagType == "em") { _characterName = _childName; _allCharacter.Push(_characterName); } else if (_tagType == "img") { _imageSource = _reader.GetAttribute("src") ?? string.Empty; _imageSource = _imageSource.ToLower(); _imageLongDesc = _reader.GetAttribute("longdesc") ?? string.Empty; _imageLongDesc = _imageLongDesc.ToLower(); _imageAltText = _reader.GetAttribute("alt") ?? string.Empty; _imageInsert = true; _imageClass = StackPeek(_allStyle); _imageSrcClass = _className; } else if (_tagType == "a") { _anchorBookMarkName = Common.RightString(_classNameWithLang, Common.SepTag); _anchorStart = true; } else { if (_reader.Name == "title" || _reader.Name == "style") // skip the node { _reader.Read(); } else { _tagType = "O"; } } if (_tagType != "img") { _allStyle.Push(_childName); } }