001package com.hfg.xml.msofficexml.docx.drawingml;
002
003import com.hfg.xml.msofficexml.docx.Docx;
004import com.hfg.xml.msofficexml.docx.wordprocessingml.WmlXMLTag;
005
006/**
007
008 From the ECMA-TC45 Primer: "BLIPs refer to Binary Large Image or Pictures. Blip Fills are made up of several components:
009 a Blip Reference, a Source Rectangle, and a Fill Mode."
010 */
011
012public class DmlBlipFill extends WmlXMLTag
013{
014   private DmlStretch mStretch;
015   private DmlBlip    mBlip;
016   private DmlSrcRect mSrcRect;
017
018   //---------------------------------------------------------------------------
019   public DmlBlipFill(Docx inDocx)
020   {
021      super(DmlXML.BLIP_FILL, inDocx);
022      init();
023   }
024
025   //---------------------------------------------------------------------------
026   private void init()
027   {
028      getSrcRect();
029   }
030
031   //---------------------------------------------------------------------------
032   /**
033    * Returns the stretch tag if one exists or else instantiates a new one.
034    * @return the stretch tag for this blipFill tag
035    */
036   public DmlStretch getStretch()
037   {
038      if (null == mStretch)
039      {
040         // Check if it has been added via addSubtag()...
041         mStretch = (DmlStretch) getOptionalSubtagByName(DmlXML.STRETCH);
042         if (null == mStretch)
043         {
044            mStretch = new DmlStretch(getParentDoc());
045            addSubtag(mStretch);
046         }
047      }
048
049      return mStretch;
050   }
051
052   //---------------------------------------------------------------------------
053   /**
054    * Returns the source rectangle tag if one exists or else instantiates a new one.
055    * @return the source rectangle tag for this blipFill tag
056    */
057   public DmlSrcRect getSrcRect()
058   {
059      if (null == mSrcRect)
060      {
061         // Check if it has been added via addSubtag()...
062         mSrcRect = (DmlSrcRect) getOptionalSubtagByName(DmlXML.SRC_RECT);
063         if (null == mSrcRect)
064         {
065            mSrcRect = new DmlSrcRect();
066            addSubtag(mSrcRect);
067         }
068      }
069
070      return mSrcRect;
071   }
072
073   //---------------------------------------------------------------------------
074   /**
075    * Returns the blip tag if one exists or else instantiates a new one.
076    * @return the blip tag for this blipFill tag
077    */
078   public DmlBlip getBlip()
079   {
080      if (null == mBlip)
081      {
082         // Check if it has been added via addSubtag()...
083         mBlip = (DmlBlip) getOptionalSubtagByName(DmlXML.BLIP);
084         if (null == mBlip)
085         {
086            mBlip = new DmlBlip(getParentDoc());
087            addSubtag(0, mBlip);
088         }
089      }
090
091      return mBlip;
092   }
093
094}