blob: 5f50e3e58c7729225ad02edfe3ecf703ef4f5bce [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2008 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tatsuya ISHIHARA - initial API and implementation
*******************************************************************************/
package org.eclipse.actf.model.dom.odf.office.impl;
import org.eclipse.actf.model.dom.odf.ODFException;
import org.eclipse.actf.model.dom.odf.base.ODFDocument;
import org.eclipse.actf.model.dom.odf.base.impl.ODFElementImpl;
import org.eclipse.actf.model.dom.odf.office.AutomaticStylesElement;
import org.eclipse.actf.model.dom.odf.office.BodyElement;
import org.eclipse.actf.model.dom.odf.office.DocumentContentElement;
import org.eclipse.actf.model.dom.odf.office.FontFaceDeclsElement;
import org.eclipse.actf.model.dom.odf.office.OfficeConstants;
import org.eclipse.actf.model.dom.odf.style.StyleElement;
import org.eclipse.actf.util.xpath.XPathUtil;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
class DocumentContentElementImpl extends ODFElementImpl implements
DocumentContentElement {
private static final long serialVersionUID = -6010974975405611664L;
protected DocumentContentElementImpl(ODFDocument odfDoc, Element element) {
super(odfDoc, element);
}
public double getAttrOfficeVersion() {
if (hasAttributeNS(OfficeConstants.OFFICE_NAMESPACE_URI,
OfficeConstants.ATTR_VERSION)) {
return new Double(getAttributeNS(
OfficeConstants.OFFICE_NAMESPACE_URI,
OfficeConstants.ATTR_VERSION)).doubleValue();
}
return -1.0;
}
public FontFaceDeclsElement getFontFaceDeclsElement() {
NodeList children = getChildNodes();
if ((children != null) && (children.getLength() != 0)) {
for (int i = 0; i < children.getLength(); i++) {
if (children.item(i) instanceof FontFaceDeclsElement) {
return (FontFaceDeclsElement) children.item(i);
}
}
}
return null;
}
public AutomaticStylesElement getAutomaticStylesElement() {
NodeList children = getChildNodes();
if ((children != null) && (children.getLength() != 0)) {
for (int i = 0; i < children.getLength(); i++) {
if (children.item(i) instanceof AutomaticStylesElement) {
return (AutomaticStylesElement) children.item(i);
}
}
}
return null;
}
public BodyElement getBodyElement() {
NodeList body = XPathUtil.evalXPathNodeList(this,
"./*[namespace-uri()='" + OfficeConstants.OFFICE_NAMESPACE_URI
+ "' and local-name()='" + OfficeConstants.ELEMENT_BODY
+ "']");
if ((body == null) || (body.getLength() != 1)) {
new ODFException("ODF document must have one office:body element")
.printStackTrace();
return null;
}
return (BodyElement) body.item(0);
}
public void save(String uri) {
// TODO Auto-generated method stub
}
public StyleElement createStyle(String family) {
// TODO Auto-generated method stub
return null;
}
}