001package com.hfg.xml.msofficexml.docx.wordprocessingml;
002
003
004import com.hfg.xml.msofficexml.docx.Docx;
005
006//------------------------------------------------------------------------------
007/**
008 Represents an Office Open XML body (<w:body>) tag.
009
010 @author J. Alex Taylor, hairyfatguy.com
011 */
012//------------------------------------------------------------------------------
013// com.hfg XML/HTML Coding Library
014//
015// This library is free software; you can redistribute it and/or
016// modify it under the terms of the GNU Lesser General Public
017// License as published by the Free Software Foundation; either
018// version 2.1 of the License, or (at your option) any later version.
019//
020// This library is distributed in the hope that it will be useful,
021// but WITHOUT ANY WARRANTY; without even the implied warranty of
022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
023// Lesser General Public License for more details.
024//
025// You should have received a copy of the GNU Lesser General Public
026// License along with this library; if not, write to the Free Software
027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
028//
029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
030// [email protected]
031//------------------------------------------------------------------------------
032
033public class WmlBody extends WmlXMLTag
034{
035   private WmlSectionProperties   mSectionProperties;
036
037   //---------------------------------------------------------------------------
038   public WmlBody(Docx inDocx)
039   {
040      super(WmlXML.BODY, inDocx);
041   }
042
043
044   //---------------------------------------------------------------------------
045   public WmlParagraph addParagraph()
046   {
047      WmlParagraph p = new WmlParagraph(getParentDoc());
048      addSubtag(p);
049
050      return p;
051   }
052
053   //---------------------------------------------------------------------------
054   public WmlParagraph addParagraph(String inContent)
055   {
056      WmlParagraph p = addParagraph();
057      p.addTextRun().addText(inContent);
058
059      return p;
060   }
061
062   //---------------------------------------------------------------------------
063   public void addParagraph(WmlParagraph inContent)
064   {
065      addSubtag(inContent);
066      inContent.setParentDoc(getParentDoc());
067   }
068
069   //---------------------------------------------------------------------------
070   public void addSubDoc(Docx inValue)
071   {
072      addSubtag(new WmlSubDoc(getParentDoc()).setDocument(inValue));
073   }
074
075   //---------------------------------------------------------------------------
076   public WmlTable addTable()
077   {
078      WmlTable table = new WmlTable(getParentDoc());
079      addSubtag(table);
080
081      return table;
082   }
083
084   //---------------------------------------------------------------------------
085   public WmlSectionProperties getSectionProperties()
086   {
087      if (null == mSectionProperties)
088      {
089         // Check it it has been added via addSubtag()...
090         mSectionProperties = getOptionalSubtagByName(WmlXML.SECT_PROPS);
091         if (null == mSectionProperties)
092         {
093            mSectionProperties = new WmlSectionProperties(getParentDoc());
094            addSubtag(mSectionProperties);
095         }
096      }
097
098      return mSectionProperties;
099   }
100
101}