Esempio n. 1
0
        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");
        }
Esempio n. 2
0
 private string FindStyleName()
 {
     string styleName = _precedeClassAttrib.ClassName + _tagType + _classNameWithLang + Common.SepParent + StackPeek(_allStyle);
     string newStyleName;
     if (_childStyle.ContainsKey(styleName)) // note: Child Style already created
     {
         newStyleName = _childStyle[styleName];
         _psuedoBeforeStyle = _existingPsuedoBeforeStyle[styleName];
         _psuedoAfterStyle = _existingPsuedoAfterStyle[styleName];
         _psuedoContainsStyle = _existingPsuedoContainsStyle[styleName];
     }
     else
     {
         newStyleName = CreateStyle();
         _childStyle[styleName] = newStyleName;
         _existingPsuedoBeforeStyle[styleName] = _psuedoBeforeStyle;
         _existingPsuedoAfterStyle[styleName] = _psuedoAfterStyle;
         _existingPsuedoContainsStyle[styleName] = _psuedoContainsStyle;
         if (_lang.Length > 0)
             _languageStyleName[newStyleName] = _lang;
     }
     return newStyleName;
 }
Esempio n. 3
0
        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);
                _anchorTitleValue = _reader.GetAttribute("title") ?? string.Empty;
                _anchorStart = true;
            }
            else
            {
                if (_reader.Name == "title" || _reader.Name == "style") // skip the node
                {
                    _reader.Read();
                }
                else
                {
                    _tagType = "O";
                }
            }
            if (_tagType != "img")
                _allStyle.Push(_childName);
        }
Esempio n. 4
0
 protected void OpenXhtmlFile(string xhtmlFileWithPath)
 {
     _psuedoBeforeStyle = _psuedoAfterStyle = _psuedoContainsStyle = null;
 }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
        private ClassInfo SetClassInfo(string multiClass, ClassInfo cssClassInfo)
        {
            ClassInfo cssClassInfoTag;
            cssClassInfoTag = new ClassInfo();

            cssClassInfoTag.StyleName = cssClassInfo.StyleName;
            cssClassInfoTag.CoreClass.SetClassAttrib(multiClass, cssClassInfo.CoreClass.Attribute);
            cssClassInfoTag.Ancestor.SetClassAttrib(cssClassInfo.Ancestor.ClassName, cssClassInfo.Ancestor.Attribute);
            cssClassInfoTag.ParentPrecede.SetClassAttrib(cssClassInfo.ParentPrecede.ClassName, cssClassInfo.ParentPrecede.Attribute);
            cssClassInfoTag.Precede.SetClassAttrib(cssClassInfo.Precede.ClassName, cssClassInfo.Precede.Attribute);

            cssClassInfoTag.StyleName = cssClassInfo.StyleName;
            cssClassInfoTag.TagName = cssClassInfo.TagName;
            cssClassInfoTag.Content = cssClassInfo.Content;
            cssClassInfoTag.Contains = cssClassInfo.Contains;
            cssClassInfoTag.SpecificityWeightage = cssClassInfo.SpecificityWeightage;
            cssClassInfoTag.Pseudo = cssClassInfo.Pseudo;
            return cssClassInfoTag;
        }
Esempio n. 8
0
 private void ClassAndProperty(TreeNode tree)
 {
     string styleName = string.Empty;
     string tagName = string.Empty;
     string tagStyleName = string.Empty;
     _specificityWeightage = 0;
     ClassAttrib clsAttrib = new ClassAttrib();
     bool isAncestor = false;
     try
     {
         _classInfo = new ClassInfo();
         foreach (TreeNode node in tree.Nodes)
         {
             switch (node.Text)
             {
                 case "TAG":
                     _classInfo.Tag = ClassNode(node);
                     _classInfo.CoreClass.SetClassAttrib(string.Empty, _classInfo.Tag.Attribute);
                     _classInfo.TagName = Common.LeftString(_classInfo.Tag.ClassName,Common.SepAttrib); 
                     tagName = GetFirstChild(node) + Common.SepTag;
                     tagStyleName = _classInfo.Tag.ClassName;
                     tagStyleName = GetImageAttrib(tagStyleName);
                     _specificityWeightage += 1;
                     break;
                 case "CLASS":
                     if (isAncestor)
                     {
                         _classInfo.Ancestor = clsAttrib;
                         styleName = Common.SepAncestor + styleName;
                         isAncestor = false;
                     }
                     isAncestor = true;
                     clsAttrib = ClassNode(node);
                     string tagClassName = tagName + clsAttrib.ClassName;
                     styleName = tagClassName + styleName;
                     clsAttrib.ClassName = _baseClassName;
                     _specificityWeightage += 10;
                     break;
                 case "PARENTOF":
                     _classInfo.ParentPrecede = _classInfo.Precede;
                     _classInfo.Precede.Clear();
                     _classInfo.parent.Add(clsAttrib);
                     styleName = Common.SepParent + styleName;
                     isAncestor = false;
                     break;
                 case "PRECEDES":
                     _classInfo.Precede = clsAttrib;
                     styleName = Common.sepPrecede + styleName;
                     isAncestor = false;
                     break;
                 case "PSEUDO":
                     _classInfo.Pseudo = GetPseudo(node);
                     styleName = styleName + Common.SepPseudo + _classInfo.Pseudo;
                     break;
                 case "PROPERTY":
                     if (clsAttrib.ClassName == string.Empty) // tag (div,span,..)without className}
                     {
                         styleName = tagStyleName;
                     }
                     else
                     {
                         _classInfo.CoreClass = clsAttrib;
                     }
                     Property(node, styleName);
                     break;
             }
         }
         _classInfo.SpecificityWeightage = _specificityWeightage;
         _classInfo.StyleName = styleName;
         CssClassOrder.Add(_classInfo.CoreClass.ClassName);
         if (_baseClassName != null)
             SetSpecificityClass(_baseClassName,_classInfo);
     }
     catch (Exception ex)
     {
         Console.Write(ex.Message);
     }
 }
Esempio n. 9
0
        private void SetSpecificityClass(string baseClassName, ClassInfo classInfo)
        {

            if (!SpecificityClass.ContainsKey(baseClassName))
            {
                SpecificityClass[baseClassName] = new ArrayList();
                SpecificityClass[baseClassName].Add(classInfo);
            }
            else
            {
                int insertPos = 0;
                foreach (ClassInfo clsInfo in SpecificityClass[baseClassName])
                {
                    if (_specificityWeightage >= clsInfo.SpecificityWeightage)
                    {
                        break;
                    }
                    insertPos++;
                }
                SpecificityClass[baseClassName].Insert(insertPos, classInfo);
            }
        }
Esempio n. 10
0
        private string MatchCssStyle(float ancestorFontSize, string psuedo, ArrayList multiClassList)
        {
            bool resultTagClass, resultCoreClass, resultAncestor, resultParentPrecede, resultPrecede;

            _tempStyle           = new Dictionary <string, string>();
            _matchedCssStyleName = string.Empty;
            foreach (string multiClass in multiClassList)
            {
                ArrayList cssClassDetail = new ArrayList();
                if (_classFamily.ContainsKey(multiClass))
                {
                    cssClassDetail = _classFamily[multiClass];
                }
                AddTagProperty(cssClassDetail, multiClass);
                if (cssClassDetail == null)
                {
                    return(_matchedCssStyleName);
                }

                foreach (ClassInfo cssClassInfo in cssClassDetail)
                {
                    if (cssClassInfo.Pseudo == "footnote-call")
                    {
                        _footnoteMarkerClass = cssClassInfo;
                    }

                    if (cssClassInfo.Pseudo != psuedo)
                    {
                        continue;
                    }

                    if (cssClassInfo.StyleName.IndexOf(".-", System.StringComparison.Ordinal) > 0)
                    {
                        var xhtmlClassInfo = _allStyleInfo.ToArray();
                        var parentStyle    = Common.LeftString(cssClassInfo.StyleName, "..");
                        parentStyle = parentStyle.Replace(".-", "_");
                        if (parentStyle.IndexOf("_") == 0)
                        {
                            parentStyle = Common.LeftRemove(parentStyle, "_");
                        }
                        var clsNameList = parentStyle.Split('_').ToList();

                        string currClassname = Common.LeftString(clsNameList[0], "-");
                        if (currClassname == cssClassInfo.CoreClass.ClassName)
                        {
                            clsNameList.Remove(clsNameList[0]);
                        }

                        var currClsNameList = new ArrayList();

                        foreach (ClassInfo clsName in xhtmlClassInfo)
                        {
                            if (clsName.CoreClass.ClassName.IndexOf(' ') > 0)
                            {
                                string[] mulltiClass = clsName.CoreClass.ClassName.Split(' ');
                                currClsNameList.AddRange(mulltiClass);
                            }
                            else
                            {
                                currClsNameList.Add(clsName.CoreClass.ClassName);
                            }
                        }

                        //Consider only the list when is having greater than 2 classes
                        if (clsNameList.Count > 0 && clsNameList.Any(t => !currClsNameList.Contains(t)))
                        {
                            currClsNameList = new ArrayList();
                        }

                        if (currClsNameList.Count == 0)
                        {
                            continue;
                        }
                    }

                    resultCoreClass = CompareCoreClass(cssClassInfo.CoreClass, _xhtmlClassAttrib, multiClass);
                    resultTagClass  = true;
                    if (cssClassInfo.TagName != string.Empty)
                    {
                        if (cssClassInfo.TagName != _tagType)
                        {
                            resultTagClass = false;
                        }
                    }

                    resultAncestor      = CompareClass(cssClassInfo.Ancestor);
                    resultParentPrecede = CompareClass(cssClassInfo.ParentPrecede, _parentPrecedeClassAttrib);
                    resultPrecede       = CompareClass(cssClassInfo.Precede, _precedeClassAttrib);

                    if (resultCoreClass && resultTagClass && resultAncestor && resultParentPrecede &&
                        resultPrecede)
                    {
                        AssignProperty(cssClassInfo.StyleName, ancestorFontSize);
                        if (_matchedCssStyleName == string.Empty)
                        {
                            _matchedCssStyleName = cssClassInfo.StyleName;
                            if (psuedo == "before")
                            {
                                _psuedoBeforeStyle = SetClassInfo(cssClassInfo.CoreClass.ClassName, cssClassInfo);
                            }
                            else if (psuedo == "after")
                            {
                                _psuedoAfterStyle = SetClassInfo(cssClassInfo.CoreClass.ClassName, cssClassInfo);
                            }
                            else if (psuedo == "contains")
                            {
                                _psuedoContainsStyle = SetClassInfo(cssClassInfo.CoreClass.ClassName, cssClassInfo);
                            }
                        }
                    }
                }
            }
            if (_outputType != Common.OutputType.ODT)
            {
                AppendParentProperty();
            }

            if (_outputType != Common.OutputType.XETEX || _outputType != Common.OutputType.XELATEX)
            {
                _matchedCssStyleName.Replace(Common.sepPrecede, "");
                _matchedCssStyleName.Replace(Common.SepParent, "");
                _matchedCssStyleName.Replace(Common.SepPseudo, "");
                _matchedCssStyleName.Replace(Common.SepTag, "");
                _matchedCssStyleName.Replace(Common.SepAttrib, "");
                _matchedCssStyleName.Replace(Common.Space, "");
            }
            return(_matchedCssStyleName);
        }
Esempio n. 11
0
 private void Page(TreeNode tree)
 {
     StyleAttribute _attributeInfo = new StyleAttribute();
     string pageName = "@page";
     string pseudoName = "@page";
     string regionName;
     try
     {
         _classInfo = new ClassInfo();
         foreach (TreeNode node in tree.Nodes)
         {
             switch (node.Text)
             {
                 case "PSEUDO":
                     pseudoName = pageName + ":" + node.FirstNode.Text;
                     break;
                 case "REGION":
                     regionName = pseudoName + "-" + node.FirstNode.Text;
                     foreach (TreeNode property in node.Nodes)
                     {
                         if (property.Text == "PROPERTY")
                         {
                             Property(property, regionName);
                         }
                     } 
                     break;
                 case "PROPERTY":
                     Property(node, pseudoName);
                     break;
                 default:
                     break;
             }
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex.Message);
     }
 }
Esempio n. 12
0
        private string CreateStyle()
        {
            _parentClassAttrib        = GetParent();
            _parentPrecedeClassAttrib = GetParentPrecede();
            ArrayList multiClassList = MultiClassCombination(_className);

            //float ancestorFontSize = FindAncestorFontSize();
            float ancestorFontSize = 12.00F;

            _parentStyleName = StackPeek(_allStyle);

            string styleName = MatchCssStyle(ancestorFontSize, "null", multiClassList);

            if (styleName == string.Empty) // missing style in CSS
            {
                styleName = _className;
                if (_outputType == Common.OutputType.ODT)
                {
                    if (_lang.Length > 0)
                    {
                        styleName = _className + Common.SepAttrib + _lang;
                    }
                }
            }
            string newStyleName = GetStyleNumber(styleName);

            if (_newProperty.ContainsKey(newStyleName) == false)
            {
                _newProperty[newStyleName] = _tempStyle;
            }

            IdAllClass[newStyleName] = _tempStyle;
            string tagType = _tagType;

            if (_divType.Contains(_tagType))
            {
                tagType = "div";
            }
            ParentClass[newStyleName] = _parentStyleName + "|" + tagType;

            _psuedoBeforeStyle = _psuedoAfterStyle = _psuedoContainsStyle = null;
            string styleBefore = MatchCssStyle(ancestorFontSize, "before", multiClassList);

            if (styleBefore != string.Empty)
            {
                string tag            = "span"; //  always character styles
                string newStyleBefore = GetStyleNumber(styleBefore);
                _newProperty[newStyleBefore] = _tempStyle;
                IdAllClass[newStyleBefore]   = _tempStyle;
                _psuedoBeforeStyle.StyleName = newStyleBefore;
                ParentClass[newStyleBefore]  = _parentStyleName + "|" + tag;
            }

            string styleAfter = MatchCssStyle(ancestorFontSize, "after", multiClassList);

            if (styleAfter != string.Empty)
            {
                string tag           = "span"; //  always character styles
                string newStyleAfter = GetStyleNumber(styleAfter);
                _newProperty[newStyleAfter] = _tempStyle;
                IdAllClass[newStyleAfter]   = _tempStyle;
                _psuedoAfterStyle.StyleName = newStyleAfter;
                ParentClass[newStyleAfter]  = _parentStyleName + "|" + tag;
            }

            string styleContains = MatchCssStyle(ancestorFontSize, "contains", multiClassList);

            if (styleContains != string.Empty)
            {
                string newStyleContains = GetStyleNumber(styleContains);
                _newProperty[newStyleContains] = _tempStyle;
                IdAllClass[newStyleContains]   = _tempStyle;
                _psuedoContainsStyle.StyleName = newStyleContains;
                ParentClass[newStyleContains]  = _parentStyleName + "|" + _tagType;
            }

            return(newStyleName);
        }
Esempio n. 13
0
        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);
            }
        }
Esempio n. 14
0
 protected void OpenXhtmlFile(string xhtmlFileWithPath)
 {
     _psuedoBeforeStyle = _psuedoAfterStyle = _psuedoContainsStyle = null;
     _reader            = Common.DeclareXmlTextReader(xhtmlFileWithPath, true);
 }
Esempio n. 15
0
        private string CreateStyle()
        {
            _parentPrecedeClassAttrib = GetParentPrecede();
            ArrayList multiClassList = MultiClassCombination(_className);

            float ancestorFontSize = FindAncestorFontSize();
            _parentStyleName = StackPeek(_allStyle);

            string styleName = MatchCssStyle(ancestorFontSize, "null", multiClassList);
            if (styleName == string.Empty) // missing style in CSS
            {
                styleName = _className;
                if (_outputType == Common.OutputType.ODT || _outputType == Common.OutputType.XELATEX)
                {
                    if (_lang.Length > 0)
                        styleName = _className + Common.SepAttrib + _lang;
                }

            }
            else
            {
                if (_outputType == Common.OutputType.XELATEX)
                {
                    if (_lang.Length > 0)
                        styleName = _className + Common.SepAttrib + _lang;
                }
            }
            string newStyleName = GetStyleNumber(styleName);

            if (_newProperty.ContainsKey(newStyleName) == false)
            {
                _newProperty[newStyleName] = _tempStyle;
            }

            IdAllClass[newStyleName] = _tempStyle;
            string tagType = _tagType;
            if (_divType.Contains(_tagType)) tagType = "div";
            ParentClass[newStyleName] = _parentStyleName + "|" + tagType;

            _psuedoBeforeStyle = _psuedoAfterStyle = _psuedoContainsStyle = null;
            string styleBefore = MatchCssStyle(ancestorFontSize, "before", multiClassList);
            if (styleBefore != string.Empty)
            {
                string tag = "span"; //  always character styles
                string newStyleBefore = GetStyleNumber(styleBefore);
                _newProperty[newStyleBefore] = _tempStyle;
                IdAllClass[newStyleBefore] = _tempStyle;
                _psuedoBeforeStyle.StyleName = newStyleBefore;
                ParentClass[newStyleBefore] = _parentStyleName + "|" + tag;

            }

            string styleAfter = MatchCssStyle(ancestorFontSize, "after", multiClassList);
            if (styleAfter != string.Empty)
            {
                string tag = "span"; //  always character styles
                string newStyleAfter = GetStyleNumber(styleAfter);
                _newProperty[newStyleAfter] = _tempStyle;
                IdAllClass[newStyleAfter] = _tempStyle;
                _psuedoAfterStyle.StyleName = newStyleAfter;
                ParentClass[newStyleAfter] = _parentStyleName + "|" + tag;
            }

            string styleContains = MatchCssStyle(ancestorFontSize, "contains", multiClassList);
            if (styleContains != string.Empty)
            {
                string newStyleContains = GetStyleNumber(styleContains);
                _newProperty[newStyleContains] = _tempStyle;
                IdAllClass[newStyleContains] = _tempStyle;
                _psuedoContainsStyle.StyleName = newStyleContains;
                ParentClass[newStyleContains] = _parentStyleName + "|" + _tagType;
            }

            return newStyleName;
        }
Esempio n. 16
0
        private void SetDefaultTagProperty()
        {
            Dictionary<string, Dictionary<string, string>> defaultTagProperty =
                new Dictionary<string, Dictionary<string, string>>();
            Dictionary<string, string> propertyName;

            //h1 to h6
            propertyName = new Dictionary<string, string>();
            propertyName["font-weight"] = "bold";
            propertyName["padding-top"] = "12";
            propertyName["font-size"] = "24";
            defaultTagProperty["h1"] = propertyName;

            propertyName = new Dictionary<string, string>();
            propertyName["font-weight"] = "bold";
            propertyName["padding-top"] = "8";
            propertyName["font-size"] = "18";
            defaultTagProperty["h2"] = propertyName;

            propertyName = new Dictionary<string, string>();
            propertyName["font-weight"] = "bold";
            propertyName["padding-top"] = "7";
            propertyName["font-size"] = "14";
            defaultTagProperty["h3"] = propertyName;

            propertyName = new Dictionary<string, string>();
            propertyName["font-weight"] = "bold";
            propertyName["padding-top"] = "6";
            propertyName["font-size"] = "12";
            defaultTagProperty["h4"] = propertyName;

            propertyName = new Dictionary<string, string>();
            propertyName["font-weight"] = "bold";
            propertyName["padding-top"] = "5.5";
            propertyName["font-size"] = "10";
            defaultTagProperty["h5"] = propertyName;

            propertyName = new Dictionary<string, string>();
            propertyName["font-weight"] = "bold";
            propertyName["padding-top"] = "5.5";
            propertyName["font-size"] = "8";
            defaultTagProperty["h6"] = propertyName;

            //para
            propertyName = new Dictionary<string, string>();
            if (OutputType == Common.OutputType.ODT)
            {
                propertyName["margin-top"] = "6";
                propertyName["margin-bottom"] = "6";
            }
            else
            {
                propertyName["padding-top"] = "12";
                propertyName["padding-bottom"] = "12";
            }
            defaultTagProperty["p"] = propertyName;


            foreach (KeyValuePair<string, Dictionary<string, string>> pair in defaultTagProperty)
            {
                if (!_cssClass.ContainsKey(pair.Key)) // h1
                {
                    _cssClass[pair.Key] = defaultTagProperty[pair.Key];
                    //for Specificity
                    _classInfo = new ClassInfo();
                    _classInfo.Tag.SetClassAttrib(pair.Key, _classInfo.Tag.Attribute);
                    _classInfo.CoreClass.SetClassAttrib(string.Empty, _classInfo.Tag.Attribute);
                    _classInfo.TagName = _classInfo.Tag.ClassName; 
                    _classInfo.SpecificityWeightage = 1;
                    _classInfo.StyleName = pair.Key;
                    SetSpecificityClass(pair.Key, _classInfo);

                }
                else
                {
                    foreach (KeyValuePair<string, string> property in pair.Value)
                    {
                        if (!_cssClass[pair.Key].ContainsKey(property.Key))
                        {
                            _cssClass[pair.Key][property.Key] = property.Value;
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        private string MatchCssStyle(float ancestorFontSize, string psuedo, ArrayList multiClassList)
        {
            bool resultTagClass, resultCoreClass, resultAncestor, resultParent, resultParentPrecede, resultPrecede;
            _tempStyle = new Dictionary<string, string>();
            _matchedCssStyleName = string.Empty;
            foreach (string multiClass in multiClassList)
            {
                ArrayList cssClassDetail = new ArrayList();
                if (_classFamily.ContainsKey(multiClass))
                {
                    cssClassDetail = _classFamily[multiClass];
                }
                AddTagProperty(cssClassDetail, multiClass);
                if (cssClassDetail == null) return _matchedCssStyleName;

                foreach (ClassInfo cssClassInfo in cssClassDetail)
                {
                    if (cssClassInfo.Pseudo == "footnote-call")
                        _footnoteMarkerClass = cssClassInfo;

                    if (cssClassInfo.Pseudo != psuedo) continue;

                    resultCoreClass = CompareCoreClass(cssClassInfo.CoreClass, _xhtmlClassAttrib, multiClass);
                    resultTagClass = true;
                    if (cssClassInfo.TagName != string.Empty)
                    {
                        if (cssClassInfo.TagName != _tagType)
                        {
                            resultTagClass = false;
                        }
                    }

                    resultAncestor = CompareClass(cssClassInfo.Ancestor);
                    resultParent = CompareParentClass(cssClassInfo.parent);
                    resultParentPrecede = CompareClass(cssClassInfo.ParentPrecede, _parentPrecedeClassAttrib);
                    resultPrecede = CompareClass(cssClassInfo.Precede, _precedeClassAttrib);

                    if (resultCoreClass && resultTagClass && resultAncestor && resultParent && resultParentPrecede &&
                        resultPrecede)
                    {
                        AssignProperty(cssClassInfo.StyleName, ancestorFontSize);
                        if (_matchedCssStyleName == string.Empty)
                        {
                            _matchedCssStyleName = cssClassInfo.StyleName;
                            if (psuedo == "before")
                            {
                                _psuedoBeforeStyle = SetClassInfo(cssClassInfo.CoreClass.ClassName, cssClassInfo);
                            }
                            else if (psuedo == "after")
                            {
                                _psuedoAfterStyle = SetClassInfo(cssClassInfo.CoreClass.ClassName, cssClassInfo);
                            }
                            else if (psuedo == "contains")
                            {
                                _psuedoContainsStyle = SetClassInfo(cssClassInfo.CoreClass.ClassName, cssClassInfo);
                            }
                        }
                    }
                }
            }
            if (_outputType != Common.OutputType.ODT)
            {
                AppendParentProperty();
            }
            if (_outputType != Common.OutputType.XETEX || _outputType != Common.OutputType.XELATEX)
            {
                _matchedCssStyleName.Replace(Common.sepPrecede, "");
                _matchedCssStyleName.Replace(Common.SepParent, "");
                _matchedCssStyleName.Replace(Common.SepPseudo, "");
                _matchedCssStyleName.Replace(Common.SepTag, "");
                _matchedCssStyleName.Replace(Common.SepAttrib, "");
                _matchedCssStyleName.Replace(Common.Space, "");

            }
            return _matchedCssStyleName;
        }
 protected void OpenXhtmlFile(string xhtmlFileWithPath)
 {
     _psuedoBeforeStyle = _psuedoAfterStyle = _psuedoContainsStyle = null;
     _reader = Common.DeclareXmlTextReader(xhtmlFileWithPath, true);
 }