Beispiel #1
0
        /// -------------------------------------------------------------------------------------------
        /// <summary>
        /// For include space between seperators - BorderMethod1 bottom
        ///
        /// <list>
        /// </list>
        /// </summary>
        /// <param name="attribute">attribute value like border-bottom: .5pt solid #a00</param>
        /// <returns>".5pt solid #a00 </returns>
        /// -------------------------------------------------------------------------------------------
        private void BorderMethod1(StyleAttribute attribute)
        {
            string    borderStyle     = null;
            string    borderWidth     = null;
            string    borderColor     = null;
            ArrayList borderStyleList = CreateBorderStyleList();

            try
            {
                string[] value = attribute.StringValue.Split(',');

                for (int i = 0; i < value.Length; i++)
                {
                    if (borderStyleList.Contains(value[i]))
                    {
                        borderStyle = value[i];
                    }
                    else if (_unit.Contains(value[i]))
                    {
                        if (i - 1 >= 0)
                        {
                            string val  = value[i - 1];
                            string unit = value[i];
                            borderWidth = Common.UnitConverter(val + unit);
                        }
                    }
                    else if (value[i].IndexOf('#') >= 0)  // #f00 conversion to #ff0000
                    {
                        borderColor = ColorHash(value[i]);
                        GetBorderColorList(borderColor);
                    }
                    else if (_dicColorInfo.ContainsKey(value[i])) // red conversion to #ff0000
                    {
                        borderColor = _dicColorInfo[value[i]];
                    }

                    else if (value[i].ToLower().IndexOf("rgb") >= 0)  // rgb,(,255,0,0,) conversion to #ff0000
                    {
                        string rgbConcat = GetRgbConcat(i, value);
                        borderColor = ColorRGB(rgbConcat);
                    }
                }

                if (attribute.Name == "border")
                {
                    BorderAssign(attribute.Name + "-top", borderStyle, borderWidth, borderColor);
                    BorderAssign(attribute.Name + "-right", borderStyle, borderWidth, borderColor);
                    BorderAssign(attribute.Name + "-bottom", borderStyle, borderWidth, borderColor);
                    BorderAssign(attribute.Name + "-left", borderStyle, borderWidth, borderColor);
                }
                else
                {
                    BorderAssign(attribute.Name, borderStyle, borderWidth, borderColor);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #2
0
        public ArrayList GetPropertyValue(StyleAttribute styleAttributeInfo)
        {
            var ParamList = new ArrayList();

            string[] parameters = styleAttributeInfo.StringValue.Split(',');
            int      length     = parameters.Length;

            for (int i = 0; i < length; i++)
            {
                string value = parameters[i];
                if (!Common.ValidateNumber(value))
                {
                    continue;
                }
                string unit = "pt";
                if (i < length - 1)
                {
                    string nextVal = parameters[i + 1];
                    if (_unit.Contains(nextVal))
                    {
                        unit = nextVal;
                        i++;
                    }
                }
                ParamList.Add(Common.UnitConverter(value + unit));
            }
            return(ParamList);
        }
Beispiel #3
0
        /// -------------------------------------------------------------------------------------------
        /// <summary>
        /// Map _attributeInfo to MapPropertys.cs
        ///
        /// <list>
        /// </list>
        /// </summary>
        /// <param name="styleAttributeInfo">StyleAttribute styleAttributeInfo</param>
        /// <returns>StyleAttribute _attributeInfo</returns>
        /// -------------------------------------------------------------------------------------------
        ///
        private void AddProperty(StyleAttribute styleAttributeInfo)
        {
            try
            {
                if (!_cssClass.ContainsKey(styleAttributeInfo.ClassName))
                {
                    _cssProperty = new Dictionary <string, string>();
                    _cssClass[styleAttributeInfo.ClassName] = _cssProperty;
                }
                else
                {
                    _cssProperty = _cssClass[styleAttributeInfo.ClassName];
                }

                Dictionary <string, string> getProperty = new Dictionary <string, string>();
                getProperty = _mapProperty.CreateProperty(styleAttributeInfo);

                foreach (var prop in getProperty)
                {
                    if (prop.Key != "prince-text-replace" && prop.Key != "font-feature-settings")
                    {
                        _cssProperty[prop.Key] = prop.Value.Replace("\"", "");
                    }
                    else
                    {
                        _cssProperty[prop.Key] = prop.Value;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _verboseWriter.WriteError(styleAttributeInfo.ClassName, styleAttributeInfo.Name, ex.Message, styleAttributeInfo.StringValue);
            }
        }
Beispiel #4
0
        private void ValidateLineHeight(StyleAttribute styleAttributeInfo)
        {
            if (styleAttributeInfo.StringValue.ToLower() == "inherit")
            {
                return;
            }
            string attrValue = DeleteSeperator(styleAttributeInfo.StringValue);

            if (styleAttributeInfo.StringValue.ToLower() == "none" || styleAttributeInfo.StringValue.ToLower() == "normal")
            {
                attrValue = "100%";
            }
            else if (styleAttributeInfo.StringValue.IndexOf(",") < 0)
            {
                int value = int.Parse(styleAttributeInfo.StringValue) * 100;
                attrValue = value.ToString() + "%";
            }

            if (_dictFontSize.ContainsKey(attrValue))
            {
                attrValue = _dictFontSize[attrValue];
            }
            else
            {
                attrValue = Common.UnitConverter(attrValue);
            }
            _cssProperty[styleAttributeInfo.Name] = attrValue;
        }
Beispiel #5
0
 protected void SetUp()
 {
     _isLinux = Common.IsUnixOS();
     _input = new StyleAttribute();
     _makeProperty = new MakeProperty();
     _expected = new Dictionary<string, string>();
     _position = new[] { "top", "right", "bottom", "left" };
 }
Beispiel #6
0
        private void TextAlign(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "left" || attrValue == "right" || attrValue == "center" || attrValue == "justify" || attrValue == "inherit")
            {
                _cssProperty["text-align"] = attrValue;
            }
        }
Beispiel #7
0
        private void FontVariant(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "normal" || attrValue == "small-caps" || attrValue == "inherit")
            {
                _cssProperty["font-variant"] = attrValue;
            }
        }
Beispiel #8
0
        private void FontStyle(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "normal" || attrValue == "italic")
            {
                _cssProperty["font-style"] = attrValue;
            }
        }
Beispiel #9
0
        /// -------------------------------------------------------------------------------------------
        /// <summary>
        /// Margin and Padding Values
        ///
        /// <list>
        /// </list>
        /// </summary>
        /// <param name="styleAttributeInfo">margin: 1cm 2cm 3cm 4cm</param>
        /// <returns>margin-top:1cm , margin-right:2cm, margin-bottom:3cm, margin-left:4cm </returns>
        /// -------------------------------------------------------------------------------------------

        private void Margin(StyleAttribute styleAttributeInfo)
        {
            string keyWord = styleAttributeInfo.Name;
            string top     = keyWord + "-top";
            string right   = keyWord + "-right";
            string bottom  = keyWord + "-bottom";
            string left    = keyWord + "-left";

            SetPropertyDimension(styleAttributeInfo, top, right, bottom, left);
        }
Beispiel #10
0
 static private void CreateFullyQualifiedClassName(StyleAttribute _attributeInfo)
 {
     if (_attributeInfo.ClassName.IndexOf("@page") == -1)
     {
         if (_attributeInfo.Name == "margin-left" || _attributeInfo.Name == "margin-right" ||
             _attributeInfo.Name == "margin-top" || _attributeInfo.Name == "margin-bottom" || _attributeInfo.Name == "margin")
         {
             _attributeInfo.Name = "class-" + _attributeInfo.Name;
         }
     }
 }
Beispiel #11
0
        private void FontFamily(StyleAttribute styleAttributeInfo)
        {
            string[] font       = styleAttributeInfo.StringValue.Split(',');
            int      fontLength = font.Length;

            if (fontLength == 0 || styleAttributeInfo.StringValueLower == "inherit")
            {
                return;
            }

            string fontName; // Gentium

            FontFamily[] systemFontList = System.Drawing.FontFamily.Families;
            for (int counter = 0; counter < fontLength; counter++)
            {
                fontName = font[counter].Replace("\"", "").Trim();
                fontName = fontName.Replace("'", "");
                foreach (FontFamily systemFont in systemFontList)
                {
                    if (fontName.ToLower() == systemFont.Name.ToLower())
                    {
                        _cssProperty[styleAttributeInfo.Name] = fontName;
                        return;
                    }
                }
            }
            ArrayList genericFamilyList = new ArrayList(new[] { "serif", "sans-serif", "cursive", "fantasy", "monospace" });

            fontName = font[0];
            for (int i = 0; i < fontLength; i++)
            {
                fontName = font[i].Replace("<", "");
                fontName = fontName.Replace(">", "");
                fontName = fontName.Replace("default", "").Trim();

                if (genericFamilyList.Contains(fontName.ToLower()))
                {
                    string xmlFileNameWithPath = Common.PathCombine(PsSupportPath, "GenericFont.xml");

                    string    xPath    = "//font-preference/generic-family [@name = \"" + fontName.ToLower() + "\"]";
                    ArrayList fontList = new ArrayList();
                    fontList = Common.GetXmlNodeList(xmlFileNameWithPath, xPath);
                    if (fontList.Count > 0)
                    {
                        fontName = fontList[0].ToString();
                        break;
                    }
                }
            }

            _cssProperty["font-family"] = fontName.Trim();
        }
Beispiel #12
0
        private void FontFeatureSettings(StyleAttribute styleAttributeInfo)
        {
            string fontFeatureProperyValue = styleAttributeInfo.StringValue;
            int    fontLength = fontFeatureProperyValue.Length;

            if (fontLength == 0 || styleAttributeInfo.StringValueLower == "inherit")
            {
                return;
            }

            _cssProperty[styleAttributeInfo.Name] = fontFeatureProperyValue;
            return;
        }
Beispiel #13
0
        private void TextDecoration(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "none" || attrValue == "underline" || attrValue == "inherit" || attrValue == "line-through")
            {
                _cssProperty["text-decoration"] = attrValue;
            }

            if (attrValue.ToLower() == "underline,double")
            {
                _cssProperty["text-decoration"] = "underlineunderline";
            }
        }
Beispiel #14
0
        private void FontWeight(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "normal" || attrValue == "100" || attrValue == "200" ||
                attrValue == "300" || attrValue == "400" || attrValue == "500" ||
                attrValue == "lighter")
            {
                _cssProperty["font-weight"] = "normal";
            }
            else if (attrValue == "bold" || attrValue == "600" || attrValue == "700" ||
                     attrValue == "800" || attrValue == "900" || attrValue == "bolder")
            {
                _cssProperty["font-weight"] = "bold";
            }
        }
Beispiel #15
0
        private void SetPropertyDimension(StyleAttribute styleAttributeInfo, string top, string right, string bottom, string left)
        {
            try
            {
                ArrayList propertyValues = GetPropertyValue(styleAttributeInfo);

                if (propertyValues.Count == 1)
                {
                    _cssProperty[top]    = propertyValues[0].ToString();
                    _cssProperty[right]  = propertyValues[0].ToString();
                    _cssProperty[bottom] = propertyValues[0].ToString();
                    _cssProperty[left]   = propertyValues[0].ToString();
                }
                else if (propertyValues.Count == 2)
                {
                    _cssProperty[top]    = propertyValues[0].ToString();
                    _cssProperty[right]  = propertyValues[1].ToString();
                    _cssProperty[bottom] = propertyValues[0].ToString();
                    _cssProperty[left]   = propertyValues[1].ToString();
                }
                else if (propertyValues.Count == 3)
                {
                    _cssProperty[top]    = propertyValues[0].ToString();
                    _cssProperty[right]  = propertyValues[1].ToString();
                    _cssProperty[bottom] = propertyValues[2].ToString();
                    _cssProperty[left]   = propertyValues[1].ToString();
                }
                else if (propertyValues.Count == 4)
                {
                    _cssProperty[top]    = propertyValues[0].ToString();
                    _cssProperty[right]  = propertyValues[1].ToString();
                    _cssProperty[bottom] = propertyValues[2].ToString();
                    _cssProperty[left]   = propertyValues[3].ToString();
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                _cssProperty[right]  = "0";
                _cssProperty[bottom] = "0";
                _cssProperty[left]   = "0";
                _cssProperty[top]    = "0";
                throw new Exception(ex.Message);
            }
        }
Beispiel #16
0
        private void Numeric(StyleAttribute styleAttributeInfo)
        {
            if (styleAttributeInfo.StringValue == "inherit")
            {
                return;
            }
            string attrValue = DeleteSeperator(styleAttributeInfo.StringValue);

            if (_dictFontSize.ContainsKey(attrValue))
            {
                attrValue = _dictFontSize[attrValue];
            }
            else
            {
                attrValue = Common.UnitConverter(attrValue);
            }
            _cssProperty[styleAttributeInfo.Name] = attrValue;
        }
Beispiel #17
0
        private void BorderMethod2(StyleAttribute styleAttributeInfo)
        {
            string propertyName  = styleAttributeInfo.Name;
            string propertyValue = styleAttributeInfo.StringValue;
            var    borderSide    = new[] { "border-top-", "border-right-", "border-bottom-", "border-left-" };

            switch (styleAttributeInfo.Name)
            {
            case "border-style":
                propertyName = "style";
                break;

            case "border-color":
                propertyName = "color";
                GetBorderColorList(styleAttributeInfo.StringValue);
                break;

            case "border-width":
                const string top    = "border-top-width";
                const string right  = "border-right-width";
                const string bottom = "border-bottom-width";
                const string left   = "border-left-width";
                SetPropertyDimension(styleAttributeInfo, top, right, bottom, left);
                propertyName = "";
                break;

            default:
                if (styleAttributeInfo.Name.IndexOf("width") > 0)
                {
                    propertyValue = propertyValue.Replace(",", "");
                }
                _cssProperty[propertyName] = propertyValue;
                propertyName = "";
                break;
            }

            if (propertyName.Length > 0)
            {
                for (int i = 0; i < borderSide.Length; i++)
                {
                    _cssProperty[borderSide[i] + propertyName] = propertyValue;
                }
            }
        }
Beispiel #18
0
 public string Color2Hash(StyleAttribute styleAttributeInfo)
 {
     if (styleAttributeInfo.StringValue.IndexOf("rgb") >= 0)
     {
         styleAttributeInfo.StringValue = ColorRGB(styleAttributeInfo.StringValue);
     }
     else if (styleAttributeInfo.StringValue.IndexOf("#") >= 0)
     {
         styleAttributeInfo.StringValue = ColorHash(styleAttributeInfo.StringValue);
     }
     else if (styleAttributeInfo.StringValue.IndexOf("cmyk") >= 0)
     {
         styleAttributeInfo.StringValue = ColorCMYK(styleAttributeInfo.StringValue);
         styleAttributeInfo.StringValue = ColorRGB(styleAttributeInfo.StringValue);
     }
     else if (_dicColorInfo.ContainsKey(styleAttributeInfo.StringValue.ToLower()))
     {
         styleAttributeInfo.StringValue = _dicColorInfo[styleAttributeInfo.StringValue.ToLower()];
     }
     return(styleAttributeInfo.StringValue);
 }
Beispiel #19
0
        private void Language(StyleAttribute styleAttributeInfo)
        {
            string[] languageCountrySplit = styleAttributeInfo.StringValue.Split('-');
            string   language             = languageCountrySplit[0];

            _cssProperty["language"] = language;

            string country;

            if (languageCountrySplit.Length > 1)
            {
                country = languageCountrySplit[1];
                _cssProperty["country"] = country;
            }
            else // find country for english language
            {
                if (language.ToLower() == "en")
                {
                    string[] langCountry = Application.CurrentCulture.IetfLanguageTag.Split('-');
                    country = langCountry[1];
                    _cssProperty["country"] = country;
                }
            }
        }
Beispiel #20
0
 private void Size(StyleAttribute styleAttributeInfo)
 {
     string[] parameters = styleAttributeInfo.StringValue.Split(',');
     _cssProperty["page-width"] = Math.Round(double.Parse(Common.UnitConverter(parameters[0] + parameters[1]), CultureInfo.GetCultureInfo("en-US")), 9).ToString(CultureInfo.GetCultureInfo("en-US"));
     _cssProperty["page-height"] = Math.Round(double.Parse(Common.UnitConverter(parameters[2] + parameters[3]), CultureInfo.GetCultureInfo("en-US")), 9).ToString(CultureInfo.GetCultureInfo("en-US"));
 }
Beispiel #21
0
        private void FontStyle(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "normal" || attrValue == "italic")
            {
                _cssProperty["font-style"] = attrValue;
            }
        }
Beispiel #22
0
        private void TextDecoration(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "none" || attrValue == "underline" || attrValue == "inherit")
            {
                _cssProperty["text-decoration"] = attrValue;
            }
        }
Beispiel #23
0
 private void FontSize(StyleAttribute styleAttributeInfo)
 {
     Numeric(styleAttributeInfo);
 }
Beispiel #24
0
        private void BorderMethod2(StyleAttribute styleAttributeInfo)
        {
            string propertyName = styleAttributeInfo.Name;
            string propertyValue = styleAttributeInfo.StringValue;
            var borderSide = new[] { "border-top-", "border-right-", "border-bottom-", "border-left-" };
            switch (styleAttributeInfo.Name)
            {
                case "border-style":
                    propertyName = "style";
                    break;
                case "border-color":
                    propertyName = "color";
                    GetBorderColorList(styleAttributeInfo.StringValue);
                    break;
                case "border-width":
                    const string top = "border-top-width";
                    const string right = "border-right-width";
                    const string bottom = "border-bottom-width";
                    const string left = "border-left-width";
                    SetPropertyDimension(styleAttributeInfo, top, right, bottom, left);
                    propertyName = "";
                    break;
                default:
                    if (styleAttributeInfo.Name.IndexOf("width") > 0)
                    {
                        propertyValue = propertyValue.Replace(",", "");
                    }
                    _cssProperty[propertyName] = propertyValue;
                    propertyName = "";
                    break;
            }

            if (propertyName.Length > 0)
                for (int i = 0; i < borderSide.Length; i++)
                {
                    _cssProperty[borderSide[i] + propertyName] = propertyValue;
                }
        }
Beispiel #25
0
 private void ColumnGap(StyleAttribute styleAttributeInfo)
 {
     Numeric(styleAttributeInfo);
 }
Beispiel #26
0
        public ArrayList GetPropertyValue(StyleAttribute styleAttributeInfo)
        {
            var ParamList = new ArrayList();
            string[] parameters = styleAttributeInfo.StringValue.Split(',');
            int length = parameters.Length;
            for (int i = 0; i < length; i++)
            {
                string value = parameters[i];
                if (!Common.ValidateNumber(value))
                    continue;
                string unit = "pt";
                if (i < length - 1)
                {
                    string nextVal = parameters[i + 1];
                    if (_unit.Contains(nextVal))
                    {
                        unit = nextVal;
                        i++;
                    }
                }
                ParamList.Add(Common.UnitConverter(value + unit));

            }
            return ParamList;
        }
Beispiel #27
0
        public void SimpleProperty(StyleAttribute styleAttributeInfo)
        {
            string value = DeleteSeperator(styleAttributeInfo.StringValue);

            switch (styleAttributeInfo.Name.ToLower())
            {
            case "column-fill":
            case "columns":
            case "page-break-before":
            case "page-break-after":
            case "page-break-inside":
            case "visibility":
            case "display":
            case "vertical-align":
            case "column-count":
            case "column-gap":
            case "text-transform":
            case "white-space":
            case "list-style-position":
            case "list-style-type":
            case "list-style":
            case "direction":
            case "float":
            case "clear":
            case "hyphens":
            case "hyphenate-before":
            case "hyphenate-after":
            case "hyphenate-lines":
            case "counter-reset":
            case "content":
            case "position":
            case "-ps-vertical-justification":
            case "-ps-fileproduce":
            case "prince-text-replace":
            case "-ps-referenceformat":
            case "-ps-positionchapternumbers-string":
            case "-ps-includeversenumber-string":
            case "-ps-includeverseinheaderreferences-string":
            case "ps-nonconsecutivereferenceseparator-string":
            case "-ps-nonconsecutivereferenceseparator-string":
            case "-ps-custom-footnote-caller":
            case "-ps-custom-xref-caller":
            case "-ps-hide-versenumber-one":
            case "-ps-hide-space-versenumber":
            case "prince-hyphenate-patterns":
            case "guideword-length":
            case "-ps-split-file-by-letter":
            case "-ps-center-title-header":
            case "-ps-header-font-size":
            case "top":
                _cssProperty[styleAttributeInfo.Name] = value;
                break;

            // convert to pt
            case "text-indent":
            case "margin-top":
            case "margin-right":
            case "margin-bottom":
            case "margin-left":
            case "class-margin-top":
            case "class-margin-right":
            case "class-margin-bottom":
            case "class-margin-left":
            case "padding-top":
            case "padding-bottom":
            case "padding-right":
            case "padding-left":
            case "line-height":
            case "letter-spacing":
            case "word-spacing":
            case "left":
            case "right":
            case "border-radius":
                _cssProperty[styleAttributeInfo.Name] = Common.UnitConverter(value);
                break;

            case "height":
            case "width":
            case "max-height":
                value = styleAttributeInfo.StringValue.ToLower() == "auto" ? "72" : Common.UnitConverter(value);
                _cssProperty[styleAttributeInfo.Name] = value;
                break;

            case "-ps-fixed-line-height":
            case "-ps-disable-widow-orphan":
            case "string-set":
            case "unicode-bidi":
            case "pathway":
            case "-webkit-column-count":
            case "overflow-wrap":
            case "-webkit-font-feature-settings":
            case "-moz-font-feature-settings":
            case "-ms-font-feature-settings":
                break;

            default:
                throw new Exception("Not a valid CSS Command: " + styleAttributeInfo.Name);
            }
        }
Beispiel #28
0
 /// <summary>
 /// Returns the Color Value in # (Hash Format)
 /// </summary>
 /// <param name="styleAttributeInfo">StyleAttribute</param>
 private void Color(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = Color2Hash(styleAttributeInfo);
 }
Beispiel #29
0
 private void Size(StyleAttribute styleAttributeInfo)
 {
     string[] parameters = styleAttributeInfo.StringValue.Split(',');
     _cssProperty["page-width"]  = Math.Round(double.Parse(Common.UnitConverter(parameters[0] + parameters[1]), CultureInfo.GetCultureInfo("en-US")), 9).ToString(CultureInfo.GetCultureInfo("en-US"));
     _cssProperty["page-height"] = Math.Round(double.Parse(Common.UnitConverter(parameters[2] + parameters[3]), CultureInfo.GetCultureInfo("en-US")), 9).ToString(CultureInfo.GetCultureInfo("en-US"));
 }
Beispiel #30
0
 private void DisableWidowandOrphan(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = styleAttributeInfo.StringValue;
 }
Beispiel #31
0
        private void ValidateFixedLineHeight(StyleAttribute styleAttributeInfo)
        {
            string attrValue = DeleteSeperator(styleAttributeInfo.StringValue);

            _cssProperty[styleAttributeInfo.Name] = attrValue;
        }
Beispiel #32
0
 public string Color2Hash(StyleAttribute styleAttributeInfo)
 {
     if (styleAttributeInfo.StringValue.IndexOf("rgb") >= 0)
     {
         styleAttributeInfo.StringValue = ColorRGB(styleAttributeInfo.StringValue);
     }
     else if (styleAttributeInfo.StringValue.IndexOf("#") >= 0)
     {
         styleAttributeInfo.StringValue = ColorHash(styleAttributeInfo.StringValue);
     }
     else if (styleAttributeInfo.StringValue.IndexOf("cmyk") >= 0)
     {
         styleAttributeInfo.StringValue = ColorCMYK(styleAttributeInfo.StringValue);
         styleAttributeInfo.StringValue = ColorRGB(styleAttributeInfo.StringValue);
     }
     else if (_dicColorInfo.ContainsKey(styleAttributeInfo.StringValue.ToLower()))
     {
         styleAttributeInfo.StringValue = _dicColorInfo[styleAttributeInfo.StringValue.ToLower()];
     }
     return styleAttributeInfo.StringValue;
 }
Beispiel #33
0
        /// -------------------------------------------------------------------------------------------
        /// <summary>
        /// Margin and Padding Values 
        /// 
        /// <list>
        /// </list>
        /// </summary>
        /// <param name="styleAttributeInfo">margin: 1cm 2cm 3cm 4cm</param>
        /// <returns>margin-top:1cm , margin-right:2cm, margin-bottom:3cm, margin-left:4cm </returns>
        /// -------------------------------------------------------------------------------------------

        private void Margin(StyleAttribute styleAttributeInfo)
        {

            string keyWord = styleAttributeInfo.Name;
            string top = keyWord + "-top";
            string right = keyWord + "-right";
            string bottom = keyWord + "-bottom";
            string left = keyWord + "-left";

            SetPropertyDimension(styleAttributeInfo, top, right, bottom, left);
        }
Beispiel #34
0
 private void FixedLineHeight(StyleAttribute styleAttributeInfo)
 {
     ValidateFixedLineHeight(styleAttributeInfo);
 }
Beispiel #35
0
        private void FontFamily(StyleAttribute styleAttributeInfo)
        {
            string[] font = styleAttributeInfo.StringValue.Split(',');
            int fontLength = font.Length;
            if (fontLength == 0 || styleAttributeInfo.StringValueLower == "inherit")
            {
                return;
            }

            string fontName; // Gentium 
            FontFamily[] systemFontList = System.Drawing.FontFamily.Families;
            for (int counter = 0; counter < fontLength; counter++)
            {


                fontName = font[counter].Replace("\"", "").Trim();
                foreach (FontFamily systemFont in systemFontList)
                {
                    if (fontName.ToLower() == systemFont.Name.ToLower())
                    {
                        _cssProperty[styleAttributeInfo.Name] = fontName;
                        return;
                    }
                }
            }
            ArrayList genericFamilyList = new ArrayList(new[] { "serif", "sans-serif", "cursive", "fantasy", "monospace" });
            fontName = font[0];
            for (int i = 0; i < fontLength; i++)
            {
                fontName = font[i].Replace("<", "");
                fontName = fontName.Replace(">", "");
                fontName = fontName.Replace("default", "").Trim();

                if (genericFamilyList.Contains(fontName.ToLower()))
                {
                    string xmlFileNameWithPath = Common.PathCombine(PsSupportPath, "GenericFont.xml");

                    string xPath = "//font-preference/generic-family [@name = \"" + fontName.ToLower() + "\"]";
                    ArrayList fontList = new ArrayList();
                    fontList = Common.GetXmlNodeList(xmlFileNameWithPath, xPath);
                    if (fontList.Count > 0)
                    {
                        fontName = fontList[0].ToString();
                        break;
                    }
                }
            }

            _cssProperty["font-family"] = fontName.Trim();

        }
Beispiel #36
0
 private void ColumnGap(StyleAttribute styleAttributeInfo)
 {
     Numeric(styleAttributeInfo);
 }
Beispiel #37
0
 private void DisableWidowandOrphan(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = styleAttributeInfo.StringValue;
 }
Beispiel #38
0
        private void ValidateLineHeight(StyleAttribute styleAttributeInfo)
        {
            if (styleAttributeInfo.StringValue.ToLower() == "inherit")
                return;
            string attrValue = DeleteSeperator(styleAttributeInfo.StringValue);
            if (styleAttributeInfo.StringValue.ToLower() == "none" || styleAttributeInfo.StringValue.ToLower() == "normal")
            {
                attrValue = "100%";
            }
            else if (styleAttributeInfo.StringValue.IndexOf(",") < 0)
            {
                int value = int.Parse(styleAttributeInfo.StringValue) * 100;
                attrValue = value.ToString() + "%";
            }

            if (_dictFontSize.ContainsKey(attrValue))
            {
                attrValue = _dictFontSize[attrValue];
            }
            else
            {
                attrValue = Common.UnitConverter(attrValue);
            }
            _cssProperty[styleAttributeInfo.Name] = attrValue;
        }
Beispiel #39
0
 private void FontSize(StyleAttribute styleAttributeInfo)
 {
     Numeric(styleAttributeInfo);
 }
Beispiel #40
0
        private void TextAlign(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "left" || attrValue == "right" || attrValue == "center" || attrValue == "justify" || attrValue == "inherit")
            {
                _cssProperty["text-align"] = attrValue;
            }
        }
Beispiel #41
0
        private void Numeric(StyleAttribute styleAttributeInfo)
        {
            if (styleAttributeInfo.StringValue == "inherit") return;
            string attrValue = DeleteSeperator(styleAttributeInfo.StringValue);

            if (_dictFontSize.ContainsKey(attrValue))
            {
                attrValue = _dictFontSize[attrValue];
            }
            else
            {
                attrValue = Common.UnitConverter(attrValue);
            }
            _cssProperty[styleAttributeInfo.Name] = attrValue;
        }
Beispiel #42
0
 private void CounterIncrement(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = styleAttributeInfo.StringValue;
 }
Beispiel #43
0
 private void ValidateFixedLineHeight(StyleAttribute styleAttributeInfo)
 {
     string attrValue = DeleteSeperator(styleAttributeInfo.StringValue);
     _cssProperty[styleAttributeInfo.Name] = attrValue;
 }
Beispiel #44
0
        public void Font(StyleAttribute styleAttributeInfo)
        {
            try
            {
                string[] parameters = styleAttributeInfo.StringValue.Split(',');
                // font-size: xx-small | x-small | small | medium | large | x-large | xx-large / pt / em / %
                // line-height:
                string param;
                int    fontsizeBegin = -1;
                int    fontsizeEnd   = -1;

                for (int counter = 0; counter < parameters.Length; counter++)
                {
                    param = parameters[counter];
                    if (_unit.Contains(param))
                    {
                        if (counter - 1 >= 0)
                        {
                            string val      = parameters[counter - 1];
                            string unit     = parameters[counter];
                            string fontSize = Common.UnitConverter(val + unit);

                            if (!_cssProperty.ContainsKey("font-size"))
                            {
                                _cssProperty["font-size"] = fontSize;
                                fontsizeBegin             = counter - 2;
                            }
                            else
                            {
                                _cssProperty["line-height"] = fontSize;
                            }
                            fontsizeEnd = counter; // for font-family
                        }
                    }
                    else if (_dictFontSize.ContainsKey(param))
                    {
                        _cssProperty["font-size"] = param;
                        if (fontsizeBegin == -1)
                        {
                            fontsizeBegin = counter - 1;
                        }
                        fontsizeEnd = counter; // for font-family
                    }
                }

                // font-family "New Century Schoolbook", serif  (or) sans-serif
                string fontFaceClean = string.Empty;
                for (int counter = fontsizeEnd + 1; counter < parameters.Length; counter++)
                {
                    param         = parameters[counter];
                    fontFaceClean = fontFaceClean + "," + param;
                }

                fontFaceClean = fontFaceClean.Substring(1);

                StyleAttribute fontFamily = new StyleAttribute();
                fontFamily.Name        = "font-family";
                fontFamily.StringValue = fontFaceClean;
                FontFamily(fontFamily);

                // font-style: italic,  font-variant: small-caps,
                // font-weight: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
                for (int counter = 0; counter <= fontsizeBegin; counter++)
                {
                    param = parameters[counter];
                    if (param == "italic" || param == "oblique")
                    {
                        _cssProperty["font-style"] = param;
                    }
                    else if (param == "small-caps")
                    {
                        _cssProperty["font-variant"] = param;
                    }
                    else if (param == "bold" || param == "bolder" || param == "lighter")
                    {
                        _cssProperty["font-weight"] = param;
                    }
                    else if (Common.ValidateNumber(param))
                    {
                        _cssProperty["font-weight"] = param;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
        }
Beispiel #45
0
        private void FontVariant(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "normal" || attrValue == "small-caps" || attrValue == "inherit")
            {
                _cssProperty["font-variant"] = attrValue;
            }
        }
Beispiel #46
0
 private void Orphans(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = styleAttributeInfo.StringValue;
 }
Beispiel #47
0
        private void FontWeight(StyleAttribute styleAttributeInfo)
        {
            string attrValue = styleAttributeInfo.StringValue;

            if (attrValue == "normal" || attrValue == "100" || attrValue == "200"
                || attrValue == "300" || attrValue == "400" || attrValue == "500"
                || attrValue == "lighter")
            {
                _cssProperty["font-weight"] = "normal";
            }
            else if (attrValue == "bold" || attrValue == "600" || attrValue == "700"
                || attrValue == "800" || attrValue == "900" || attrValue == "bolder")
            {
                _cssProperty["font-weight"] = "bold";
            }
        }
Beispiel #48
0
 private void CommomProperty(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = styleAttributeInfo.StringValue;
 }
Beispiel #49
0
        private void Language(StyleAttribute styleAttributeInfo)
        {
            string[] languageCountrySplit = styleAttributeInfo.StringValue.Split('-');
            string language = languageCountrySplit[0];
            _cssProperty["language"] = language;

            string country;
            if (languageCountrySplit.Length > 1)
            {
                country = languageCountrySplit[1];
                _cssProperty["country"] = country;
            }
            else // find country for english language
            {
                if (language.ToLower() == "en")
                {
                    string[] langCountry = Application.CurrentCulture.IetfLanguageTag.Split('-');
                    country = langCountry[1];
                    _cssProperty["country"] = country;
                }
            }
        }
 protected void SetUp()
 {
     target = new StyleAttribute();
 }
Beispiel #51
0
 /// <summary>
 /// Returns the Color Value in # (Hash Format)
 /// </summary>
 /// <param name="styleAttributeInfo">StyleAttribute</param>
 private void Color(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = Color2Hash(styleAttributeInfo);
 }
Beispiel #52
0
        /// -------------------------------------------------------------------------------------------
        /// Map _attributeInfo to MapPropertys.cs
        /// -------------------------------------------------------------------------------------------        

        public Dictionary<string, string> CreateProperty(StyleAttribute styleAttributeInfo)
        {
            _cssProperty.Clear();
            styleAttributeInfo.Name = styleAttributeInfo.Name.ToLower();
            styleAttributeInfo.StringValueLower = styleAttributeInfo.StringValue.ToLower();
            switch (styleAttributeInfo.Name)
            {
                case "padding":
                case "margin":
                case "class-margin":
                    Margin(styleAttributeInfo);
                    break;
                case "color":
                case "background-color":
                    Color(styleAttributeInfo);
                    break;
                case "size":
                    Size(styleAttributeInfo);
                    break;
                case "language":
                    Language(styleAttributeInfo);
                    break;
                case "border":
                case "border-top":
                case "border-bottom":
                case "border-left":
                case "border-right":
                case "column-rule":
                    BorderMethod1(styleAttributeInfo);
                    break;
                case "border-style":
                case "border-top-style":
                case "border-right-style":
                case "border-bottom-style":
                case "border-left-style":
                case "border-color":
                case "border-top-color":
                case "border-right-color":
                case "border-bottom-color":
                case "border-left-color":
                case "border-width":
                case "border-top-width":
                case "border-right-width":
                case "border-bottom-width":
                case "border-left-width":
                    BorderMethod2(styleAttributeInfo);
                    break;
                case "font-family":
                    FontFamily(styleAttributeInfo);
                    break;
                case "font":
                    Font(styleAttributeInfo);
                    break;
                case "text-align":
                    TextAlign(styleAttributeInfo);
                    break;
                case "font-variant":
                    FontVariant(styleAttributeInfo);
                    break;
                case "text-decoration":
                    TextDecoration(styleAttributeInfo);
                    break;
                case "font-style":
                    FontStyle(styleAttributeInfo);
                    break;
                case "font-weight":
                    FontWeight(styleAttributeInfo);
                    break;
                case "font-size":
                    FontSize(styleAttributeInfo);
                    break;
                case "column-gap":
                    ColumnGap(styleAttributeInfo);
                    break;
                case "line-height":
                    LineHeight(styleAttributeInfo);
                    break;
                case "-ps-fixed-line-height":
                    FixedLineHeight(styleAttributeInfo);
                    break;
                case "-ps-disable-widow-orphan":
                    DisableWidowandOrphan(styleAttributeInfo);
                    break;
                case "counter-increment":
                    CounterIncrement(styleAttributeInfo);
                    break;
                case "orphans":
                    Orphans(styleAttributeInfo);
                    break;
                case "widows":
                    Widows(styleAttributeInfo);
                    break;
                case "marks":
                    Marks(styleAttributeInfo);
                    break;
                case "-ps-outline-level":
                    CommomProperty(styleAttributeInfo);
                    break;
                default:
                    SimpleProperty(styleAttributeInfo);
                    break;
            }
            return _cssProperty;
        }
Beispiel #53
0
        public void SimpleProperty(StyleAttribute styleAttributeInfo)
        {
            string value = DeleteSeperator(styleAttributeInfo.StringValue);
            switch (styleAttributeInfo.Name.ToLower())
            {
                case "column-fill":
                case "columns":
                case "page-break-before":
                case "page-break-after":
                case "page-break-inside":
                case "visibility":
                case "display":
                case "vertical-align":
                case "column-count":
                case "column-gap":
                case "text-transform":
                case "white-space":
                case "list-style-position":
                case "list-style-type":
                case "list-style":
                case "direction":
                case "float":
                case "clear":
                case "hyphens":
                case "hyphenate-before":
                case "hyphenate-after":
                case "hyphenate-lines":
                case "counter-reset":
                case "content":
                case "position":
                case "-ps-vertical-justification":
                case "-ps-fileproduce":
                case "prince-text-replace":
                case "-ps-referenceformat":
                case "-ps-positionchapternumbers-string":
                case "-ps-includeversenumber-string":
                case "-ps-includeverseinheaderreferences-string":
                case "ps-nonconsecutivereferenceseparator-string":
                case "-ps-nonconsecutivereferenceseparator-string":
                case "-ps-custom-footnote-caller":
                case "-ps-custom-xref-caller":
                case "-ps-hide-versenumber-one":
                case "-ps-hide-space-versenumber":
                case "prince-hyphenate-patterns":
                case "guideword-length":
                case "-ps-split-file-by-letter":
                case "-ps-center-title-header":
                case "-ps-header-font-size":
                    _cssProperty[styleAttributeInfo.Name] = value;
                    break;

                // convert to pt
                case "text-indent":
                case "margin-top":
                case "margin-right":
                case "margin-bottom":
                case "margin-left":
                case "class-margin-top":
                case "class-margin-right":
                case "class-margin-bottom":
                case "class-margin-left":
                case "padding-top":
                case "padding-bottom":
                case "padding-right":
                case "padding-left":
                case "line-height":
                case "letter-spacing":
                case "word-spacing":
                case "left":
                case "right":
                case "border-radius":
                    _cssProperty[styleAttributeInfo.Name] = Common.UnitConverter(value);
                    break;
                case "height":
                case "width":
                    value = styleAttributeInfo.StringValue.ToLower() == "auto" ? "72" : Common.UnitConverter(value);
                    _cssProperty[styleAttributeInfo.Name] = value;
                    break;
                case "-ps-fixed-line-height":
                case "-ps-disable-widow-orphan":
                case "string-set":
                case "unicode-bidi":
                case "pathway":
                    break;
                default:
                    throw new Exception("Not a valid CSS Command");
            }
        }
Beispiel #54
0
 private void CommomProperty(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = styleAttributeInfo.StringValue;
 }
Beispiel #55
0
        private void SetPropertyDimension(StyleAttribute styleAttributeInfo, string top, string right, string bottom, string left)
        {
            try
            {
                ArrayList propertyValues = GetPropertyValue(styleAttributeInfo);

                if (propertyValues.Count == 1)
                {
                    _cssProperty[top] = propertyValues[0].ToString();
                    _cssProperty[right] = propertyValues[0].ToString();
                    _cssProperty[bottom] = propertyValues[0].ToString();
                    _cssProperty[left] = propertyValues[0].ToString();
                }
                else if (propertyValues.Count == 2)
                {
                    _cssProperty[top] = propertyValues[0].ToString();
                    _cssProperty[right] = propertyValues[1].ToString();
                    _cssProperty[bottom] = propertyValues[0].ToString();
                    _cssProperty[left] = propertyValues[1].ToString();
                }
                else if (propertyValues.Count == 3)
                {
                    _cssProperty[top] = propertyValues[0].ToString();
                    _cssProperty[right] = propertyValues[1].ToString();
                    _cssProperty[bottom] = propertyValues[2].ToString();
                    _cssProperty[left] = propertyValues[1].ToString();
                }
                else if (propertyValues.Count == 4)
                {
                    _cssProperty[top] = propertyValues[0].ToString();
                    _cssProperty[right] = propertyValues[1].ToString();
                    _cssProperty[bottom] = propertyValues[2].ToString();
                    _cssProperty[left] = propertyValues[3].ToString();
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                _cssProperty[right] = "0";
                _cssProperty[bottom] = "0";
                _cssProperty[left] = "0";
                _cssProperty[top] = "0";
                throw new Exception(ex.Message);
            }
        }
Beispiel #56
0
 private void Orphans(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = styleAttributeInfo.StringValue;
 }
Beispiel #57
0
        public void Font(StyleAttribute styleAttributeInfo)
        {
            try
            {
                string[] parameters = styleAttributeInfo.StringValue.Split(',');
                // font-size: xx-small | x-small | small | medium | large | x-large | xx-large / pt / em / %
                // line-height:
                string param;
                int fontsizeBegin = -1;
                int fontsizeEnd = -1;

                for (int counter = 0; counter < parameters.Length; counter++)
                {
                    param = parameters[counter];
                    if (_unit.Contains(param))
                    {
                        if (counter - 1 >= 0)
                        {
                            string val = parameters[counter - 1];
                            string unit = parameters[counter];
                            string fontSize = Common.UnitConverter(val + unit);

                            if (!_cssProperty.ContainsKey("font-size"))
                            {
                                _cssProperty["font-size"] = fontSize;
                                fontsizeBegin = counter - 2;
                            }
                            else
                            {
                                _cssProperty["line-height"] = fontSize;
                            }
                            fontsizeEnd = counter; // for font-family
                        }
                    }
                    else if (_dictFontSize.ContainsKey(param))
                    {
                        _cssProperty["font-size"] = param;
                        if (fontsizeBegin == -1)
                        {
                            fontsizeBegin = counter - 1;
                        }
                        fontsizeEnd = counter; // for font-family
                    }
                }

                // font-family "New Century Schoolbook", serif  (or) sans-serif
                string fontFaceClean = string.Empty;
                for (int counter = fontsizeEnd + 1; counter < parameters.Length; counter++)
                {
                    param = parameters[counter];
                    fontFaceClean = fontFaceClean + "," + param;
                }

                fontFaceClean = fontFaceClean.Substring(1);

                StyleAttribute fontFamily = new StyleAttribute();
                fontFamily.Name = "font-family";
                fontFamily.StringValue = fontFaceClean;
                FontFamily(fontFamily);

                // font-style: italic,  font-variant: small-caps,  
                // font-weight: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 
                for (int counter = 0; counter <= fontsizeBegin; counter++)
                {
                    param = parameters[counter];
                    if (param == "italic" || param == "oblique")
                    {
                        _cssProperty["font-style"] = param;
                    }
                    else if (param == "small-caps")
                    {
                        _cssProperty["font-variant"] = param;
                    }
                    else if (param == "bold" || param == "bolder" || param == "lighter")
                    {
                        _cssProperty["font-weight"] = param;
                    }
                    else if (Common.ValidateNumber(param))
                    {
                        _cssProperty["font-weight"] = param;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);

            }
        }
Beispiel #58
0
 private void CounterIncrement(StyleAttribute styleAttributeInfo)
 {
     _cssProperty[styleAttributeInfo.Name] = styleAttributeInfo.StringValue;
 }
Beispiel #59
0
        /// -------------------------------------------------------------------------------------------
        /// <summary>
        /// For include space between seperators - BorderMethod1 bottom
        /// 
        /// <list>
        /// </list>
        /// </summary>
        /// <param name="attribute">attribute value like border-bottom: .5pt solid #a00</param>
        /// <returns>".5pt solid #a00 </returns>
        /// -------------------------------------------------------------------------------------------
        private void BorderMethod1(StyleAttribute attribute)
        {
            string borderStyle = null;
            string borderWidth = null;
            string borderColor = null;
            ArrayList borderStyleList = CreateBorderStyleList();
            try
            {
                string[] value = attribute.StringValue.Split(',');

                for (int i = 0; i < value.Length; i++)
                {
                    if (borderStyleList.Contains(value[i]))
                    {
                        borderStyle = value[i];
                    }
                    else if (_unit.Contains(value[i]))
                    {
                        if (i - 1 >= 0)
                        {
                            string val = value[i - 1];
                            string unit = value[i];
                            borderWidth = Common.UnitConverter(val + unit);
                        }
                    }
                    else if (value[i].IndexOf('#') >= 0)  // #f00 conversion to #ff0000
                    {
                        borderColor = ColorHash(value[i]);
                        GetBorderColorList(borderColor);

                    }
                    else if (_dicColorInfo.ContainsKey(value[i])) // red conversion to #ff0000
                    {
                        borderColor = _dicColorInfo[value[i]];
                    }

                    else if (value[i].ToLower().IndexOf("rgb") >= 0)  // rgb,(,255,0,0,) conversion to #ff0000
                    {
                        string rgbConcat = GetRgbConcat(i, value);
                        borderColor = ColorRGB(rgbConcat);
                    }
                }

                if (attribute.Name == "border")
                {
                    BorderAssign(attribute.Name + "-top", borderStyle, borderWidth, borderColor);
                    BorderAssign(attribute.Name + "-right", borderStyle, borderWidth, borderColor);
                    BorderAssign(attribute.Name + "-bottom", borderStyle, borderWidth, borderColor);
                    BorderAssign(attribute.Name + "-left", borderStyle, borderWidth, borderColor);
                }
                else
                {
                    BorderAssign(attribute.Name, borderStyle, borderWidth, borderColor);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #60
0
 private void FixedLineHeight(StyleAttribute styleAttributeInfo)
 {
     ValidateFixedLineHeight(styleAttributeInfo);
 }