Get shape's master slide shape

Hi,

Is it possible to get the shape’s master slide original shape somehow?
I cannot do it by name since it is different in my case.
E.g.
I have a shape with name “My shape 1” in a master slide with a specific slide and position.
I have in the regular slide this shape with a name ''My completed shape". If I move this shape somewhere in the slide and click reset in Powerpoint - it will restore styles and position for this ''My completed shape". So it definitely can identify it’s master slide shape. Is it possible to get it in Aspose(.net)?

Thank you

@LostAndFound,

Can you please share source presentation so that we may further investigate to help you out.

sure, here it is.
You can find a shape with a name “My shape 1” on a Master slide of first slide.
So when on the first slide of presentation I change the position of the only element (Title …) and then click Reset - it restores the position to it’s Master slide shape ‘My shape 1’. So it has some connection, however names are different. So I’m wondering how can I get that Maste Slide shape by knowing only the shape ‘Title…’

test_example.zip (673.1 KB)

@LostAndFound,

When the shape is inherited from master slide it’s Placeholder is not null. Please try using following sample code to identify such shapes.

public static void TestMasterShape()
{
    String path = @"C:\Aspose Data\";
    Presentation pres = new Presentation(path + "test_example.pptx");
    foreach (ISlide slide in pres.Slides)
    {
        foreach (IShape shape in slide.Shapes)
        {
            if (shape.Placeholder != null)
            {
                //It means shape is inherited from master

                PlaceholderType type = shape.Placeholder.Type;
            }
        }
    }
}

Is it possible to get master slide shape from this placeholder, because I don’t see any connection and I need to get the shape itself from a master slide. I see some Index, but I don’t know to what it refers.

Can you help with that?

@LostAndFound,

You need to access the master slide and traverse through its shapes collection for accessing the desired shape. I hope the shared information will be helpful.

Ok, let’s check the example above.

Can you please provide a way to find the master slide shape knowing the shape in my slide?
They have different names in my example, so how can I match them?
Shape placeholder is not having any connections to master slide shape as I see

Thank you

@LostAndFound,

Please try using following modified code sample on your end.

public static void TestMasterShape()
{
    String path = @"C:\Aspose Data\";
    Presentation pres = new Presentation(path + "test_example.pptx");
    foreach (ISlide slide in pres.Slides)
    {
        foreach (IShape shape in slide.Shapes)
        {
            if (shape.Placeholder != null)
            {
                //It means shape is inherited from master

                PlaceholderType type = shape.Placeholder.Type;


               //Checking layout slide
                ILayoutSlide layout = slide.LayoutSlide;
                foreach (IShape lShape in layout.Shapes)
                {
                    if (lShape.Placeholder.Type == shape.Placeholder.Type &&
                        lShape.Placeholder.Size == shape.Placeholder.Size &&
                        lShape.Placeholder.Orientation == shape.Placeholder.Orientation)
                    {
                        String s = "matching shape found";
                    }

                }

            }
        }
    }
}
1 Like

Thank you. It solves my needs

@LostAndFound,

You are very welcome.