private static void ValidateBackgroundImage(Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageSource, Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageValue, Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageMIMEType, Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundEmbeddingMode, Microsoft.ReportingServices.ReportIntermediateFormat.Style style, ObjectType objectType, string objectName, ErrorContext errorContext)
        {
            if (backgroundImageSource == null)
            {
                return;
            }
            bool flag = true;

            Global.Tracer.Assert(Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo.Types.Constant == backgroundImageSource.Type);
            Microsoft.ReportingServices.OnDemandReportRendering.Image.SourceType intValue = (Microsoft.ReportingServices.OnDemandReportRendering.Image.SourceType)backgroundImageSource.IntValue;
            Global.Tracer.Assert(backgroundImageValue != null);
            if (Microsoft.ReportingServices.OnDemandReportRendering.Image.SourceType.Database == intValue && Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo.Types.Constant == backgroundImageValue.Type)
            {
                errorContext.Register(ProcessingErrorCode.rsBinaryConstant, Severity.Error, objectType, objectName, "BackgroundImageValue");
                flag = false;
            }
            if (Microsoft.ReportingServices.OnDemandReportRendering.Image.SourceType.Database == intValue && !ValidateMimeType(backgroundImageMIMEType, objectType, objectName, "BackgroundImageMIMEType", errorContext))
            {
                flag = false;
            }
            if (flag)
            {
                style.AddAttribute("BackgroundImageSource", backgroundImageSource);
                style.AddAttribute("BackgroundImageValue", backgroundImageValue);
                if (backgroundEmbeddingMode != null)
                {
                    style.AddAttribute("EmbeddingMode", backgroundEmbeddingMode);
                }
                if (Microsoft.ReportingServices.OnDemandReportRendering.Image.SourceType.Database == intValue)
                {
                    style.AddAttribute("BackgroundImageMIMEType", backgroundImageMIMEType);
                }
            }
        }
예제 #2
0
 private void AddAttribute(AutomaticSubtotalContext context, Style originalStyle, Style newStyle, string name, ExpressionInfo meDotValueExpression)
 {
     if (originalStyle.GetAttributeInfo(name, out AttributeInfo styleAttribute))
     {
         if (styleAttribute.IsExpression)
         {
             newStyle.AddAttribute(name, (ExpressionInfo)originalStyle.ExpressionList[styleAttribute.IntValue].PublishClone(context));
         }
         else
         {
             newStyle.StyleAttributes.Add(name, styleAttribute.PublishClone(context));
         }
     }
 }
        internal static Microsoft.ReportingServices.ReportIntermediateFormat.Style ValidateAndCreateStyle(List <StyleInformation.StyleInformationAttribute> attributes, ObjectType objectType, string objectName, bool isDynamicImageSubElement, ErrorContext errorContext, bool checkForMeDotValue, out bool meDotValueReferenced)
        {
            meDotValueReferenced = false;
            Microsoft.ReportingServices.ReportIntermediateFormat.Style style = new Microsoft.ReportingServices.ReportIntermediateFormat.Style(Microsoft.ReportingServices.ReportIntermediateFormat.ConstructionPhase.Publishing);
            Global.Tracer.Assert(attributes != null);
            Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageSource   = null;
            Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageValue    = null;
            Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundImageMIMEType = null;
            Microsoft.ReportingServices.ReportIntermediateFormat.ExpressionInfo backgroundEmbeddingMode = null;
            for (int i = 0; i < attributes.Count; i++)
            {
                StyleInformation.StyleInformationAttribute styleInformationAttribute = attributes[i];
                if (checkForMeDotValue && styleInformationAttribute.ValueType == Microsoft.ReportingServices.ReportIntermediateFormat.ValueType.Constant && styleInformationAttribute.Value.MeDotValueDetected)
                {
                    meDotValueReferenced = true;
                }
                switch (attributes[i].Name)
                {
                case "BackgroundImageSource":
                    backgroundImageSource = styleInformationAttribute.Value;
                    break;

                case "BackgroundImageValue":
                    backgroundImageValue = styleInformationAttribute.Value;
                    break;

                case "BackgroundImageMIMEType":
                    backgroundImageMIMEType = styleInformationAttribute.Value;
                    break;

                case "BackgroundRepeat":
                    if (ValidateBackgroundRepeat(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "EmbeddingMode":
                    backgroundEmbeddingMode = styleInformationAttribute.Value;
                    break;

                case "Transparency":
                    if (ValidateTransparency(styleInformationAttribute.Value, objectType, objectName, "Transparency", errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "TransparentColor":
                    if (ValidateColor(styleInformationAttribute.Value, objectType, objectName, "TransparentColor", errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BorderColor":
                case "BorderColorLeft":
                case "BorderColorRight":
                case "BorderColorTop":
                case "BorderColorBottom":
                    if (ValidateColor(styleInformationAttribute.Value, objectType, objectName, "BorderColor", errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BorderStyle":
                    if (ValidateBorderStyle(styleInformationAttribute.Value, objectType, objectName, isDynamicImageSubElement, "BorderStyle", isDefaultBorder: true, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BorderStyleLeft":
                case "BorderStyleRight":
                case "BorderStyleTop":
                case "BorderStyleBottom":
                    if (ValidateBorderStyle(styleInformationAttribute.Value, objectType, objectName, isDynamicImageSubElement, "BorderStyle", isDefaultBorder: false, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BorderWidth":
                case "BorderWidthLeft":
                case "BorderWidthRight":
                case "BorderWidthTop":
                case "BorderWidthBottom":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.BorderWidthMin, Validator.BorderWidthMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BackgroundGradientEndColor":
                    if (ValidateColor(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BackgroundGradientType":
                    if (ValidateBackgroundGradientType(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "FontStyle":
                    if (ValidateFontStyle(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "FontFamily":
                    style.AddAttribute(styleInformationAttribute);
                    break;

                case "FontSize":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.FontSizeMin, Validator.FontSizeMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "FontWeight":
                    if (ValidateFontWeight(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Format":
                    style.AddAttribute(styleInformationAttribute);
                    break;

                case "TextDecoration":
                    if (ValidateTextDecoration(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "TextAlign":
                    if (ValidateTextAlign(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "VerticalAlign":
                    if (ValidateVerticalAlign(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Color":
                case "BackgroundColor":
                    if (ValidateColor(styleInformationAttribute, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "PaddingLeft":
                case "PaddingRight":
                case "PaddingTop":
                case "PaddingBottom":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.PaddingMin, Validator.PaddingMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "LineHeight":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.LineHeightMin, Validator.LineHeightMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Direction":
                    if (ValidateDirection(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "WritingMode":
                    if (ValidateWritingMode(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Language":
                {
                    if (ValidateSpecificLanguage(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext, out CultureInfo _))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;
                }

                case "UnicodeBiDi":
                    if (ValidateUnicodeBiDi(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Calendar":
                    if (ValidateCalendar(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "CurrencyLanguage":
                    if (ValidateLanguage(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "NumeralLanguage":
                    if (ValidateLanguage(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "NumeralVariant":
                    if (ValidateNumeralVariant(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "ShadowColor":
                    if (ValidateColor(styleInformationAttribute.Value, objectType, objectName, "ShadowColor", errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "ShadowOffset":
                    if (ValidateSize(styleInformationAttribute.Value, Validator.NormalMin, Validator.NormalMax, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "BackgroundHatchType":
                    if (ValidateBackgroundHatchType(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "TextEffect":
                    if (ValidateTextEffect(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                case "Position":
                    if (ValidatePosition(styleInformationAttribute.Value, objectType, objectName, styleInformationAttribute.Name, errorContext))
                    {
                        style.AddAttribute(styleInformationAttribute);
                    }
                    break;

                default:
                    Global.Tracer.Assert(condition: false);
                    break;
                }
            }
            ValidateBackgroundImage(backgroundImageSource, backgroundImageValue, backgroundImageMIMEType, backgroundEmbeddingMode, style, objectType, objectName, errorContext);
            if (0 < style.StyleAttributes.Count)
            {
                return(style);
            }
            return(null);
        }