コード例 #1
0
        private short[] BuildSRCStream(ShapeSheetSurface surface)
        {
            if (surface.Target.Shape == null)
            {
                string msg = "Shape must be set in surface not page or master";
                throw new AutomationException(msg);
            }

            this._per_shape_section_info = new List <List <SectionColumnDetails> >();

            if (this.SectionColumns.Count > 0)
            {
                var section_infos = new List <SectionColumnDetails>();
                foreach (var sec in this.SectionColumns)
                {
                    // Figure out which rows to query
                    int num_rows     = surface.Target.Shape.RowCount[(short)sec.SectionIndex];
                    var section_info = new SectionColumnDetails(sec, surface.Target.Shape.ID16, num_rows);
                    section_infos.Add(section_info);
                }
                this._per_shape_section_info.Add(section_infos);
            }

            int total = this.GetTotalCellCount(1);

            var stream_builder = new StreamBuilder(3, total);

            foreach (var col in this.CellColumns)
            {
                var src = col.SRC;
                stream_builder.Add(src.Section, src.Row, src.Cell);
            }

            // And then the sections if any exist
            if (this._per_shape_section_info.Count > 0)
            {
                var data_for_shape = this._per_shape_section_info[0];
                foreach (var section in data_for_shape)
                {
                    foreach (int rowindex in section.RowIndexes)
                    {
                        foreach (var col in section.SectionColumn.CellColumns)
                        {
                            stream_builder.Add((short)section.SectionColumn.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 AutomationException(msg);
            }

            return(stream_builder.Stream);
        }
コード例 #2
0
        private void CalculatePerShapeInfo(ShapeSheetSurface surface, IList <int> shapeids)
        {
            this._per_shape_section_info = new List <List <SectionColumnDetails> >();

            if (this.SectionColumns.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 <SectionColumnDetails>(this.SectionColumns.Count);
                foreach (var sec in this.SectionColumns)
                {
                    int num_rows     = CellQuery.GetNumRowsForSection(shape, sec);
                    var section_info = new SectionColumnDetails(sec, shapeid, num_rows);
                    section_infos.Add(section_info);
                }
                this._per_shape_section_info.Add(section_infos);
            }

            if (shapeids.Count != this._per_shape_section_info.Count)
            {
                string msg = String.Format("Expected {0} PerShape structs. Actual = {1}", shapeids.Count,
                                           this._per_shape_section_info.Count);
                throw new AutomationException(msg);
            }
        }