001package com.hfg.xml.msofficexml.docx.part;
002
003import java.io.File;
004
005import com.hfg.xml.msofficexml.docx.Docx;
006import com.hfg.xml.msofficexml.docx.wordprocessingml.*;
007
008//------------------------------------------------------------------------------
009/**
010 Represents an Office Open XML header part.
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 HeaderPart extends WmlContentPart
036{
037   //###########################################################################
038   // PRIVATE FIELDS
039   //###########################################################################
040
041   private static int sIndexSrc = 0;
042
043   private int  mHeaderIndex = ++sIndexSrc;
044
045   private HeaderRelationshipPart mRelationshipPart;
046
047   //###########################################################################
048   // CONSTRUCTORS
049   //###########################################################################
050
051   //---------------------------------------------------------------------------
052   public HeaderPart(Docx inDocx, WmlHeader inRootNode)
053   {
054      super(inDocx);
055
056      setRootNode(inRootNode);
057   }
058
059   //###########################################################################
060   // PUBLIC METHODS
061   //###########################################################################
062
063   //---------------------------------------------------------------------------
064   @Override
065   public File getFile()
066   {
067      return new File(WmlXML.WORD_DIR, "header" + mHeaderIndex + ".xml");
068   }
069
070   //---------------------------------------------------------------------------
071   @Override
072   public HeaderRelationshipPart getRelationshipPart()
073   {
074      if (null == mRelationshipPart)
075      {
076         mRelationshipPart = new HeaderRelationshipPart(getParentDoc(), getFile().getName());
077         getParentDoc().addPart(mRelationshipPart);
078      }
079
080      return mRelationshipPart;
081   }
082
083}
084
085