Welcome to OpenXML Developer Sign in | Join | Help

How does powerpoint link txbody formatting from the slide to a slidelayout/master

Last post 08-05-2008, 7:24 PM by adamm. 8 replies.
Sort Posts: Previous Next
  •  06-17-2008, 3:48 PM 3366

    How does powerpoint link txbody formatting from the slide to a slidelayout/master

    So i am currently developing a parser that reads in pptx files, does some internal processing, and then outputs in various other formats (primarily .pdf, and .pptx), and to do this correctly i need to get the right formatting information for a given shape and more specifically the textbody within a shape. The current example i am working on is very simple, its just one slide with a title and a subtitle, no themes or backgrounds.

    I am able to get the text, and the positioning info by linking to the correct slidelayout using the <p:ph> tag. From what i have gathered it looks like the formatting info is in <a:lstStyle> and more specifically the LvLpPr's. In the OOXML part 4 ML reference it says that a paragraph should reference the level property it is using by including an attribute   'lvl=[0-8]'  . But none of the text bodies use this attribute. And in the slide layouts there are definitions for all 9 levels. So im wondering how does the parser know which level property to use for a given paragraph. Below ive included sections from the slide, and corresponding layout file. Ive 'closed' some of the non pertinent sections of xml.

    The specification does say something about precedence, and that the lvlpPr's should be constructed in order from lowest to highest level. Does that mean that unless otherwise specified it will take the properties from level 1 ?

    slide1.xml

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
        xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
        xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
        <p:cSld>
            <p:spTree>
                <p:nvGrpSpPr>
                </p:nvGrpSpPr>
                <p:grpSpPr>
                </p:grpSpPr>
                <p:sp>
                </p:sp>
                <p:sp>
                    <p:nvSpPr>
                        <p:cNvPr id="3" name="Subtitle 2"/>
                        <p:cNvSpPr>
                            <a:spLocks noGrp="1"/>
                        </p:cNvSpPr>
                        <p:nvPr>
                            <p:ph type="subTitle" idx="1"/>
                        </p:nvPr>
                    </p:nvSpPr>
                    <p:spPr/>
                    <p:txBody>
                        <a:bodyPr/>
                        <a:lstStyle/>
                        <a:p>
                            <a:r>
                                <a:rPr lang="en-US" smtClean="0"/>
                                <a:t>Subtitle</a:t>
                            </a:r>
                            <a:endParaRPr lang="en-US"/>
                        </a:p>
                    </p:txBody>
                </p:sp>
            </p:spTree>
        </p:cSld>
        <p:clrMapOvr>
            <a:masterClrMapping/>
        </p:clrMapOvr>
    </p:sld>


    slideLayout1.xml

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
        xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
        xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" type="title" preserve="1">
        <p:cSld name="Title Slide">
            <p:spTree>
                <p:nvGrpSpPr>
                </p:nvGrpSpPr>
                <p:grpSpPr>
                </p:grpSpPr>
                <p:sp>
                </p:sp>
                <p:sp>
                    <p:nvSpPr>
                        <p:cNvPr id="3" name="Subtitle 2"/>
                        <p:cNvSpPr>
                            <a:spLocks noGrp="1"/>
                        </p:cNvSpPr>
                        <p:nvPr>
                            <p:ph type="subTitle" idx="1"/>
                        </p:nvPr>
                    </p:nvSpPr>
                    <p:spPr>
                        <a:xfrm>
                            <a:off x="1371600" y="3886200"/>
                            <a:ext cx="6400800" cy="1752600"/>
                        </a:xfrm>
                    </p:spPr>
                    <p:txBody>
                        <a:bodyPr/>
                        <a:lstStyle>
                            <a:lvl1pPr marL="0" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl1pPr>
                            <a:lvl2pPr marL="457200" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl2pPr>
                            <a:lvl3pPr marL="914400" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl3pPr>
                            <a:lvl4pPr marL="1371600" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl4pPr>
                            <a:lvl5pPr marL="1828800" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl5pPr>
                            <a:lvl6pPr marL="2286000" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl6pPr>
                            <a:lvl7pPr marL="2743200" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl7pPr>
                            <a:lvl8pPr marL="3200400" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl8pPr>
                            <a:lvl9pPr marL="3657600" indent="0" algn="ctr">
                                <a:buNone/>
                                <a:defRPr>
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:tint val="75000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:defRPr>
                            </a:lvl9pPr>
                        </a:lstStyle>
                        <a:p>
                            <a:r>
                                <a:rPr lang="en-US" smtClean="0"/>
                                <a:t>Click to edit Master subtitle style</a:t>
                            </a:r>
                            <a:endParaRPr lang="en-US"/>
                        </a:p>
                    </p:txBody>
                </p:sp>
                <p:sp>
                </p:sp>
                <p:sp>
                </p:sp>
                <p:sp>
                </p:sp>
            </p:spTree>
        </p:cSld>
        <p:clrMapOvr>
            <a:masterClrMapping/>
        </p:clrMapOvr>
    </p:sldLayout>

    Thanks in Advance
    -Adam





  •  06-18-2008, 2:01 AM 3369 in reply to 3366

    Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master

    Hi,
    I guess,In your case from p:ph you are getting the information about your placeholders
    if it is subTitle or ctrTitle and from slidelayout.xml you are getting information
    about that.And the formatting information(colour,font size etc)will be in the
    particular run property.(a:rPr) in slide1.xml


    But if you don't have p:ph then in slide1.xml in the particular p:sp
    you have to search for lvl attribute and according to the value you have
    to go to slidelayout and search for the particular level.

    Mallika

  •  06-18-2008, 12:57 PM 3370 in reply to 3369

    Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master

    Thanks for the quick response, but im still confused on how it decides what formatting to use because in the xml that i posted, which is from a valid pptx file that was created in powerpoint, there is no lvl attribute in either the slide.xml file or the slideLayout file. And there isnt any meaningful info in the rPr tag, does powerpoint just default to some value if you dont specify ?
  •  06-18-2008, 7:16 PM 3371 in reply to 3370

    Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master

    Small update, luckily where i work we have an MSDN account, so this question has been sent to microsoft and i should have an answer by tomorrow, friday at the latest. But while im waiting on this information still feel free to comment if you have any ideas.
  •  06-18-2008, 11:25 PM 3372 in reply to 3371

    Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master

    Hi,

    I guess if you don't specify any formatting(change the font size,color etc) for your text
    in the presentation document,it will take the default value and there will be no information
    in the rPr tag.Change the formatting of you text and you can see the formatting information
    in the corresponding rPr tag.

    Mallika

  •  06-20-2008, 3:38 PM 3378 in reply to 3372

    Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master

    MallikaBiswas:

    Hi,

    I guess if you don't specify any formatting(change the font size,color etc) for your text
    in the presentation document,it will take the default value and there will be no information
    in the rPr tag.Change the formatting of you text and you can see the formatting information
    in the corresponding rPr tag.

    Mallika



    Where is this default located, i know that the slideMaster file has defaults but they are qualified as LevelRunProperties. So to get to these defaults you still have to specify a lvl attribute in your rPr, and assuming you dont specify the levelRPr's in the slide or layout then it defaults to whats in the master.

    I did get a reply from msdn, ill post it below, maybe im not interpreting their response correctly, but it doesnt really answer my question, so ive sent a followup question and i should have a response on monday.

    For the second question, the "Title Slide" layout used in the example does

    not have a placeholder with bullet level text (p:txBody) defined for it. 

    It has a:lstStyle defined.  You can see the difference in the definitions

    of slideLayout1.xml ("Title Slide") and slideLayout2.xml ("Title and

    Content"). 

     

    1. slideLayout1.xml

                <p:sp>

                    <p:nvSpPr>

                        <p:cNvPr id="3" name="Subtitle 2"/>

                        <p:cNvSpPr>

                            <a:spLocks noGrp="1"/>

                        </p:cNvSpPr>

                        <p:nvPr>

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

                        </p:nvPr>

                    </p:nvSpPr>

                    <p:spPr>

                        <a:xfrm>

                            <a:off x="1371600" y="3886200"/>

                            <a:ext cx="6400800" cy="1752600"/>

                        </a:xfrm>

                    </p:spPr>

                    <p:txBody>

                        <a:bodyPr/>

                        <a:lstStyle>

                            <a:lvl1pPr marL="0" indent="0" algn="ctr">

                                <a:buNone/>

                                <a:defRPr>

                                    <a:solidFill>

                                        <a:schemeClr val="tx1">

                                            <a:tint val="75000"/>

                                        </a:schemeClr>

                                    </a:solidFill>

                                </a:defRPr>

                            </a:lvl1pPr>

                            <a:lvl2pPr marL="457200" indent="0" algn="ctr">

                                <a:buNone/>

                                <a:defRPr>

                                    <a:solidFill>

                                        <a:schemeClr val="tx1">

                                            <a:tint val="75000"/>

                                        </a:schemeClr>

                                    </a:solidFill>

                                </a:defRPr>

                            </a:lvl2pPr>

    <snip - continues through a:lvl9pPr>

                        </a:lstStyle>

                        <a:p>

                            <a:r>

                                <a:rPr lang="en-US" smtClean="0"/>

                                <a:t>Click to edit Master subtitle style</a:t>

                            </a:r>

                            <a:endParaRPr lang="en-US"/>

                        </a:p>

                    </p:txBody>

                </p:sp>

     

    2. slideLayout2.xml

                <p:sp>

                    <p:nvSpPr>

                        <p:cNvPr id="3" name="Content Placeholder 2"/>

                        <p:cNvSpPr>

                            <a:spLocks noGrp="1"/>

                        </p:cNvSpPr>

                        <p:nvPr>

                            <p:ph idx="1"/>

                        </p:nvPr>

                    </p:nvSpPr>

                    <p:spPr/>

                    <p:txBody>

                        <a:bodyPr/>

                        <a:lstStyle/>

                        <a:p>

                            <a:pPr lvl="0"/>

                            <a:r>

                                <a:rPr lang="en-US" smtClean="0"/>

                                <a:t>Click to edit Master text styles</a:t>

                            </a:r>

                        </a:p>

                        <a:p>

                            <a:pPr lvl="1"/>

                            <a:r>

                                <a:rPr lang="en-US" smtClean="0"/>

                                <a:t>Second level</a:t>

                            </a:r>

                        </a:p>

                        <a:p>

                            <a:pPr lvl="2"/>

                            <a:r>

                                <a:rPr lang="en-US" smtClean="0"/>

                                <a:t>Third level</a:t>

                            </a:r>

                        </a:p>

    <snip - continues through a:pPr lvl="5">

                    </p:txBody>

                </p:sp>


  •  06-26-2008, 1:02 PM 3409 in reply to 3378

    Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master

    Ok, so i think ive got this figured out. Basically if no formatting is specified in the layout or the slide, it goes to the master, and if its a 'title' or 'ctrTitle' shape it uses the formatting in <p:titleStyle> and it defaults to lvl1. Same goes for text that is not in a title shape, for these it defaults to the formatting in <p:bodyStyle> and if no lvl is specified it defaults to lvl1. And another piece of advice, although not pertinent to my original question, there is another txStyle in the slideMaster, <p:otherStyle> which is used for text in a shape that is not in a txBody.

    This is what MSDN sent me.

    Sorry for letting you wait. I have discussed it with the powerpoint team.
    They told me the bullet style/type is defined in slideMaster1.xml:

    <a:lvl1pPr marL="342900" indent="-342900" algn="l" defTabSz="914400"
    rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
    - <a:spcBef>
      <a:spcPct val="20000" />
      </a:spcBef>
      <a:buFont typeface="Arial" pitchFamily="34" charset="0" />
      <a:buChar char="o" />
    - <a:defRPr sz="3200" kern="1200">
    - <a:solidFill>
      <a:schemeClr val="tx1" />
      </a:solidFill>
      <a:latin typeface="+mn-lt" />
      <a:ea typeface="+mn-ea" />
      <a:cs typeface="+mn-cs" />
      </a:defRPr>
      </a:lvl1pPr>

    And to disable the bullet in the slide, we add this in slide2.xml
    - <a:pPr>
      <a:buNone />
      </a:pPr>

    For example:
    <a:p>
    - <a:pPr>
      <a:buNone />
      </a:pPr>
    - <a:r>
      <a:rPr lang="en-US" dirty="0" smtClean="0" />
      <a:t>Bullet 1</a:t>
      </a:r>
      </a:p>

    Of course, the bullet style can also be overridden in the slide2.xml, for
    example:

    <a:p>
    - <a:pPr>
      <a:buFont typeface="Courier New" pitchFamily="49" charset="0" />
      <a:buChar char="o" />
      </a:pPr>
    - <a:r>
      <a:rPr lang="en-US" dirty="0" smtClean="0" />
      <a:t>Bullet 1</a:t>
      </a:r>
      </a:p>
    - <a:p>

    Regarding the size of the text for a given shape, it is also defined in
    slideMaster1.xml when nowhere else overrides it. For example, in the
    slide1.xml, the title's font size is 44. It's defined in slideMaster1.xml:
    a:defRPr sz="4400"

    <p:titleStyle>
    - <a:lvl1pPr algn="ctr" defTabSz="914400" rtl="0" eaLnBrk="1"
    latinLnBrk="0" hangingPunct="1">
    - <a:spcBef>
      <a:spcPct val="0" />
      </a:spcBef>
      <a:buNone />
    - <a:defRPr sz="4400" kern="1200">
    - <a:solidFill>
      <a:schemeClr val="tx1" />
      </a:solidFill>
      <a:latin typeface="+mj-lt" />
      <a:ea typeface="+mj-ea" />
      <a:cs typeface="+mj-cs" />
      </a:defRPr>
      </a:lvl1pPr>
      </p:titleStyle>

    The font name uses the major font in theme1.xml.


    Also, if none of the above helps resolve the formatting it defaults to the textstyles in the presentation.xml file under <p:defaultTextStyle>. For example if you have a shape that doesnt use any placeholders, and therefore cant determine its type, and it also doesnt specify the formatting, youll wanna goto the presentation.xml file to get the formatting, which always defaults to lvl1 unless another level is specified.

  •  08-02-2008, 11:04 PM 3527 in reply to 3409

    Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master

    I'm still a little unclear about the exact process for resolving text properties.


    We have:

    - rPr properties on the run level (font, color, size, etc)

    - pPr properties on the paragraph level (bullets, etc)

    - defPPr, lvl1pPr, etc in lstStyle in the sp tag

    - possibly the same above 4 things repeated on the placeholder shape in the layout and/or master

    - defPPr, lvl1pPr, etc in the master's bodyStyle, titleStyle, and otherStyle

    - and finally again defPPr, lvl1pPr, etc in the presentation's defaultTextStyle


    And we also have font stuff in

    - fontRef in the the styles tag of the sp tag

    - fontScheme in the theme


    Am I missing anything?

    What is the exact process for finding the formatting of a run of text?
  •  08-05-2008, 7:24 PM 3534 in reply to 3527

    Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master

    Hi tlrobinson,
    first off im gonna say that so far the order i came up with in this post has worked for me about 90% of the time. And your post is a good place to start if you want to determine the order, but youll need to remove the line "possibly the same 4 above in layout" because you dont want to be using the rPr, pPr, stuff in the layout. Only use the defrPr/pPr, bodyPr, lstStyle stuff. Also from my experience dont use anything in the csld portion of the master, only focus on the stuff in txStyles.

    Also if a shape doesnt have a placeholder, and you cant find what you need within the slide.xml file, go directly to the presentation, because the layout cant help you without a ph, and the master wont help unless you have a ph that specifies a type.

    But even when i follow that logic im getting unexpected behavior.

    SO, one of the things im going to do in the next couple of days is to draw up a Deterministic Machine (flow diagram) with all of the assumptions i have made thus far mainly based from trial and error, and send this to MSDN. Usually it takes a few replies back and forth to pin them down on the issue at hand, so hopefully in a week or so i will have a more definitive process to post for everyone to see.

    Since i have been dealing with this problem for the past 2 months, and seen alot of the sneaky things powerpoint does with respect to where it places formatting, feel free to post specific examples and i will help you find the formatting. if your gonna do this, you could PM me and email me the entire file, or post up txt snippets here. if you do the latter make sure you post the entire shape from the slide, the entire shape from the layout it links to (if it has a ph), the txStyles info from the master ( if it has a ph) and then finally the default stuff from the presentation.

    also if anyone else thinks they know how to determine the formatting please chime in.
View as RSS news feed in XML