19package org.openoffice.xmerge.converter.xml;
21import java.io.IOException;
23import javax.xml.parsers.DocumentBuilder;
24import javax.xml.parsers.DocumentBuilderFactory;
25import javax.xml.parsers.ParserConfigurationException;
27import org.w3c.dom.Document;
28import org.w3c.dom.DOMException;
29import org.w3c.dom.Element;
30import org.w3c.dom.Node;
32import org.xml.sax.SAXException;
92 super(name, type, source);
195 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
197 factory.setValidating(
false);
198 builder = factory.newDocumentBuilder();
203 return OfficeDocument.parse(
builder, data);
208 }
catch (ParserConfigurationException pce) {
209 throw new SAXException(pce);
221 void write(OfficeZip zip)
throws IOException {
224 zip.setNamedBytes((
objName +
"/content.xml"),
228 zip.setNamedBytes((
objName +
"/settings.xml"),
232 zip.setNamedBytes((
objName +
"/styles.xml"),
245 void writeManifestData(Document manifestDoc)
throws DOMException {
246 Node root = manifestDoc.getDocumentElement();
249 Element contentNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE);
251 contentNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE,
"text/xml");
252 contentNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, (
objName +
"/content.xml"));
254 root.appendChild(contentNode);
258 Element settingsNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE);
260 settingsNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE,
"text/xml");
261 settingsNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, (
objName +
"/settings.xml"));
263 root.appendChild(settingsNode);
267 Element stylesNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE);
269 stylesNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE,
"text/xml");
270 stylesNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, (
objName +
"/styles.xml"));
273 Element objectNode = manifestDoc.createElement(OfficeConstants.TAG_MANIFEST_FILE);
275 objectNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_TYPE,
objType);
276 objectNode.setAttribute(OfficeConstants.ATTRIBUTE_MANIFEST_FILE_PATH, (
objName +
"/"));
278 root.appendChild(objectNode);
boolean hasChanged
Flag indicating if this document has changed since reading or is new.
OfficeZip zipFile
Representation of the file from which this object was read.
This class represents those embedded objects in an OpenOffice.org document that have an XML represent...
EmbeddedXMLObject(String name, String type)
Constructor for an embedded object stored using an XML representation.
void setSettingsDOM(Document settings)
Sets the settings data for the embedded object.
Document getSettingsDOM()
Returns the settings data for this embedded object.
Document getStylesDOM()
Returns the style data for this embedded object.
void setContentDOM(Document content)
Sets the content data for the embedded object.
Document getNamedDOM(String name)
This method extracts the data for the given XML file from the SX? file and creates a DOM representati...
Document getContentDOM()
Returns the content data for this embedded object.
void setStylesDOM(Document styles)
Sets the styles data for the embedded object.
PointerStyles const styles[]