none
p:nvPr/p:ph - What if idx is missing RRS feed

  • Question

  • Hi all;

    In a very simple 1 title slide PPTX I have 2 shapes containing:

    					<p:nvPr>
    						<p:ph type="ctrTitle"/>
    					</p:nvPr>
    ...
    
    					<p:nvPr>
    						<p:ph type="subTitle" idx="1"/>
    					</p:nvPr>
    

    Now the slideLayout.1.xml has the same matching <p:nvPr> in shapes in it. But for the case of the missing idx attribute, is that that there can be one per xml file with no idx and those marry up? or is there some other rule?

    thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Sunday, August 9, 2020 7:41 PM

Answers

  • Hi David,

    There's a lot of implicit/explicit inheritance going on when working with placeholder shapes. Basically, you need to find out what you're looking for in "type" (e.g. title, ctrTitle, subTitle, body, (and "other") etc.) and "style", (e.g. titleStyle, otherStyle, bodyStyle). The idx attribute simply looks up a placeholder in the slideLayout by number, rather than type. If idx is omitted, you'll simply look up the placeholder type in the slideLayout (in your example, you're going to look up "ctrTitle" in slideLayout) to match what you're looking for. (As a side note, this may imply that you can have two "subTitles", for example, in a slideLayout each with it's own separate idx value, but I've never seen it)

    AFAIK, "ctrTitle" and "subTitle" are placeholders that only go so far up as the slideLayout - they don't appear in the master. But for them, you'll look up "title" in the Master go gain more properties.

    Essentially, you're going to merge properties starting from slide, then slideLayout, then Master to get your final properties, for both the shape properties and it's text styles. The text styles are listed in the master under <p:txStyles/>.

    Not sure if this is helpful, but this is how I do the lookups before merging up the chain (note: VB.Net, lots of XML Literals).

    Function placeholderShape(ByVal placeholderType As String, ByVal pShp As XElement) As XElement
            Dim masterPlaceholder As XElement = Nothing
            Dim slideLayoutPlaceholder As XElement = Nothing
    
            If placeholderType = "ctrTitle" OrElse placeholderType = "subTitle" Then
    
                masterPlaceholder = master.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@type = "title").SingleOrDefault
            Else
                masterPlaceholder = master.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@type = placeholderType).SingleOrDefault
            End If
    
    
            Dim placeholderIndex As String = pShp...<p:nvPr>.<p:ph>.@idx
            If placeholderIndex IsNot Nothing Then
                slideLayoutPlaceholder = slideLayout.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@type = placeholderIndex).SingleOrDefault
            Else
                slideLayoutPlaceholder = slideLayout.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@type = placeholderType).SingleOrDefault
            End If
    
            If slideLayoutPlaceholder Is Nothing Then
                slideLayoutPlaceholder = slideLayout.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@idx = pShp...<p:ph>.@idx).FirstOrDefault
            End If
    
            'Merge code here
    
            Return mergedShape
    
        End Function

    Todd

    • Marked as answer by DavidThi808 Friday, August 14, 2020 2:36 PM
    Thursday, August 13, 2020 10:55 PM

All replies

  • Hi David,

    Thank you for your question.  An engineer will contact you soon.


    Bryan S. Burgin Senior Escalation Engineer Microsoft Protocol Open Specifications Team

    Sunday, August 9, 2020 8:50 PM
    Moderator
  • Hi David

    I will be looking to find an answer for you.


    HungChun Yu (MSFT)

    Tuesday, August 11, 2020 12:59 AM
  • Hi Dave

    idx. where no idx attribute appeared, indicating the singleton title placeholder. 

    Hopefully, this answered your question.



    HungChun Yu (MSFT)

    Tuesday, August 11, 2020 9:41 PM
  • Hi Yu;

    What do you mean by singleton title placeholder? That means just one, but that doesn't tell me how it maps or when it is referenced.

    ??? - thanks - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Wednesday, August 12, 2020 12:34 AM
  • Hi Dave

    It means placeholder for the title does not have IDX associated with.


    HungChun Yu (MSFT)

    Wednesday, August 12, 2020 1:24 AM
  • Hi Yu;

    Ok, but that doesn't tell me how it is used. When/where/how is this placeholder/singleton idx used?

    ??? - dave


    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Wednesday, August 12, 2020 3:46 PM
  • Hi David,

    There's a lot of implicit/explicit inheritance going on when working with placeholder shapes. Basically, you need to find out what you're looking for in "type" (e.g. title, ctrTitle, subTitle, body, (and "other") etc.) and "style", (e.g. titleStyle, otherStyle, bodyStyle). The idx attribute simply looks up a placeholder in the slideLayout by number, rather than type. If idx is omitted, you'll simply look up the placeholder type in the slideLayout (in your example, you're going to look up "ctrTitle" in slideLayout) to match what you're looking for. (As a side note, this may imply that you can have two "subTitles", for example, in a slideLayout each with it's own separate idx value, but I've never seen it)

    AFAIK, "ctrTitle" and "subTitle" are placeholders that only go so far up as the slideLayout - they don't appear in the master. But for them, you'll look up "title" in the Master go gain more properties.

    Essentially, you're going to merge properties starting from slide, then slideLayout, then Master to get your final properties, for both the shape properties and it's text styles. The text styles are listed in the master under <p:txStyles/>.

    Not sure if this is helpful, but this is how I do the lookups before merging up the chain (note: VB.Net, lots of XML Literals).

    Function placeholderShape(ByVal placeholderType As String, ByVal pShp As XElement) As XElement
            Dim masterPlaceholder As XElement = Nothing
            Dim slideLayoutPlaceholder As XElement = Nothing
    
            If placeholderType = "ctrTitle" OrElse placeholderType = "subTitle" Then
    
                masterPlaceholder = master.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@type = "title").SingleOrDefault
            Else
                masterPlaceholder = master.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@type = placeholderType).SingleOrDefault
            End If
    
    
            Dim placeholderIndex As String = pShp...<p:nvPr>.<p:ph>.@idx
            If placeholderIndex IsNot Nothing Then
                slideLayoutPlaceholder = slideLayout.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@type = placeholderIndex).SingleOrDefault
            Else
                slideLayoutPlaceholder = slideLayout.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@type = placeholderType).SingleOrDefault
            End If
    
            If slideLayoutPlaceholder Is Nothing Then
                slideLayoutPlaceholder = slideLayout.<p:cSld>.<p:spTree>.Elements.Where(Function(c) c...<p:ph>.@idx = pShp...<p:ph>.@idx).FirstOrDefault
            End If
    
            'Merge code here
    
            Return mergedShape
    
        End Function

    Todd

    • Marked as answer by DavidThi808 Friday, August 14, 2020 2:36 PM
    Thursday, August 13, 2020 10:55 PM
  • thanks you!

    What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing

    Friday, August 14, 2020 2:36 PM