codegirl.blog(this);

Christina A. Odom — Developing SharePoint Solutions

More additions on the docx -> html topic: Shapes & things.

Posted on June 4, 2009 - Filed Under Life

I’ve posted in the past about Vincent (TheKid) Rothwell’s article on Creating a docx -> Html Preview Handler for SharePoint and about how to render customxml nodes, so this is just further expansion on the coolness of this topic.

Essentially, the problem was when you pasted in a PowerPoint slide into the docx, it wouldn’t render in the web.  After dipping around the inner workings of the document, i realized that the slide was being saved as a .sldx in the embeddings folder of the word document. 

(Embedded powerpoint slide found in document.xml)
  <w:object w:dxaOrig=7218 w:dyaOrig=5399>
      <
v:shapetype id=”_x0000_t75″
               coordsize=”21600,21600″
               o:spt=”75″
               o:preferrelative=”t”
               path=m@4@5l@4@11@9@11@9@5xe
               filled=”f”
               stroked=”f”>
      <
v:stroke joinstyle=”miter” />
        <
v:formulas>
        <
v:f eqn=”if lineDrawn pixelLineWidth 0″ />
        <
v:f eqn=”sum @0 1 0″ />
        <
v:f eqn=”sum 0 0 @1″ />
        <
v:f eqn=”prod @2 1 2″ />
        <
v:f eqn=”prod @3 21600 pixelWidth” />
        <
v:f eqn=”prod @3 21600 pixelHeight” />
        <
v:f eqn=”sum @0 0 1″ />
        <
v:f eqn=”prod @6 1 2″ />
        <
v:f eqn=”prod @7 21600 pixelWidth” />
        <
v:f eqn=”sum @8 21600 0″ />
        <
v:f eqn=”prod @7 21600 pixelHeight” />
        <
v:f eqn=”sum @10 21600 0″ />
      </v:formulas>
      <
v:path o:extrusionok=”f” gradientshapeok=”t” o:connecttype=”rect” />
      <
o:lock v:ext=”edit” aspectratio=”t” />
    </v:shapetype>
      <
v:shape id=”_x0000_i1025″�
              
type=”#_x0000_t75″�
              
style=”width:182.35pt;height:136.6pt”�
              
o:ole=”">
      <
v:imagedata r:id=”rId14″ o:title=”" />
    </v:shape>
    <
o:OLEObject Type=”Embed”
               ProgID=”PowerPoint.Slide.12″
               ShapeID=”_x0000_i1025″
               DrawAspect=”Content”
               ObjectID=”_1305441816″
               r:id=”rId15″ />
  </w:object>

 The embedded file didn’t help me but the <v:imagedata> seemed promising, and after i followed the relation I found that there was an image1.emf that was in the media folder of the word document.  Below is the xslt that i appended to Vincent’s solution.   

//additional functionality to show embedded objects. (e.g. a powerpoint slide that was pasted into word)
 
<xsl:template match=”w:object”>
  <
xsl:variable name=”size”>
    <
xsl:value-of select=”.//v:shape/@style[1]“/>
  </xsl:variable>
  <
a href=”?image={.//v:imagedata/@r:id[1]}”>
    <
img src=”?image={.//v:imagedata/@r:id[1]}”>
      <
xsl:attribute name=”border”><xsl:number value=”0″/>xsl:attribute>
      <
xsl:attribute name=”width”><xsl:value-of select=”substring-before(substring-after($size,’width:’), ‘.’)”/></xsl:attribute>
      <
xsl:attribute name=”height”><xsl:value-of select=”substring-before(substring-after($size,’height:’),’.')”/></xsl:attribute>
    </img>
  </a>
</xsl:template>

//additional functionality so that the handler doesn’t choke when it sees the w:customXml node
<
xsl:template match=”w:customXml”>
  <
xsl:apply-templates select=”*”/>
</xsl:template>

So what am I doing in Office-land?  Some rather nifty stuff.  Expect a lot of posts from me in the near future.

Comments

Leave a Reply

You must be logged in to post a comment.