codegirl.blog(this);

Christina A. Odom — Developing SharePoint Solutions

Modular Document Generation: A Series

Posted on June 10, 2009 - Filed Under Code Girl

I give an academic exercise:  a simple Form Server application based in MOSS that collects weekly status reports for a project.  (At time of the implementation, the user base did not have Office 2007, InfoPath or Exchange) The owners of this application want a couple of extras based on users’ response:

I know what you’re thinking, “why not use code-behind”.  Lets say business-wise, it wasn’t an option at this point.  The user base recently received Office 2007 and now the business owners want to look to upgrade their application to utilize Word 2007 and OpenXML format as well as create a few extra documents to better capture the project’s documentation lifecycle. However, several of these documents have pieces of re-usable information in it.  Oh, and the business owners want to see everything in SharePoint while the users only will accept working within Microsoft Word.

Step 1:  The existing situation

Step 1: The existing situation


So prepare yourselves for a series of blogposts.

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.

MOSS Document Conversion not working for your documents? Do they have attached XML schemas?

Posted on January 22, 2009 - Filed Under Life

Senerio:  You have a nice .docx that you want to use MOSS Document Conversions on to convert a .docx to a web page.  You hit convert and the resulting page has nothing on it.  You take out all the fancy stuff and try the same sequence with a regular “hello world” document.  Works fine.  Try again with a “Hello World” with images.. no images (I’ll come back to that).  Try it a third time, attaching a xml schema to the document and surround Hello in your document with your custom schema and leave World alone.  Only World renders.

For the Images, Check out TheKid’s very excellent article on making a custom handler for document previews.  He gets around the lack of embedded images.

If you are still having problems with your document now rendering and you have custom XML markup in your document, add this line to your c:\\temp\\DocX2Html.xsl when trying out TheKid’s solution.

  <xsl:template match=w:customXml >
    <
xsl:apply-templates select=*/>
  xsl:template>

This will ignore any w:customXml tags in your document (how Microsoft says “this part belongs to this custom schema located somewhere else) and render things nicely. 

Just don’t be an idiot and modify the original .xsl.

keep looking »