source: trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/ActiveXControlXmlPart.java @ 1102

Revision 1102, 2.9 KB checked in by jharrop, 2 years ago (diff)

Support for ActiveX parts. Previously the Xml part was being represented as binary, and hence encoded in output.

Line 
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
21package org.docx4j.openpackaging.parts;
22
23
24import java.io.InputStream;
25import java.util.HashMap;
26import java.util.Iterator;
27import java.util.Map;
28
29import javax.xml.XMLConstants;
30import javax.xml.namespace.NamespaceContext;
31import javax.xml.parsers.DocumentBuilder;
32import javax.xml.parsers.DocumentBuilderFactory;
33import javax.xml.parsers.ParserConfigurationException;
34import javax.xml.xpath.XPath;
35import javax.xml.xpath.XPathConstants;
36import javax.xml.xpath.XPathFactory;
37
38import org.apache.commons.lang.text.StrTokenizer;
39import org.docx4j.openpackaging.exceptions.Docx4JException;
40import org.docx4j.openpackaging.exceptions.InvalidFormatException;
41import org.docx4j.openpackaging.parts.relationships.Namespaces;
42import org.w3c.dom.Document;
43import org.w3c.dom.Node;
44import org.w3c.dom.NodeList;
45import 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 * */
59public 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}
Note: See TracBrowser for help on using the repository browser.