001package com.hfg.xml.msofficexml.docx.wordprocessingml;
002
003import com.hfg.xml.XMLName;
004import com.hfg.xml.XMLTag;
005import com.hfg.xml.msofficexml.docx.Docx;
006import com.hfg.xml.msofficexml.docx.wordprocessingml.style.WmlJustification;
007
008//------------------------------------------------------------------------------
009/**
010 Represents an Office Open XML document numbering level (<w:lvl>) tag.
011
012 @author J. Alex Taylor, hairyfatguy.com
013 */
014//------------------------------------------------------------------------------
015// com.hfg XML/HTML Coding Library
016//
017// This library is free software; you can redistribute it and/or
018// modify it under the terms of the GNU Lesser General Public
019// License as published by the Free Software Foundation; either
020// version 2.1 of the License, or (at your option) any later version.
021//
022// This library is distributed in the hope that it will be useful,
023// but WITHOUT ANY WARRANTY; without even the implied warranty of
024// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
025// Lesser General Public License for more details.
026//
027// You should have received a copy of the GNU Lesser General Public
028// License along with this library; if not, write to the Free Software
029// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030//
031// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
032// jataylor@hairyfatguy.com
033//------------------------------------------------------------------------------
034
035public class WmlNumberingLevelDef extends WmlXMLTag
036{
037   private WmlParagraphProperties mParagraphProperties;
038   private WmlTextRunProperties mRunProperties;
039
040   //###########################################################################
041   // CONSTRUCTORS
042   //###########################################################################
043
044   //---------------------------------------------------------------------------
045   public WmlNumberingLevelDef(Docx inDocx)
046   {
047      super(WmlXML.LEVEL, inDocx);
048   }
049
050   //###########################################################################
051   // PUBLIC METHODS
052   //###########################################################################
053
054   //---------------------------------------------------------------------------
055   public WmlNumberingLevelDef setLevel(int inValue)
056   {
057      setAttribute(WmlXML.NUMBERING_LEVEL_ATT, inValue);
058      return this;
059   }
060
061   //---------------------------------------------------------------------------
062   public WmlNumberingLevelDef setTentative(boolean inValue)
063   {
064      setAttribute(WmlXML.TENTATIVE_ATT, inValue ? 1 : 0);
065      return this;
066   }
067
068   //---------------------------------------------------------------------------
069   public WmlNumberingLevelDef setStartingValue(int inValue)
070   {
071      XMLTag tag = getOptionalSubtagByName(WmlXML.START);
072      if (null == tag)
073      {
074         tag = new WmlXMLTag(WmlXML.START, getParentDoc());
075         addSubtag(tag);
076      }
077
078      tag.setAttribute(WmlXML.VALUE_ATT, inValue);
079
080      return this;
081   }
082
083   //---------------------------------------------------------------------------
084   public WmlNumberingLevelDef setNumberingFormat(WmlNumberingFormat inValue)
085   {
086      XMLName tagName = WmlXML.NUMBERING_FORMAT;
087      XMLTag tag = getOptionalSubtagByName(tagName);
088      if (null == tag)
089      {
090         tag = new WmlXMLTag(tagName, getParentDoc());
091         addSubtag(tag);
092      }
093
094      tag.setAttribute(WmlXML.VALUE_ATT, inValue);
095
096      return this;
097   }
098
099   //---------------------------------------------------------------------------
100   public WmlNumberingFormat getNumberingFormat()
101   {
102      WmlNumberingFormat value = null;
103
104      XMLTag tag = getOptionalSubtagByName(WmlXML.NUMBERING_FORMAT);
105      if (tag != null)
106      {
107         value = WmlNumberingFormat.valueOf(tag.getAttributeValue(WmlXML.VALUE_ATT));
108      }
109
110      return value;
111   }
112
113   //---------------------------------------------------------------------------
114   public WmlNumberingLevelDef setLevelText(String inValue)
115   {
116      XMLName tagName = WmlXML.LEVEL_TEXT;
117      XMLTag tag = getOptionalSubtagByName(tagName);
118      if (null == tag)
119      {
120         tag = new WmlXMLTag(tagName, getParentDoc());
121         addSubtag(tag);
122      }
123
124      tag.setAttribute(WmlXML.VALUE_ATT, inValue);
125
126      return this;
127   }
128
129   //---------------------------------------------------------------------------
130   public WmlNumberingLevelDef setJustification(WmlJustification inValue)
131   {
132      XMLName tagName = WmlXML.LEVEL_JUSTIFICATION;
133      XMLTag tag = getOptionalSubtagByName(tagName);
134      if (null == tag)
135      {
136         tag = new WmlXMLTag(tagName, getParentDoc());
137         addSubtag(tag);
138      }
139
140      tag.setAttribute(WmlXML.VALUE_ATT, inValue);
141
142      return this;
143   }
144
145
146   //---------------------------------------------------------------------------
147   public WmlTextRunProperties getTextRunProperties()
148   {
149      if (null == mRunProperties)
150      {
151         // Check it it has been added via addSubtag()...
152         mRunProperties = getOptionalSubtagByName(WmlXML.RUN_PROPS);
153         if (null == mRunProperties)
154         {
155            mRunProperties = new WmlTextRunProperties(getParentDoc());
156            addSubtag(mRunProperties);
157         }
158      }
159
160      return mRunProperties;
161   }
162
163
164   //---------------------------------------------------------------------------
165   public WmlParagraphProperties getParagraphProperties()
166   {
167      if (null == mParagraphProperties)
168      {
169         // Check it it has been added via addSubtag()...
170         mParagraphProperties = getOptionalSubtagByName(WmlXML.PARAGRAPH_PROPS);
171         if (null == mParagraphProperties)
172         {
173            mParagraphProperties = new WmlParagraphProperties(getParentDoc());
174            addSubtag(mParagraphProperties);
175         }
176      }
177
178      return mParagraphProperties;
179   }
180
181}