001package com.hfg.xml.msofficexml.docx.drawingml;
002
003/*
004<p:pic>
005  <p:nvPicPr>
006   <p:cNvPr id="4" name="St_Patrick's_Day.jpg"/> <p:cNvPicPr>
007   <a:picLocks noChangeAspect="1"/>
008  </p:cNvPicPr>
009  <p:nvPr/>
010  </p:nvPicPr>
011  <p:blipFill>
012    <a:blip r:embed="rId2"/>
013    <a:stretch>
014      <a:fillRect/>
015    </a:stretch>
016  </p:blipFill>
017  <p:spPr>
018<a:xfrm>
019<a:off x="1346200" y="914400"/> <a:ext cx="3657600" cy="2743200"/>
020    </a:xfrm>
021    <a:prstGeom prst="rect">
022      <a:avLst/>
023    </a:prstGeom>
024    <a:noFill/>
025    <a:ln>
026      <a:noFill/>
027    </a:ln>
028  </p:spPr>
029</p:pic>
030 */
031
032import com.hfg.xml.msofficexml.docx.Docx;
033import com.hfg.xml.msofficexml.docx.wordprocessingml.WmlXMLTag;
034
035public class DmlPicture extends WmlXMLTag
036{
037   private DmlNonVisualPictureProperties mNonVisualPictureProperties;
038   private DmlBlipFill                   mBlipFill;
039   private DmlShapeProperties            mShapeProperties;
040
041   //---------------------------------------------------------------------------
042   public DmlPicture(Docx inDocx)
043   {
044      super(DmlXML.PIC, inDocx);
045      init();
046   }
047
048   //---------------------------------------------------------------------------
049   private void init()
050   {
051   }
052
053
054   //---------------------------------------------------------------------------
055   /**
056    * Returns the non-visible picture properties tag if one exists or else instantiates a new one.
057    * @return the non-visible picture properties for this picture tag
058    */
059   public DmlNonVisualPictureProperties getNonVisualPictureProperties()
060   {
061      if (null == mNonVisualPictureProperties)
062      {
063         // Check if it has been added via addSubtag()...
064         mNonVisualPictureProperties = (DmlNonVisualPictureProperties) getOptionalSubtagByName(DmlXML.NON_VISUAL_PIC_PROPS);
065         if (null == mNonVisualPictureProperties)
066         {
067            mNonVisualPictureProperties = new DmlNonVisualPictureProperties();
068            addSubtag(mNonVisualPictureProperties);
069         }
070      }
071
072      return mNonVisualPictureProperties;
073   }
074
075   //---------------------------------------------------------------------------
076   /**
077    * Returns the blipFill tag if one exists or else instantiates a new one.
078    * @return the blipFill for this picture tag
079    */
080   public DmlBlipFill getBlipFill()
081   {
082      if (null == mBlipFill)
083      {
084         // Check if it has been added via addSubtag()...
085         mBlipFill = (DmlBlipFill) getOptionalSubtagByName(DmlXML.BLIP_FILL);
086         if (null == mBlipFill)
087         {
088            mBlipFill = new DmlBlipFill(getParentDoc());
089            addSubtag(mBlipFill);
090         }
091      }
092
093      return mBlipFill;
094   }
095
096   //---------------------------------------------------------------------------
097   /**
098    * Returns the shape properties tag if one exists or else instantiates a new one.
099    * @return the shape properties for this picture tag
100    */
101   public DmlShapeProperties getShapeProperties()
102   {
103      if (null == mShapeProperties)
104      {
105         // Check if it has been added via addSubtag()...
106         mShapeProperties = (DmlShapeProperties) getOptionalSubtagByName(DmlXML.SHAPE_PROPS);
107         if (null == mShapeProperties)
108         {
109            mShapeProperties = new DmlShapeProperties(getParentDoc());
110            addSubtag(mShapeProperties);
111         }
112      }
113
114      return mShapeProperties;
115   }
116
117}