private short[] BuildSRCStream(VA.Drawing.DrawingSurface surface) { if (surface.Shape == null) { string msg = string.Format("Shape must be set in surface not page or master"); throw new VA.AutomationException(msg); } this.PerShapeSectionInfo = new List <List <SectionQueryInfo> >(); if (this.Sections.Count > 0) { var section_infos = new List <SectionQueryInfo>(); foreach (var sec in this.Sections) { // Figure out which rows to query int num_rows = surface.Shape.RowCount[(short)sec.SectionIndex]; var section_info = new SectionQueryInfo(sec, surface.Shape.ID16, num_rows); section_infos.Add(section_info); } this.PerShapeSectionInfo.Add(section_infos); } int total = this.GetTotalCellCount(1); var stream_builder = new StreamBuilder(3, total); foreach (var col in this.Columns) { var src = col.SRC; stream_builder.Add(src.Section, src.Row, src.Cell); } // And then the sections if any exist if (this.PerShapeSectionInfo.Count > 0) { var data_for_shape = this.PerShapeSectionInfo[0]; foreach (var section in data_for_shape) { foreach (int rowindex in section.RowIndexes) { foreach (var col in section.SectionQuery.Columns) { stream_builder.Add((short)section.SectionQuery.SectionIndex, (short)rowindex, col.SRC.Cell); } } } } if (stream_builder.ChunksWrittenCount != total) { string msg = string.Format("Expected {0} Checks to be written. Actual = {1}", total, stream_builder.ChunksWrittenCount); throw new VA.AutomationException(msg); } return(stream_builder.Stream); }
private void CalculatePerShapeInfo(VA.Drawing.DrawingSurface surface, IList <int> shapeids) { this.PerShapeSectionInfo = new List <List <SectionQueryInfo> >(); if (this.Sections.Count < 1) { return; } var pageshapes = surface.Shapes; // For each shapeid fetch the corresponding shape from the page // this is needed because we'll need to get per shape section information var shapes = new List <IVisio.Shape>(shapeids.Count); foreach (int shapeid in shapeids) { var shape = pageshapes.ItemFromID16[(short)shapeid]; shapes.Add(shape); } for (int n = 0; n < shapeids.Count; n++) { var shapeid = (short)shapeids[n]; var shape = shapes[n]; var section_infos = new List <SectionQueryInfo>(this.Sections.Count); foreach (var sec in this.Sections) { int num_rows = GetNumRowsForSection(shape, sec); var section_info = new SectionQueryInfo(sec, shapeid, num_rows); section_infos.Add(section_info); } this.PerShapeSectionInfo.Add(section_infos); } if (shapeids.Count != this.PerShapeSectionInfo.Count) { string msg = string.Format("Expected {0} PerShape structs. Actual = {1}", shapeids.Count, this.PerShapeSectionInfo.Count); throw new VA.AutomationException(msg); } }