private short[] _build_src_stream(ShapeSheetSurface surface) { if (surface.Target.Shape == null) { string msg = "Target must be Shape not Page or Master"; throw new System.ArgumentException(msg); } this._subquery_shape_info = new List <List <SubQuerySectionDetails> >(); if (this.SubQueries.Count > 0) { var section_infos = new List <SubQuerySectionDetails>(); foreach (var sec in this.SubQueries) { // Figure out which rows to query int num_rows = surface.Target.Shape.RowCount[(short)sec.SectionIndex]; var section_info = new SubQuerySectionDetails(sec, num_rows); section_infos.Add(section_info); } this._subquery_shape_info.Add(section_infos); } int total = this._get_total_cell_count(1); var stream_builder = new StreamBuilderSRC(total); foreach (var col in this.Cells) { var src = col.SRC; stream_builder.Add(src.Section, src.Row, src.Cell); } // And then the sections if any exist if (this._subquery_shape_info.Count > 0) { var data_for_shape = this._subquery_shape_info[0]; foreach (var section in data_for_shape) { foreach (int rowindex in section.RowIndexes) { foreach (var col in section.SubQuery.Columns) { stream_builder.Add((short)section.SubQuery.SectionIndex, (short)rowindex, col.CellIndex); } } } } if (!stream_builder.IsFull) { string msg = string.Format("StreamBuilder is not full"); throw new InternalAssertionException(msg); } return(stream_builder.Stream); }
private void _calcualte_per_shape_info(ShapeSheetSurface surface, IList <int> shapeids) { this._subquery_shape_info = new List <List <SubQuerySectionDetails> >(); if (this.SubQueries.Count < 1) { return; } var pageshapes = surface.Target.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 shape = shapes[n]; var section_infos = new List <SubQuerySectionDetails>(this.SubQueries.Count); foreach (var sec in this.SubQueries) { int num_rows = _get_num_rows_for_section(shape, sec); var section_info = new SubQuerySectionDetails(sec, num_rows); section_infos.Add(section_info); } this._subquery_shape_info.Add(section_infos); } if (shapeids.Count != this._subquery_shape_info.Count) { string msg = string.Format("Expected {0} PerShape structs. Actual = {1}", shapeids.Count, this._subquery_shape_info.Count); throw new InternalAssertionException(msg); } }