I wrote a PowerPoint 2010 addin that allows the user to create pairs of shapes. These pairs are synchronized (e.g. position, color, text…). The pairs are stored as objects of the following class:
class Pair
{
Shape LeftShape { get; set; }
Shape RightShape { get; set; }
}
If a Shape is modified, where there is a pair that contains the Shape, the other shape is updated.
It is possible to define pairs on the master layout. The synchronization works on the master. If the pair is made of two placeholders and I create a slide based on the master, of course, the new shapes are not synchronized. Is there a way to find the shape’s master equivalent and vice versa? The algorithm then would be:
s1's modification is recognized
if s1 is a placeholder
find s1's equivalent in master -> m1
look up the partner of m1 -> m2
find the shape in the current slide that is based on m2 -> s2
update s2
I had a look at the Name and Idproperties of the new shapes. But they differ from the properties of the master shapes.
Btw, is there a nice way to determine, if a shape is a placeholder? My current approach is to query the PlaceholderFormat which throws an exception, if the shape is no placeholder. But this is definitely not a good way.
I’m curious: how?
The Shape’s .Type property will indicate whether it’s a placeholder or some other shape type.
If the shape is msoPlaceholder ( 14 ) it’s a placeholder. In that case, its .PlaceholderFormat.Type property tells you which type of placeholder it is, and if it’s a type that can hold more than one type of content, its .PlaceholderFormat.ContainedType tells you whether it contains a chart, object, picture, etc.
You might instead consider using tags to indicate pairs. To “tag” the members of a shape range, using the currently selected shapes as an example range:
To return the other half of one of your pairs, write a simple function that looks at each shape on the current slide and checks to see if its MagicPair tag value matches that of the first shape.