internal Formatter(Microsoft.ReportingServices.ReportIntermediateFormat.Style styleClass, OnDemandProcessingContext context, ObjectType objectType, string objectName) { m_context = context; m_styleClass = styleClass; m_objectType = objectType; m_objectName = objectName; }
private bool StyleAttributeExpressionBased(Microsoft.ReportingServices.ReportIntermediateFormat.Style style, string styleName) { if (style.GetAttributeInfo(styleName, out AttributeInfo styleAttribute)) { return(styleAttribute.IsExpression); } return(false); }
internal static string Format(object value, ref Formatter formatter, Microsoft.ReportingServices.ReportIntermediateFormat.Style reportItemStyle, Microsoft.ReportingServices.ReportIntermediateFormat.Style reportElementStyle, OnDemandProcessingContext context, ObjectType objectType, string objectName) { if (formatter == null) { formatter = new Formatter(reportItemStyle, context, objectType, objectName); } TypeCode typeCode = Type.GetTypeCode(value.GetType()); bool sharedFormatSettings = false; string styleStringValue = ""; reportElementStyle?.GetStyleAttribute(objectType, objectName, "Format", context, ref sharedFormatSettings, out styleStringValue); return(formatter.FormatValue(value, styleStringValue, typeCode)); }
internal static void ValidateBorderColorNotTransparent(ObjectType objectType, string objectName, Microsoft.ReportingServices.ReportIntermediateFormat.Style styleClass, string styleName, ErrorContext errorContext) { if (styleClass.GetAttributeInfo(styleName, out Microsoft.ReportingServices.ReportIntermediateFormat.AttributeInfo styleAttribute) && !styleAttribute.IsExpression && ReportColor.TryParse(styleAttribute.Value, allowTransparency: true, out ReportColor reportColor) && reportColor.ToColor().A != byte.MaxValue) { errorContext.Register(ProcessingErrorCode.rsInvalidColor, Severity.Error, objectType, objectName, styleName, styleAttribute.Value); } }
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); }
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); } } }