Example #1
0
 private static void ValidateBackgroundImage(ExpressionInfo backgroundImageSource, ExpressionInfo backgroundImageValue, ExpressionInfo backgroundImageMIMEType, Style style, ObjectType objectType, string objectName, ErrorContext errorContext)
 {
     if (backgroundImageSource != null)
     {
         bool flag = true;
         Global.Tracer.Assert(ExpressionInfo.Types.Constant == backgroundImageSource.Type);
         Image.SourceType intValue = (Image.SourceType)backgroundImageSource.IntValue;
         Global.Tracer.Assert(null != backgroundImageValue);
         if (Image.SourceType.Database == intValue && ExpressionInfo.Types.Constant == backgroundImageValue.Type)
         {
             errorContext.Register(ProcessingErrorCode.rsBinaryConstant, Severity.Error, objectType, objectName, "BackgroundImageValue");
             flag = false;
         }
         if (Image.SourceType.Database == intValue && !PublishingValidator.ValidateMimeType(backgroundImageMIMEType, objectType, objectName, "BackgroundImageMIMEType", errorContext))
         {
             flag = false;
         }
         if (flag)
         {
             style.AddAttribute("BackgroundImageSource", backgroundImageSource);
             style.AddAttribute("BackgroundImageValue", backgroundImageValue);
             if (Image.SourceType.Database == intValue)
             {
                 style.AddAttribute("BackgroundImageMIMEType", backgroundImageMIMEType);
             }
         }
     }
 }
Example #2
0
        public static bool ValidateSize(string size, ObjectType objectType, string objectName, string propertyName, bool restrictMaxValue, ErrorContext errorContext, out double sizeInMM, out string roundSize)
        {
            bool   flag     = ObjectType.Line == objectType;
            double minValue = flag ? Validator.NegativeMin : Validator.NormalMin;
            double maxValue = restrictMaxValue ? Validator.NormalMax : 1.7976931348623157E+308;

            return(PublishingValidator.ValidateSize(size, flag, minValue, maxValue, objectType, objectName, propertyName, errorContext, out sizeInMM, out roundSize));
        }
Example #3
0
 public static bool ValidateEmbeddedImageName(AttributeInfo embeddedImageName, EmbeddedImageHashtable embeddedImages, ObjectType objectType, string objectName, string propertyName, ErrorContext errorContext)
 {
     Global.Tracer.Assert(null != embeddedImageName);
     if (!embeddedImageName.IsExpression)
     {
         return(PublishingValidator.ValidateEmbeddedImageName(embeddedImageName.Value, embeddedImages, objectType, objectName, propertyName, errorContext));
     }
     return(true);
 }
Example #4
0
 private static bool ValidateSize(ExpressionInfo size, double minValue, double maxValue, ObjectType objectType, string objectName, string propertyName, ErrorContext errorContext)
 {
     Global.Tracer.Assert(null != size);
     if (ExpressionInfo.Types.Constant == size.Type)
     {
         bool   allowNegative = false;
         double num           = default(double);
         string text          = default(string);
         return(PublishingValidator.ValidateSize(size.Value, allowNegative, minValue, maxValue, objectType, objectName, propertyName, errorContext, out num, out text));
     }
     return(true);
 }
Example #5
0
 public static bool ValidateMimeType(ExpressionInfo mimeType, ObjectType objectType, string objectName, string propertyName, ErrorContext errorContext)
 {
     if (mimeType == null)
     {
         errorContext.Register(ProcessingErrorCode.rsMissingMIMEType, Severity.Error, objectType, objectName, propertyName);
         return(false);
     }
     if (ExpressionInfo.Types.Constant == mimeType.Type)
     {
         return(PublishingValidator.ValidateMimeType(mimeType.Value, objectType, objectName, propertyName, errorContext));
     }
     return(true);
 }
Example #6
0
 public override bool Initialize(InitializationContext context)
 {
     context.ObjectType = this.ObjectType;
     context.ObjectName = base.m_name;
     context.ExprHostBuilder.ImageStart(base.m_name);
     base.Initialize(context);
     if (base.m_visibility != null)
     {
         base.m_visibility.Initialize(context, false, false);
     }
     if (this.m_action != null)
     {
         this.m_action.Initialize(context);
     }
     if (this.m_value != null)
     {
         this.m_value.Initialize("Value", context);
         context.ExprHostBuilder.GenericValue(this.m_value);
         if (ExpressionInfo.Types.Constant == this.m_value.Type && this.m_source == SourceType.External && !context.ReportContext.IsSupportedProtocol(this.m_value.Value, true))
         {
             context.ErrorContext.Register(ProcessingErrorCode.rsUnsupportedProtocol, Severity.Error, this.ObjectType, base.m_name, "Value", this.m_value.Value, "http://, https://, ftp://, file:, mailto:, or news:");
         }
     }
     if (this.m_MIMEType != null)
     {
         this.m_MIMEType.Initialize("MIMEType", context);
         context.ExprHostBuilder.ImageMIMEType(this.m_MIMEType);
     }
     if (SourceType.Embedded == this.m_source)
     {
         Global.Tracer.Assert(null != this.m_value);
         PublishingValidator.ValidateEmbeddedImageName(this.m_value, context.EmbeddedImages, this.ObjectType, base.m_name, "Value", context.ErrorContext);
     }
     base.ExprHostID = context.ExprHostBuilder.ImageEnd();
     return(true);
 }
Example #7
0
        public static Style ValidateAndCreateStyle(StringList names, ExpressionInfoList values, ObjectType objectType, string objectName, ErrorContext errorContext)
        {
            Style style = new Style(ConstructionPhase.Publishing);

            Global.Tracer.Assert(null != names);
            Global.Tracer.Assert(null != values);
            Global.Tracer.Assert(names.Count == values.Count);
            ExpressionInfo backgroundImageSource   = null;
            ExpressionInfo backgroundImageValue    = null;
            ExpressionInfo backgroundImageMIMEType = null;

            for (int i = 0; i < names.Count; i++)
            {
                switch (names[i])
                {
                case "BackgroundImageSource":
                    backgroundImageSource = values[i];
                    break;

                case "BackgroundImageValue":
                    backgroundImageValue = values[i];
                    break;

                case "BackgroundImageMIMEType":
                    backgroundImageMIMEType = values[i];
                    break;

                case "BackgroundRepeat":
                    if (PublishingValidator.ValidateBackgroundRepeat(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderColor":
                case "BorderColorLeft":
                case "BorderColorRight":
                case "BorderColorTop":
                case "BorderColorBottom":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, "BorderColor", errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderStyle":
                case "BorderStyleLeft":
                case "BorderStyleRight":
                case "BorderStyleTop":
                case "BorderStyleBottom":
                    if (PublishingValidator.ValidateBorderStyle(values[i], objectType, objectName, "BorderStyle", errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BorderWidth":
                case "BorderWidthLeft":
                case "BorderWidthRight":
                case "BorderWidthTop":
                case "BorderWidthBottom":
                    if (PublishingValidator.ValidateSize(values[i], Validator.BorderWidthMin, Validator.BorderWidthMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BackgroundColor":
                case "BackgroundGradientEndColor":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "BackgroundGradientType":
                    if (PublishingValidator.ValidateBackgroundGradientType(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontStyle":
                    if (PublishingValidator.ValidateFontStyle(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontFamily":
                    style.AddAttribute(names[i], values[i]);
                    break;

                case "FontSize":
                    if (PublishingValidator.ValidateSize(values[i], Validator.FontSizeMin, Validator.FontSizeMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "FontWeight":
                    if (PublishingValidator.ValidateFontWeight(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Format":
                    style.AddAttribute(names[i], values[i]);
                    break;

                case "TextDecoration":
                    if (PublishingValidator.ValidateTextDecoration(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "TextAlign":
                    if (PublishingValidator.ValidateTextAlign(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "VerticalAlign":
                    if (PublishingValidator.ValidateVerticalAlign(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Color":
                    if (PublishingValidator.ValidateColor(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "PaddingLeft":
                case "PaddingRight":
                case "PaddingTop":
                case "PaddingBottom":
                    if (PublishingValidator.ValidateSize(values[i], Validator.PaddingMin, Validator.PaddingMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "LineHeight":
                    if (PublishingValidator.ValidateSize(values[i], Validator.LineHeightMin, Validator.LineHeightMax, objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Direction":
                    if (PublishingValidator.ValidateDirection(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "WritingMode":
                    if (PublishingValidator.ValidateWritingMode(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Language":
                {
                    CultureInfo cultureInfo = default(CultureInfo);
                    if (PublishingValidator.ValidateSpecificLanguage(values[i], objectType, objectName, names[i], errorContext, out cultureInfo))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;
                }

                case "UnicodeBiDi":
                    if (PublishingValidator.ValidateUnicodeBiDi(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "Calendar":
                    if (PublishingValidator.ValidateCalendar(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "NumeralLanguage":
                    if (PublishingValidator.ValidateLanguage(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                case "NumeralVariant":
                    if (PublishingValidator.ValidateNumeralVariant(values[i], objectType, objectName, names[i], errorContext))
                    {
                        style.AddAttribute(names[i], values[i]);
                    }
                    break;

                default:
                    Global.Tracer.Assert(false);
                    break;
                }
            }
            PublishingValidator.ValidateBackgroundImage(backgroundImageSource, backgroundImageValue, backgroundImageMIMEType, style, objectType, objectName, errorContext);
            if (0 < style.StyleAttributes.Count)
            {
                return(style);
            }
            return(null);
        }
Example #8
0
        public void Initialize(InitializationContext context)
        {
            Global.Tracer.Assert(null != this.m_styleAttributes);
            IDictionaryEnumerator enumerator = this.m_styleAttributes.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string        text          = (string)enumerator.Key;
                AttributeInfo attributeInfo = (AttributeInfo)enumerator.Value;
                Global.Tracer.Assert(null != text);
                Global.Tracer.Assert(null != attributeInfo);
                if (attributeInfo.IsExpression)
                {
                    string name = text;
                    switch (text)
                    {
                    case "BorderColorLeft":
                    case "BorderColorRight":
                    case "BorderColorTop":
                    case "BorderColorBottom":
                        text = "BorderColor";
                        break;

                    case "BorderStyleLeft":
                    case "BorderStyleRight":
                    case "BorderStyleTop":
                    case "BorderStyleBottom":
                        text = "BorderStyle";
                        break;

                    case "BorderWidthLeft":
                    case "BorderWidthRight":
                    case "BorderWidthTop":
                    case "BorderWidthBottom":
                        text = "BorderWidth";
                        break;
                    }
                    Global.Tracer.Assert(null != this.m_expressionList);
                    ExpressionInfo expressionInfo = this.m_expressionList[attributeInfo.IntValue];
                    expressionInfo.Initialize(text, context);
                    context.ExprHostBuilder.StyleAttribute(name, expressionInfo);
                }
            }
            AttributeInfo attributeInfo2 = this.m_styleAttributes["BackgroundImageSource"];

            if (attributeInfo2 != null)
            {
                Global.Tracer.Assert(!attributeInfo2.IsExpression);
                Image.SourceType intValue = (Image.SourceType)attributeInfo2.IntValue;
                if (Image.SourceType.Embedded == intValue)
                {
                    AttributeInfo attributeInfo3 = this.m_styleAttributes["BackgroundImageValue"];
                    Global.Tracer.Assert(null != attributeInfo3);
                    PublishingValidator.ValidateEmbeddedImageName(attributeInfo3, context.EmbeddedImages, context.ObjectType, context.ObjectName, "BackgroundImageValue", context.ErrorContext);
                }
                else if (intValue == Image.SourceType.External)
                {
                    AttributeInfo attributeInfo4 = this.m_styleAttributes["BackgroundImageValue"];
                    Global.Tracer.Assert(null != attributeInfo4);
                    if (!attributeInfo4.IsExpression)
                    {
                        context.ImageStreamNames[attributeInfo4.Value] = new ImageInfo(context.ObjectName, null);
                    }
                }
            }
            context.CheckInternationalSettings(this.m_styleAttributes);
        }