001package com.hfg.xml.msofficexml.docx.part; 002 003 004import com.hfg.xml.XMLTag; 005import com.hfg.xml.msofficexml.OfficeXML; 006import com.hfg.xml.msofficexml.docx.Docx; 007import com.hfg.xml.msofficexml.docx.RelationshipXML; 008import com.hfg.xml.msofficexml.docx.drawingml.DmlXML; 009import com.hfg.xml.msofficexml.docx.wordprocessingml.WmlBody; 010import com.hfg.xml.msofficexml.docx.wordprocessingml.WmlXML; 011 012//------------------------------------------------------------------------------ 013/** 014 * Document Part of a OfficeOpenXML Docx document. 015 * 016 * @author J. Alex Taylor, hairyfatguy.com 017 */ 018//------------------------------------------------------------------------------ 019// com.hfg XML/HTML Coding Library 020// 021// This library is free software; you can redistribute it and/or 022// modify it under the terms of the GNU Lesser General Public 023// License as published by the Free Software Foundation; either 024// version 2.1 of the License, or (at your option) any later version. 025// 026// This library is distributed in the hope that it will be useful, 027// but WITHOUT ANY WARRANTY; without even the implied warranty of 028// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 029// Lesser General Public License for more details. 030// 031// You should have received a copy of the GNU Lesser General Public 032// License along with this library; if not, write to the Free Software 033// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 034// 035// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 036// jataylor@hairyfatguy.com 037//------------------------------------------------------------------------------ 038 039public class DocumentPart extends WmlContentPart 040{ 041 private MainDocPartRelationshipPart mRelationshipPart; 042 043 //--------------------------------------------------------------------------- 044 public DocumentPart(Docx inDocx) 045 { 046 super(inDocx); 047 setFile(WmlXML.DOCUMENT_FILE); 048 049 XMLTag rootNode = new XMLTag(WmlXML.DOCUMENT); 050 rootNode.addXMLNamespaceDeclaration(WmlXML.WORDPROCESSINGML_NAMESPACE); 051 rootNode.addXMLNamespaceDeclaration(OfficeXML.OFFICE_NAMESPACE); 052 rootNode.addXMLNamespaceDeclaration(RelationshipXML.RELATIONSHIP_NAMESPACE); 053 rootNode.addXMLNamespaceDeclaration(WmlXML.WORDPROCESSING_DRAWING_NAMESPACE); 054 rootNode.addXMLNamespaceDeclaration(DmlXML.DRAWINGML_NAMESPACE); 055 rootNode.addXMLNamespaceDeclaration(DmlXML.PIC_NAMESPACE); 056/* 057 rootNode.addXMLNamespaceDeclaration(XMLNamespace.getNamespace("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006")); 058 rootNode.addXMLNamespaceDeclaration(XMLNamespace.getNamespace("m", "http://schemas.openxmlformats.org/officeDocument/2006/math")); 059 rootNode.addXMLNamespaceDeclaration(XMLNamespace.getNamespace("v", "urn:schemas-microsoft-com:vml")); 060 rootNode.addXMLNamespaceDeclaration(XMLNamespace.getNamespace("w10", "urn:schemas-microsoft-com:office:word")); 061 rootNode.addXMLNamespaceDeclaration(XMLNamespace.getNamespace("wne", "http://schemas.microsoft.com/office/word/2006/wordml")); 062*/ 063 setRootNode(rootNode); 064 } 065 066 //--------------------------------------------------------------------------- 067 @Override 068 public MainDocPartRelationshipPart getRelationshipPart() 069 { 070 if (null == mRelationshipPart) 071 { 072 mRelationshipPart = new MainDocPartRelationshipPart(getParentDoc()); 073 getParentDoc().addPart(mRelationshipPart); 074 } 075 076 return mRelationshipPart; 077 } 078 079 //--------------------------------------------------------------------------- 080 public WmlBody getBody() 081 { 082 WmlBody body = getRootNode().getOptionalSubtagByName(WmlXML.BODY.getLocalName()); 083 if (null == body) 084 { 085 body = new WmlBody(getParentDoc()); 086 getRootNode().addSubtag(body); 087 } 088 089 return body; 090 } 091}