001package com.hfg.xml.msofficexml.docx.drawingml.theme;
002
003
004
005import com.hfg.xml.msofficexml.OfficeOpenXMLTag;
006import com.hfg.xml.msofficexml.OfficeOpenXmlDocument;
007import com.hfg.xml.msofficexml.docx.drawingml.DmlXML;
008import com.hfg.xml.msofficexml.docx.drawingml.font.DmlFontScheme;
009
010//------------------------------------------------------------------------------
011/**
012 Represents an Office Open XML drawingml theme elements (<a:themeElements>) tag.
013 <div>
014 @author J. Alex Taylor, hairyfatguy.com
015 </div>
016 */
017//------------------------------------------------------------------------------
018// com.hfg XML/HTML Coding Library
019//
020// This library is free software; you can redistribute it and/or
021// modify it under the terms of the GNU Lesser General Public
022// License as published by the Free Software Foundation; either
023// version 2.1 of the License, or (at your option) any later version.
024//
025// This library is distributed in the hope that it will be useful,
026// but WITHOUT ANY WARRANTY; without even the implied warranty of
027// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
028// Lesser General Public License for more details.
029//
030// You should have received a copy of the GNU Lesser General Public
031// License along with this library; if not, write to the Free Software
032// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
033//
034// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
035// jataylor@hairyfatguy.com
036//------------------------------------------------------------------------------
037
038public class DmlThemeElements extends OfficeOpenXMLTag
039{
040   private DmlColorScheme  mColorScheme;
041   private DmlFontScheme   mFontScheme;
042   private DmlFormatScheme mFormatScheme;
043
044   //###########################################################################
045   // CONSTRUCTORS
046   //###########################################################################
047
048   //---------------------------------------------------------------------------
049   public DmlThemeElements(OfficeOpenXmlDocument inParentDoc)
050   {
051      super(DmlXML.THEME_ELEMENTS, inParentDoc);
052      init();
053   }
054
055   //---------------------------------------------------------------------------
056   public void init()
057   {
058      getColorScheme();
059      getFontScheme();
060      getFormatScheme();
061   }
062
063   //###########################################################################
064   // PUBLIC METHODS
065   //###########################################################################
066
067   //---------------------------------------------------------------------------
068   /**
069    * Returns the color scheme tag.
070    * @return the color scheme tag
071    */
072   public DmlColorScheme getColorScheme()
073   {
074      if (null == mColorScheme)
075      {
076         // Check if it has been added via addSubtag()...
077         mColorScheme = getOptionalSubtagByName(DmlXML.COLOR_SCHEME);
078         if (null == mColorScheme)
079         {
080            mColorScheme = new DmlColorScheme(getParentDoc());
081            addSubtag(mColorScheme);
082         }
083      }
084
085      return mColorScheme;
086   }
087
088   //---------------------------------------------------------------------------
089   /**
090    * Returns the font scheme tag.
091    * @return the font scheme tag
092    */
093   public DmlFontScheme getFontScheme()
094   {
095      if (null == mFontScheme)
096      {
097         // Check if it has been added via addSubtag()...
098         mFontScheme = getOptionalSubtagByName(DmlXML.FONT_SCHEME);
099         if (null == mFontScheme)
100         {
101            mFontScheme = new DmlFontScheme(getParentDoc());
102            addSubtag(mFontScheme);
103         }
104      }
105
106      return mFontScheme;
107   }
108
109   //---------------------------------------------------------------------------
110   /**
111    * Returns the format scheme tag.
112    * @return the format scheme tag
113    */
114   public DmlFormatScheme getFormatScheme()
115   {
116      if (null == mFormatScheme)
117      {
118         // Check if it has been added via addSubtag()...
119         mFormatScheme = getOptionalSubtagByName(DmlXML.FORMAT_SCHEME);
120         if (null == mFormatScheme)
121         {
122            mFormatScheme = new DmlFormatScheme(getParentDoc());
123            addSubtag(mFormatScheme);
124         }
125      }
126
127      return mFormatScheme;
128   }
129}