wordpress hit counter
Re: How does powerpoint link txbody formatting from the slide to a slidelayout/master - PresentationML - Formats - OpenXML Developer

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

Formats

Discussions about working with different Open XML Formats

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

  • rated by 0 users
  • This post has 11 Replies |
  • 4 Followers
  • 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





  • 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

  • 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 ?
  • 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.
  • 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

  • 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>


  • 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.

  • 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?
  • 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.
  • Hi Adamm,

    Not sure whether you get this mesage since it's after long time back.

    Did you resolve the problem. I am in exactly same situation, I am too writing a parser, and stuck with same issue for past weeks. So, its helps if you could let me know any resolution that you find.

    Thank in advance,

    Vins

  • Just in case these forums do get looked at.

    I have exactly the same problem = trying to construct a deterministic process for resolving formatting defaults.

    I am particularly confused as to when the defPPR in a lstStyle gets used - as in all cases mentioned it seems the lvl1pPR supplies the defaults.

  • I found a very helpful page today (published on Feb 11 2013) listing many corrections and explanations of OOXML behaviour in MS Office.

    msdn.microsoft.com/.../ee908652(v=office.12).aspx.

    This lists 1873 pages of corrections to the OOXML specification - many of which directly contradict the specification.

    The main implication of these pages seems to be that the OOXML specification cannot be relied on to determine the behaviour of a document when used by MS Office.

    If you find a discrepancy it may well be that Office is not obeying the specification - or is using it's own defaults.

    And if you rely on the specification to write conforming documents to be read by MS Office you may get surprising behaviour.

    After spending over a month trying to determine default formatting values using the specification I am on the point of giving up as it seems that whatever I deduce may fail in future when implmenting a specific case that I have not compared to MS Office behaviour.

    It seems one of the main purposes of the standard = to enable documents to be read in 10+ years when all related software has perished = is now invalid.

    We will have to revert to scribing documents on parchment to ensure anything is readable in 1000 years.

Page 1 of 1 (12 items)