001package com.hfg.xml.msofficexml.xlsx.spreadsheetDrawing;
002
003
004
005import com.hfg.xml.msofficexml.docx.drawingml.DmlXML;
006import com.hfg.xml.msofficexml.docx.drawingml.text.DmlParagraph;
007import com.hfg.xml.msofficexml.docx.drawingml.text.DmlTextBodyProperties;
008import com.hfg.xml.msofficexml.xlsx.Xlsx;
009import com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlXMLTag;
010
011//------------------------------------------------------------------------------
012/**
013 Represents an Office Open XML worksheet shape text body (<xdr:txBody>) tag.
014 <div>
015 @author J. Alex Taylor, hairyfatguy.com
016 </div>
017 */
018//------------------------------------------------------------------------------
019// com.hfg XML/HTML Coding Library
020//
021// This library is free software; you can redistribute it and/or
022// modify it under the terms of the GNU Lesser General Public
023// License as published by the Free Software Foundation; either
024// version 2.1 of the License, or (at your option) any later version.
025//
026// This library is distributed in the hope that it will be useful,
027// but WITHOUT ANY WARRANTY; without even the implied warranty of
028// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
029// Lesser General Public License for more details.
030//
031// You should have received a copy of the GNU Lesser General Public
032// License along with this library; if not, write to the Free Software
033// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
034//
035// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
036// jataylor@hairyfatguy.com
037//------------------------------------------------------------------------------
038
039public class SsDrawTextBody extends SsmlXMLTag
040{
041   private DmlTextBodyProperties mProperties;
042
043   //---------------------------------------------------------------------------
044   public SsDrawTextBody(Xlsx inXlsx)
045   {
046      super(SsDrawXML.TEXT_BODY, inXlsx);
047      init();
048   }
049
050   //---------------------------------------------------------------------------
051   private void init()
052   {
053      // Initialize required subtags
054      getProperties();
055   }
056
057   //---------------------------------------------------------------------------
058   public DmlTextBodyProperties getProperties()
059   {
060      if (null == mProperties)
061      {
062         // Check if it has been added via addSubtag()...
063         mProperties = getOptionalSubtagByName(DmlXML.BODY_PROPS);
064         if (null == mProperties)
065         {
066            mProperties = new DmlTextBodyProperties();
067            addSubtag(mProperties);
068         }
069      }
070
071      return mProperties;
072   }
073
074   //---------------------------------------------------------------------------
075   public DmlParagraph addParagraph()
076   {
077      DmlParagraph p = new DmlParagraph();
078      addSubtag(p);
079
080      return p;
081   }
082
083   //---------------------------------------------------------------------------
084   public void addParagraph(String inText)
085   {
086      addParagraph().addTextRun().addText(inText);
087   }
088
089
090}