private static void ProcessReportObject(ReportObject ro, Utf8JsonWriter jsonw) { jsonw.WriteStartObject(); // for all types the same properties jsonw.WriteString("Height", ro.Height.ToStringSafe()); jsonw.WriteString("Kind", ro.Kind.ToStringSafe()); jsonw.WriteString("Left", ro.Left.ToStringSafe()); jsonw.WriteString("LinkedURI", ro.LinkedURI); jsonw.WriteString("Name", ro.Name); //jsonw.WriteString("ReportPartIDDataContext", ro.ReportPartBookmark.ReportPartID.DataContext); //jsonw.WriteString("ReportPartIDName", ro.ReportPartBookmark.ReportPartID.Name); //jsonw.WriteString("ReportURI", ro.ReportPartBookmark.ReportURI); jsonw.WriteString("Top", ro.Top.ToStringSafe()); jsonw.WriteString("Width", ro.Width.ToStringSafe()); // kind specific properties switch (ro.Kind) { case CrReportObjectKindEnum.crReportObjectKindBlobField: { BlobFieldObject bfo = (BlobFieldObject)ro; jsonw.WriteString("DataSourceName", bfo.DataSourceName); jsonw.WriteString("OriginalHeight", bfo.OriginalHeight.ToStringSafe()); jsonw.WriteString("OriginalWidth", bfo.OriginalWidth.ToStringSafe()); jsonw.WriteString("XScaling", bfo.XScaling.ToStringSafe()); jsonw.WriteString("YScaling", bfo.YScaling.ToStringSafe()); ProcessPictureFormat(bfo.PictureFormat, jsonw); break; } case CrReportObjectKindEnum.crReportObjectKindBox: { BoxObject bo = (BoxObject)ro; jsonw.WriteString("Bottom", bo.Bottom.ToStringSafe()); jsonw.WriteString("CornerEllipseHeight", bo.CornerEllipseHeight.ToStringSafe()); jsonw.WriteString("CornerEllipseWidth", bo.CornerEllipseWidth.ToStringSafe()); jsonw.WriteString("EnableExtendToBottomOfSection", bo.EnableExtendToBottomOfSection.ToStringSafe()); jsonw.WriteString("EndSectionName", bo.EndSectionName); jsonw.WriteString("FillColor", bo.FillColor.ToStringSafe()); jsonw.WriteString("LineColor", bo.LineColor.ToStringSafe()); jsonw.WriteString("LineStyle", bo.LineStyle.ToStringSafe()); jsonw.WriteString("LineThickness", bo.LineThickness.ToStringSafe()); jsonw.WriteString("Right", bo.Right.ToStringSafe()); break; } case CrReportObjectKindEnum.crReportObjectKindFieldHeading: { FieldHeadingObject fho = (FieldHeadingObject)ro; jsonw.WriteString("FieldObjectName", fho.FieldObjectName); jsonw.WriteString("MaxNumberOfLines", fho.MaxNumberOfLines.ToStringSafe()); jsonw.WriteString("ReadingOrder", fho.ReadingOrder.ToStringSafe()); jsonw.WriteString("Text", fho.Text); ProcessFontColor(fho.FontColor, jsonw); ProcessParagraphs(fho.Paragraphs, jsonw); break; } case CrReportObjectKindEnum.crReportObjectKindField: { FieldObject fo = (FieldObject)ro; jsonw.WriteString("DataSourceName", fo.DataSourceName); jsonw.WriteString("FieldValueType", fo.FieldValueType.ToStringSafe()); ProcessFieldFormat(fo.FieldFormat, jsonw, fo.FieldValueType); ProcessFontColor(fo.FontColor, jsonw); break; } case CrReportObjectKindEnum.crReportObjectKindLine: { LineObject lo = (LineObject)ro; jsonw.WriteString("Bottom", lo.Bottom.ToStringSafe()); jsonw.WriteString("EnableExtendToBottomOfSection", lo.EnableExtendToBottomOfSection.ToStringSafe()); jsonw.WriteString("EndSectionName", lo.EndSectionName); jsonw.WriteString("LineColor", lo.LineColor.ToStringSafe()); jsonw.WriteString("LineStyle", lo.LineStyle.ToStringSafe()); jsonw.WriteString("LineThickness", lo.LineThickness.ToStringSafe()); jsonw.WriteString("Right", lo.Right.ToStringSafe()); break; } case CrReportObjectKindEnum.crReportObjectKindSubreport: { SubreportObject so = (SubreportObject)ro; jsonw.WriteString("EnableOnDemand", so.EnableOnDemand.ToStringSafe()); jsonw.WriteString("IsImported", so.IsImported.ToStringSafe()); jsonw.WriteString("SubreportLocation", so.SubreportLocation); jsonw.WriteString("SubreportName", so.SubreportName); break; } case CrReportObjectKindEnum.crReportObjectKindText: { TextObject to = (TextObject)ro; jsonw.WriteString("MaxNumberOfLines", to.MaxNumberOfLines.ToStringSafe()); jsonw.WriteString("ReadingOrder", to.ReadingOrder.ToStringSafe()); jsonw.WriteString("Text", to.Text); ProcessFontColor(to.FontColor, jsonw); ProcessParagraphs(to.Paragraphs, jsonw); break; } default: { break; } } ProcessBorder(ro.Border, jsonw); ProcessObjectFormat(ro.Format, jsonw); jsonw.WriteEndObject(); }
private static void ProcessReportObjects(ReportObject ro, XmlWriter xmlw) { xmlw.WriteStartElement(ro.Kind.ToStringSafe()); // for all types the same properties xmlw.WriteAttributeString("Height", ro.Height.ToStringSafe()); xmlw.WriteAttributeString("Kind", ro.Kind.ToStringSafe()); xmlw.WriteAttributeString("Left", ro.Left.ToStringSafe()); xmlw.WriteAttributeString("Name", ro.Name); xmlw.WriteAttributeString("Top", ro.Top.ToStringSafe()); xmlw.WriteAttributeString("Width", ro.Width.ToStringSafe()); // kind specific properties switch (ro.Kind) { case ReportObjectKind.BlobFieldObject: { BlobFieldObject bfo = (BlobFieldObject)ro; ProcessDatabaseFieldDefinition(bfo.DataSource, xmlw); break; } case ReportObjectKind.BoxObject: { BoxObject bo = (BoxObject)ro; xmlw.WriteAttributeString("Bottom", bo.Bottom.ToStringSafe()); xmlw.WriteAttributeString("EnableExtendToBottomOfSection", bo.EnableExtendToBottomOfSection.ToStringSafe()); xmlw.WriteAttributeString("EndSectionName", bo.EndSectionName); xmlw.WriteAttributeString("FillColor", bo.FillColor.ToStringSafe()); xmlw.WriteAttributeString("LineColor", bo.LineColor.ToStringSafe()); xmlw.WriteAttributeString("LineStyle", bo.LineStyle.ToStringSafe()); xmlw.WriteAttributeString("LineThickness", bo.LineThickness.ToStringSafe()); xmlw.WriteAttributeString("Right", bo.Right.ToStringSafe()); break; } case ReportObjectKind.FieldHeadingObject: { FieldHeadingObject fho = (FieldHeadingObject)ro; xmlw.WriteAttributeString("Color", fho.Color.ToStringSafe()); xmlw.WriteAttributeString("Font", fho.Font.ToStringSafe()); xmlw.WriteAttributeString("Text", fho.Text); xmlw.WriteAttributeString("FieldObjectName", fho.FieldObjectName); break; } case ReportObjectKind.FieldObject: { FieldObject fo = (FieldObject)ro; xmlw.WriteAttributeString("Color", fo.Color.ToStringSafe()); xmlw.WriteAttributeString("Font", fo.Font.ToStringSafe()); if (fo.DataSource != null) { ProcessFieldDefinition(fo.DataSource, xmlw, "DataSource"); } ProcessFieldFormat(fo.FieldFormat, xmlw); break; } case ReportObjectKind.LineObject: { LineObject lo = (LineObject)ro; xmlw.WriteAttributeString("Bottom", lo.Bottom.ToStringSafe()); xmlw.WriteAttributeString("EnableExtendToBottomOfSection", lo.EnableExtendToBottomOfSection.ToStringSafe()); xmlw.WriteAttributeString("EndSectionName", lo.EndSectionName); xmlw.WriteAttributeString("LineColor", lo.LineColor.ToStringSafe()); xmlw.WriteAttributeString("LineStyle", lo.LineStyle.ToStringSafe()); xmlw.WriteAttributeString("LineThickness", lo.LineThickness.ToStringSafe()); xmlw.WriteAttributeString("Right", lo.Right.ToStringSafe()); break; } case ReportObjectKind.SubreportObject: { SubreportObject so = (SubreportObject)ro; xmlw.WriteAttributeString("EnableOnDemand", so.EnableOnDemand.ToStringSafe()); xmlw.WriteAttributeString("SubreportName", so.SubreportName); break; } case ReportObjectKind.TextObject: { TextObject to = (TextObject)ro; xmlw.WriteAttributeString("Color", to.Color.ToStringSafe()); xmlw.WriteAttributeString("Font", to.Font.ToStringSafe()); xmlw.WriteAttributeString("Text", to.Text); break; } default: { break; } } ProcessBorder(ro.Border, xmlw); ProcessObjectFormat(ro.ObjectFormat, xmlw); xmlw.WriteEndElement(); }
private void initializeItem(ReportObject item, SectInfo[] sectInfos, ObjectInfo oinfo) { try { var sinfo = (from s in sectInfos where s.name == oinfo.sectionname select s).First(); double offset = sinfo.offset; bool visible = !(item.ObjectFormat.EnableSuppress); switch (item.Kind) { case CrystalDecisions.Shared.ReportObjectKind.FieldObject: { FieldObject fld = item as FieldObject; this.ObjectType = ObjectInfoType.Label; //this.cBox.Visibility = System.Windows.Visibility.Collapsed; this.cText.Visibility = System.Windows.Visibility.Visible; this.Name = fld.Name; this.Width = item.Width; this.Height = item.Height; this.Content = string.Format("{{{0}}}", fld.Name); if (visible) { this.Foreground = new SolidColorBrush(Color.FromArgb(fld.Color.A, fld.Color.R, fld.Color.G, fld.Color.B)); } else { this.Foreground = Brushes.LightGray; } this.FontFamily = new System.Windows.Media.FontFamily(fld.Font.FontFamily.Name); this.FontSize = fld.Font.Size * fontSizeScale; this.FontStretch = FontStretches.ExtraExpanded; switch (fld.ObjectFormat.HorizontalAlignment) { case Alignment.HorizontalCenterAlign: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; break; case Alignment.LeftAlign: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left; break; case Alignment.RightAlign: case Alignment.Decimal: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; break; case Alignment.Justified: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; break; default: switch (fld.DataSource.ValueType) { default: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left; break; case FieldValueType.CurrencyField: case FieldValueType.Int32sField: case FieldValueType.Int32uField: case FieldValueType.Int16sField: case FieldValueType.Int16uField: case FieldValueType.NumberField: case FieldValueType.Int8sField: case FieldValueType.Int8uField: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; break; } break; } this.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; this.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; this.TextDecorations = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Underline) ? System.Windows.TextDecorations.Underline : null; this.FontWeight = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Bold) ? FontWeights.Bold : FontWeights.Normal; this.FontStyle = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Italic) ? FontStyles.Italic : FontStyles.Normal; DrawFieldFrameBorder(fld); this.SetValue(Canvas.TopProperty, (double)((fld.Top) + offset)); this.SetValue(Canvas.LeftProperty, (double)(fld.Left)); } break; case CrystalDecisions.Shared.ReportObjectKind.FieldHeadingObject: { FieldHeadingObject fld = item as FieldHeadingObject; //this.cBox.Visibility = System.Windows.Visibility.Collapsed; this.cText.Visibility = System.Windows.Visibility.Visible; this.ObjectType = ObjectInfoType.Label; this.Name = fld.Name; this.Width = item.Width; this.Height = item.Height; this.Content = fld.Text; if (visible) { this.Foreground = new SolidColorBrush(Color.FromArgb(fld.Color.A, fld.Color.R, fld.Color.G, fld.Color.B)); } else { this.Foreground = Brushes.LightGray; } this.FontFamily = new System.Windows.Media.FontFamily(fld.Font.FontFamily.Name); this.FontSize = fld.Font.Size * fontSizeScale; this.FontStretch = FontStretches.ExtraExpanded; switch (fld.ObjectFormat.HorizontalAlignment) { case Alignment.HorizontalCenterAlign: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; break; case Alignment.LeftAlign: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left; break; case Alignment.RightAlign: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; break; case Alignment.Justified: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; break; } this.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; this.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; this.TextDecorations = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Underline) ? System.Windows.TextDecorations.Underline : null; this.FontWeight = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Bold) ? FontWeights.Bold : FontWeights.Normal; this.FontStyle = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Italic) ? FontStyles.Italic : FontStyles.Normal; DrawFieldFrameBorder(fld); this.SetValue(Canvas.TopProperty, (double)((fld.Top) + offset)); this.SetValue(Canvas.LeftProperty, (double)(fld.Left)); } break; case CrystalDecisions.Shared.ReportObjectKind.TextObject: { TextObject fld = item as TextObject; //this.cBox.Visibility = System.Windows.Visibility.Collapsed; this.cText.Visibility = System.Windows.Visibility.Visible; this.ObjectType = ObjectInfoType.Label; this.Name = fld.Name; this.Width = item.Width; this.Height = item.Height; this.Content = fld.Text; if (visible) { this.Foreground = new SolidColorBrush(Color.FromArgb(fld.Color.A, fld.Color.R, fld.Color.G, fld.Color.B)); } else { this.Foreground = Brushes.LightGray; } this.FontFamily = new System.Windows.Media.FontFamily(fld.Font.FontFamily.Name); this.FontSize = fld.Font.Size * fontSizeScale; this.FontStretch = FontStretches.ExtraExpanded; switch (fld.ObjectFormat.HorizontalAlignment) { case Alignment.HorizontalCenterAlign: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; break; case Alignment.LeftAlign: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left; break; case Alignment.RightAlign: case Alignment.Decimal: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right; break; case Alignment.Justified: this.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch; break; } this.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; this.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; this.TextDecorations = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Underline) ? System.Windows.TextDecorations.Underline : null; this.FontWeight = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Bold) ? FontWeights.Bold : FontWeights.Normal; this.FontStyle = fld.Font.Style.HasFlag(System.Drawing.FontStyle.Italic) ? FontStyles.Italic : FontStyles.Normal; DrawFieldFrameBorder(fld); this.SetValue(Canvas.TopProperty, (double)((fld.Top) + offset)); this.SetValue(Canvas.LeftProperty, (double)(fld.Left)); } break; case CrystalDecisions.Shared.ReportObjectKind.BoxObject: { this.FrameT.Visibility = System.Windows.Visibility.Hidden; this.FrameB.Visibility = System.Windows.Visibility.Hidden; this.FrameL.Visibility = System.Windows.Visibility.Hidden; this.FrameR.Visibility = System.Windows.Visibility.Hidden; BoxObject fld = item as BoxObject; this.cBox.Visibility = System.Windows.Visibility.Visible; this.ObjectType = ObjectInfoType.Box; this.Name = fld.Name; System.Windows.Shapes.Rectangle box = this.cBox; box.Fill = Brushes.Transparent; if (visible) { box.Stroke = new SolidColorBrush(Color.FromArgb(fld.Border.BorderColor.A, fld.Border.BorderColor.R, fld.Border.BorderColor.G, fld.Border.BorderColor.B)); } else { box.Stroke = Brushes.LightGray; } box.StrokeThickness = fld.LineThickness; this.Width = box.Width = fld.Right - fld.Left; double top = fld.Top + offset; double ht = fld.Top; if (fld.EndSectionName == oinfo.sectionname) { ht = fld.Bottom - fld.Top; } else { var ofs = (from s in sectInfos where s.name == fld.EndSectionName select s.offset).First(); double bottom = fld.Bottom + ofs; ht = bottom - top; } this.Height = box.Height = ht; if (fld.Name.Contains("枠線")) { try { // 角丸の値はCOMオブジェクトから取得する方法しかない var bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; MethodInfo mi = fld.ObjectFormat.GetType().GetMethod("get_RasReportObject", bf); ParameterInfo[] plist = mi.GetParameters(); object ret = mi.Invoke(fld.ObjectFormat, new object[] { }); // レポート定義側の値の半分で表示する box.RadiusY = ((CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject)ret).CornerEllipseHeight / 2; box.RadiusX = ((CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject)ret).CornerEllipseWidth / 2; } catch (Exception ex) { appLog.Error("枠線コーナー丸め情報取得エラー", ex); } } this.SetValue(Canvas.TopProperty, top); this.SetValue(Canvas.LeftProperty, (double)(fld.Left)); oinfo.extendSection = fld.EndSectionName != oinfo.sectionname; oinfo.endSectionName = fld.EndSectionName; } break; case CrystalDecisions.Shared.ReportObjectKind.LineObject: { this.FrameT.Visibility = System.Windows.Visibility.Hidden; this.FrameB.Visibility = System.Windows.Visibility.Hidden; this.FrameL.Visibility = System.Windows.Visibility.Hidden; this.FrameR.Visibility = System.Windows.Visibility.Hidden; LineObject fld = item as LineObject; this.cBox.Visibility = System.Windows.Visibility.Visible; this.ObjectType = (fld.Top == fld.Bottom) ? ObjectInfoType.HLine : ObjectInfoType.VLine; this.Name = fld.Name; System.Windows.Shapes.Rectangle box = this.cBox; if (visible) { box.Stroke = new SolidColorBrush(Color.FromArgb(fld.Border.BorderColor.A, fld.Border.BorderColor.R, fld.Border.BorderColor.G, fld.Border.BorderColor.B)); } else { box.Stroke = Brushes.LightGray; } box.Fill = box.Stroke; box.StrokeThickness = fld.LineThickness + 5; this.Width = box.Width = fld.Right - fld.Left + fld.LineThickness; if (oinfo.objectType == ObjectInfoType.VLine) { this.Width += 5; } double top = fld.Top + offset; double ht = fld.Top; if (fld.EndSectionName == oinfo.sectionname) { ht = fld.Bottom - fld.Top; } else { var ofs = (from s in sectInfos where s.name == fld.EndSectionName select s.offset).First(); double bottom = fld.Bottom + ofs; ht = bottom - top; } this.Height = box.Height = ht + fld.LineThickness; if (oinfo.objectType == ObjectInfoType.HLine) { this.Height += 5; } this.SetValue(Canvas.TopProperty, top); this.SetValue(Canvas.LeftProperty, (double)(fld.Left)); oinfo.extendSection = fld.EndSectionName != oinfo.sectionname; oinfo.endSectionName = fld.EndSectionName; } break; // 追加 case CrystalDecisions.Shared.ReportObjectKind.BlobFieldObject: { BlobFieldObject Blob = item as BlobFieldObject; this.cText.Visibility = System.Windows.Visibility.Collapsed; this.ObjectType = ObjectInfoType.Label; this.Name = Blob.Name; this.Width = Blob.Width; this.Height = Blob.Height; this.Foreground = Brushes.LightGray; DrawFieldFrameBorder(Blob); this.SetValue(Canvas.TopProperty, (double)((Blob.Top) + offset)); this.SetValue(Canvas.LeftProperty, (double)(Blob.Left)); } break; default: break; } } catch (Exception ex) { } }