Example #1
0
            public override void WriteTo(XmlWriter xmlWriter)
            {
                SetUpCells();
                SetUpColumnsGroupings();
                SetUpRowGroupings();

                xmlWriter.WriteStartElement("Matrix");
                {
                    xmlWriter.WriteAttributeString("Name", Name);

                    if (Corner != null)
                    {
                        Corner.WriteTo(xmlWriter);
                    }

                    ColumnGroupings.WriteTo(xmlWriter);
                    RowGroupings.WriteTo(xmlWriter);

                    MatrixColumns.WriteTo(xmlWriter);
                    MatrixRows.WriteTo(xmlWriter);

                    base.WriteTo(xmlWriter);
                }
                xmlWriter.WriteEndElement();
            }
		public Matrix(ReportDefn r, ReportLink p, XmlNode xNode):base(r,p,xNode)
		{
			_Corner=null;
			_ColumnGroupings=null;
			_RowGroupings=null;
			_MatrixRows=null;
			_MatrixColumns=null;
			_LayoutDirection=MatrixLayoutDirectionEnum.LTR;
			_GroupsBeforeRowHeaders=0;
			_CellDataElementName=null;
			_CellDataElementOutput=MatrixCellDataElementOutputEnum.Output;

			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "Corner":
						_Corner = new Corner(r, this, xNodeLoop);
						break;
					case "ColumnGroupings":
						_ColumnGroupings = new ColumnGroupings(r, this, xNodeLoop);
						break;
					case "RowGroupings":
						_RowGroupings = new RowGroupings(r, this, xNodeLoop);
						break;
					case "MatrixRows":
						_MatrixRows = new MatrixRows(r, this, xNodeLoop);
						break;
					case "MatrixColumns":
						_MatrixColumns = new MatrixColumns(r, this, xNodeLoop);
						break;
					case "LayoutDirection":
						_LayoutDirection = MatrixLayoutDirection.GetStyle(xNodeLoop.InnerText, OwnerReport.rl);
						break;
					case "GroupsBeforeRowHeaders":
						_GroupsBeforeRowHeaders = XmlUtil.Integer(xNodeLoop.InnerText);
						break;
					case "CellDataElementName":
						_CellDataElementName = xNodeLoop.InnerText;
						break;
					case "CellDataElementOutput":
						_CellDataElementOutput = MatrixCellDataElementOutput.GetStyle(xNodeLoop.InnerText, OwnerReport.rl);
						break;
					default:
						if (DataRegionElement(xNodeLoop))	// try at DataRegion level
							break;
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown Matrix element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
			}
			DataRegionFinish();			// Tidy up the DataRegion

			if (_ColumnGroupings == null)
				OwnerReport.rl.LogError(8, "Matrix element ColumnGroupings not specified for " + (this.Name == null? "'name not specified'": this.Name.Nm));
			if (_RowGroupings == null)
				OwnerReport.rl.LogError(8, "Matrix element RowGroupings not specified for " + (this.Name == null? "'name not specified'": this.Name.Nm));
			if (_MatrixRows == null)
				OwnerReport.rl.LogError(8, "Matrix element MatrixRows not specified for " + (this.Name == null? "'name not specified'": this.Name.Nm));
			if (_MatrixColumns == null)
 				OwnerReport.rl.LogError(8, "Matrix element MatrixColumns not specified for " + (this.Name == null? "'name not specified'": this.Name.Nm));

			// MatrixCells count must be the same as the number of StaticColumns.
			//   If there are no StaticColumns it must be 1
			if (OwnerReport.rl.MaxSeverity > 4)
				return;			// don't perform this check if we've already go errors
			int mc = _MatrixRows.CellCount;	// MatrixCells
			int sc = Math.Max(1, _ColumnGroupings.StaticCount);
			if (mc != sc)
			{
				OwnerReport.rl.LogError(8, "The count of MatrixCells must be 1 or equal to the number of StaticColumns if there are any.  Matrix " + (this.Name == null? "unknown.": this.Name.Nm));
			}
			// matrix columns must also equal the static count (or 1 if no static columns)
			mc = this.CountMatrixColumns;
			if (mc != sc)
			{
				OwnerReport.rl.LogError(8, "The count of MatrixColumns must be 1 or equal to the number of StaticColumns if there are any.  Matrix " + (this.Name == null? "unknown.": this.Name.Nm));
			}
			// matrix rows must also equal the static count (or 1 if no static rows)
			int mr = this.CountMatrixRows;
			int sr = Math.Max(1, _RowGroupings.StaticCount);
			if (mr != sr)
			{
				OwnerReport.rl.LogError(8, "The count of MatrixRows must be 1 or equal to the number of StaticRows if there are any.  Matrix " + (this.Name == null? "unknown.": this.Name.Nm));
			}
		}