private ICollection GetRestrictedShapes(PowerPoint.Presentation presentation) { IDictionary rsTable = this.GetRestrictedTable(presentation); // Check correctness of the cache. bool correct = true; ArrayList /* of ShapeKey */ keysToDelete = new ArrayList(); foreach (PPTLibrary.ShapeKey key in rsTable.Keys) { PowerPoint.Shape shape = (PowerPoint.Shape)rsTable[key]; PPTLibrary.ShapeKey oldKey = key; try { oldKey = new PPTLibrary.ShapeKey(shape, this.myPPT.GetSlideFromShape(shape).SlideID); } catch (System.Runtime.InteropServices.COMException) { // Shape does not exist, delete it from the cache. keysToDelete.Add(key); continue; } if (!key.Equals(oldKey) || !this.IsRestricted(shape)) { correct = false; break; } } if (!correct) { this.RebuildCache(presentation); rsTable = this.GetRestrictedTable(presentation); } else { foreach (PPTLibrary.ShapeKey key in keysToDelete) { rsTable.Remove(key); } } ArrayList shapes = new ArrayList(); // No need to test if objects exist since non-existant objects have // just been weeded out. foreach (PowerPoint.Shape shape in rsTable.Values) { shapes.Add(shape); } return(shapes); }
private void RecacheShapeRestricted(PowerPoint.Shape shape) { PowerPoint.Slide slide = this.myPPT.GetSlideFromShape(shape); if (slide == null) { throw new Exception("Not handling shapes on Slide Masters."); } PowerPoint.Presentation presentation = this.myPPT.GetPresentationFromSlide(slide); PPTLibrary.ShapeKey key = new PPTLibrary.ShapeKey(shape, slide.SlideID); IDictionary rsTable = this.GetRestrictedTable(presentation); PowerPoint.Shape oldShape = null; PPTLibrary.ShapeKey oldKey = key; if (rsTable.Contains(key)) { oldShape = (PowerPoint.Shape)rsTable[key]; try { oldKey = new PPTLibrary.ShapeKey(oldShape, this.myPPT.GetSlideFromShape(oldShape).SlideID); } catch (System.Runtime.InteropServices.COMException) { // Old shape does not exist. Ignore it. } } if (oldShape != null && !oldKey.Equals(key)) { this.RebuildCache(presentation); } else if (this.IsRestricted(shape)) { rsTable[key] = shape; } else { rsTable.Remove(key); } }
private void RecacheShapeRestricted(PowerPoint.Shape shape) { PowerPoint.Slide slide = this.myPPT.GetSlideFromShape(shape); if (slide == null) throw new Exception("Not handling shapes on Slide Masters."); PowerPoint.Presentation presentation = this.myPPT.GetPresentationFromSlide(slide); PPTLibrary.ShapeKey key = new PPTLibrary.ShapeKey(shape); IDictionary rsTable = this.GetRestrictedTable(presentation); PowerPoint.Shape oldShape = null; PPTLibrary.ShapeKey oldKey = key; if (rsTable.Contains(key)) { oldShape = (PowerPoint.Shape)rsTable[key]; try { oldKey = new PPTLibrary.ShapeKey(oldShape); } catch (System.Runtime.InteropServices.COMException) { // Old shape does not exist. Ignore it. } } if (oldShape != null && !oldKey.Equals(key)) this.RebuildCache(presentation); else if (this.IsRestricted(shape)) rsTable[key] = shape; else rsTable.Remove(key); }
private ICollection GetRestrictedShapes(PowerPoint.Presentation presentation) { IDictionary rsTable = this.GetRestrictedTable(presentation); // Check correctness of the cache. bool correct = true; ArrayList /* of ShapeKey */ keysToDelete = new ArrayList(); foreach (PPTLibrary.ShapeKey key in rsTable.Keys) { PowerPoint.Shape shape = (PowerPoint.Shape)rsTable[key]; PPTLibrary.ShapeKey oldKey = key; try { oldKey = new PPTLibrary.ShapeKey(shape); } catch (System.Runtime.InteropServices.COMException) { // Shape does not exist, delete it from the cache. keysToDelete.Add(key); continue; } if (!key.Equals(oldKey) || !this.IsRestricted(shape)) { correct = false; break; } } if (!correct) { this.RebuildCache(presentation); rsTable = this.GetRestrictedTable(presentation); } else foreach (PPTLibrary.ShapeKey key in keysToDelete) rsTable.Remove(key); ArrayList shapes = new ArrayList(); // No need to test if objects exist since non-existant objects have // just been weeded out. foreach (PowerPoint.Shape shape in rsTable.Values) shapes.Add(shape); return shapes; }