| 1 | /* |
|---|
| 2 | * Copyright 2007-2008, Plutext Pty Ltd. |
|---|
| 3 | * |
|---|
| 4 | * This file is part of docx4j. |
|---|
| 5 | |
|---|
| 6 | docx4j is licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 7 | you may not use this file except in compliance with the License. |
|---|
| 8 | |
|---|
| 9 | You may obtain a copy of the License at |
|---|
| 10 | |
|---|
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 12 | |
|---|
| 13 | Unless required by applicable law or agreed to in writing, software |
|---|
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 16 | See the License for the specific language governing permissions and |
|---|
| 17 | limitations under the License. |
|---|
| 18 | |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | package org.docx4j.openpackaging.parts; |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | import java.io.InputStream; |
|---|
| 25 | import java.util.HashMap; |
|---|
| 26 | import java.util.Iterator; |
|---|
| 27 | import java.util.Map; |
|---|
| 28 | |
|---|
| 29 | import javax.xml.XMLConstants; |
|---|
| 30 | import javax.xml.namespace.NamespaceContext; |
|---|
| 31 | import javax.xml.parsers.DocumentBuilder; |
|---|
| 32 | import javax.xml.parsers.DocumentBuilderFactory; |
|---|
| 33 | import javax.xml.parsers.ParserConfigurationException; |
|---|
| 34 | import javax.xml.xpath.XPath; |
|---|
| 35 | import javax.xml.xpath.XPathConstants; |
|---|
| 36 | import javax.xml.xpath.XPathFactory; |
|---|
| 37 | |
|---|
| 38 | import org.apache.commons.lang.text.StrTokenizer; |
|---|
| 39 | import org.docx4j.openpackaging.exceptions.Docx4JException; |
|---|
| 40 | import org.docx4j.openpackaging.exceptions.InvalidFormatException; |
|---|
| 41 | import org.docx4j.openpackaging.parts.relationships.Namespaces; |
|---|
| 42 | import org.w3c.dom.Document; |
|---|
| 43 | import org.w3c.dom.Node; |
|---|
| 44 | import org.w3c.dom.NodeList; |
|---|
| 45 | import org.w3c.dom.Text; |
|---|
| 46 | |
|---|
| 47 | /** OPC Parts are either XML, or binary (or text) documents. |
|---|
| 48 | * |
|---|
| 49 | * Most are XML documents. |
|---|
| 50 | * |
|---|
| 51 | * docx4j aims to represent XML parts using JAXB. However, |
|---|
| 52 | * at present there are some parts for which we don't have |
|---|
| 53 | * JAXB representations. |
|---|
| 54 | * |
|---|
| 55 | * Until such time as a JAXB representation for an XML Part exists, |
|---|
| 56 | * the Part should extend this class. |
|---|
| 57 | * |
|---|
| 58 | * */ |
|---|
| 59 | public class ActiveXControlXmlPart extends XmlPart { |
|---|
| 60 | |
|---|
| 61 | public ActiveXControlXmlPart(PartName partName) throws InvalidFormatException { |
|---|
| 62 | super(partName); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | /* Note, you also need |
|---|
| 66 | * |
|---|
| 67 | <rel:Relationships xmlns:rel="http://schemas.openxmlformats.org/package/2006/relationships"> |
|---|
| 68 | <rel:Relationship xmlns="" Id="rId1" Target="activeX1.bin" Type="http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary"/> |
|---|
| 69 | </rel:Relationships> |
|---|
| 70 | * |
|---|
| 71 | */ |
|---|
| 72 | |
|---|
| 73 | public ActiveXControlXmlPart() throws InvalidFormatException { |
|---|
| 74 | super(new PartName("/word/activeX/activeX1.xml")); |
|---|
| 75 | init(); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | public void init() { |
|---|
| 79 | |
|---|
| 80 | // Used if this Part is added to [Content_Types].xml |
|---|
| 81 | setContentType(new org.docx4j.openpackaging.contenttype.ContentType( |
|---|
| 82 | org.docx4j.openpackaging.contenttype.ContentTypes.OFFICEDOCUMENT_ACTIVEX_XML_OBJECT)); |
|---|
| 83 | |
|---|
| 84 | // Used when this Part is added to a rels |
|---|
| 85 | setRelationshipType(Namespaces.ACTIVEX_XML_OBJECT); |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | @Override |
|---|
| 89 | public Document getDocument() throws Docx4JException { |
|---|
| 90 | return doc; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | } |
|---|