Page 1 of 1

Rotation on picture content control

PostPosted: Wed Feb 15, 2012 9:09 am
by olabrosse
Hi Jason,

It seems the rotation parameter isn't kept when image bindings are applied. Here's what I have in my template:

Code: Select all
<w:sdt>
   <w:sdtPr>
      <w:tag w:val="od:xpath=image1"/>
      <w:id w:val="-121613004"/>
      <w:dataBinding w:xpath="/to/my/image" w:storeItemID="{90DDC184-492D-4602-BCF8-DB1CC997AB61}"/>
      <w:picture/>
   </w:sdtPr>
   <w:sdtEndPr/>
   <w:sdtContent>
      <w:p w:rsidR="0027246B" w:rsidRPr="0027246B" w:rsidRDefault="0027246B" w:rsidP="0027246B">
         <w:r>
            <w:rPr>
               <w:noProof/>
            </w:rPr>
            <w:drawing>
               <wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="2D9DE040" wp14:editId="1CB0C926">
                  <wp:extent cx="5483700" cy="5486398"/>
                  <wp:effectExtent l="0" t="1270" r="1905" b="1905"/>
                  <wp:docPr id="1" name="Picture 1"/>
                  <wp:cNvGraphicFramePr>
                     <a:graphicFrameLocks/>
                  </wp:cNvGraphicFramePr>
                  <a:graphic>
                     <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                        <pic:pic>
                           <pic:nvPicPr>
                              <pic:cNvPr id="0" name="Picture 1"/>
                              <pic:cNvPicPr>
                                 <a:picLocks noChangeAspect="1" noChangeArrowheads="1"/>
                              </pic:cNvPicPr>
                           </pic:nvPicPr>
                           <pic:blipFill>
                              <a:blip r:embed="rId14">
                                 <a:extLst>
                                    <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                                       <a14:useLocalDpi val="0"/>
                                    </a:ext>
                                 </a:extLst>
                              </a:blip>
                              <a:stretch>
                                 <a:fillRect/>
                              </a:stretch>
                           </pic:blipFill>
                           <pic:spPr bwMode="auto">
                              <a:xfrm rot="5400000">
                                 <a:off x="0" y="0"/>
                                 <a:ext cx="5483700" cy="5486398"/>
                              </a:xfrm>
                              <a:prstGeom prst="rect">
                                 <a:avLst/>
                              </a:prstGeom>
                              <a:noFill/>
                              <a:ln>
                                 <a:noFill/>
                              </a:ln>
                           </pic:spPr>
                        </pic:pic>
                     </a:graphicData>
                  </a:graphic>
               </wp:inline>
            </w:drawing>
         </w:r>
      </w:p>
   </w:sdtContent>
</w:sdt>

I think what I'm looking to keep is the <a:xfrm> element, more specifically its @rot attribute.

Is this something that's easily done?

Thank you!

-Olivier

Re: Rotation on picture content control

PostPosted: Wed Feb 15, 2012 10:46 pm
by jason
It would require some code change.

bind.xslt uses an extension function:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
                                                        <xsl:copy-of
                                                        select="java:org.docx4j.model.datastorage.BindingHandler.xpathInjectImage(
                                                                                $wmlPackage,
                                                                                $sourcePart,
                                                                                $customXmlDataStorageParts,
                                                                                string(w:sdtPr/w:dataBinding/@w:storeItemID),
                                                                                string(w:sdtPr/w:dataBinding/@w:xpath),
                                                                                string(w:sdtPr/w:dataBinding/@w:prefixMappings),
                                                                                local-name(..),
                                                                                local-name(w:sdtContent/*[1]),
                                                                                string(w:sdtContent//wp:extent[1]/@cx),
                                                                                string(w:sdtContent//wp:extent[1]/@cy))" />

 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


and gets back a new w:drawing element, using BinaryPartAbstractImage.

You'd need to pass @rot to the extension function, and BinaryPartAbstractImage would need to be enhanced to accept @rot.

Re: Rotation on picture content control

PostPosted: Sat Feb 18, 2012 7:02 am
by olabrosse
Sounds simple enough, though I don't currently have the time to setup a local build environment or to look into implementing the change.

If and when I do, I'll make sure to send the patch over to you.

Thanks!

-Olivier