001package com.hfg.xml.msofficexml.docx.wordprocessingml;
002
003
004
005import com.hfg.xml.XMLTag;
006import com.hfg.xml.msofficexml.docx.Docx;
007
008//------------------------------------------------------------------------------
009/**
010 Represents an Office Open XML document defaults (<w:docDefaults>) 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// http://officeopenxml.com/WPstyleDefaults.php
035
036public class WmlDocDefaults extends WmlXMLTag
037{
038   private WmlTextRunProperties   mTextRunProperties;
039   private WmlParagraphProperties mParagraphProperties;
040
041   //---------------------------------------------------------------------------
042   public WmlDocDefaults(Docx inDocx)
043   {
044      super(WmlXML.DOCUMENT_DEFAULTS, inDocx);
045   }
046
047
048   //---------------------------------------------------------------------------
049   /**
050    * Returns the text run properties tag if one exists or else instantiates a new one.
051    * @return the default  text run properties to be used for the document
052    */
053   public WmlTextRunProperties getTextRunProperties()
054   {
055      if (null == mTextRunProperties)
056      {
057         // Check if it has been added via addSubtag()...
058         XMLTag defaultTag = getOptionalSubtagByName(WmlXML.RUN_PROPS_DEFAULT);
059         if (null == defaultTag)
060         {
061            mTextRunProperties = new WmlTextRunProperties(getParentDoc());
062
063            defaultTag = new XMLTag(WmlXML.RUN_PROPS_DEFAULT);
064            addSubtag(defaultTag);
065            defaultTag.addSubtag(mTextRunProperties);
066         }
067      }
068
069      return mTextRunProperties;
070   }
071
072
073   //---------------------------------------------------------------------------
074   /**
075    * Returns the paragraph properties tag if one exists or else instantiates a new one.
076    * @return the default paragraph properties to be used for the document
077    */
078   public WmlParagraphProperties getParagraphProperties()
079   {
080      if (null == mParagraphProperties)
081      {
082         // Check if it has been added via addSubtag()...
083         XMLTag defaultTag = getOptionalSubtagByName(WmlXML.PARAGRAPH_PROPS_DEFAULT);
084         if (null == defaultTag)
085         {
086            mParagraphProperties = new WmlParagraphProperties(getParentDoc());
087
088            defaultTag = new XMLTag(WmlXML.PARAGRAPH_PROPS_DEFAULT);
089            addSubtag(defaultTag);
090            defaultTag.addSubtag(mParagraphProperties);
091         }
092      }
093
094      return mParagraphProperties;
095   }
096}