001package com.hfg.xml.msofficexml.docx.wordprocessingml;
002
003
004import com.hfg.xml.msofficexml.OfficeXML;
005import com.hfg.xml.msofficexml.docx.Docx;
006import com.hfg.xml.msofficexml.docx.RelationshipXML;
007import com.hfg.xml.msofficexml.docx.drawingml.DmlXML;
008import com.hfg.xml.msofficexml.docx.part.FooterPart;
009import com.hfg.xml.msofficexml.docx.part.HeaderPart;
010
011//------------------------------------------------------------------------------
012/**
013 Represents an Office Open XML header (<w:hdr>) tag.
014
015 @author J. Alex Taylor, hairyfatguy.com
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 WmlHeader extends WmlContentContainer
039{
040   //---------------------------------------------------------------------------
041   public WmlHeader(Docx inDocx)
042   {
043      super(WmlXML.HEADER, inDocx);
044      // Word is sensitive to the namespace prefixes being used.
045      // To ensure that tags are prefixed, we pre-define the namespace.
046      addXMLNamespaceDeclaration(WmlXML.WORDPROCESSINGML_NAMESPACE);
047
048      addXMLNamespaceDeclaration(RelationshipXML.RELATIONSHIP_NAMESPACE);
049      addXMLNamespaceDeclaration(OfficeXML.OFFICE_NAMESPACE);
050      addXMLNamespaceDeclaration(WmlXML.WORDPROCESSING_DRAWING_NAMESPACE);
051      addXMLNamespaceDeclaration(DmlXML.DRAWINGML_NAMESPACE);
052      addXMLNamespaceDeclaration(DmlXML.PIC_NAMESPACE);
053
054      setPart(new HeaderPart(inDocx, this));
055   }
056
057   //###########################################################################
058   // PUBLIC METHODS
059   //###########################################################################
060
061   //---------------------------------------------------------------------------
062   @Override
063   public HeaderPart getPart()
064   {
065      return (HeaderPart) super.getPart();
066   }
067
068   //---------------------------------------------------------------------------
069   public WmlParagraph addParagraph()
070   {
071      WmlParagraph p = new WmlParagraph(getParentDoc());
072      addSubtag(p);
073
074      return p;
075   }
076
077   //---------------------------------------------------------------------------
078   public WmlParagraph addParagraph(String inContent)
079   {
080      WmlParagraph p = addParagraph();
081      p.addTextRun().addText(inContent);
082
083      return p;
084   }
085
086   //---------------------------------------------------------------------------
087   public WmlTable addTable()
088   {
089      WmlTable table = new WmlTable(getParentDoc());
090      addSubtag(table);
091
092      return table;
093   }
094
095}