Started modifying project structure
This commit is contained in:
parent
4e16ed01c2
commit
1e4ee37f89
566 changed files with 3340 additions and 176 deletions
131
src/main/java/writer2latex/office/BibMark.java
Normal file
131
src/main/java/writer2latex/office/BibMark.java
Normal file
|
@ -0,0 +1,131 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* BibMark.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.6 (2014-11-24)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** This class represents a single bibliography-mark in an ODF document
|
||||
*/
|
||||
public final class BibMark {
|
||||
|
||||
/** Entry types in an ODF bibliography marks. These are more or less modeled on BibTeX with
|
||||
* the following exceptions: organizations is organization in BibTeX, report_type is report in BibTeX,
|
||||
* the BibTeX fields crossref and key are missing in ODF, the ODF fields
|
||||
* url, custom1, custom2, custom3, custom4, custom5, isbn are not standard in BibTeX
|
||||
*
|
||||
*/
|
||||
public enum EntryType { address, annote, author, booktitle, chapter,
|
||||
edition, editor, howpublished, institution, journal, month,
|
||||
note, number, organizations, pages, publisher, school, series,
|
||||
title, report_type, volume, year,
|
||||
url, custom1, custom2, custom3, custom4, custom5, isbn
|
||||
}
|
||||
|
||||
// The data of the bibliography mark
|
||||
private String sIdentifier;
|
||||
private String sEntryType;
|
||||
private Map<EntryType,String> fields = new HashMap<EntryType,String>();
|
||||
|
||||
/** Create a new BibMark from scratch.
|
||||
* @param sIdentifier the unique identifier for this BibMark
|
||||
* @param sEntryType the type of entry such as book or article
|
||||
*/
|
||||
public BibMark(String sIdentifier, String sEntryType) {
|
||||
this.sIdentifier = sIdentifier;
|
||||
this.sEntryType = sEntryType;
|
||||
}
|
||||
|
||||
/** Create a new <code>BibMark</code> from a text:bibliography-mark node.
|
||||
*/
|
||||
public BibMark(Node node) {
|
||||
sIdentifier = Misc.getAttribute(node,XMLString.TEXT_IDENTIFIER);
|
||||
sEntryType = Misc.getAttribute(node,XMLString.TEXT_BIBLIOGRAPHY_TYPE);
|
||||
if (sEntryType==null) { // bug in OOo 1.0!
|
||||
sEntryType = Misc.getAttribute(node,XMLString.TEXT_BIBILIOGRAPHIC_TYPE);
|
||||
}
|
||||
fields.put(EntryType.address, Misc.getAttribute(node,XMLString.TEXT_ADDRESS));
|
||||
fields.put(EntryType.annote, Misc.getAttribute(node,XMLString.TEXT_ANNOTE));
|
||||
fields.put(EntryType.author, Misc.getAttribute(node,XMLString.TEXT_AUTHOR));
|
||||
fields.put(EntryType.booktitle, Misc.getAttribute(node,XMLString.TEXT_BOOKTITLE));
|
||||
fields.put(EntryType.chapter, Misc.getAttribute(node,XMLString.TEXT_CHAPTER));
|
||||
fields.put(EntryType.edition, Misc.getAttribute(node,XMLString.TEXT_EDITION));
|
||||
fields.put(EntryType.editor, Misc.getAttribute(node,XMLString.TEXT_EDITOR));
|
||||
fields.put(EntryType.howpublished, Misc.getAttribute(node,XMLString.TEXT_HOWPUBLISHED));
|
||||
fields.put(EntryType.institution, Misc.getAttribute(node,XMLString.TEXT_INSTITUTION));
|
||||
fields.put(EntryType.journal, Misc.getAttribute(node,XMLString.TEXT_JOURNAL));
|
||||
fields.put(EntryType.month, Misc.getAttribute(node,XMLString.TEXT_MONTH));
|
||||
fields.put(EntryType.note, Misc.getAttribute(node,XMLString.TEXT_NOTE));
|
||||
fields.put(EntryType.number, Misc.getAttribute(node,XMLString.TEXT_NUMBER));
|
||||
fields.put(EntryType.organizations, Misc.getAttribute(node,XMLString.TEXT_ORGANIZATIONS));
|
||||
fields.put(EntryType.pages, Misc.getAttribute(node,XMLString.TEXT_PAGES));
|
||||
fields.put(EntryType.publisher, Misc.getAttribute(node,XMLString.TEXT_PUBLISHER));
|
||||
fields.put(EntryType.school, Misc.getAttribute(node,XMLString.TEXT_SCHOOL));
|
||||
fields.put(EntryType.series, Misc.getAttribute(node,XMLString.TEXT_SERIES));
|
||||
fields.put(EntryType.title, Misc.getAttribute(node,XMLString.TEXT_TITLE));
|
||||
fields.put(EntryType.report_type, Misc.getAttribute(node,XMLString.TEXT_REPORT_TYPE));
|
||||
fields.put(EntryType.volume, Misc.getAttribute(node,XMLString.TEXT_VOLUME));
|
||||
fields.put(EntryType.year, Misc.getAttribute(node,XMLString.TEXT_YEAR));
|
||||
fields.put(EntryType.url, Misc.getAttribute(node,XMLString.TEXT_URL));
|
||||
fields.put(EntryType.custom1, Misc.getAttribute(node,XMLString.TEXT_CUSTOM1));
|
||||
fields.put(EntryType.custom2, Misc.getAttribute(node,XMLString.TEXT_CUSTOM2));
|
||||
fields.put(EntryType.custom3, Misc.getAttribute(node,XMLString.TEXT_CUSTOM3));
|
||||
fields.put(EntryType.custom4, Misc.getAttribute(node,XMLString.TEXT_CUSTOM4));
|
||||
fields.put(EntryType.custom5, Misc.getAttribute(node,XMLString.TEXT_CUSTOM5));
|
||||
fields.put(EntryType.isbn, Misc.getAttribute(node,XMLString.TEXT_ISBN));
|
||||
}
|
||||
|
||||
/** Get the identifier.
|
||||
*
|
||||
* @return the unique identifier of this <code>BibMark</code>
|
||||
*/
|
||||
public String getIdentifier() { return sIdentifier; }
|
||||
|
||||
/** Get the entry type.
|
||||
*
|
||||
* @return the entry type of this <code>BibMark</code>
|
||||
*/
|
||||
public String getEntryType() { return sEntryType; }
|
||||
|
||||
/** Set a specific field.
|
||||
*
|
||||
* @param entryType the type of field to set
|
||||
* @param sValue the new value of the field
|
||||
*/
|
||||
public void setField(EntryType entryType,String sValue) { fields.put(entryType, sValue); }
|
||||
|
||||
/** Return a specific field.
|
||||
*
|
||||
* @param entryType the type of the field to get
|
||||
* @return the value of the field, or null if the field is not set
|
||||
*/
|
||||
public String getField(EntryType entryType) {
|
||||
return fields.containsKey(entryType) ? fields.get(entryType) : null;
|
||||
}
|
||||
}
|
39
src/main/java/writer2latex/office/CellView.java
Normal file
39
src/main/java/writer2latex/office/CellView.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* CellView.java
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.0 (2008-09-07)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* This class represent a cell in a table view
|
||||
*/
|
||||
public class CellView {
|
||||
public Element cell = null;
|
||||
public int nRowSpan = 1;
|
||||
public int nColSpan = 1;
|
||||
public int nOriginalRow = -1;
|
||||
public int nOriginalCol = -1;
|
||||
}
|
150
src/main/java/writer2latex/office/ControlReader.java
Normal file
150
src/main/java/writer2latex/office/ControlReader.java
Normal file
|
@ -0,0 +1,150 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* ControlReader.java
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.0 (2008-11-23)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
//import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** <p> This class reads a form control in an OOo document (a form:control
|
||||
* node). A control always has an owner form.
|
||||
* Properties and events are ignored.</p>
|
||||
*/
|
||||
public class ControlReader {
|
||||
|
||||
private FormReader ownerForm; // a control always belongs to a form
|
||||
private String sId; // a control is identified by id
|
||||
private Element control; // the control element
|
||||
private Element controlType; // the type specific child element
|
||||
private Vector<Node> items = new Vector<Node>(); // the options/items of a list/combobox
|
||||
|
||||
/** <p>The constructor reads the content of a control element</p>
|
||||
* The representation in OpenDocument differs slightly from OOo 1.x.
|
||||
|
||||
* @param control a DOM element, which must be control node
|
||||
*/
|
||||
public ControlReader(Element control, FormReader ownerForm) {
|
||||
this.ownerForm = ownerForm;
|
||||
this.control = control;
|
||||
sId = control.getAttribute(XMLString.FORM_ID);
|
||||
// Read the control type specific info
|
||||
if (control.getTagName().equals(XMLString.FORM_CONTROL)) { // old format
|
||||
controlType = Misc.getFirstChildElement(control);
|
||||
}
|
||||
else { // oasos
|
||||
controlType = control;
|
||||
}
|
||||
if (controlType!=null) { // must always be the case!
|
||||
// Collect options/items
|
||||
Node child = controlType.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE && (
|
||||
child.getNodeName().equals(XMLString.FORM_OPTION) ||
|
||||
child.getNodeName().equals(XMLString.FORM_ITEM))) {
|
||||
items.add(child);
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** <p>A control in OOo is identified by id (<code>form:control-id</code>
|
||||
* attribute. The id is accessed by this method.</p>
|
||||
* @return the id of the control
|
||||
*/
|
||||
public String getId() { return sId; }
|
||||
|
||||
/** <p>A control in OOo belongs to a form.</p>
|
||||
* @return the form containing this control
|
||||
*/
|
||||
public FormReader getOwnerForm() { return ownerForm; }
|
||||
|
||||
/** <p>Get an attribute of the control. If the attribute does not exist,
|
||||
* this method returns <code>null</code>.
|
||||
* @param sName the name of the attribute
|
||||
* @return the value of the attribute, or <code>null</code>
|
||||
*/
|
||||
public String getAttribute(String sName) {
|
||||
return control.hasAttribute(sName) ? control.getAttribute(sName) : null;
|
||||
}
|
||||
|
||||
/** <p>The type of the control is identified by a name, eg. form:submit</p>
|
||||
* @return the type of this control
|
||||
*/
|
||||
public String getControlType() { return controlType.getTagName(); }
|
||||
|
||||
/** <p>Get an attribute specific to this type of control.
|
||||
* If the attribute does not exist, this method returns <code>null</code>.
|
||||
* @param sName the name of the attribute
|
||||
* @return the value of the attribute, or <code>null</code>
|
||||
*/
|
||||
public String getTypeAttribute(String sName) {
|
||||
return controlType!=null && controlType.hasAttribute(sName) ?
|
||||
controlType.getAttribute(sName) : null;
|
||||
}
|
||||
|
||||
/** <p>Return the number of options/items in this control.
|
||||
* Only listbox (options) and combobox (items) controls can have these,
|
||||
* for other controls this will return 0.
|
||||
* @return the number of options/items
|
||||
*/
|
||||
public int getItemCount() { return items.size(); }
|
||||
|
||||
/** <p>Get an attribute of an option/item.
|
||||
* If the index and/or the attribute does not exist, this method returns
|
||||
* <code>null</code>.
|
||||
* @param nIndex the index of the option/item
|
||||
* @param sName the name of the attribute
|
||||
* @return the value of the attribute, or <code>null</code>
|
||||
*/
|
||||
public String getItemAttribute(int nIndex, String sName) {
|
||||
if (0<=nIndex && nIndex<=items.size()) {
|
||||
return ((Element)items.get(nIndex)).hasAttribute(sName) ?
|
||||
((Element)items.get(nIndex)).getAttribute(sName) : null;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** <p>Get the value of an option/item.
|
||||
* If the index does not exist, this method returns
|
||||
* <code>null</code>.
|
||||
* @param nIndex the index of the option/item
|
||||
* @return the value of the option/item, or <code>null</code>
|
||||
*/
|
||||
public String getItemValue(int nIndex) {
|
||||
if (0<=nIndex && nIndex<=items.size()) {
|
||||
return Misc.getPCDATA((Element)items.get(nIndex));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
65
src/main/java/writer2latex/office/EmbeddedBinaryObject.java
Normal file
65
src/main/java/writer2latex/office/EmbeddedBinaryObject.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* EmbeddedBinaryObject.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2012-03-28)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import writer2latex.util.SimpleZipReader;
|
||||
|
||||
/**
|
||||
* This class represents an embedded object with a binary representation in an ODF package document
|
||||
*/
|
||||
public class EmbeddedBinaryObject extends EmbeddedObject {
|
||||
|
||||
/** The object's binary representation. */
|
||||
private byte[] blob = null;
|
||||
|
||||
/**
|
||||
* Package private constructor for use when reading an object from a
|
||||
* package ODF file
|
||||
*
|
||||
* @param sName The name of the object.
|
||||
* @param sType The MIME-type of the object.
|
||||
* @param doc The document containing the object.
|
||||
* @param source A <code>SimpleZipReader</code> containing the object
|
||||
*/
|
||||
protected EmbeddedBinaryObject(String sName, String sType, OfficeDocument doc, SimpleZipReader source) {
|
||||
super(sName,sType,doc);
|
||||
blob = source.getEntry(sName);
|
||||
}
|
||||
|
||||
/** Get the binary data for this object
|
||||
*
|
||||
* @return A <code>byte</code> array containing the object's data.
|
||||
*/
|
||||
public byte[] getBinaryData() {
|
||||
return blob;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
blob = null;
|
||||
}
|
||||
|
||||
}
|
71
src/main/java/writer2latex/office/EmbeddedObject.java
Normal file
71
src/main/java/writer2latex/office/EmbeddedObject.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* EmbeddedObject.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-08-27)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
/** This class represents and embedded object within an ODF package document
|
||||
*/
|
||||
public abstract class EmbeddedObject {
|
||||
private OfficeDocument doc;
|
||||
private String sName;
|
||||
private String sType;
|
||||
|
||||
/** Construct a new embedded object
|
||||
*
|
||||
* @param sName The name of the object.
|
||||
* @param sType The MIME-type of the object.
|
||||
* @param doc The document to which the object belongs.
|
||||
*/
|
||||
protected EmbeddedObject(String sName, String sType, OfficeDocument doc) {
|
||||
this.sName = sName;
|
||||
this.sType = sType;
|
||||
this.doc = doc;
|
||||
}
|
||||
|
||||
/** Get the name of the embedded object represented by this instance.
|
||||
* The name refers to the manifest.xml file
|
||||
*
|
||||
* @return The name of the object.
|
||||
*/
|
||||
public final String getName() {
|
||||
return sName;
|
||||
}
|
||||
|
||||
/** Get the MIME type of the embedded object represented by this instance.
|
||||
* The MIME type refers to the manifest.xml file
|
||||
*/
|
||||
public final String getType() {
|
||||
return sType;
|
||||
}
|
||||
|
||||
/** Dispose this <code>EmbeddedObject</code>. This implies that the content is nullified and the object
|
||||
* is removed from the collection in the <code>OfficeDocument</code>.
|
||||
*
|
||||
*/
|
||||
public void dispose() {
|
||||
doc.removeEmbeddedObject(sName);
|
||||
}
|
||||
|
||||
}
|
111
src/main/java/writer2latex/office/EmbeddedXMLObject.java
Normal file
111
src/main/java/writer2latex/office/EmbeddedXMLObject.java
Normal file
|
@ -0,0 +1,111 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* EmbeddedXMLObject.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-08-28)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import writer2latex.util.SimpleZipReader;
|
||||
|
||||
/** This class represents those embedded objects in an ODF document that have an XML representation:
|
||||
* Formulas, charts, spreadsheets, text, drawings and presentations.
|
||||
* These object types are stored using a combination of content, settings and styles XML files.
|
||||
* The settings are application specific and ignored.
|
||||
*/
|
||||
public class EmbeddedXMLObject extends EmbeddedObject {
|
||||
|
||||
// Byte entries for the XML streams of this object
|
||||
private byte[] contentBytes = null;
|
||||
private byte[] stylesBytes = null;
|
||||
|
||||
// DOM trees representing the XML parts of this object
|
||||
protected Document contentDOM = null;
|
||||
protected Document stylesDOM = null;
|
||||
|
||||
/** Read an object from an ODF package document
|
||||
*
|
||||
* @param sName The name of the object.
|
||||
* @param sType The MIME-type of the object.
|
||||
* @param source A ZIP reader providing the contents of the package
|
||||
*/
|
||||
protected EmbeddedXMLObject(String sName, String sType, OfficeDocument doc, SimpleZipReader source) {
|
||||
super(sName, sType, doc);
|
||||
// Read the bytes, but defer parsing until required (at that point, the bytes are nullified)
|
||||
contentBytes = source.getEntry(sName+"/"+OfficeDocument.CONTENTXML);
|
||||
stylesBytes = source.getEntry(sName+"/"+OfficeDocument.STYLESXML);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content data for this embedded object.
|
||||
*
|
||||
* @return DOM representation of "content.xml"
|
||||
*
|
||||
* @throws SAXException If any parser error occurs
|
||||
* @throws IOException If any IO error occurs
|
||||
*/
|
||||
public Document getContentDOM() throws SAXException, IOException {
|
||||
if (contentDOM==null) {
|
||||
contentDOM=getDOM(contentBytes);
|
||||
contentBytes=null;
|
||||
}
|
||||
return contentDOM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the style data for this embedded object.
|
||||
*
|
||||
* @return DOM representation of "styles.xml"
|
||||
*
|
||||
* @throws SAXException If any parser error occurs
|
||||
* @throws IOException If any IO error occurs
|
||||
*/
|
||||
public Document getStylesDOM() throws SAXException, IOException {
|
||||
if (stylesDOM==null) {
|
||||
stylesDOM = getDOM(stylesBytes);
|
||||
stylesBytes=null;
|
||||
}
|
||||
return stylesDOM;
|
||||
}
|
||||
|
||||
private Document getDOM(byte[] data) throws SAXException, IOException {
|
||||
if (data!=null) {
|
||||
return OfficeDocument.parse(data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
contentBytes = null;
|
||||
stylesBytes = null;
|
||||
contentDOM = null;
|
||||
stylesDOM = null;
|
||||
}
|
||||
|
||||
}
|
60
src/main/java/writer2latex/office/FontDeclaration.java
Normal file
60
src/main/java/writer2latex/office/FontDeclaration.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* FontDeclaration.java
|
||||
*
|
||||
* Copyright: 2002-2005 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 0.5 (2005-10-10)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/** <p> Class representing a font declaration in OOo</p>
|
||||
*/
|
||||
public class FontDeclaration extends OfficeStyle {
|
||||
private PropertySet properties = new PropertySet();
|
||||
|
||||
private String sFontFamily = null;
|
||||
private String sFontFamilyGeneric = null;
|
||||
private String sFontPitch = null;
|
||||
|
||||
public void loadStyleFromDOM(Node node) {
|
||||
super.loadStyleFromDOM(node);
|
||||
properties.loadFromDOM(node);
|
||||
sFontFamily = properties.getProperty(XMLString.FO_FONT_FAMILY);
|
||||
if (sFontFamily==null) { // oasis
|
||||
sFontFamily = properties.getProperty(XMLString.SVG_FONT_FAMILY);
|
||||
}
|
||||
sFontFamilyGeneric = properties.getProperty(XMLString.STYLE_FONT_FAMILY_GENERIC);
|
||||
sFontPitch = properties.getProperty(XMLString.STYLE_FONT_PITCH);
|
||||
}
|
||||
|
||||
public String getProperty(String sProperty){
|
||||
return properties.getProperty(sProperty);
|
||||
}
|
||||
|
||||
public String getFontFamily() { return sFontFamily; }
|
||||
|
||||
public String getFontFamilyGeneric() { return sFontFamilyGeneric; }
|
||||
|
||||
public String getFontPitch() { return sFontPitch; }
|
||||
|
||||
}
|
78
src/main/java/writer2latex/office/FormReader.java
Normal file
78
src/main/java/writer2latex/office/FormReader.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* FormReader.java
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Version 1.0 (2008-11-22)
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
//import java.util.Hashtable;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** <p> This class reads a form in an OOo document (a form:form node)</p>
|
||||
* Note: Subforms, properties and events are ignored.
|
||||
*/
|
||||
public class FormReader {
|
||||
|
||||
//private FormsReader forms; // the global collection of all forms
|
||||
private String sName; // a form is identified by name
|
||||
private Element form; // the form element
|
||||
|
||||
/** <p>The constructor reads the content of a <code>form:form</code> element</p>
|
||||
* @param form a DOM element, which must be <code>form:form</code> node
|
||||
*/
|
||||
public FormReader(Element form, FormsReader forms) {
|
||||
//this.forms = forms;
|
||||
this.form = form;
|
||||
sName = form.getAttribute(XMLString.FORM_NAME);
|
||||
// Collect all controls contained in this form
|
||||
Node child = form.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE) {
|
||||
String sId = Misc.getAttribute((Element)child,XMLString.FORM_ID);
|
||||
if (sId!=null) {
|
||||
ControlReader control = new ControlReader((Element) child, this);
|
||||
forms.addControl(control);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
/** <p>A form in OOo is identified by name (<code>form:name</code>
|
||||
* attribute. The name is accessed by this method.</p>
|
||||
* @return the name of the form
|
||||
*/
|
||||
public String getName() { return sName; }
|
||||
|
||||
/** <p>Get an attribute of the form. If the attribute does not exist,
|
||||
* this method returns <code>null</code>.
|
||||
* @param sName the name of the attribute
|
||||
* @return the value of the attribute, or <code>null</code>
|
||||
*/
|
||||
public String getAttribute(String sName) {
|
||||
return form.hasAttribute(sName) ? form.getAttribute(sName) : null;
|
||||
}
|
||||
|
||||
}
|
113
src/main/java/writer2latex/office/FormsReader.java
Normal file
113
src/main/java/writer2latex/office/FormsReader.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* FormsReader.java
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.0 (2008-11-23)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/** <p> This class reads the collection of all forms in an OOo document
|
||||
* (the <code>office:forms</code> element).</p>
|
||||
* <p>An OOo document may contain any number of forms; these are declared
|
||||
* within this element. In OOo, unlike eg. html, the form declaration is
|
||||
* separated from the presentation. This element contains the
|
||||
* <em>declaration</em>. The <em>presentation</em> is given by inclusion of
|
||||
* <code>draw:control</code> elements in the document flow. These refer to form
|
||||
* controls by id.</p>
|
||||
* <p>Note: A form is identified by a unique name, a control is
|
||||
* identified by a (globally) unique id.</p>
|
||||
*/
|
||||
public class FormsReader {
|
||||
|
||||
private Element formsElement; // The office:forms element
|
||||
private Hashtable<String, FormReader> forms = new Hashtable<String, FormReader>(); // all forms, indexed by name
|
||||
private Hashtable<String, ControlReader> controls = new Hashtable<String, ControlReader>(); // all controls, indexed by id
|
||||
|
||||
/** <p>Read the content of an <code>office:forms</code> element</p>
|
||||
* @param formsElement a DOM element, which must be <code>office:forms</code> node
|
||||
*/
|
||||
public void read(Element formsElement) {
|
||||
this.formsElement = formsElement;
|
||||
// Collect all forms
|
||||
Node child = formsElement.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE &&
|
||||
child.getNodeName().equals(XMLString.FORM_FORM)) {
|
||||
FormReader form = new FormReader((Element) child, this);
|
||||
forms.put(form.getName(),form);
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
/** <p>Get an attribute of the forms. If the attribute does not exist,
|
||||
* this method returns <code>null</code>.
|
||||
* @param sName the name of the attribute
|
||||
* @return the value of the attribute, or <code>null</code>
|
||||
*/
|
||||
public String getAttribute(String sName) {
|
||||
return formsElement.hasAttribute(sName) ? formsElement.getAttribute(sName) : null;
|
||||
}
|
||||
|
||||
/** <p>Get a <code>Iterator</code> over all forms.</p>
|
||||
* @return a <code>Iterator</code> over all forms
|
||||
*/
|
||||
public Iterator<FormReader> getFormsIterator() {
|
||||
return forms.values().iterator();
|
||||
}
|
||||
|
||||
/** <p>Get a form by name</p>
|
||||
* @param sName the <code>form:name</code> of the form
|
||||
* @return the form as a <code>FormReader</code> object
|
||||
*/
|
||||
public FormReader getForm(String sName) {
|
||||
return forms.get(sName);
|
||||
}
|
||||
|
||||
/** <p>Get a <code>Iterator</code> over all controls.</p>
|
||||
* @return a <code>Iterator</code> over all controls
|
||||
*/
|
||||
public Iterator<ControlReader> getControlsIterator() {
|
||||
return controls.values().iterator();
|
||||
}
|
||||
|
||||
/** <p>Get a control by id</p>
|
||||
* @param sId the <code>form:control-id</code> of the control
|
||||
* @return the control as a <code>ControlReader</code> object
|
||||
*/
|
||||
public ControlReader getControl(String sId) {
|
||||
return controls.get(sId);
|
||||
}
|
||||
|
||||
/** <p>Add a control</p>
|
||||
* @param control a <code>ControlReader</code> representing the control
|
||||
*/
|
||||
protected void addControl(ControlReader control) {
|
||||
controls.put(control.getId(),control);
|
||||
}
|
||||
|
||||
}
|
96
src/main/java/writer2latex/office/IndexMark.java
Normal file
96
src/main/java/writer2latex/office/IndexMark.java
Normal file
|
@ -0,0 +1,96 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* IndexMark.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-09-16)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import writer2latex.util.*;
|
||||
|
||||
/**
|
||||
* <p>This class contains static methods to read an index-mark.</p>
|
||||
*/
|
||||
public final class IndexMark {
|
||||
|
||||
// Node must be text:*-mark or text:*-mark-start
|
||||
public final static String getIndexValue(Node node) {
|
||||
if (!node.getNodeName().endsWith("start")) {
|
||||
return Misc.getAttribute(node,XMLString.TEXT_STRING_VALUE);
|
||||
}
|
||||
else {
|
||||
return collectMark(node);
|
||||
}
|
||||
}
|
||||
|
||||
// Node must be text:*-mark or text:*-mark-start
|
||||
public final static String getKey1(Node node) {
|
||||
return Misc.getAttribute(node,XMLString.TEXT_KEY1);
|
||||
}
|
||||
|
||||
// Node must be text:*-mark or text:*-mark-start
|
||||
public final static String getKey2(Node node) {
|
||||
return Misc.getAttribute(node,XMLString.TEXT_KEY2);
|
||||
}
|
||||
|
||||
// Collect a mark
|
||||
private final static Node getRightNode(Node node) {
|
||||
Node nextNode;
|
||||
do {nextNode = node.getNextSibling();
|
||||
if (nextNode!=null) { return nextNode; }
|
||||
node = node.getParentNode();
|
||||
} while (node!=null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private final static String collectMark(Node node) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
String sId = Misc.getAttribute(node,XMLString.TEXT_ID);
|
||||
node = getRightNode(node);
|
||||
while (node!=null) {
|
||||
if (node.getNodeType()==Node.TEXT_NODE) {
|
||||
buf.append(node.getNodeValue());
|
||||
node = getRightNode(node);
|
||||
}
|
||||
else if (node.getNodeType()==Node.ELEMENT_NODE) {
|
||||
boolean bReady = false;
|
||||
//String sNodeName = node.getNodeName();
|
||||
if (sId.equals(Misc.getAttribute(node,XMLString.TEXT_ID))) {
|
||||
node = null; // found the end mark
|
||||
bReady = true;
|
||||
}
|
||||
else if (OfficeReader.isTextElement(node) &&
|
||||
!OfficeReader.isNoteElement(node)) {
|
||||
if (node.hasChildNodes()) {
|
||||
node = node.getFirstChild(); bReady=true;
|
||||
}
|
||||
}
|
||||
if (!bReady) { node=getRightNode(node); };
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
149
src/main/java/writer2latex/office/ListCounter.java
Normal file
149
src/main/java/writer2latex/office/ListCounter.java
Normal file
|
@ -0,0 +1,149 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* ListCounter.java
|
||||
*
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.2 (2011-03-09)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import writer2latex.util.*;
|
||||
|
||||
/**
|
||||
* <p>This class produces labels for OOo lists/outlines (for xhtml
|
||||
* and text, which cannot produce them on their own).</p>
|
||||
*
|
||||
*/
|
||||
public class ListCounter {
|
||||
private int[] nCounter = new int[11];
|
||||
private String[] sNumFormat = new String[11];
|
||||
private int[] nStartValue = new int[11];
|
||||
private ListStyle style;
|
||||
private int nLevel=1; // current level
|
||||
|
||||
public ListCounter() {
|
||||
// Create a dummy counter
|
||||
this.style = null;
|
||||
for (int i=1; i<=10; i++) {
|
||||
sNumFormat[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public ListCounter(ListStyle style) {
|
||||
this();
|
||||
if (style!=null) {
|
||||
this.style = style;
|
||||
for (int i=1; i<=10; i++) {
|
||||
sNumFormat[i] = style.getLevelProperty(i,XMLString.STYLE_NUM_FORMAT);
|
||||
nStartValue[i] = Misc.getPosInteger(style.getLevelProperty(i, XMLString.TEXT_START_VALUE),1);
|
||||
}
|
||||
}
|
||||
restart(1);
|
||||
}
|
||||
|
||||
public ListCounter step(int nLevel) {
|
||||
// Make sure no higher levels are zero
|
||||
// This means that unlike eg. LaTeX, step(1).step(3) does not create
|
||||
// the value 1.0.1 but rather 1.1.1
|
||||
for (int i=1; i<nLevel; i++) {
|
||||
if (nCounter[i]==0) { nCounter[i]=1; }
|
||||
}
|
||||
// Then step this level
|
||||
nCounter[nLevel]++;
|
||||
// Finally clear lower levels
|
||||
if (nLevel<10) { restart(nLevel+1); }
|
||||
this.nLevel = nLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListCounter restart(int nLevel) {
|
||||
restart(nLevel,nStartValue[nLevel]-1);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListCounter restart(int nLevel, int nValue) {
|
||||
nCounter[nLevel] = nValue;
|
||||
for (int i=nLevel+1; i<=10; i++) {
|
||||
nCounter[i] = 0;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getValue(int nLevel) {
|
||||
return nCounter[nLevel];
|
||||
}
|
||||
|
||||
public int[] getValues() {
|
||||
int[] nCounterSnapshot = new int[11];
|
||||
System.arraycopy(nCounter,0,nCounterSnapshot,0,11);
|
||||
return nCounterSnapshot;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return getPrefix()+getLabelAndSuffix();
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
if (style != null && style.isNumber(nLevel)) {
|
||||
String sPrefix = style.getLevelProperty(nLevel,XMLString.STYLE_NUM_PREFIX);
|
||||
return sPrefix!=null ? sPrefix : "";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getLabelAndSuffix() {
|
||||
if (style != null && style.isNumber(nLevel)) {
|
||||
String sLabel="";
|
||||
if (sNumFormat[nLevel]==null) return "";
|
||||
int nLevels = Misc.getPosInteger(style.getLevelProperty(nLevel,
|
||||
XMLString.TEXT_DISPLAY_LEVELS),1);
|
||||
String sSuffix = style.getLevelProperty(nLevel,XMLString.STYLE_NUM_SUFFIX);
|
||||
String sSpace = "nothing".equals(style.getLevelStyleProperty(nLevel, XMLString.TEXT_LABEL_FOLLOWED_BY)) ? "" : " ";
|
||||
for (int j=nLevel-nLevels+1; j<nLevel; j++) {
|
||||
sLabel+=formatNumber(nCounter[j],sNumFormat[j],true)+".";
|
||||
}
|
||||
// TODO: Lettersync
|
||||
sLabel+=formatNumber(nCounter[nLevel],sNumFormat[nLevel],true);
|
||||
if (sSuffix!=null) { sLabel+=sSuffix; }
|
||||
if (sLabel.length()>0 && sSpace!=null) { sLabel+=sSpace; }
|
||||
return sLabel;
|
||||
}
|
||||
else if (style != null && style.isBullet(nLevel)) {
|
||||
return style.getLevelProperty(nLevel,XMLString.TEXT_BULLET_CHAR);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Utility method to generate number
|
||||
private String formatNumber(int number,String sStyle,boolean bLetterSync) {
|
||||
if ("a".equals(sStyle)) { return Misc.int2alph(number,bLetterSync); }
|
||||
else if ("A".equals(sStyle)) { return Misc.int2Alph(number,bLetterSync); }
|
||||
else if ("i".equals(sStyle)) { return Misc.int2roman(number); }
|
||||
else if ("I".equals(sStyle)) { return Misc.int2Roman(number); }
|
||||
else if ("1".equals(sStyle)) { return Misc.int2arabic(number); }
|
||||
else return "";
|
||||
}
|
||||
|
||||
|
||||
}
|
146
src/main/java/writer2latex/office/ListStyle.java
Normal file
146
src/main/java/writer2latex/office/ListStyle.java
Normal file
|
@ -0,0 +1,146 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* ListStyle.java
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.2 (2010-05-09)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** <p> Class representing a list style (including outline numbering) in OOo Writer</p>
|
||||
*/
|
||||
public class ListStyle extends OfficeStyle {
|
||||
// the file format doesn't specify a maximum nesting level, but OOo
|
||||
// currently supports 10
|
||||
private static final int MAX_LEVEL = 10;
|
||||
private PropertySet[] level;
|
||||
private PropertySet[] levelStyle;
|
||||
|
||||
public ListStyle() {
|
||||
level = new PropertySet[MAX_LEVEL+1];
|
||||
levelStyle = new PropertySet[MAX_LEVEL+1];
|
||||
for (int i=1; i<=MAX_LEVEL; i++) {
|
||||
level[i] = new PropertySet();
|
||||
levelStyle[i] = new PropertySet();
|
||||
}
|
||||
}
|
||||
|
||||
public String getLevelType(int i) {
|
||||
if (i>=1 && i<=MAX_LEVEL) {
|
||||
return level[i].getName();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNumber(int i) {
|
||||
return XMLString.TEXT_LIST_LEVEL_STYLE_NUMBER.equals(level[i].getName()) ||
|
||||
XMLString.TEXT_OUTLINE_LEVEL_STYLE.equals(level[i].getName());
|
||||
}
|
||||
|
||||
public boolean isBullet(int i) {
|
||||
return XMLString.TEXT_LIST_LEVEL_STYLE_BULLET.equals(level[i].getName());
|
||||
}
|
||||
|
||||
public boolean isImage(int i) {
|
||||
return XMLString.TEXT_LIST_LEVEL_STYLE_IMAGE.equals(level[i].getName());
|
||||
}
|
||||
|
||||
// Return true if this level is using the new list formatting of ODT 1.2
|
||||
public boolean isNewType(int i) {
|
||||
return "label-alignment".equals(getLevelStyleProperty(i,XMLString.TEXT_LIST_LEVEL_POSITION_AND_SPACE_MODE));
|
||||
}
|
||||
|
||||
public String getLevelProperty(int i, String sName) {
|
||||
if (i>=1 && i<=MAX_LEVEL) {
|
||||
return level[i].getProperty(sName);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getLevelStyleProperty(int i, String sName) {
|
||||
if (i>=1 && i<=MAX_LEVEL) {
|
||||
return levelStyle[i].getProperty(sName);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadStyleFromDOM(Node node) {
|
||||
super.loadStyleFromDOM(node);
|
||||
// Collect level information from child elements (text:list-level-style-*):
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE){
|
||||
String sLevel = Misc.getAttribute(child,XMLString.TEXT_LEVEL);
|
||||
if (sLevel!=null) {
|
||||
int nLevel = Misc.getPosInteger(sLevel,1);
|
||||
if (nLevel>=1 && nLevel<=MAX_LEVEL) {
|
||||
loadLevelPropertiesFromDOM(nLevel,child);
|
||||
}
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLevelPropertiesFromDOM(int nLevel, Node node) {
|
||||
// Load the attributes
|
||||
level[nLevel].loadFromDOM(node);
|
||||
// Also include style:properties
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE){
|
||||
if (child.getNodeName().equals(XMLString.STYLE_PROPERTIES)) {
|
||||
levelStyle[nLevel].loadFromDOM(child);
|
||||
loadLevelLabelPropertiesFromDOM(nLevel,node);
|
||||
}
|
||||
if (child.getNodeName().equals(XMLString.STYLE_LIST_LEVEL_PROPERTIES)) { // oasis
|
||||
levelStyle[nLevel].loadFromDOM(child);
|
||||
loadLevelLabelPropertiesFromDOM(nLevel,child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLevelLabelPropertiesFromDOM(int nLevel, Node node) {
|
||||
// Merge the properties from style:list-level-label-alignment
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE){
|
||||
if (child.getNodeName().equals(XMLString.STYLE_LIST_LEVEL_LABEL_ALIGNMENT)) {
|
||||
levelStyle[nLevel].loadFromDOM(child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
134
src/main/java/writer2latex/office/LoftReader.java
Normal file
134
src/main/java/writer2latex/office/LoftReader.java
Normal file
|
@ -0,0 +1,134 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* LoftReader.java
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.0 (2008-11-22)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
//import java.util.Hashtable;
|
||||
//import java.util.Set;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
//import org.w3c.dom.Node;
|
||||
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
* <p>The class reads a <code>text:illustration-index</code> or
|
||||
* <code>text:table-index</code> element.</p>
|
||||
*/
|
||||
public class LoftReader {
|
||||
|
||||
private Element loftSource = null;
|
||||
private Element indexBody = null;
|
||||
|
||||
private String sName = null; // (section) name for this lof/lot
|
||||
private String sStyleName = null; // section style name
|
||||
|
||||
private boolean bUseCaption = true;
|
||||
private String sCaptionSequenceName = null;
|
||||
private boolean bIsByChapter = false; // default is document
|
||||
|
||||
private Element indexTitleTemplate = null;
|
||||
private Element loftEntryTemplate = null;
|
||||
|
||||
private boolean bIsTableIndex;
|
||||
|
||||
|
||||
/** <p>Initialize the LoftReader with a illustration/table index node
|
||||
* @param onode a <code>text:*-index</code>
|
||||
*/
|
||||
public LoftReader(Element onode) {
|
||||
bIsTableIndex = onode.getTagName().equals(XMLString.TEXT_TABLE_INDEX);
|
||||
|
||||
sName = Misc.getAttribute(onode,XMLString.TEXT_NAME);
|
||||
sStyleName = Misc.getAttribute(onode,XMLString.TEXT_STYLE_NAME);
|
||||
|
||||
loftSource = bIsTableIndex ?
|
||||
Misc.getChildByTagName(onode,XMLString.TEXT_TABLE_INDEX_SOURCE) :
|
||||
Misc.getChildByTagName(onode,XMLString.TEXT_ILLUSTRATION_INDEX_SOURCE);
|
||||
|
||||
indexBody = Misc.getChildByTagName(onode,XMLString.TEXT_INDEX_BODY);
|
||||
|
||||
if (loftSource!=null) {
|
||||
bUseCaption = !"false".equals(loftSource.getAttribute(XMLString.TEXT_USE_CAPTION));
|
||||
sCaptionSequenceName = loftSource.getAttribute(XMLString.TEXT_CAPTION_SEQUENCE_NAME);
|
||||
bIsByChapter = "chapter".equals(loftSource.getAttribute(XMLString.TEXT_INDEX_SCOPE));
|
||||
|
||||
indexTitleTemplate = Misc.getChildByTagName(loftSource,XMLString.TEXT_INDEX_TITLE_TEMPLATE);
|
||||
loftEntryTemplate = bIsTableIndex ?
|
||||
Misc.getChildByTagName(loftSource,XMLString.TEXT_TABLE_INDEX_ENTRY_TEMPLATE) :
|
||||
Misc.getChildByTagName(loftSource,XMLString.TEXT_ILLUSTRATION_INDEX_ENTRY_TEMPLATE);
|
||||
}
|
||||
}
|
||||
|
||||
/** <p>Get the (section) name for this loft </p>
|
||||
* @return the name of the loft
|
||||
*/
|
||||
public String getName() { return sName; }
|
||||
|
||||
/** <p>Get the (section) style name for this loft </p>
|
||||
* @return name of the section style to use for this loft
|
||||
*/
|
||||
public String getStyleName() { return sStyleName; }
|
||||
|
||||
/** <p>Is this a table index or a figure index? </p>
|
||||
* @return true if it's a table index
|
||||
*/
|
||||
public boolean isTableIndex() { return bIsTableIndex; }
|
||||
|
||||
/** <p>Is this loft by chapter? </p>
|
||||
* @return true if the scope is a chapter only
|
||||
*/
|
||||
public boolean isByChapter() { return bIsByChapter; }
|
||||
|
||||
/** <p>Is this loft generated by captions? (otherwise: by object names)</p>
|
||||
* @return true if we use captions
|
||||
*/
|
||||
public boolean useCaption() { return bUseCaption; }
|
||||
|
||||
/** <p>Get the sequence name to use for the caption</p>
|
||||
* @return the name of the caption
|
||||
*/
|
||||
public String getCaptionSequenceName() { return sCaptionSequenceName; }
|
||||
|
||||
/** <p>Get the index title template for this loft</p>
|
||||
* @return the <code>text:index-title-template</code> element, or null
|
||||
*/
|
||||
public Element getIndexTitleTemplate() { return indexTitleTemplate; }
|
||||
|
||||
/** <p>Get the entry template for this loft at a specific level</p>
|
||||
* @param nLevel the outline level
|
||||
* @return the <code>text:table-of-content-entry-template</code> element, or null
|
||||
*/
|
||||
public Element getLoftEntryTemplate(int nLevel) {
|
||||
return loftEntryTemplate;
|
||||
}
|
||||
|
||||
/** <p>Return the generated content of this loft, if available</p>
|
||||
* @return the <code>text:index-body</code> element
|
||||
*/
|
||||
public Element getIndexBody() { return indexBody; }
|
||||
|
||||
|
||||
}
|
186
src/main/java/writer2latex/office/MIMETypes.java
Normal file
186
src/main/java/writer2latex/office/MIMETypes.java
Normal file
|
@ -0,0 +1,186 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* MIMETypes.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-09-05)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
/* Some helpers to handle the MIME types used by OOo
|
||||
*/
|
||||
|
||||
public final class MIMETypes extends writer2latex.api.MIMETypes {
|
||||
// OOo MIME types, taken from
|
||||
// http://framework.openoffice.org/documentation/mimetypes/mimetypes.html
|
||||
public static final String WRITER="application/vnd.sun.xml.writer";
|
||||
public static final String CALC="application/vnd.sun.xml.calc";
|
||||
public static final String IMPRESS="application/vnd.sun.xml.impress";
|
||||
public static final String DRAW="application/vnd.sun.xml.draw";
|
||||
public static final String CHART="application/vnd.sun.xml.chart";
|
||||
public static final String MATH="application/vnd.sun.xml.math";
|
||||
// OpenDocument MIME types (from spec)
|
||||
public static final String ODT="application/vnd.oasis.opendocument.text";
|
||||
public static final String ODS="application/vnd.oasis.opendocument.spreadsheet";
|
||||
public static final String ODP="application/vnd.oasis.opendocument.presentation";
|
||||
public static final String ODF="application/vnd.oasis.opendocument.formula";
|
||||
|
||||
// zip
|
||||
public static final String ZIP="application/zip";
|
||||
|
||||
// Magic signatures for some binary files
|
||||
public static final byte[] PNG_SIG = { (byte) 0x89, 0x50, 0x4e, 0x47 }; // .PNG
|
||||
public static final byte[] JPEG_SIG = { (byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xe0 };
|
||||
public static final byte[] JPEG_EXIF_SIG = { (byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xe1 };
|
||||
public static final byte[] GIF87_SIG = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61 }; // GIF87a
|
||||
public static final byte[] GIF89_SIG = { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61 }; // GIF89a
|
||||
public static final byte[] TIFF_SIG = { 0x49, 0x49, 0x2A }; // II*
|
||||
public static final byte[] BMP_SIG = { 0x42, 0x4d }; // BM
|
||||
public static final byte[] EMF_SIG = { 1, 0, 0, 0 };
|
||||
public static final byte[] WMF_SIG = { (byte) 0xd7, (byte) 0xcd, (byte) 0xc6, (byte) 0x9a };
|
||||
public static final byte[] WMF30_SIG = { 1, 0, 9, 0 }; // Old WMF format, not reliable - see below
|
||||
public static final byte[] EPS_SIG = { 0x25, 0x21 }; // %!
|
||||
public static final byte[] SVM_SIG = { 0x56, 0x43, 0x4c, 0x4d, 0x54, 0x46 }; // VCLMTF
|
||||
public static final byte[] ZIP_SIG = { 0x50, 0x4b, 0x03, 0x04 }; // PK..
|
||||
public static final byte[] SVG_SIG = { 0x3c, 0x73, 0x76, 0x67 }; // Not so magic: <svg
|
||||
|
||||
|
||||
// Preferred file extensions for some files
|
||||
public static final String LATEX_EXT = ".tex";
|
||||
public static final String BIBTEX_EXT = ".bib";
|
||||
public static final String XHTML_EXT = ".html";
|
||||
public static final String XHTML_MATHML_EXT = ".xhtml";
|
||||
public static final String HTML5_EXT = ".html";
|
||||
public static final String PNG_EXT = ".png";
|
||||
public static final String JPEG_EXT = ".jpg"; // this is the default in graphicx.sty
|
||||
public static final String GIF_EXT = ".gif";
|
||||
public static final String TIFF_EXT = ".tif";
|
||||
public static final String BMP_EXT = ".bmp";
|
||||
public static final String EMF_EXT = ".emf";
|
||||
public static final String WMF_EXT = ".wmf";
|
||||
public static final String EPS_EXT = ".eps";
|
||||
public static final String SVG_EXT = ".svg";
|
||||
public static final String SVM_EXT = ".svm";
|
||||
public static final String PDF_EXT = ".pdf";
|
||||
|
||||
private static final boolean isType(byte[] blob, byte[] sig) {
|
||||
int n = sig.length;
|
||||
for (int i=0; i<n; i++) {
|
||||
if (blob[i]!=sig[i]) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final boolean isSVG(byte[] blob) {
|
||||
// Look for <svg within the first 500 bytes
|
||||
int m = Math.min(blob.length, 500);
|
||||
int n = SVG_SIG.length;
|
||||
for (int j=0; j<m-n; j++) {
|
||||
boolean bFound = true;
|
||||
for (int i=0; i<n; i++) {
|
||||
if (blob[j+i]!=SVG_SIG[i]) {
|
||||
bFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bFound) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static final String getMagicMIMEType(byte[] blob) {
|
||||
if (isType(blob,PNG_SIG)) { return PNG; }
|
||||
if (isType(blob,JPEG_SIG)) { return JPEG; }
|
||||
if (isType(blob,JPEG_EXIF_SIG)) { return JPEG; }
|
||||
if (isType(blob,GIF87_SIG)) { return GIF; }
|
||||
if (isType(blob,GIF89_SIG)) { return GIF; }
|
||||
if (isType(blob,TIFF_SIG)) { return TIFF; }
|
||||
if (isType(blob,BMP_SIG)) { return BMP; }
|
||||
if (isType(blob,EMF_SIG)) { return EMF; }
|
||||
if (isType(blob,WMF_SIG)) { return WMF; }
|
||||
if (isType(blob,WMF30_SIG)) { return WMF; } // do not trust this..
|
||||
if (isType(blob,EPS_SIG)) { return EPS; }
|
||||
if (isType(blob,SVM_SIG)) { return SVM; }
|
||||
if (isType(blob,ZIP_SIG)) { return ZIP; }
|
||||
if (isSVG(blob)) { return SVG; }
|
||||
return "";
|
||||
}
|
||||
|
||||
public static final String getFileExtension(String sMIME) {
|
||||
if (PNG.equals(sMIME)) { return PNG_EXT; }
|
||||
if (JPEG.equals(sMIME)) { return JPEG_EXT; }
|
||||
if (GIF.equals(sMIME)) { return GIF_EXT; }
|
||||
if (TIFF.equals(sMIME)) { return TIFF_EXT; }
|
||||
if (BMP.equals(sMIME)) { return BMP_EXT; }
|
||||
if (EMF.equals(sMIME)) { return EMF_EXT; }
|
||||
if (WMF.equals(sMIME)) { return WMF_EXT; }
|
||||
if (EPS.equals(sMIME)) { return EPS_EXT; }
|
||||
if (SVG.equals(sMIME)) { return SVG_EXT; }
|
||||
if (SVM.equals(sMIME)) { return SVM_EXT; }
|
||||
if (PDF.equals(sMIME)) { return PDF_EXT; }
|
||||
if (LATEX.equals(sMIME)) { return LATEX_EXT; }
|
||||
if (BIBTEX.equals(sMIME)) { return BIBTEX_EXT; }
|
||||
if (XHTML.equals(sMIME)) { return XHTML_EXT; }
|
||||
if (XHTML_MATHML.equals(sMIME)) { return XHTML_MATHML_EXT; }
|
||||
if (HTML5.equals(sMIME)) { return XHTML_EXT; }
|
||||
return "";
|
||||
}
|
||||
|
||||
public static boolean isVectorFormat(String sMIME) {
|
||||
return EMF.equals(sMIME) || WMF.equals(sMIME) || EPS.equals(sMIME) || SVG.equals(sMIME) || SVM.equals(sMIME) || PDF.equals(sMIME);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Notes on old WMF format:
|
||||
Found on math type objects: 1 0 - 9 0 - 0 3 - 90 1 - 0 0
|
||||
|
||||
Explanation from http://wvware.sourceforge.net/caolan/ora-wmf.html :
|
||||
The standard Windows metafile header is 18 bytes in length and is structured as follows:
|
||||
|
||||
typedef struct _WindowsMetaHeader
|
||||
{
|
||||
WORD FileType; Type of metafile (0=memory, 1=disk)
|
||||
WORD HeaderSize; Size of header in WORDS (always 9)
|
||||
WORD Version; Version of Microsoft Windows used
|
||||
DWORD FileSize; Total size of the metafile in WORDs
|
||||
WORD NumOfObjects; Number of objects in the file
|
||||
DWORD MaxRecordSize; The size of largest record in WORDs
|
||||
WORD NumOfParams; Not Used (always 0)
|
||||
} WMFHEAD;
|
||||
|
||||
FileType contains a value which indicates the location of the metafile data. A value of 0 indicates that the metafile is stored in memory, while a 1 indicates that it is stored on disk.
|
||||
|
||||
HeaderSize contains the size of the metafile header in 16-bit WORDs. This value is always 9.
|
||||
|
||||
Version stores the version number of Microsoft Windows that created the metafile. This value is always read in hexadecimal format. For example, in a metafile created by Windows 3.0 and 3.1, this item would have the value 0x0300.
|
||||
|
||||
FileSize specifies the total size of the metafile in 16-bit WORDs.
|
||||
|
||||
NumOfObjects specifies the number of objects that are in the metafile.
|
||||
|
||||
MaxRecordSize specifies the size of the largest record in the metafile in WORDs.
|
||||
|
||||
NumOfParams is not used and is set to a value of 0.
|
||||
|
||||
*/
|
65
src/main/java/writer2latex/office/MasterPage.java
Normal file
65
src/main/java/writer2latex/office/MasterPage.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* MasterPage.java
|
||||
*
|
||||
* Copyright: 2002-2005 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 0.5 (2005-10-10)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** <p> Class representing a master page in OOo Writer </p> */
|
||||
public class MasterPage extends OfficeStyle {
|
||||
private PropertySet properties = new PropertySet();
|
||||
private Node header = null;
|
||||
private Node headerLeft = null;
|
||||
private Node footer = null;
|
||||
private Node footerLeft = null;
|
||||
|
||||
public String getProperty(String sPropName) {
|
||||
return properties.getProperty(sPropName);
|
||||
}
|
||||
|
||||
public String getPageLayoutName() {
|
||||
String sName = properties.getProperty(XMLString.STYLE_PAGE_MASTER_NAME);
|
||||
if (sName==null) { // try oasis format
|
||||
sName = properties.getProperty(XMLString.STYLE_PAGE_LAYOUT_NAME);
|
||||
}
|
||||
return sName;
|
||||
}
|
||||
|
||||
public Node getHeader() { return header; }
|
||||
public Node getHeaderLeft() { return headerLeft; }
|
||||
public Node getFooter() { return footer; }
|
||||
public Node getFooterLeft() { return footerLeft; }
|
||||
|
||||
public void loadStyleFromDOM(Node node) {
|
||||
super.loadStyleFromDOM(node);
|
||||
properties.loadFromDOM(node);
|
||||
header = Misc.getChildByTagName(node,XMLString.STYLE_HEADER);
|
||||
headerLeft = Misc.getChildByTagName(node,XMLString.STYLE_HEADER_LEFT);
|
||||
footer = Misc.getChildByTagName(node,XMLString.STYLE_FOOTER);
|
||||
footerLeft = Misc.getChildByTagName(node,XMLString.STYLE_FOOTER_LEFT);
|
||||
}
|
||||
|
||||
}
|
187
src/main/java/writer2latex/office/MetaData.java
Normal file
187
src/main/java/writer2latex/office/MetaData.java
Normal file
|
@ -0,0 +1,187 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* MetaData.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-09-16)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import writer2latex.util.*;
|
||||
//import writer2latex.office.*;
|
||||
|
||||
|
||||
/**
|
||||
* <p>This class represents the metadata of an OOo Writer document.</p>
|
||||
*/
|
||||
public class MetaData implements writer2latex.api.MetaData {
|
||||
// Dublin Core
|
||||
private String sTitle = "";
|
||||
private String sCreator = "";
|
||||
private String sInitialCreator = "";
|
||||
private String sDate = "";
|
||||
private String sDescription = "";
|
||||
private String sLanguage = "";
|
||||
private String sSubject = "";
|
||||
// Keywords
|
||||
private String sKeywords = "";
|
||||
// User-defined
|
||||
private Map<String,String> userdefined = new HashMap<String,String>();
|
||||
|
||||
/** <p>Construct a new instance from an OOo Writer document.</p>
|
||||
* @param oooDoc is the OOo document
|
||||
*/
|
||||
public MetaData(OfficeDocument oooDoc) {
|
||||
// get the DOM (either package or flat)
|
||||
Document dom = oooDoc.getMetaDOM();
|
||||
if (dom==null) { dom = oooDoc.getContentDOM(); }
|
||||
|
||||
// get the office:meta element
|
||||
NodeList list = dom.getElementsByTagName(XMLString.OFFICE_META);
|
||||
if (list.getLength() == 0) { return; } // oops, no metadata - fails silently
|
||||
Node meta = list.item(0);
|
||||
if (!meta.hasChildNodes()) { return; }
|
||||
|
||||
// traverse the metadata
|
||||
CSVList keywords = new CSVList(", ");
|
||||
list = meta.getChildNodes();
|
||||
int nLen = list.getLength();
|
||||
for (int i=0; i<nLen; i++) {
|
||||
Node child = list.item(i);
|
||||
String sName = child.getNodeName();
|
||||
if (XMLString.DC_TITLE.equals(sName)) {
|
||||
sTitle = getContent(child);
|
||||
}
|
||||
else if (XMLString.DC_CREATOR.equals(sName)) {
|
||||
sCreator = getContent(child);
|
||||
}
|
||||
else if (XMLString.DC_DATE.equals(sName)) {
|
||||
sDate = getContent(child);
|
||||
}
|
||||
else if (XMLString.DC_DESCRIPTION.equals(sName)) {
|
||||
sDescription = getContent(child);
|
||||
}
|
||||
else if (XMLString.DC_LANGUAGE.equals(sName)) {
|
||||
sLanguage = getContent(child);
|
||||
}
|
||||
else if (XMLString.DC_SUBJECT.equals(sName)) {
|
||||
sSubject = getContent(child);
|
||||
}
|
||||
else if (XMLString.META_INITIAL_CREATOR.equals(sName)) {
|
||||
sInitialCreator = getContent(child);
|
||||
}
|
||||
else if (XMLString.META_KEYWORD.equals(sName)) { // oasis
|
||||
keywords.addValue(getContent(child));
|
||||
}
|
||||
else if (XMLString.META_KEYWORDS.equals(sName)) {
|
||||
// Old format: Keywords are contained within meta:keywords
|
||||
if (child.hasChildNodes()) {
|
||||
// traverse the keywords
|
||||
NodeList keywordList = child.getChildNodes();
|
||||
int nWordCount = keywordList.getLength();
|
||||
for (int j=0; j<nWordCount; j++) {
|
||||
Node grandchild = keywordList.item(j);
|
||||
if (XMLString.META_KEYWORD.equals(grandchild.getNodeName())){
|
||||
keywords.addValue(getContent(grandchild));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (XMLString.META_USER_DEFINED.equals(sName)) {
|
||||
String sPropertyName = Misc.getAttribute(child, XMLString.META_NAME);
|
||||
if (sPropertyName!=null) {
|
||||
userdefined.put(sPropertyName,getContent(child));
|
||||
}
|
||||
}
|
||||
}
|
||||
sKeywords = keywords.toString();
|
||||
}
|
||||
|
||||
/** <p> Get the title of this document (may be empty)</p>
|
||||
* @return the title of the document
|
||||
*/
|
||||
public String getTitle() { return sTitle; }
|
||||
|
||||
/** <p> Get the creator of this document (may be empty)</p>
|
||||
* @return the creator of the document (or the initial creator if none is specified)
|
||||
*/
|
||||
public String getCreator() { return sCreator==null ? sInitialCreator : sCreator; }
|
||||
|
||||
/** <p> Get the initial creator of this document (may be empty)</p>
|
||||
* @return the initial creator of the document
|
||||
*/
|
||||
public String getInitialCreator() { return sInitialCreator; }
|
||||
|
||||
/** <p> Get the date of this document (may be empty)</p>
|
||||
* @return the date of the document
|
||||
*/
|
||||
public String getDate() { return sDate; }
|
||||
|
||||
/** <p> Get the description of this document (may be empty)</p>
|
||||
* @return the description of the document
|
||||
*/
|
||||
public String getDescription() { return sDescription; }
|
||||
|
||||
/** <p> Get the language of this document (may be empty)</p>
|
||||
* @return the language of the document
|
||||
*/
|
||||
public String getLanguage() { return sLanguage; }
|
||||
|
||||
public void setLanguage(String sLanguage) {
|
||||
this.sLanguage = sLanguage;
|
||||
}
|
||||
|
||||
/** <p> Get the subject of this document (may be empty)</p>
|
||||
* @return the subject of the document
|
||||
*/
|
||||
public String getSubject() { return sSubject; }
|
||||
|
||||
/** <p> Get the keywords of this document as a comma separated list (may be epmty)</p>
|
||||
* @return the keywords of the document
|
||||
*/
|
||||
public String getKeywords() { return sKeywords; }
|
||||
|
||||
/** Get the user-defined meta data
|
||||
*
|
||||
* @return the user-defined meta data as a name-value map
|
||||
*/
|
||||
public Map<String,String> getUserDefinedMetaData() { return userdefined; }
|
||||
|
||||
private String getContent(Node node) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.TEXT_NODE) {
|
||||
buf.append(child.getNodeValue());
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
}
|
309
src/main/java/writer2latex/office/OfficeDocument.java
Normal file
309
src/main/java/writer2latex/office/OfficeDocument.java
Normal file
|
@ -0,0 +1,309 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* OfficeDocument.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-08-28)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import writer2latex.util.SimpleXMLParser;
|
||||
import writer2latex.util.SimpleZipReader;
|
||||
|
||||
/**
|
||||
* This class implements reading of ODF files from various sources
|
||||
*/
|
||||
public class OfficeDocument {
|
||||
// File names for the XML streams in a package document (settings.xml is ignored)
|
||||
protected final static String CONTENTXML = "content.xml";
|
||||
protected final static String STYLESXML = "styles.xml";
|
||||
private final static String METAXML = "meta.xml";
|
||||
private final static String MANIFESTXML = "META-INF/manifest.xml";
|
||||
|
||||
// Some tag and attribute names in manifest.xml
|
||||
private final static String MANIFEST_FILE_ENTRY = "manifest:file-entry";
|
||||
private final static String MANIFEST_MEDIA_TYPE = "manifest:media-type";
|
||||
private final static String MANIFEST_FULL_PATH = "manifest:full-path";
|
||||
|
||||
// Identify package format
|
||||
private boolean bIsPackageFormat = false;
|
||||
|
||||
/** DOM <code>Document</code> of content.xml. */
|
||||
private Document contentDoc = null;
|
||||
|
||||
/** DOM <code>Document</code> of meta.xml. */
|
||||
private Document metaDoc = null;
|
||||
|
||||
/** DOM <code>Document</code> of content.xml. */
|
||||
private Document styleDoc = null;
|
||||
|
||||
/** DOM <code>Document</code> of META-INF/manifest.xml. */
|
||||
private Document manifestDoc = null;
|
||||
|
||||
/** Collection to keep track of the embedded objects in the document. */
|
||||
private Map<String, EmbeddedObject> embeddedObjects = null;
|
||||
|
||||
/** Package or flat format?
|
||||
* @return true if the document is in package format, false if it's flat XML
|
||||
*/
|
||||
public boolean isPackageFormat() {
|
||||
return bIsPackageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a DOM <code>Document</code> object of the content.xml file.
|
||||
* file. Note that a content DOM is not created when the constructor
|
||||
* is called, but only after the <code>read</code> method has been invoked
|
||||
*
|
||||
* @return DOM <code>Document</code> object.
|
||||
*/
|
||||
public Document getContentDOM() {
|
||||
return contentDoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a DOM <code>Document</code> object of the meta.xml
|
||||
* file. Note that a meta DOM is not created when the constructor
|
||||
* is called, but only after the <code>read</code> method has been invoked
|
||||
*
|
||||
* @return DOM <code>Document</code> object.
|
||||
*/
|
||||
public Document getMetaDOM() {
|
||||
return metaDoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a DOM <code>Document</code> object of the style.xml file.
|
||||
* Note that a style DOM is not created when the constructor
|
||||
* is called, but only after the <code>read</code> method has been invoked
|
||||
*
|
||||
* @return DOM <code>Document</code> object.
|
||||
*/
|
||||
public Document getStyleDOM() {
|
||||
return styleDoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect all the embedded objects (graphics, formulae, etc.) present in
|
||||
* this document. If the document is read from flat XML there will be no embedded objects.
|
||||
*/
|
||||
private void getEmbeddedObjects(SimpleZipReader zip) {
|
||||
embeddedObjects = new HashMap<String, EmbeddedObject>();
|
||||
if (manifestDoc != null) {
|
||||
// Need to read the manifest file and construct a list of objects
|
||||
NodeList nl = manifestDoc.getElementsByTagName(MANIFEST_FILE_ENTRY);
|
||||
int nLen = nl.getLength();
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Element elm = (Element) nl.item(i);
|
||||
String sType = elm.getAttribute(MANIFEST_MEDIA_TYPE);
|
||||
String sPath = elm.getAttribute(MANIFEST_FULL_PATH);
|
||||
|
||||
/* According to the ODF spec there are only two types of embedded object:
|
||||
* Objects with an XML representation.
|
||||
* Objects without an XML representation.
|
||||
* The former are represented by one or more XML files.
|
||||
* The latter are in binary form.
|
||||
*/
|
||||
if (sType.startsWith("application/vnd.oasis.opendocument") || sType.startsWith("application/vnd.sun.xml")) {
|
||||
// Allow either ODF or old OOo 1.x embedded objects
|
||||
if (!sPath.equals("/")) { // Exclude the main document entries
|
||||
if (sPath.endsWith("/")) { // Remove trailing slash
|
||||
sPath=sPath.substring(0, sPath.length()-1);
|
||||
}
|
||||
embeddedObjects.put(sPath, new EmbeddedXMLObject(sPath, sType, this, zip));
|
||||
}
|
||||
}
|
||||
else if (!sType.equals("text/xml")) {
|
||||
// XML entries are either embedded ODF doc entries or main document entries, all other
|
||||
// entries are included as binary objects
|
||||
embeddedObjects.put(sPath, new EmbeddedBinaryObject(sPath, sType, this, zip));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the embedded object corresponding to the name provided.
|
||||
* The name should be stripped of any preceding path characters, such as
|
||||
* '/', '.' or '#'.
|
||||
*
|
||||
* @param sName The name of the embedded object to retrieve.
|
||||
*
|
||||
* @return An <code>EmbeddedObject</code> instance representing the named
|
||||
* object.
|
||||
*/
|
||||
public EmbeddedObject getEmbeddedObject(String sName) {
|
||||
if (sName!=null && embeddedObjects!=null && embeddedObjects.containsKey(sName)) {
|
||||
return embeddedObjects.get(sName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void removeEmbeddedObject(String sName) {
|
||||
if (sName!=null && embeddedObjects!=null && embeddedObjects.containsKey(sName)) {
|
||||
embeddedObjects.remove(sName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the document from a DOM tree (flat XML format)
|
||||
*
|
||||
* @param dom the DOM tree
|
||||
*/
|
||||
public void read(org.w3c.dom.Document dom) {
|
||||
contentDoc = dom;
|
||||
styleDoc = null;
|
||||
metaDoc = null;
|
||||
manifestDoc = null;
|
||||
bIsPackageFormat = false;
|
||||
embeddedObjects = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read the Office <code>Document</code> from the given
|
||||
* <code>InputStream</code>.
|
||||
* Performs simple type detection to determine package or flat format
|
||||
*
|
||||
* @param is Office document <code>InputStream</code>.
|
||||
*
|
||||
* @throws IOException If any I/O error occurs.
|
||||
* @throws SAXException
|
||||
*/
|
||||
public void read(InputStream is) throws IOException {
|
||||
// We need to read 4 bytes ahead to detect flat or zip format
|
||||
BufferedInputStream inbuf = new BufferedInputStream(is);
|
||||
byte[] bytes = new byte[4];
|
||||
inbuf.mark(4);
|
||||
inbuf.read(bytes);
|
||||
inbuf.reset();
|
||||
boolean bZip = MIMETypes.ZIP.equals(MIMETypes.getMagicMIMEType(bytes));
|
||||
if (bZip) {
|
||||
readZip(inbuf);
|
||||
}
|
||||
else {
|
||||
readFlat(inbuf);
|
||||
}
|
||||
}
|
||||
|
||||
private void readZip(InputStream is) throws IOException {
|
||||
SimpleZipReader zip = new SimpleZipReader();
|
||||
zip.read(is);
|
||||
|
||||
byte contentBytes[] = zip.getEntry(CONTENTXML);
|
||||
if (contentBytes == null) {
|
||||
throw new IOException("Entry content.xml not found in file");
|
||||
}
|
||||
try {
|
||||
contentDoc = parse(contentBytes);
|
||||
} catch (SAXException ex) {
|
||||
throw new IOException(ex);
|
||||
}
|
||||
|
||||
byte styleBytes[] = zip.getEntry(STYLESXML);
|
||||
if (styleBytes != null) {
|
||||
try {
|
||||
styleDoc = parse(styleBytes);
|
||||
} catch (SAXException ex) {
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
byte metaBytes[] = zip.getEntry(METAXML);
|
||||
if (metaBytes != null) {
|
||||
try {
|
||||
metaDoc = parse(metaBytes);
|
||||
} catch (SAXException ex) {
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
byte manifestBytes[] = zip.getEntry(MANIFESTXML);
|
||||
if (manifestBytes != null) {
|
||||
try {
|
||||
manifestDoc = parse(manifestBytes);
|
||||
} catch (SAXException ex) {
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
bIsPackageFormat = true;
|
||||
getEmbeddedObjects(zip);
|
||||
}
|
||||
|
||||
|
||||
private void readFlat(InputStream is) throws IOException {
|
||||
try {
|
||||
contentDoc = SimpleXMLParser.parse(is);
|
||||
} catch (SAXException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
styleDoc = null;
|
||||
metaDoc = null;
|
||||
manifestDoc = null;
|
||||
bIsPackageFormat = false;
|
||||
embeddedObjects = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse given <code>byte</code> array into a DOM
|
||||
* <code>Document</code> object using the
|
||||
* <code>DocumentBuilder</code> object.
|
||||
*
|
||||
* @param builder <code>DocumentBuilder</code> object for parsing.
|
||||
* @param bytes <code>byte</code> array for parsing.
|
||||
*
|
||||
* @return Resulting DOM <code>Document</code> object.
|
||||
*
|
||||
* @throws SAXException If any parsing error occurs.
|
||||
*/
|
||||
static Document parse(byte bytes[]) throws SAXException, IOException {
|
||||
SAXParserFactory factory=SAXParserFactory.newInstance();
|
||||
SimpleXMLParser handler = new SimpleXMLParser();
|
||||
try {
|
||||
SAXParser saxParser = factory.newSAXParser();
|
||||
saxParser.parse(new ByteArrayInputStream(bytes),handler);
|
||||
return handler.getDOM();
|
||||
}
|
||||
catch (ParserConfigurationException e) {
|
||||
System.err.println("Oops - failed to get XML parser!?");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
1332
src/main/java/writer2latex/office/OfficeReader.java
Normal file
1332
src/main/java/writer2latex/office/OfficeReader.java
Normal file
File diff suppressed because it is too large
Load diff
69
src/main/java/writer2latex/office/OfficeStyle.java
Normal file
69
src/main/java/writer2latex/office/OfficeStyle.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* OfficeStyle.java
|
||||
*
|
||||
* Copyright: 2002-2006 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 0.5 (2006-11-23)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** <p> Abstract class representing a style in OOo </p> */
|
||||
public abstract class OfficeStyle {
|
||||
// These attributes are defined by OfficeStyleFamily upon collection of styles
|
||||
protected String sName;
|
||||
protected OfficeStyleFamily family;
|
||||
protected boolean bAutomatic;
|
||||
|
||||
private String sDisplayName;
|
||||
private String sParentName;
|
||||
private String sListStyleName;
|
||||
private String sMasterPageName;
|
||||
|
||||
public String getName() { return sName; }
|
||||
|
||||
public OfficeStyleFamily getFamily() { return family; }
|
||||
|
||||
public boolean isAutomatic() { return bAutomatic; }
|
||||
|
||||
public String getDisplayName() { return sDisplayName; }
|
||||
|
||||
public String getParentName() { return sParentName; }
|
||||
|
||||
public OfficeStyle getParentStyle() {
|
||||
return family.getStyle(sParentName);
|
||||
}
|
||||
|
||||
public String getListStyleName() { return sListStyleName; }
|
||||
|
||||
public String getMasterPageName() { return sMasterPageName; }
|
||||
|
||||
public void loadStyleFromDOM(Node node){
|
||||
sDisplayName = Misc.getAttribute(node,XMLString.STYLE_DISPLAY_NAME);
|
||||
if (sDisplayName==null) { sDisplayName = sName; }
|
||||
sParentName = Misc.getAttribute(node,XMLString.STYLE_PARENT_STYLE_NAME);
|
||||
sListStyleName = Misc.getAttribute(node,XMLString.STYLE_LIST_STYLE_NAME);
|
||||
sMasterPageName = Misc.getAttribute(node,XMLString.STYLE_MASTER_PAGE_NAME);
|
||||
}
|
||||
|
||||
}
|
136
src/main/java/writer2latex/office/OfficeStyleFamily.java
Normal file
136
src/main/java/writer2latex/office/OfficeStyleFamily.java
Normal file
|
@ -0,0 +1,136 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* OfficeStyleFamily.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-08-27)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** Container class representing a style family in OOo */
|
||||
public class OfficeStyleFamily {
|
||||
private Hashtable<String, OfficeStyle> styles = new Hashtable<String, OfficeStyle>();
|
||||
private Class<? extends OfficeStyle> styleClass;
|
||||
|
||||
private Hashtable<String, String> displayNames = new Hashtable<String, String>();
|
||||
|
||||
private OfficeStyle defaultStyle = null;
|
||||
|
||||
/** Create a new OfficeStyleFamily based on a class
|
||||
* @param styleClass the subclass of OfficeStyle used to represent styles
|
||||
* in this family
|
||||
*/
|
||||
public OfficeStyleFamily(Class<? extends OfficeStyle> styleClass) {
|
||||
this.styleClass = styleClass;
|
||||
}
|
||||
|
||||
/** Define the default style for this family, ie. an unnamed style providing
|
||||
* defaults for some style properties. This style cannot be found using
|
||||
* getStyle or getStyleByDisplayName.
|
||||
* @param style the new default style
|
||||
*/
|
||||
public void setDefaultStyle(OfficeStyle style) {
|
||||
defaultStyle = style;
|
||||
}
|
||||
|
||||
/** Get the default style for this family
|
||||
* @return the default style, or null if none is defined
|
||||
*/
|
||||
public OfficeStyle getDefaultStyle() {
|
||||
return defaultStyle;
|
||||
}
|
||||
|
||||
/** Get a style by name
|
||||
* @param sName the name of the style
|
||||
* @return the style, or null if such a style does not exist
|
||||
*/
|
||||
public OfficeStyle getStyle(String sName) {
|
||||
if (sName==null) { return null; }
|
||||
else { return styles.get(sName); }
|
||||
}
|
||||
|
||||
/** Get a style by display name. Automatic styles does not have a display
|
||||
* name, so only common styles can be retrieved with this method
|
||||
* @param sDisplayName the display name of the style
|
||||
* @return the style, or null if such a style does not exist
|
||||
*/
|
||||
public OfficeStyle getStyleByDisplayName(String sDisplayName) {
|
||||
if (sDisplayName==null) { return null; }
|
||||
else { return getStyle(displayNames.get(sDisplayName)); }
|
||||
}
|
||||
|
||||
/** Get the display name for the style with the specified name.
|
||||
* If this is an automatic style, the parent style is used
|
||||
* @param sName the style name
|
||||
* @return the display name, or null if the style does not exist
|
||||
*/
|
||||
public String getDisplayName(String sName) {
|
||||
OfficeStyle style = getStyle(sName);
|
||||
if (style==null) { return null; }
|
||||
if (style.isAutomatic()) {
|
||||
style = getStyle(style.getParentName());
|
||||
if (style==null) { return null; }
|
||||
}
|
||||
return style.getDisplayName();
|
||||
}
|
||||
|
||||
/** Get all named styles in the family (ie. excluding the default style)
|
||||
* @return an enumeration of all styles represented by OfficeStyle objects
|
||||
*/
|
||||
public Enumeration<OfficeStyle> getStylesEnumeration(){
|
||||
return styles.elements();
|
||||
}
|
||||
|
||||
/** Load a style from a DOM representation
|
||||
* @param node the style:... node representing the style
|
||||
* @param bAutomatic if true, the style is an automatic style
|
||||
*/
|
||||
public void loadStyleFromDOM(Node node, boolean bAutomatic) {
|
||||
String sName = Misc.getAttribute(node,XMLString.STYLE_NAME);
|
||||
if (sName!=null) {
|
||||
try {
|
||||
OfficeStyle style = styleClass.newInstance();
|
||||
style.sName=sName;
|
||||
style.family=this;
|
||||
style.bAutomatic=bAutomatic;
|
||||
style.loadStyleFromDOM(node);
|
||||
styles.put(sName,style);
|
||||
if (!bAutomatic) {
|
||||
// Create backlink from display name to name
|
||||
displayNames.put(style.getDisplayName(),sName);
|
||||
}
|
||||
}
|
||||
catch (InstantiationException e) {
|
||||
// Will not happen if a proper class is passed in the constructor
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
// Should also not happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
13
src/main/java/writer2latex/office/Package.html
Normal file
13
src/main/java/writer2latex/office/Package.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>The package writer2latex.office</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>A collection of classes that reads ODF files.</p>
|
||||
<p>In general the DOM tree is used directly, but these classes provides a more
|
||||
convenient interface to specific parts of the document.</p>
|
||||
</body>
|
||||
</html>
|
90
src/main/java/writer2latex/office/PageLayout.java
Normal file
90
src/main/java/writer2latex/office/PageLayout.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* PageLayout.java
|
||||
*
|
||||
* Copyright: 2002-2007 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 0.5 (2007-03-17)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** <p> Class representing a page master in OOo Writer. This is represented
|
||||
* like other styles + a separate style for header and footer</p>
|
||||
*/
|
||||
public class PageLayout extends StyleWithProperties {
|
||||
private String sPageUsage = null;
|
||||
|
||||
private boolean bHasHeaderStyle = false;
|
||||
private PropertySet headerStyle = new PropertySet();
|
||||
|
||||
private boolean bHasFooterStyle = false;
|
||||
private PropertySet footerStyle = new PropertySet();
|
||||
|
||||
|
||||
public String getPageUsage() {
|
||||
return sPageUsage;
|
||||
}
|
||||
|
||||
public boolean hasHeaderStyle() { return bHasHeaderStyle; }
|
||||
|
||||
public String getHeaderProperty(String sPropName) {
|
||||
return headerStyle.getProperty(sPropName);
|
||||
}
|
||||
|
||||
public boolean hasFooterStyle() { return bHasFooterStyle; }
|
||||
|
||||
public String getFooterProperty(String sPropName) {
|
||||
return footerStyle.getProperty(sPropName);
|
||||
}
|
||||
|
||||
public void loadStyleFromDOM(Node node) {
|
||||
super.loadStyleFromDOM(node);
|
||||
sPageUsage = Misc.getAttribute(node,XMLString.STYLE_PAGE_USAGE);
|
||||
|
||||
Node hsNode = Misc.getChildByTagName(node,XMLString.STYLE_HEADER_STYLE);
|
||||
if (hsNode!=null) {
|
||||
Node hsProperties = Misc.getChildByTagName(hsNode,XMLString.STYLE_PROPERTIES);
|
||||
if (hsProperties==null) { // oasis:
|
||||
hsProperties = Misc.getChildByTagName(hsNode,XMLString.STYLE_HEADER_FOOTER_PROPERTIES);
|
||||
}
|
||||
if (hsProperties!=null) {
|
||||
bHasHeaderStyle = true;
|
||||
headerStyle.loadFromDOM(hsProperties);
|
||||
}
|
||||
}
|
||||
|
||||
Node fsNode = Misc.getChildByTagName(node,XMLString.STYLE_FOOTER_STYLE);
|
||||
if (fsNode!=null) {
|
||||
Node fsProperties = Misc.getChildByTagName(fsNode,XMLString.STYLE_PROPERTIES);
|
||||
if (fsProperties==null) { // oasis:
|
||||
fsProperties = Misc.getChildByTagName(fsNode,XMLString.STYLE_HEADER_FOOTER_PROPERTIES);
|
||||
}
|
||||
if (fsProperties!=null) {
|
||||
bHasFooterStyle = true;
|
||||
footerStyle.loadFromDOM(fsProperties);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
97
src/main/java/writer2latex/office/PropertySet.java
Normal file
97
src/main/java/writer2latex/office/PropertySet.java
Normal file
|
@ -0,0 +1,97 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* PropertySet.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-08-27)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/** <p> Class representing a set of style properties in OOo (actually this
|
||||
is simply the set of attributes of an element). </p>
|
||||
*/
|
||||
public class PropertySet {
|
||||
private Hashtable<String, String> properties = new Hashtable<String, String>();
|
||||
private String sName;
|
||||
|
||||
public PropertySet() {
|
||||
properties = new Hashtable<String, String>();
|
||||
sName="";
|
||||
}
|
||||
|
||||
public String getProperty(String sPropName) {
|
||||
if (sPropName!=null) {
|
||||
String sValue = properties.get(sPropName);
|
||||
if (sValue!=null && sValue.endsWith("inch")) {
|
||||
// Cut of inch to in
|
||||
return sValue.substring(0,sValue.length()-2);
|
||||
}
|
||||
else {
|
||||
return sValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() { return sName; }
|
||||
|
||||
public void loadFromDOM(Node node) {
|
||||
// read the attributes of the node, if any
|
||||
if (node!=null) {
|
||||
sName = node.getNodeName();
|
||||
NamedNodeMap attrNodes = node.getAttributes();
|
||||
if (attrNodes!=null) {
|
||||
int nLen = attrNodes.getLength();
|
||||
for (int i=0; i<nLen; i++){
|
||||
Node attr = attrNodes.item(i);
|
||||
properties.put(attr.getNodeName(),attr.getNodeValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsProperty(String sProperty) {
|
||||
return sProperty!=null && properties.containsKey(sProperty);
|
||||
}
|
||||
|
||||
public void setProperty(String sProperty, String sValue){
|
||||
properties.put(sProperty,sValue);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String s="";
|
||||
Enumeration<String> keys = properties.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String sKey = keys.nextElement();
|
||||
String sValue = properties.get(sKey);
|
||||
s += sKey+"="+sValue+" ";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
231
src/main/java/writer2latex/office/SVMReader.java
Normal file
231
src/main/java/writer2latex/office/SVMReader.java
Normal file
|
@ -0,0 +1,231 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* SVMReader.java
|
||||
*
|
||||
* Copyright: 2004 by Urban Widmark
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 0.4 (2004-02-26)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
/** This class contains a static method to extract EPS data from an SVM file */
|
||||
public final class SVMReader {
|
||||
|
||||
/* Notes on SVM file format:
|
||||
|
||||
Relevant OO 1.1.0 Source Files include:
|
||||
tools/source/stream/vcompat.cxx
|
||||
vcl/source/gdi/gdimtf.cxx
|
||||
vcl/inc/gdimtf.hxx
|
||||
vcl/source/gdi/metaact.cxx
|
||||
vcl/inc/metaact.hxx
|
||||
vcl/source/gdi/mapmod.cxx
|
||||
vcl/inc/mapmod.hxx
|
||||
tools/source/generic/fract.cxx
|
||||
tools/inc/fract.hxx
|
||||
tools/source/generic/gen.cxx
|
||||
tools/inc/gen.hxx
|
||||
|
||||
VersionCompat (6 bytes)
|
||||
version - 2 bytes
|
||||
totalsize - 4 bytes
|
||||
|
||||
Point (Pair) (8 bytes)
|
||||
X - 4 bytes (long)
|
||||
Y - 4 bytes (long)
|
||||
|
||||
Fraction (8 bytes)
|
||||
nNumerator - 4 bytes (long)
|
||||
nDenominator - 4 bytes (long)
|
||||
|
||||
MapMode (6 + 2 + 8 + 8 + 8 + 1 = 33 bytes)
|
||||
VersionCompat
|
||||
meUnit - UINT16
|
||||
maOrigin - Point
|
||||
maScaleX - Fraction
|
||||
maScaleY - Fraction
|
||||
mbSimple - BOOL (1 byte)
|
||||
|
||||
Size (Pair) (8 bytes)
|
||||
width - 4 bytes (long)
|
||||
height - 4 bytes (long)
|
||||
|
||||
GfxLink (16 or 57 bytes)
|
||||
VersionCompat
|
||||
nType - 2 bytes
|
||||
nSize - 4 bytes
|
||||
nUserId - 4 bytes
|
||||
aSize - Size (version >=2)
|
||||
aMapMode - MapMode (version >=2)
|
||||
|
||||
MetaEPSAction
|
||||
VersionCompat
|
||||
maGfxLink - GfxLink
|
||||
data[maGfxLink.nSize] - bytes
|
||||
maPoint - Point
|
||||
maSize - Size
|
||||
maSubst - GDIMetaFile (alternative image?)
|
||||
|
||||
SVM file
|
||||
"VCLMTF"
|
||||
Compat - VersionCompat
|
||||
nStmCompressMode - UINT32
|
||||
aPrefMapMode - MapMode
|
||||
aPrefSize - Size
|
||||
count - UINT32
|
||||
action[count] - MetaAction
|
||||
|
||||
|
||||
Example header from an EPS image included in a Writer document:
|
||||
00000000: 5643 4c4d 5446 0100 3100 0000 0000 0000 VCLMTF..1.......
|
||||
00000010: 0100 1b00 0000 0800 0000 0000 0000 0000 ................
|
||||
00000020: 0100 0000 0100 0000 0100 0000 0100 0000 ................
|
||||
00000030: 0169 0100 00fd 0000 0001 0000 008f 0001 .i..............
|
||||
00000040: 0096 3200 0002 0033 0000 0001 003f 3000 ..2....3.....?0.
|
||||
00000050: 0000 0000 0000 0000 0000 0000 0001 001b ................
|
||||
00000060: 0000 000a 0000 0000 0000 0000 0001 0000 ................
|
||||
00000070: 0001 0000 0001 0000 0001 0000 0001 2521 ..............%!
|
||||
|
||||
5643 4c4d 5446 "VCLMTF" 0
|
||||
|
||||
0100 version 6
|
||||
3100 0000 totalsize
|
||||
|
||||
0000 0000 compress 12
|
||||
|
||||
0100 aPrefMapMode.version 16
|
||||
1b00 0000 aPrefMapMode.totalsize
|
||||
0800 aPrefMapMode.meUnit
|
||||
0000 0000 aPrefMapMode.maOrigin
|
||||
0000 0000
|
||||
0100 0000 aPrefMapMode.maScaleX
|
||||
0100 0000
|
||||
0100 0000 aPrefMapMode.maScaleY
|
||||
0100 0000
|
||||
01 aPrefMapMode.mbSimple
|
||||
|
||||
6901 0000 aPrefSize 49
|
||||
fd00 0000
|
||||
|
||||
0100 0000 nCount 57
|
||||
|
||||
8f00 type == META_EPS_ACTION 61
|
||||
|
||||
0100 version
|
||||
9632 0000 totalsize
|
||||
|
||||
0200 version
|
||||
3300 0000 totalsize
|
||||
|
||||
0100 nType
|
||||
3f30 0000 nSize 75
|
||||
0000 0000 nUserId
|
||||
|
||||
0000 0000 aSize
|
||||
0000 0000
|
||||
|
||||
0100
|
||||
1b00 0000
|
||||
0a00
|
||||
|
||||
0000 0000
|
||||
0000 0000
|
||||
0100 0000
|
||||
0100 0000
|
||||
0100 0000
|
||||
0100 0000
|
||||
01
|
||||
|
||||
Beginning of EPS data:
|
||||
|
||||
2521
|
||||
|
||||
Note that maPoint/maSize/maSubst are all after the EPS file.
|
||||
|
||||
*/
|
||||
|
||||
/** Determine if this SVM contains an EPS document and retrieve start and
|
||||
* end positions if so.
|
||||
*
|
||||
* @param blob byte array containing SVM file
|
||||
* @param offlen integer array to retrieve the offset into the SVM file
|
||||
* (offlen[0]) and the length (offlen[1]) of the EPS
|
||||
* document. If the method returns false, the array
|
||||
* will be unchanged.
|
||||
*
|
||||
* @return returns true if the SVM contains an EPS document
|
||||
*/
|
||||
public static final boolean readSVM(byte[] blob, int[] offlen) {
|
||||
int pos = 57;
|
||||
int nCount = getInt(blob, pos);
|
||||
pos += 4;
|
||||
|
||||
for (int i=0; i<nCount; i++) {
|
||||
int type = getShort(blob, pos);
|
||||
pos += 2;
|
||||
|
||||
// We only understand META_EPS_ACTION
|
||||
if (type != 143)
|
||||
return false;
|
||||
|
||||
pos += 6;
|
||||
int version = getShort(blob, pos);
|
||||
pos += 6; // version + totalsize
|
||||
pos += 2; // nType
|
||||
|
||||
// This is the size of the EPS data.
|
||||
int size = getInt(blob, pos);
|
||||
pos += 8;
|
||||
|
||||
if (version >= 2)
|
||||
pos += 41;
|
||||
|
||||
for (int j=0; j<MIMETypes.EPS_SIG.length; j++)
|
||||
if (MIMETypes.EPS_SIG[j] != blob[pos + j])
|
||||
return false;
|
||||
|
||||
offlen[0] = pos;
|
||||
offlen[1] = size;
|
||||
|
||||
// For now we only understand files where the EPS entry is
|
||||
// the first MetaAction
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int getInt(byte[] blob, int pos)
|
||||
{
|
||||
return
|
||||
((blob[pos+0] & 0xff) << 0) +
|
||||
((blob[pos+1] & 0xff) << 8) +
|
||||
((blob[pos+2] & 0xff) << 16) +
|
||||
((blob[pos+3] & 0xff) << 24);
|
||||
}
|
||||
|
||||
private static int getShort(byte[] blob, int pos)
|
||||
{
|
||||
return
|
||||
((blob[pos+0] & 0xff) << 0) +
|
||||
((blob[pos+1] & 0xff) << 8);
|
||||
}
|
||||
|
||||
}
|
298
src/main/java/writer2latex/office/StyleWithProperties.java
Normal file
298
src/main/java/writer2latex/office/StyleWithProperties.java
Normal file
|
@ -0,0 +1,298 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* StyleWithProperties.java
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.0 (2008-11-22)
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
//import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import writer2latex.util.Calc;
|
||||
//import org.w3c.dom.NamedNodeMap;
|
||||
//import java.util.Hashtable;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/** <p> Class representing a style in OOo which contains a style:properties
|
||||
* element </p>
|
||||
*/
|
||||
public class StyleWithProperties extends OfficeStyle {
|
||||
private final static int OLDPROPS = 0;
|
||||
private final static int TEXT = 1;
|
||||
private final static int PAR = 2;
|
||||
private final static int SECTION = 3;
|
||||
private final static int TABLE = 4;
|
||||
private final static int COLUMN = 5;
|
||||
private final static int ROW = 6;
|
||||
private final static int CELL = 7;
|
||||
private final static int GRAPHIC = 8;
|
||||
private final static int PAGE = 9;
|
||||
//private final static int DRAWPAGE = 10;
|
||||
private final static int COUNT = 10;
|
||||
|
||||
private PropertySet[] properties = new PropertySet[COUNT];
|
||||
private boolean bIsOldProps = false;
|
||||
|
||||
private PropertySet backgroundImageProperties = new PropertySet();
|
||||
|
||||
private int nColCount = 0;
|
||||
|
||||
private boolean bHasFootnoteSep = false;
|
||||
private PropertySet footnoteSep = new PropertySet();
|
||||
|
||||
|
||||
public StyleWithProperties() {
|
||||
for (int i=0; i<COUNT; i++) {
|
||||
properties[i] = new PropertySet();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadStyleFromDOM(Node node) {
|
||||
super.loadStyleFromDOM(node);
|
||||
// read the properties of the style, if any
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (XMLString.STYLE_PROPERTIES.equals(sName)) {
|
||||
bIsOldProps = true; // style:properties identifies old format
|
||||
loadPropertiesFromDOM(OLDPROPS,child);
|
||||
}
|
||||
else if (XMLString.STYLE_TEXT_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(TEXT,child);
|
||||
}
|
||||
else if (XMLString.STYLE_PARAGRAPH_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(PAR,child);
|
||||
}
|
||||
else if (XMLString.STYLE_SECTION_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(SECTION,child);
|
||||
}
|
||||
else if (XMLString.STYLE_TABLE_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(TABLE,child);
|
||||
}
|
||||
else if (XMLString.STYLE_TABLE_COLUMN_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(COLUMN,child);
|
||||
}
|
||||
else if (XMLString.STYLE_TABLE_ROW_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(ROW,child);
|
||||
}
|
||||
else if (XMLString.STYLE_TABLE_CELL_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(CELL,child);
|
||||
}
|
||||
else if (XMLString.STYLE_GRAPHIC_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(GRAPHIC,child);
|
||||
}
|
||||
else if (XMLString.STYLE_PAGE_LAYOUT_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(PAGE,child);
|
||||
}
|
||||
else if (XMLString.STYLE_DRAWING_PAGE_PROPERTIES.equals(sName)) {
|
||||
loadPropertiesFromDOM(PAGE,child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPropertiesFromDOM(int nIndex,Node node) {
|
||||
properties[nIndex].loadFromDOM(node);
|
||||
// Several property sets may contain these complex properties, but only one per style:
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (XMLString.STYLE_BACKGROUND_IMAGE.equals(sName)) {
|
||||
backgroundImageProperties.loadFromDOM(child);
|
||||
}
|
||||
else if (XMLString.STYLE_COLUMNS.equals(sName)) {
|
||||
nColCount = Misc.getPosInteger(Misc.getAttribute(child,
|
||||
XMLString.FO_COLUMN_COUNT),1);
|
||||
// TODO: read individual columns
|
||||
}
|
||||
else if (XMLString.STYLE_FOOTNOTE_SEP.equals(sName)) {
|
||||
bHasFootnoteSep = true;
|
||||
footnoteSep.loadFromDOM(child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
protected String getProperty(int nIndex, String sName, boolean bInherit) {
|
||||
int nRealIndex = bIsOldProps ? OLDPROPS : nIndex;
|
||||
if (properties[nRealIndex].containsProperty(sName)) {
|
||||
String sValue = properties[nRealIndex].getProperty(sName);
|
||||
return Calc.truncateLength(sValue);
|
||||
}
|
||||
else if (bInherit && getParentName()!=null) {
|
||||
StyleWithProperties parentStyle = (StyleWithProperties) family.getStyle(getParentName());
|
||||
if (parentStyle!=null) {
|
||||
return parentStyle.getProperty(nIndex,sName,bInherit);
|
||||
}
|
||||
}
|
||||
return null; // no value
|
||||
}
|
||||
|
||||
public String getTextProperty(String sName, boolean bInherit) {
|
||||
return getProperty(TEXT,sName,bInherit);
|
||||
}
|
||||
|
||||
public String getParProperty(String sName, boolean bInherit) {
|
||||
return getProperty(PAR,sName,bInherit);
|
||||
}
|
||||
|
||||
public String getSectionProperty(String sName, boolean bInherit) {
|
||||
return getProperty(SECTION,sName,bInherit);
|
||||
}
|
||||
|
||||
public String getTableProperty(String sName, boolean bInherit) {
|
||||
return getProperty(TABLE,sName,bInherit);
|
||||
}
|
||||
|
||||
public String getColumnProperty(String sName, boolean bInherit) {
|
||||
return getProperty(COLUMN,sName,bInherit);
|
||||
}
|
||||
|
||||
public String getRowProperty(String sName, boolean bInherit) {
|
||||
return getProperty(ROW,sName,bInherit);
|
||||
}
|
||||
|
||||
public String getCellProperty(String sName, boolean bInherit) {
|
||||
return getProperty(CELL,sName,bInherit);
|
||||
}
|
||||
|
||||
public String getGraphicProperty(String sName, boolean bInherit) {
|
||||
return getProperty(GRAPHIC,sName,bInherit);
|
||||
}
|
||||
|
||||
// TODO: Remove this method
|
||||
public String getProperty(String sProperty, boolean bInherit){
|
||||
String sValue;
|
||||
for (int i=0; i<COUNT; i++) {
|
||||
sValue = getProperty(i,sProperty,bInherit);
|
||||
if (sValue!=null) { return sValue; }
|
||||
}
|
||||
return null; // no value
|
||||
}
|
||||
|
||||
// TODO: Remove this method
|
||||
public String getProperty(String sProperty){
|
||||
return getProperty(sProperty,true);
|
||||
}
|
||||
|
||||
protected String getAbsoluteProperty(int nIndex, String sProperty){
|
||||
int nRealIndex = bIsOldProps ? OLDPROPS : nIndex;
|
||||
if (properties[nRealIndex].containsProperty(sProperty)){
|
||||
String sValue=(String) properties[nRealIndex].getProperty(sProperty);
|
||||
if (sValue.endsWith("%")) {
|
||||
StyleWithProperties parentStyle
|
||||
= (StyleWithProperties) family.getStyle(getParentName());
|
||||
if (parentStyle!=null) {
|
||||
String sParentValue = parentStyle.getAbsoluteProperty(nIndex,sProperty);
|
||||
if (sParentValue!=null) { return Calc.multiply(sValue,sParentValue); }
|
||||
}
|
||||
else if (getFamily()!=null && getFamily().getDefaultStyle()!=null) {
|
||||
StyleWithProperties style = (StyleWithProperties) getFamily().getDefaultStyle();
|
||||
String sDefaultValue=(String) style.getProperty(nIndex,sProperty,false);
|
||||
if (sValue !=null) { return Calc.multiply(sValue,sDefaultValue); }
|
||||
}
|
||||
}
|
||||
else {
|
||||
return Calc.truncateLength(sValue);
|
||||
}
|
||||
}
|
||||
else if (getParentName()!=null){
|
||||
StyleWithProperties parentStyle
|
||||
= (StyleWithProperties) family.getStyle(getParentName());
|
||||
if (parentStyle!=null) {
|
||||
return parentStyle.getAbsoluteProperty(nIndex,sProperty);
|
||||
}
|
||||
}
|
||||
else if (getFamily()!=null && getFamily().getDefaultStyle()!=null) {
|
||||
StyleWithProperties style = (StyleWithProperties) getFamily().getDefaultStyle();
|
||||
String sValue=(String) style.getProperty(nIndex,sProperty,false);
|
||||
if (sValue !=null) { return sValue; }
|
||||
}
|
||||
// no value!
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getAbsoluteTextProperty(String sName) {
|
||||
return getAbsoluteProperty(TEXT,sName);
|
||||
}
|
||||
|
||||
public String getAbsoluteParProperty(String sName) {
|
||||
return getAbsoluteProperty(PAR,sName);
|
||||
}
|
||||
|
||||
public String getAbsoluteSectionProperty(String sName) {
|
||||
return getAbsoluteProperty(SECTION,sName);
|
||||
}
|
||||
|
||||
public String getAbsoluteTableProperty(String sName) {
|
||||
return getAbsoluteProperty(TABLE,sName);
|
||||
}
|
||||
|
||||
public String getAbsoluteColumnProperty(String sName) {
|
||||
return getAbsoluteProperty(COLUMN,sName);
|
||||
}
|
||||
|
||||
public String getAbsoluteRowProperty(String sName) {
|
||||
return getAbsoluteProperty(ROW,sName);
|
||||
}
|
||||
|
||||
public String getAbsoluteCellProperty(String sName) {
|
||||
return getAbsoluteProperty(CELL,sName);
|
||||
}
|
||||
|
||||
public String getAbsoluteGraphicProperty(String sName) {
|
||||
return getAbsoluteProperty(GRAPHIC,sName);
|
||||
}
|
||||
|
||||
// TODO: Remove this method
|
||||
public String getAbsoluteProperty(String sProperty){
|
||||
String sValue;
|
||||
for (int i=0; i<COUNT; i++) {
|
||||
sValue = getAbsoluteProperty(i,sProperty);
|
||||
if (sValue!=null) { return sValue; }
|
||||
}
|
||||
return null; // no value
|
||||
}
|
||||
|
||||
// Get a length property that defaults to 0cm
|
||||
public String getAbsoluteLength(String sProperty) {
|
||||
String s = getAbsoluteProperty(sProperty);
|
||||
if (s==null) { return "0cm"; }
|
||||
else { return s; }
|
||||
}
|
||||
|
||||
public String getBackgroundImageProperty(String sName) {
|
||||
return backgroundImageProperties.getProperty(sName);
|
||||
}
|
||||
|
||||
public int getColCount() { return nColCount; }
|
||||
|
||||
public boolean hasFootnoteSep() { return bHasFootnoteSep; }
|
||||
|
||||
public String getFootnoteProperty(String sPropName) {
|
||||
return footnoteSep.getProperty(sPropName);
|
||||
}
|
||||
|
||||
}
|
65
src/main/java/writer2latex/office/TableLine.java
Normal file
65
src/main/java/writer2latex/office/TableLine.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* TableLine.java
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.0 (2008-09-04)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
* <p> This class represents the properties of a row or column in a table</p>
|
||||
*/
|
||||
public class TableLine {
|
||||
private String sStyleName;
|
||||
private String sVisibility;
|
||||
private String sDefaultCellStyleName;
|
||||
private boolean bDisplay;
|
||||
private boolean bHeader;
|
||||
|
||||
public TableLine(Node node, boolean bHeader, boolean bDisplay) {
|
||||
// Node must be table:table-column or table:table-row
|
||||
sStyleName = Misc.getAttribute(node,XMLString.TABLE_STYLE_NAME);
|
||||
sVisibility = Misc.getAttribute(node,XMLString.TABLE_VISIBILITY);
|
||||
if (sVisibility==null) { sVisibility = "visible"; }
|
||||
sDefaultCellStyleName = Misc.getAttribute(node,XMLString.TABLE_DEFAULT_CELL_STYLE_NAME);
|
||||
this.bDisplay = bDisplay;
|
||||
this.bHeader = bHeader;
|
||||
}
|
||||
|
||||
public String getStyleName() { return sStyleName; }
|
||||
|
||||
public String getVisibility() { return sVisibility; }
|
||||
|
||||
public boolean isCollapse() { return "collapse".equals(sVisibility); }
|
||||
|
||||
public boolean isFilter() { return "filter".equals(sVisibility); }
|
||||
|
||||
public String getDefaultCellStyleName() { return sDefaultCellStyleName; }
|
||||
|
||||
public boolean isDisplay() { return bDisplay; }
|
||||
|
||||
public boolean isHeader() { return bHeader; }
|
||||
|
||||
}
|
121
src/main/java/writer2latex/office/TableRange.java
Normal file
121
src/main/java/writer2latex/office/TableRange.java
Normal file
|
@ -0,0 +1,121 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* TableRange.java
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.0 (2008-09-07)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
/**
|
||||
* This class represent a table range within a table. A table range is defined
|
||||
* as a rectangular area (such as a print range), possibly excluding filtered
|
||||
* and hidden rows. A <code>TableView</code> can be derived from a table range,
|
||||
* providing read access to the range.
|
||||
*/
|
||||
public class TableRange {
|
||||
private TableReader reader;
|
||||
|
||||
private int nFirstRow;
|
||||
private int nLastRow;
|
||||
private int nFirstCol;
|
||||
private int nLastCol;
|
||||
private boolean bIncludeHidden;
|
||||
private boolean bIncludeFiltered;
|
||||
|
||||
public TableRange(TableReader reader) {
|
||||
this.reader = reader;
|
||||
|
||||
// The initial view is the complete table
|
||||
nFirstRow = 0;
|
||||
nLastRow = reader.getRowCount()-1;
|
||||
nFirstCol = 0;
|
||||
nLastCol = reader.getColCount()-1;
|
||||
bIncludeHidden = true;
|
||||
bIncludeFiltered = true;
|
||||
}
|
||||
|
||||
public void setFirstRow(int nRow) {
|
||||
// Adjust to a valid value (in 0..nLastRow)
|
||||
if (nRow<0) { nFirstRow = 0; }
|
||||
else if (nRow>nLastRow) { nFirstRow = nLastRow; }
|
||||
else { nFirstRow = nRow; }
|
||||
}
|
||||
|
||||
public int getFirstRow() {
|
||||
return nFirstRow;
|
||||
}
|
||||
|
||||
public void setLastRow(int nRow) {
|
||||
// Adjust to a valid value (in nFirstRow..(nRowCount-1))
|
||||
if (nRow<nFirstRow) { nLastRow = nFirstRow; }
|
||||
else if (nRow>=reader.getRowCount()) { nLastRow = reader.getRowCount()-1; }
|
||||
else { nLastRow = nRow; }
|
||||
}
|
||||
|
||||
public int getLastRow() {
|
||||
return nLastRow;
|
||||
}
|
||||
|
||||
public void setFirstCol(int nCol) {
|
||||
// Adjust to a valid value (in 0..nLastCol)
|
||||
if (nCol<0) { nFirstCol = 0; }
|
||||
else if (nCol>nLastCol) { nFirstCol = nLastCol; }
|
||||
else { nFirstCol = nCol; }
|
||||
}
|
||||
|
||||
public int getFirstCol() {
|
||||
return nFirstCol;
|
||||
}
|
||||
|
||||
public void setLastCol(int nCol) {
|
||||
// Adjust to a valid value (in nFirstCol..(nColCount-1))
|
||||
if (nCol<nFirstCol) { nLastCol = nFirstCol; }
|
||||
else if (nCol>=reader.getColCount()) { nLastCol = reader.getColCount()-1; }
|
||||
else { nLastCol = nCol; }
|
||||
}
|
||||
|
||||
public int getLastCol() {
|
||||
return nLastCol;
|
||||
}
|
||||
|
||||
public void setIncludeHidden(boolean b) {
|
||||
bIncludeHidden = b;
|
||||
}
|
||||
|
||||
public boolean includeHidden() {
|
||||
return bIncludeHidden;
|
||||
}
|
||||
|
||||
public void setIncludeFiltered(boolean b) {
|
||||
bIncludeFiltered = b;
|
||||
}
|
||||
|
||||
public boolean includeFiltered() {
|
||||
return bIncludeFiltered;
|
||||
}
|
||||
|
||||
public TableView createTableView() {
|
||||
return new TableView(reader, this);
|
||||
}
|
||||
|
||||
|
||||
}
|
130
src/main/java/writer2latex/office/TableRangeParser.java
Normal file
130
src/main/java/writer2latex/office/TableRangeParser.java
Normal file
|
@ -0,0 +1,130 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* TableRangeParser.java
|
||||
*
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.0 (2009-02-16)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import writer2latex.util.Misc;
|
||||
import writer2latex.util.SimpleInputBuffer;
|
||||
|
||||
/**
|
||||
* This class parses a space separated list of table ranges. A table range is of the form
|
||||
* <sheet name>.<column><row>:<sheet name>.<column><row>
|
||||
* where the sheet name is quoted (single quotes) if it contains spaces
|
||||
* the column is one or two uppercase letters (A-Z)
|
||||
* the row is an integer.
|
||||
* The sheet name is currently ignored, and so are any syntax errors
|
||||
*/
|
||||
public class TableRangeParser {
|
||||
private SimpleInputBuffer inbuf;
|
||||
|
||||
public TableRangeParser(String s) {
|
||||
inbuf = new SimpleInputBuffer(s);
|
||||
inbuf.skipSpaces();
|
||||
}
|
||||
|
||||
public boolean hasMoreRanges() {
|
||||
return !inbuf.atEnd();
|
||||
}
|
||||
|
||||
// returns { first col, first row, last col, last row }
|
||||
public int[] getRange() {
|
||||
if (!inbuf.atEnd()) {
|
||||
int[] nFirst = parseAddress();
|
||||
parseCharacter(':');
|
||||
int[] nLast = parseAddress();
|
||||
int[] nResult = { nFirst[0], nFirst[1], nLast[0], nLast[1] };
|
||||
return nResult;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void parseCharacter(char c) {
|
||||
// ignore the character if it's missing
|
||||
if (inbuf.peekChar()==c) { inbuf.getChar(); }
|
||||
inbuf.skipSpaces();
|
||||
}
|
||||
|
||||
// returns { col, row }
|
||||
private int[] parseAddress() {
|
||||
parseSheetName();
|
||||
parseCharacter('.');
|
||||
int[] nResult = new int[2];
|
||||
nResult[0] = parseColumn();
|
||||
nResult[1] = parseRow();
|
||||
inbuf.skipSpaces();
|
||||
return nResult;
|
||||
}
|
||||
|
||||
private void parseSheetName() {
|
||||
if (inbuf.peekChar()=='.') {
|
||||
// The sheet name may be omitted
|
||||
}
|
||||
else if (inbuf.peekChar()=='\'') {
|
||||
// The sheet name must be quoted if it contains space, dots or apostrophes
|
||||
inbuf.getChar(); // skip leading '
|
||||
while (!inbuf.atEnd() && inbuf.peekChar()!='\'') {
|
||||
inbuf.getChar();
|
||||
if (inbuf.peekChar()=='\'' && inbuf.peekFollowingChar()=='\'') {
|
||||
// Escaped '
|
||||
inbuf.getChar(); inbuf.getChar();
|
||||
}
|
||||
}
|
||||
inbuf.getChar(); // skip trailing '
|
||||
}
|
||||
else {
|
||||
// Unquoted sheet name, ends with dot
|
||||
while (!inbuf.atEnd() && inbuf.peekChar()!='.') {
|
||||
inbuf.getChar();
|
||||
}
|
||||
}
|
||||
inbuf.skipSpaces();
|
||||
}
|
||||
|
||||
// Return column number, starting with 0
|
||||
private int parseColumn() {
|
||||
if (inbuf.peekChar()>='A' && inbuf.peekChar()<='Z') {
|
||||
int nFirst = inbuf.getChar()-65;
|
||||
if (inbuf.peekChar()>='A' && inbuf.peekChar()<='Z') {
|
||||
int nSecond = inbuf.getChar()-65;
|
||||
return 26*(nFirst+1)+nSecond;
|
||||
}
|
||||
else {
|
||||
return nFirst;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0; // syntax error
|
||||
}
|
||||
}
|
||||
|
||||
// Return row number, starting with 0
|
||||
private int parseRow() {
|
||||
return Misc.getPosInteger(inbuf.getInteger(),1)-1;
|
||||
}
|
||||
|
||||
|
||||
}
|
500
src/main/java/writer2latex/office/TableReader.java
Normal file
500
src/main/java/writer2latex/office/TableReader.java
Normal file
|
@ -0,0 +1,500 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* TableReader.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* Version 1.4 (2014-09-05)
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import writer2latex.util.Calc;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
* <p> This class reads a table from a table:table or table:sub-table element
|
||||
* and presents it as an n by m grid. In addition it gives access to the
|
||||
* absolute and relative widths of tables, columns and cells.</p>
|
||||
*/
|
||||
public class TableReader {
|
||||
//private OfficeReader ofr;
|
||||
private Element tableNode;
|
||||
private LinkedList<TableLine> cols = new LinkedList<TableLine>();
|
||||
private LinkedList<TableLine> rows = new LinkedList<TableLine>();
|
||||
private LinkedList<LinkedList<Element>> cells = new LinkedList<LinkedList<Element>>();
|
||||
private int nMaxCols = 1; // real number of columns (count to last non-empty)
|
||||
private int nMaxRows = 1; // real number of rows (count to last non-empty)
|
||||
private String[] sColWidth;
|
||||
private String[] sRelColWidth;
|
||||
private String sTableWidth;
|
||||
private String sRelTableWidth;
|
||||
private Vector<TableRange> printRanges;
|
||||
|
||||
private int nRowCount;
|
||||
private int nEmptyRowCount;
|
||||
|
||||
/**
|
||||
* <p> The constructor reads a table from a table:table or table:sub-table
|
||||
* node.</p>
|
||||
* @param ofr the OfficeReader object to get style information from
|
||||
* @param tableNode the table node
|
||||
*/
|
||||
public TableReader(OfficeReader ofr, Element tableNode) {
|
||||
//this.ofr = ofr;
|
||||
this.tableNode = tableNode;
|
||||
if (!tableNode.hasChildNodes()) { return; } // empty table!
|
||||
|
||||
// Count the actual number of rows (trailing repeated rows are ignored)
|
||||
countTableRows(tableNode);
|
||||
|
||||
NodeList nl = tableNode.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Node child = nl.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_COLUMN)) {
|
||||
readTableColumn(child,false,false);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_COLUMNS)) {
|
||||
readTableColumns(child,false,false);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_COLUMN_GROUP)) {
|
||||
readTableColumnGroup(child,false,false);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_HEADER_COLUMNS)) {
|
||||
readTableHeaderColumns(child,false,false);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
readTableRow(child,false,false);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROWS)) {
|
||||
readTableRows(child,false,false);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
readTableRowGroup(child,false,false);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_HEADER_ROWS)) {
|
||||
readTableHeaderRows(child,false,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read table width from style
|
||||
StyleWithProperties tableStyle = ofr.getTableStyle(getTableStyleName());
|
||||
if (tableStyle!=null) {
|
||||
sTableWidth = tableStyle.getProperty(XMLString.STYLE_WIDTH);
|
||||
sRelTableWidth = tableStyle.getProperty(XMLString.STYLE_REL_WIDTH);
|
||||
}
|
||||
|
||||
// Determine column widths
|
||||
int nCols = cols.size();
|
||||
sColWidth = new String[nCols];
|
||||
sRelColWidth = new String[nCols];
|
||||
int[] nRelColWidth = new int[nCols];
|
||||
boolean bHasRelWidth=true; // set to false if some columns does not have a relative width set
|
||||
int nColSum = 0;
|
||||
for (int nCol=0; nCol<nCols; nCol++) {
|
||||
StyleWithProperties style = ofr.getColumnStyle(cols.get(nCol).getStyleName());
|
||||
if (style!=null) {
|
||||
sColWidth[nCol] = style.getProperty(XMLString.STYLE_COLUMN_WIDTH);
|
||||
String s = style.getProperty(XMLString.STYLE_REL_COLUMN_WIDTH);
|
||||
if (s!=null && s.endsWith("*")) {
|
||||
nRelColWidth[nCol] = Misc.getPosInteger(s.substring(0,s.length()-1),1);
|
||||
}
|
||||
}
|
||||
if (sColWidth[nCol]==null) { sColWidth[nCol] = "2cm"; } // emergency, should not happen
|
||||
if (nRelColWidth[nCol]==0) { bHasRelWidth = false; }
|
||||
nColSum += nRelColWidth[nCol];
|
||||
}
|
||||
for (int nCol=0; nCol<nCols; nCol++) {
|
||||
if (bHasRelWidth) {
|
||||
sRelColWidth[nCol] = (100.0F*nRelColWidth[nCol]/nColSum)+"%";
|
||||
}
|
||||
else if (sTableWidth!=null){
|
||||
// Calculate the relative column width from the absolute column widths
|
||||
// This may not add up to exactly 100%, but we will live with that
|
||||
sRelColWidth[nCol] = Calc.divide(sColWidth[nCol], sTableWidth, true);
|
||||
}
|
||||
else {
|
||||
// The table has not width, distribute the columns evenly
|
||||
sRelColWidth[nCol] = Double.toString(100.0/nCols)+"%";
|
||||
}
|
||||
}
|
||||
|
||||
// Now determine the actual number of rows and columns
|
||||
// (Calc exports a lot of empty rows at columns bottom/right)
|
||||
int nRows = cells.size();
|
||||
for (int nRow=0; nRow<nRows; nRow++) {
|
||||
LinkedList<Element> row = cells.get(nRow);
|
||||
nCols = row.size();
|
||||
int nMaxCol = 0;
|
||||
int nMaxRow = 0;
|
||||
for (int nCol=0; nCol<nCols; nCol++) {
|
||||
Element cell = (Element) row.get(nCol);
|
||||
if (cell.hasChildNodes()) {
|
||||
nMaxRow = nRow + Misc.getPosInteger(cell.getAttribute(
|
||||
XMLString.TABLE_NUMBER_ROWS_SPANNED),1);
|
||||
if (nMaxRow>nMaxRows) { nMaxRows = nMaxRow; }
|
||||
nMaxCol = nCol + Misc.getPosInteger(cell.getAttribute(
|
||||
XMLString.TABLE_NUMBER_COLUMNS_SPANNED),1);
|
||||
if (nMaxCol>nMaxCols) { nMaxCols = nMaxCol; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Finally get the print ranges, if any
|
||||
printRanges = new Vector<TableRange>();
|
||||
if (!"false".equals(tableNode.getAttribute(XMLString.TABLE_PRINT))) {
|
||||
TableRangeParser parser = new TableRangeParser(tableNode.getAttribute(XMLString.TABLE_PRINT_RANGES));
|
||||
while (parser.hasMoreRanges()) {
|
||||
int[] nRange = parser.getRange();
|
||||
TableRange range = new TableRange(this);
|
||||
range.setFirstCol(nRange[0]);
|
||||
range.setFirstRow(nRange[1]);
|
||||
range.setLastCol(nRange[2]);
|
||||
range.setLastRow(nRange[3]);
|
||||
printRanges.add(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readTableColumn(Node node, boolean bHeader, boolean bDisplay) {
|
||||
int nRepeat = Misc.getPosInteger(Misc.getAttribute(node,
|
||||
XMLString.TABLE_NUMBER_COLUMNS_REPEATED),1);
|
||||
while (nRepeat-->0) {
|
||||
cols.add(new TableLine(node,bHeader,bDisplay));
|
||||
}
|
||||
}
|
||||
|
||||
private void readTableColumns(Node node, boolean bHeader, boolean bDisplay) {
|
||||
if (!node.hasChildNodes()) { return; } // no columns here!
|
||||
NodeList nl = node.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Node child = nl.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_COLUMN)) {
|
||||
readTableColumn(child,bHeader,bDisplay);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_COLUMN_GROUP)) {
|
||||
readTableColumnGroup(child,bHeader,bDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readTableColumnGroup(Node node, boolean bHeader, boolean bDisplay) {
|
||||
bDisplay = !"false".equals(Misc.getAttribute(node,XMLString.TABLE_DISPLAY));
|
||||
if (!node.hasChildNodes()) { return; } // no columns here!
|
||||
NodeList nl = node.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Node child = nl.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_HEADER_COLUMNS)) {
|
||||
readTableHeaderColumns(child,bHeader,bDisplay);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_COLUMN)) {
|
||||
readTableColumn(child,bHeader,bDisplay);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_COLUMN_GROUP)) {
|
||||
readTableColumnGroup(child,bHeader,bDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readTableHeaderColumns(Node node, boolean bHeader, boolean bDisplay) {
|
||||
readTableColumns(node,true,bDisplay);
|
||||
}
|
||||
|
||||
private void readTableRow(Node node, boolean bHeader, boolean bDisplay) {
|
||||
int nRepeat = Misc.getPosInteger(Misc.getAttribute(node,
|
||||
XMLString.TABLE_NUMBER_ROWS_REPEATED),1);
|
||||
while (nRepeat-->0 && rows.size()<nRowCount) {
|
||||
rows.add(new TableLine(node,bHeader,bDisplay));
|
||||
|
||||
// Read the cells in the row
|
||||
LinkedList<Element> row = new LinkedList<Element>();
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList nl = node.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Node child = nl.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element cell = (Element) child;
|
||||
String sName = cell.getTagName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_CELL)) {
|
||||
int nColRepeat = Misc.getPosInteger(cell.getAttribute(
|
||||
XMLString.TABLE_NUMBER_COLUMNS_REPEATED),1);
|
||||
while (nColRepeat-->0) { row.add(cell); }
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_COVERED_TABLE_CELL)) {
|
||||
int nColRepeat = Misc.getPosInteger(cell.getAttribute(
|
||||
XMLString.TABLE_NUMBER_COLUMNS_REPEATED),1);
|
||||
while (nColRepeat-->0) { row.add(cell); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cells.add(row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void readTableRows(Node node, boolean bHeader, boolean bDisplay) {
|
||||
if (!node.hasChildNodes()) { return; } // no rows here!
|
||||
NodeList nl = node.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Node child = nl.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
readTableRow(child,bHeader,bDisplay);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
readTableRowGroup(child,bHeader,bDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readTableRowGroup(Node node, boolean bHeader, boolean bDisplay) {
|
||||
bDisplay = !"false".equals(Misc.getAttribute(node,XMLString.TABLE_DISPLAY));
|
||||
if (!node.hasChildNodes()) { return; } // no rows here!
|
||||
NodeList nl = node.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Node child = nl.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_HEADER_ROWS)) {
|
||||
readTableHeaderRows(child,bHeader,bDisplay);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
readTableRow(child,bHeader,bDisplay);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
readTableRowGroup(child,bHeader,bDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSubTable() {
|
||||
return XMLString.TABLE_SUB_TABLE.equals(tableNode.getTagName()) || // old
|
||||
"true".equals(Misc.getAttribute(tableNode,XMLString.TABLE_IS_SUB_TABLE)); // oasis
|
||||
}
|
||||
|
||||
private void readTableHeaderRows(Node node, boolean bHeader, boolean bDisplay) {
|
||||
readTableRows(node,true,bDisplay);
|
||||
}
|
||||
|
||||
private void countTableRows(Element table) {
|
||||
nRowCount = 0;
|
||||
nEmptyRowCount = 0;
|
||||
Node child = table.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
countTableRow(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROWS)) {
|
||||
countTableRows(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
countTableRowGroup(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_HEADER_ROWS)) {
|
||||
countTableHeaderRows(child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
// We will accept only one trailing empty row
|
||||
if (nEmptyRowCount>1) { nRowCount-=nEmptyRowCount-1; }
|
||||
}
|
||||
|
||||
private void countTableRow(Node node) {
|
||||
int nRepeat = Misc.getPosInteger(Misc.getAttribute(node,
|
||||
XMLString.TABLE_NUMBER_ROWS_REPEATED),1);
|
||||
nRowCount += nRepeat;
|
||||
if (isEmptyRow(node)) {
|
||||
nEmptyRowCount+=nRepeat;
|
||||
}
|
||||
else {
|
||||
nEmptyRowCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmptyRow(Node node) {
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element cell = (Element) child;
|
||||
String sName = cell.getTagName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_CELL)) {
|
||||
if (cell.hasChildNodes()) { return false; }
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void countTableRows(Node node) {
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
countTableRow(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
countTableRowGroup(child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void countTableRowGroup(Node node) {
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String sName = child.getNodeName();
|
||||
if (sName.equals(XMLString.TABLE_TABLE_HEADER_ROWS)) {
|
||||
countTableHeaderRows(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW)) {
|
||||
countTableRow(child);
|
||||
}
|
||||
else if (sName.equals(XMLString.TABLE_TABLE_ROW_GROUP)) {
|
||||
countTableRowGroup(child);
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void countTableHeaderRows(Node node) {
|
||||
countTableRows(node);
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableNode.getAttribute(XMLString.TABLE_NAME);
|
||||
}
|
||||
|
||||
public String getTableStyleName() {
|
||||
return tableNode.getAttribute(XMLString.TABLE_STYLE_NAME);
|
||||
}
|
||||
|
||||
public String getTableWidth() { return sTableWidth; }
|
||||
|
||||
public String getRelTableWidth() { return sRelTableWidth; }
|
||||
|
||||
public int getRowCount() { return rows.size(); }
|
||||
|
||||
public int getMaxRowCount() { return nMaxRows; }
|
||||
|
||||
public int getFirstBodyRow() {
|
||||
int nRows = rows.size();
|
||||
for (int nRow=0; nRow<nRows; nRow++) {
|
||||
if (!getRow(nRow).isHeader()) {
|
||||
return nRow;
|
||||
}
|
||||
}
|
||||
return nRows; // no body rows!
|
||||
}
|
||||
|
||||
public int getColCount() { return cols.size(); }
|
||||
|
||||
public int getMaxColCount() { return nMaxCols; }
|
||||
|
||||
public String getColumnWidth(int nCol) {
|
||||
return 0<=nCol && nCol<=cols.size() ? sColWidth[nCol] : null;
|
||||
}
|
||||
|
||||
public String getRelColumnWidth(int nCol) {
|
||||
return 0<=nCol && nCol<=cols.size() ? sRelColWidth[nCol] : null;
|
||||
}
|
||||
|
||||
public Element getCell(int nRow, int nCol) {
|
||||
if (nRow<0 || nRow>=cells.size()) { return null; }
|
||||
LinkedList<Element> row = cells.get(nRow);
|
||||
if (nCol<0 || nCol>=row.size()) { return null; }
|
||||
return (Element) row.get(nCol);
|
||||
}
|
||||
|
||||
public String getCellStyleName(int nRow, int nCol) {
|
||||
Element cell = (Element) getCell(nRow,nCol);
|
||||
if (cell==null) { return null; }
|
||||
String s = cell.getAttribute(XMLString.TABLE_STYLE_NAME); // try the cell
|
||||
if (s!=null && s.length()>0) { return s; }
|
||||
s = getRow(nRow).getDefaultCellStyleName(); // try row default
|
||||
if (s!=null && s.length()>0) { return s; }
|
||||
s = getCol(nCol).getDefaultCellStyleName(); // try column default
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getCellWidth(int nRow, int nCol) {
|
||||
Element cell = (Element) getCell(nRow,nCol);
|
||||
if (cell==null) { return null; }
|
||||
int nCols = Misc.getPosInteger(cell.getAttribute(XMLString.TABLE_NUMBER_COLUMNS_SPANNED),1);
|
||||
String sWidth = sColWidth[nCol];
|
||||
for (int i=nCol+1; i<nCol+nCols; i++) {
|
||||
sWidth = Calc.add(sWidth,sColWidth[i]);
|
||||
}
|
||||
return sWidth;
|
||||
}
|
||||
|
||||
public TableLine getRow(int nRow) {
|
||||
if (nRow<0 || nRow>=rows.size()) { return null; }
|
||||
return rows.get(nRow);
|
||||
}
|
||||
|
||||
public TableLine getCol(int nCol) {
|
||||
if (nCol<0 || nCol>=cols.size()) { return null; }
|
||||
return cols.get(nCol);
|
||||
}
|
||||
|
||||
public int getPrintRangeCount() { return printRanges.size(); }
|
||||
|
||||
public TableRange getPrintRange(int nIndex) {
|
||||
if (0<=nIndex && nIndex<printRanges.size()) {
|
||||
return printRanges.get(nIndex);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
209
src/main/java/writer2latex/office/TableView.java
Normal file
209
src/main/java/writer2latex/office/TableView.java
Normal file
|
@ -0,0 +1,209 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* TableView.java
|
||||
*
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.2 (2011-04-20)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
* This class represents a view of a <code>TableRange</code>. A view provides
|
||||
* read access to the range using a simple grid model.
|
||||
*/
|
||||
public class TableView {
|
||||
|
||||
private TableReader reader;
|
||||
private TableRange range;
|
||||
|
||||
// The size of the view (visible part of the range)
|
||||
private int nRowCount;
|
||||
private int nColCount;
|
||||
|
||||
// Map view row/col index to original index
|
||||
private int[] nRowMap;
|
||||
private int[] nColMap;
|
||||
|
||||
// The cells in the view
|
||||
private CellView[][] cells;
|
||||
|
||||
public TableView(TableReader reader, TableRange range) {
|
||||
this.reader = reader;
|
||||
this.range = range;
|
||||
|
||||
// Count visible rows & cols in this range
|
||||
nRowCount = 0;
|
||||
for (int nRow=range.getFirstRow(); nRow<=range.getLastRow(); nRow++) {
|
||||
if (isVisibleRow(nRow)) { nRowCount++; }
|
||||
}
|
||||
nColCount = 0;
|
||||
for (int nCol=range.getFirstCol(); nCol<=range.getLastCol(); nCol++) {
|
||||
if (isVisibleCol(nCol)) { nColCount++; }
|
||||
}
|
||||
|
||||
// Fill the row & col maps
|
||||
nRowMap = new int[nRowCount];
|
||||
int nRealRow = range.getFirstRow();
|
||||
for (int nRow=0; nRow<nRowCount; nRow++) {
|
||||
// Skip invisible rows
|
||||
while (!isVisibleRow(nRealRow)) { nRealRow++; }
|
||||
nRowMap[nRow] = nRealRow++;
|
||||
}
|
||||
nColMap = new int[nColCount];
|
||||
int nRealCol = range.getFirstCol();
|
||||
for (int nCol=0; nCol<nColCount; nCol++) {
|
||||
// Skip invisible cols
|
||||
while (!isVisibleCol(nRealCol)) { nRealCol++; }
|
||||
nColMap[nCol] = nRealCol++;
|
||||
}
|
||||
|
||||
// Initialize the cell views
|
||||
cells = new CellView[nRowCount][nColCount];
|
||||
for (int nRow=0; nRow<nRowCount; nRow++) {
|
||||
for (int nCol=0; nCol<nColCount; nCol++) {
|
||||
cells[nRow][nCol] = new CellView();
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the cell views
|
||||
// (must start in the upper left corner of the original table)
|
||||
int nViewRow = 0;
|
||||
for (int nRow=0; nRow<=range.getLastRow(); nRow++) {
|
||||
if (nViewRow<nRowCount && nRowMap[nViewRow]<nRow) { nViewRow++; }
|
||||
int nViewCol = 0;
|
||||
for (int nCol=0; nCol<=range.getLastCol(); nCol++) {
|
||||
if (nViewCol<nColCount && nColMap[nViewCol]<nCol) { nViewCol++; }
|
||||
Element cell = reader.getCell(nRow,nCol);
|
||||
if (cell!=null) {
|
||||
if (Misc.isElement(cell,XMLString.TABLE_TABLE_CELL)) {
|
||||
int nRowSpan = Misc.getPosInteger(cell.getAttribute(XMLString.TABLE_NUMBER_ROWS_SPANNED),1);
|
||||
int nColSpan = Misc.getPosInteger(cell.getAttribute(XMLString.TABLE_NUMBER_COLUMNS_SPANNED),1);
|
||||
// Test if (parts of) the cell belongs the view
|
||||
if (nViewRow<nRowCount && nRowMap[nViewRow]<nRow+nRowSpan &&
|
||||
nViewCol<nColCount && nColMap[nViewCol]<nCol+nColSpan) {
|
||||
cells[nViewRow][nViewCol].cell=cell;
|
||||
cells[nViewRow][nViewCol].nOriginalRow=nRow;
|
||||
cells[nViewRow][nViewCol].nOriginalCol=nCol;
|
||||
// Calculate rowspan in view
|
||||
int i=nViewRow+1;
|
||||
while (i<nRowCount && nRowMap[i]<nRow+nRowSpan) { i++; }
|
||||
cells[nViewRow][nViewCol].nRowSpan = i-nViewRow;
|
||||
// Calculate colspan in view
|
||||
int j=nViewCol+1;
|
||||
while (j<nColCount && nColMap[j]<nCol+nColSpan) { j++; }
|
||||
cells[nViewRow][nViewCol].nColSpan = j-nViewCol;
|
||||
}
|
||||
}
|
||||
else if (Misc.isElement(cell,XMLString.TABLE_COVERED_TABLE_CELL)) {
|
||||
// Don't overwrite, the position may be occupied with a relocated cell
|
||||
if (cells[nViewRow][nViewCol].cell==null) {
|
||||
cells[nViewRow][nViewCol].cell=cell;
|
||||
cells[nViewRow][nViewCol].nOriginalRow=nRow;
|
||||
cells[nViewRow][nViewCol].nOriginalCol=nCol;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // Non-existing cell, treat as empty
|
||||
// Test if the cell belongs the view
|
||||
if (nViewRow<nRowCount && nRowMap[nViewRow]<nRow+1 &&
|
||||
nViewCol<nColCount && nColMap[nViewCol]<nCol+1) {
|
||||
cells[nViewRow][nViewCol].cell=null;
|
||||
cells[nViewRow][nViewCol].nOriginalRow=nRow;
|
||||
cells[nViewRow][nViewCol].nOriginalCol=nCol;
|
||||
cells[nViewRow][nViewCol].nRowSpan = 1;
|
||||
cells[nViewRow][nViewCol].nColSpan = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getRelTableWidth() { return reader.getRelTableWidth(); }
|
||||
|
||||
public int getRowCount() { return nRowCount; }
|
||||
|
||||
public int getColCount() { return nColCount; }
|
||||
|
||||
public String getColumnWidth(int nCol) {
|
||||
return 0<=nCol && nCol<=nColCount ? reader.getColumnWidth(nColMap[nCol]) : null;
|
||||
}
|
||||
|
||||
// TODO: Recalculate - the sum should be 100% even in a view!!
|
||||
public String getRelColumnWidth(int nCol) {
|
||||
return 0<=nCol && nCol<=nColCount ? reader.getRelColumnWidth(nColMap[nCol]) : null;
|
||||
}
|
||||
|
||||
public TableLine getRow(int nRow) {
|
||||
return 0<=nRow && nRow<nRowCount ? reader.getRow(nRowMap[nRow]) : null;
|
||||
}
|
||||
|
||||
public TableLine getCol(int nCol) {
|
||||
return 0<=nCol && nCol<nColCount ? reader.getCol(nColMap[nCol]) : null;
|
||||
}
|
||||
|
||||
public Element getCell(int nRow, int nCol) {
|
||||
return 0<=nRow && nRow<nRowCount && 0<=nCol && nCol<nColCount ?
|
||||
cells[nRow][nCol].cell : null;
|
||||
}
|
||||
|
||||
public int getRowSpan(int nRow, int nCol) {
|
||||
return 0<=nRow && nRow<nRowCount && 0<=nCol && nCol<nColCount ?
|
||||
cells[nRow][nCol].nRowSpan : 1;
|
||||
}
|
||||
|
||||
public int getColSpan(int nRow, int nCol) {
|
||||
return 0<=nRow && nRow<nRowCount && 0<=nCol && nCol<nColCount ?
|
||||
cells[nRow][nCol].nColSpan : 1;
|
||||
}
|
||||
|
||||
public String getCellStyleName(int nRow, int nCol) {
|
||||
return 0<=nRow && nRow<nRowCount && 0<=nCol && nCol<nColCount ?
|
||||
reader.getCellStyleName(cells[nRow][nCol].nOriginalRow, cells[nRow][nCol].nOriginalCol) : null;
|
||||
}
|
||||
|
||||
// TODO: Not correct, see TableReader
|
||||
public String getCellWidth(int nRow, int nCol) {
|
||||
return 0<=nRow && nRow<nRowCount && 0<=nCol && nCol<nColCount ?
|
||||
reader.getCellWidth(cells[nRow][nCol].nOriginalRow, cells[nRow][nCol].nOriginalCol) : null;
|
||||
}
|
||||
|
||||
// Helper method: Is this row visible in this view?
|
||||
private boolean isVisibleRow(int nRow) {
|
||||
return nRow>=range.getFirstRow() && nRow<=range.getLastRow() &&
|
||||
(range.includeHidden() || !reader.getRow(nRow).isCollapse()) &&
|
||||
(range.includeFiltered() || !reader.getRow(nRow).isFilter());
|
||||
}
|
||||
|
||||
// Helper method: Is this column visible in this view?
|
||||
private boolean isVisibleCol(int nCol) {
|
||||
return nCol>=range.getFirstCol() && nCol<=range.getLastCol() &&
|
||||
(range.includeHidden() || !reader.getCol(nCol).isCollapse()) &&
|
||||
(range.includeFiltered() || !reader.getCol(nCol).isFilter());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
186
src/main/java/writer2latex/office/TocReader.java
Normal file
186
src/main/java/writer2latex/office/TocReader.java
Normal file
|
@ -0,0 +1,186 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* TocReader.java
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.4 (2014-08-27)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
* <p>The class reads a <code>text:table-of-content</code> element.</p>
|
||||
*/
|
||||
public class TocReader {
|
||||
|
||||
Element tocSource = null;
|
||||
//Element indexBody = null;
|
||||
|
||||
String sName=null; // (section) name for this toc
|
||||
String sStyleName=null; // section style name
|
||||
|
||||
int nOutlineLevel = 10; // max level to include
|
||||
boolean bUseOutlineLevel = true; // use headings
|
||||
boolean bUseIndexSourceStyles = false; // use additional styles
|
||||
boolean bUseIndexMarks = true; // use toc marks
|
||||
boolean bIsByChapter = false; // default is document
|
||||
|
||||
Element indexTitleTemplate = null;
|
||||
Element[] tocEntryTemplate = new Element[11];
|
||||
Hashtable<String, Integer> indexSourceStyles = new Hashtable<String, Integer>();
|
||||
|
||||
|
||||
|
||||
/** <p>Initialize the TocReader with a table of content node.
|
||||
* @param onode a <code>text:table-of-content</code>
|
||||
*/
|
||||
public TocReader(Element onode) {
|
||||
sName = Misc.getAttribute(onode,XMLString.TEXT_NAME);
|
||||
sStyleName = Misc.getAttribute(onode,XMLString.TEXT_STYLE_NAME);
|
||||
|
||||
Element tocSource = Misc.getChildByTagName(onode,XMLString.TEXT_TABLE_OF_CONTENT_SOURCE);
|
||||
//Element indexBody = Misc.getChildByTagName(onode,XMLString.TEXT_INDEX_BODY);
|
||||
|
||||
if (tocSource!=null) {
|
||||
nOutlineLevel = Misc.getPosInteger(tocSource.getAttribute(XMLString.TEXT_OUTLINE_LEVEL),1);
|
||||
bUseOutlineLevel = !"false".equals(tocSource.getAttribute(XMLString.TEXT_USE_OUTLINE_LEVEL));
|
||||
bUseIndexSourceStyles = "true".equals(tocSource.getAttribute(XMLString.TEXT_USE_INDEX_SOURCE_STYLES));
|
||||
bUseIndexMarks = !"false".equals(tocSource.getAttribute(XMLString.TEXT_USE_INDEX_MARKS));
|
||||
bIsByChapter = "chapter".equals(tocSource.getAttribute(XMLString.TEXT_INDEX_SCOPE));
|
||||
|
||||
// traverse the source to collect templates
|
||||
Node child = tocSource.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE) {
|
||||
Element elm = (Element) child;
|
||||
if (XMLString.TEXT_INDEX_TITLE_TEMPLATE.equals(elm.getTagName())) {
|
||||
indexTitleTemplate = elm;
|
||||
}
|
||||
if (XMLString.TEXT_TABLE_OF_CONTENT_ENTRY_TEMPLATE.equals(elm.getTagName())) {
|
||||
int nLevel = Misc.getPosInteger(elm.getAttribute(XMLString.TEXT_OUTLINE_LEVEL),1);
|
||||
if (1<=nLevel && nLevel<=10) { tocEntryTemplate[nLevel] = elm; }
|
||||
}
|
||||
if (XMLString.TEXT_INDEX_SOURCE_STYLES.equals(elm.getTagName())) {
|
||||
int nLevel = Misc.getPosInteger(elm.getAttribute(XMLString.TEXT_OUTLINE_LEVEL),1);
|
||||
if (1<=nLevel && nLevel<=10) {
|
||||
// traverse to collect index source styles for this level
|
||||
Node child1 = elm.getFirstChild();
|
||||
while (child1!=null) {
|
||||
if (child1.getNodeType()==Node.ELEMENT_NODE) {
|
||||
Element elm1 = (Element) child1;
|
||||
if (XMLString.TEXT_INDEX_SOURCE_STYLE.equals(elm1.getTagName())) {
|
||||
String sIndexSourceStyle = Misc.getAttribute(elm1,XMLString.TEXT_STYLE_NAME);
|
||||
if (sIndexSourceStyle!=null) {
|
||||
indexSourceStyles.put(sIndexSourceStyle,new Integer(nLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
child1 = child1.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** <p>Get the (section) name for this toc </p>
|
||||
* @return the name of the toc
|
||||
*/
|
||||
public String getName() { return sName; }
|
||||
|
||||
/** <p>Get the (section) style name for this toc </p>
|
||||
* @return name of the section style to use for this toc
|
||||
*/
|
||||
public String getStyleName() { return sStyleName; }
|
||||
|
||||
/** <p>Get max outline level for this toc </p>
|
||||
* @return max outline level
|
||||
*/
|
||||
public int getOutlineLevel() { return nOutlineLevel; }
|
||||
|
||||
/** <p>Do we use outline (headings) in this toc? </p>
|
||||
* @return true if headings should be used
|
||||
*/
|
||||
public boolean useOutlineLevel() { return bUseOutlineLevel; }
|
||||
|
||||
/** <p>Do we use additional styles in this toc? </p>
|
||||
* @return true if additional styles should be used
|
||||
*/
|
||||
public boolean useIndexSourceStyles() { return bUseIndexSourceStyles; }
|
||||
|
||||
/** <p>Do we use toc marks in this toc? </p>
|
||||
* @return true if toc marks should be used
|
||||
*/
|
||||
public boolean useIndexMarks() { return bUseIndexMarks; }
|
||||
|
||||
/** <p>Is this toc by chapter? </p>
|
||||
* @return true if the scope is a chapter only
|
||||
*/
|
||||
public boolean isByChapter() { return bIsByChapter; }
|
||||
|
||||
/** <p>Get the index title template for this toc</p>
|
||||
* @return the <code>text:index-title-template</code> element, or null
|
||||
*/
|
||||
public Element getIndexTitleTemplate() { return indexTitleTemplate; }
|
||||
|
||||
/** <p>Get the entry template for this toc at a specific level</p>
|
||||
* @param nLevel the outline level
|
||||
* @return the <code>text:table-of-content-entry-template</code> element, or null
|
||||
*/
|
||||
public Element getTocEntryTemplate(int nLevel) {
|
||||
if (1<=nLevel && nLevel<=10) { return tocEntryTemplate[nLevel]; }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
/** <p>Get a set view of all index source styles</p>
|
||||
* @return a set of all index source style names
|
||||
*/
|
||||
public Set<String> getIndexSourceStyles() { return indexSourceStyles.keySet(); }
|
||||
|
||||
/** <p>Get the level associated with a specific index source style</p>
|
||||
* @param sStyleName the style name of the index source style
|
||||
* @return the level or -1 if the style is not used in this toc
|
||||
*/
|
||||
public int getIndexSourceStyleLevel(String sStyleName) {
|
||||
if (indexSourceStyles.containsKey(sStyleName)) {
|
||||
return indexSourceStyles.get(sStyleName).intValue();
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/** <p>Return the generated content of this toc, if available</p>
|
||||
* @return the <code>text:index-body</code> element
|
||||
*/
|
||||
/* public Element getIndexBody() { return indexBody; } */
|
||||
|
||||
|
||||
}
|
483
src/main/java/writer2latex/office/XMLString.java
Normal file
483
src/main/java/writer2latex/office/XMLString.java
Normal file
|
@ -0,0 +1,483 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* XMLString.java
|
||||
*
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* This file is part of Writer2LaTeX.
|
||||
*
|
||||
* Writer2LaTeX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Writer2LaTeX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Writer2LaTeX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Version 1.6 (2015-06-18)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.office;
|
||||
|
||||
/* XML strings (tags and attributes) in the OOo XML namespaces
|
||||
* typosafe but not typesafe :-)
|
||||
*/
|
||||
|
||||
public class XMLString {
|
||||
// draw namespace - elements
|
||||
public static final String DRAW_="draw:";
|
||||
public static final String DRAW_PAGE="draw:page";
|
||||
public static final String DRAW_A="draw:a";
|
||||
public static final String DRAW_FRAME="draw:frame"; // oasis
|
||||
public static final String DRAW_IMAGE="draw:image";
|
||||
public static final String DRAW_OBJECT="draw:object";
|
||||
public static final String DRAW_OBJECT_OLE="draw:object-ole";
|
||||
public static final String DRAW_TEXT_BOX="draw:text-box";
|
||||
public static final String DRAW_G="draw:g";
|
||||
public static final String DRAW_CONTROL="draw:control";
|
||||
// draw namespace - attributes
|
||||
public static final String DRAW_NAME="draw:name";
|
||||
public static final String DRAW_STYLE_NAME="draw:style-name";
|
||||
public static final String DRAW_TEXT_STYLE_NAME="draw:text-style-name";
|
||||
public static final String DRAW_MASTER_PAGE_NAME="draw:master-page-name";
|
||||
public static final String DRAW_FILL_COLOR="draw:fill-color";
|
||||
|
||||
// dc namespace - elements
|
||||
public static final String DC_CREATOR="dc:creator";
|
||||
public static final String DC_DATE="dc:date";
|
||||
public static final String DC_DESCRIPTION="dc:description";
|
||||
public static final String DC_LANGUAGE="dc:language";
|
||||
public static final String DC_SUBJECT="dc:subject";
|
||||
public static final String DC_TITLE="dc:title";
|
||||
|
||||
// meta namespace - elements
|
||||
public static final String META_INITIAL_CREATOR="meta:initial-creator";
|
||||
public static final String META_KEYWORDS="meta:keywords";
|
||||
public static final String META_KEYWORD="meta:keyword";
|
||||
public static final String META_USER_DEFINED="meta:user-defined";
|
||||
// meta namespace - attributes
|
||||
public static final String META_NAME="meta:name";
|
||||
|
||||
// manifest namespace
|
||||
public static final String MANIFEST_FILE_ENTRY="manifest:file-entry";
|
||||
public static final String MANIFEST_MEDIA_TYPE="manifest:media-type";
|
||||
public static final String MANIFEST_FULL_PATH="manifest:full-path";
|
||||
|
||||
// office namespace - elements
|
||||
public static final String OFFICE_DOCUMENT_CONTENT="office:document-content";
|
||||
public static final String OFFICE_MASTER_STYLES="office:master-styles";
|
||||
public static final String OFFICE_STYLES="office:styles";
|
||||
public static final String OFFICE_AUTOMATIC_STYLES="office:automatic-styles";
|
||||
public static final String OFFICE_FONT_DECLS="office:font-decls";
|
||||
public static final String OFFICE_FONT_FACE_DECLS="office:font-face-decls"; // oasis
|
||||
public static final String OFFICE_BODY="office:body";
|
||||
public static final String OFFICE_TEXT="office:text"; // oasis
|
||||
public static final String OFFICE_SPREADSHEET="office:spreadsheet"; // oasis
|
||||
public static final String OFFICE_PRESENTATION="office:presentation"; // oasis
|
||||
public static final String OFFICE_FORMS="office:forms";
|
||||
public static final String OFFICE_ANNOTATION="office:annotation";
|
||||
public static final String OFFICE_BINARY_DATA="office:binary-data";
|
||||
public static final String OFFICE_META="office:meta";
|
||||
// office namespace - attributes
|
||||
public static final String OFFICE_TARGET_FRAME_NAME="office:target-frame-name";
|
||||
public static final String OFFICE_NAME="office:name";
|
||||
public static final String OFFICE_VALUE_TYPE="office:value-type"; // oasis
|
||||
|
||||
// form namespace - elements
|
||||
public static final String FORM_FORM="form:form";
|
||||
public static final String FORM_CONTROL="form:control";
|
||||
public static final String FORM_TEXT="form:text";
|
||||
public static final String FORM_PASSWORD="form:password";
|
||||
public static final String FORM_FILE="form:file";
|
||||
public static final String FORM_IMAGE="form:image";
|
||||
public static final String FORM_HIDDEN="form:hidden";
|
||||
public static final String FORM_CHECKBOX="form:checkbox";
|
||||
public static final String FORM_RADIO="form:radio";
|
||||
public static final String FORM_BUTTON="form:button";
|
||||
public static final String FORM_FIXED_TEXT="form:fixed-text";
|
||||
public static final String FORM_TEXTAREA="form:textarea";
|
||||
public static final String FORM_LISTBOX="form:listbox";
|
||||
public static final String FORM_COMBOBOX="form:combobox";
|
||||
public static final String FORM_ITEM="form:item";
|
||||
public static final String FORM_OPTION="form:option";
|
||||
// form namespace - attributes
|
||||
public static final String FORM_NAME="form:name";
|
||||
public static final String FORM_ID="form:id";
|
||||
public static final String FORM_METHOD="form:method";
|
||||
public static final String FORM_TYPE="form:type";
|
||||
public static final String FORM_BUTTON_TYPE="form:button-type";
|
||||
public static final String FORM_DISABLED="form:disabled";
|
||||
public static final String FORM_READONLY="form:readonly";
|
||||
public static final String FORM_DEFAULT_VALUE="form:default-value";
|
||||
public static final String FORM_VALUE="form:value";
|
||||
public static final String FORM_TAB_INDEX="form:tab-index";
|
||||
public static final String FORM_TITLE="form:title";
|
||||
public static final String FORM_MAX_LENGTH="form:max-length";
|
||||
public static final String FORM_MULTIPLE="form:multiple";
|
||||
public static final String FORM_SELECTED="form:selected";
|
||||
public static final String FORM_LABEL="form:label";
|
||||
public static final String FORM_SIZE="form:size";
|
||||
|
||||
// presentation namespace - attributes
|
||||
public static final String PRESENTATION_CLASS="presentation:class";
|
||||
public static final String PRESENTATION_STYLE_NAME="presentation:style-name";
|
||||
|
||||
// style namespace - elements
|
||||
public static final String STYLE_PAGE_MASTER="style:page-master";
|
||||
public static final String STYLE_PAGE_LAYOUT="style:page-layout"; // oasis
|
||||
public static final String STYLE_MASTER_PAGE="style:master-page";
|
||||
public static final String STYLE_FONT_DECL="style:font-decl";
|
||||
public static final String STYLE_FONT_FACE="style:font-face"; // oasis
|
||||
public static final String STYLE_STYLE="style:style";
|
||||
public static final String STYLE_DEFAULT_STYLE="style:default-style";
|
||||
public static final String STYLE_PROPERTIES="style:properties";
|
||||
public static final String STYLE_TEXT_PROPERTIES="style:text-properties"; // oasis
|
||||
public static final String STYLE_PARAGRAPH_PROPERTIES="style:paragraph-properties"; // oasis
|
||||
public static final String STYLE_SECTION_PROPERTIES="style:section-properties"; // oasis
|
||||
public static final String STYLE_TABLE_PROPERTIES="style:table-properties"; // oasis
|
||||
public static final String STYLE_TABLE_ROW_PROPERTIES="style:table-row-properties"; // oasis
|
||||
public static final String STYLE_TABLE_COLUMN_PROPERTIES="style:table-column-properties"; // oasis
|
||||
public static final String STYLE_TABLE_CELL_PROPERTIES="style:table-cell-properties"; // oasis
|
||||
public static final String STYLE_GRAPHIC_PROPERTIES="style:graphic-properties"; // oasis
|
||||
public static final String STYLE_PAGE_LAYOUT_PROPERTIES="style:page-layout-properties"; // oasis
|
||||
public static final String STYLE_DRAWING_PAGE_PROPERTIES="style:drawing-page-properties"; // oasis
|
||||
public static final String STYLE_HEADER_FOOTER_PROPERTIES="style:header-footer-properties"; // oasis
|
||||
public static final String STYLE_LIST_LEVEL_LABEL_ALIGNMENT="style:list-level-label-alignment"; // oasis 1.2
|
||||
public static final String STYLE_BACKGROUND_IMAGE="style:background-image";
|
||||
public static final String STYLE_COLUMNS="style:columns";
|
||||
public static final String STYLE_HEADER="style:header";
|
||||
public static final String STYLE_HEADER_LEFT="style:header-left";
|
||||
public static final String STYLE_FOOTER="style:footer";
|
||||
public static final String STYLE_FOOTER_LEFT="style:footer-left";
|
||||
public static final String STYLE_FOOTNOTE_SEP="style:footnote-sep";
|
||||
public static final String STYLE_HEADER_STYLE="style:header-style";
|
||||
public static final String STYLE_FOOTER_STYLE="style:footer-style";
|
||||
// style namespace - attributes
|
||||
public static final String STYLE_NEXT_STYLE_NAME="style:next-style-name";
|
||||
public static final String STYLE_DISPLAY_NAME="style:display-name";
|
||||
public static final String STYLE_PAGE_MASTER_NAME="style:page-master-name";
|
||||
public static final String STYLE_PAGE_LAYOUT_NAME="style:page-layout-name"; // oasis
|
||||
public static final String STYLE_MASTER_PAGE_NAME="style:master-page-name";
|
||||
public static final String STYLE_PAGE_USAGE="style:page-usage";
|
||||
public static final String STYLE_PAGE_NUMBER="style:page-number";
|
||||
public static final String STYLE_FONT_FAMILY_COMPLEX="style:font-family-complex";
|
||||
public static final String STYLE_FONT_NAME="style:font-name";
|
||||
public static final String STYLE_FONT_NAME_COMPLEX="style:font-name-complex";
|
||||
public static final String STYLE_FONT_PITCH="style:font-pitch";
|
||||
public static final String STYLE_FONT_FAMILY_GENERIC="style:font-family-generic";
|
||||
public static final String STYLE_TEXT_BACKGROUND_COLOR="style:text-background-color";
|
||||
public static final String STYLE_USE_WINDOW_FONT_COLOR="style:use-window-font-color";
|
||||
public static final String STYLE_TEXT_CROSSING_OUT="style:text-crossing-out";
|
||||
public static final String STYLE_TEXT_UNDERLINE="style:text-underline";
|
||||
public static final String STYLE_TEXT_BLINKING="style:text-blinking";
|
||||
public static final String STYLE_TEXT_LINE_THROUGH_STYLE="style:text-line-through-style"; // oasis
|
||||
public static final String STYLE_TEXT_UNDERLINE_STYLE="style:text-underline-style"; // oasis
|
||||
public static final String STYLE_AUTO_TEXT_INDENT="style:auto-text-indent";
|
||||
public static final String STYLE_TEXT_ALIGN_SOURCE="style:text-align-source";
|
||||
public static final String STYLE_NAME="style:name";
|
||||
public static final String STYLE_PARENT_STYLE_NAME="style:parent-style-name";
|
||||
public static final String STYLE_FAMILY="style:family";
|
||||
public static final String STYLE_TEXT_POSITION="style:text-position";
|
||||
public static final String STYLE_LIST_STYLE_NAME="style:list-style-name";
|
||||
public static final String STYLE_LIST_LEVEL_PROPERTIES="style:list-level-properties";
|
||||
public static final String STYLE_NUM_PREFIX="style:num-prefix";
|
||||
public static final String STYLE_NUM_SUFFIX="style:num-suffix";
|
||||
public static final String STYLE_NUM_FORMAT="style:num-format";
|
||||
public static final String STYLE_VERTICAL_ALIGN="style:vertical-align";
|
||||
public static final String STYLE_MAY_BREAK_BETWEEN_ROWS="style:may-break-between-rows";
|
||||
public static final String STYLE_HORIZONTAL_POS="style:horizontal-pos";
|
||||
public static final String STYLE_WRAP="style:wrap";
|
||||
public static final String STYLE_COLUMN_WIDTH="style:column-width";
|
||||
public static final String STYLE_REL_COLUMN_WIDTH="style:rel-column-width";
|
||||
public static final String STYLE_ROW_HEIGHT="style:row-height";
|
||||
public static final String STYLE_MIN_ROW_HEIGHT="style:min-row-height";
|
||||
public static final String STYLE_FIRST_PAGE_NUMBER="style:first-page-number";
|
||||
public static final String STYLE_DISTANCE_BEFORE_SEP="style:distance-before-sep";
|
||||
public static final String STYLE_DISTANCE_AFTER_SEP="style:distance-after-sep";
|
||||
public static final String STYLE_WIDTH="style:width";
|
||||
public static final String STYLE_REL_WIDTH="style:rel-width";
|
||||
public static final String STYLE_COLOR="style:color";
|
||||
public static final String STYLE_WRITING_MODE="style:writing-mode";
|
||||
public static final String STYLE_REPEAT="style:repeat";
|
||||
public static final String STYLE_POSITION="style:position";
|
||||
public static final String STYLE_ADJUSTMENT="style:adjustment";
|
||||
public static final String STYLE_LANGUAGE_COMPLEX="style:language-complex";
|
||||
public static final String STYLE_COUNTRY_COMPLEX="style:country-complex";
|
||||
public static final String STYLE_LANGUAGE_ASIAN="style:language-asian";
|
||||
public static final String STYLE_COUNTRY_ASIAN="style:country-asian";
|
||||
|
||||
// table namespace - elements
|
||||
public static final String TABLE_="table:";
|
||||
public static final String TABLE_TABLE="table:table";
|
||||
public static final String TABLE_SUB_TABLE="table:sub-table";
|
||||
public static final String TABLE_SHAPES="table:shapes";
|
||||
public static final String TABLE_TABLE_COLUMN="table:table-column";
|
||||
public static final String TABLE_TABLE_COLUMNS="table:table-columns";
|
||||
public static final String TABLE_TABLE_COLUMN_GROUP="table:table-column-group";
|
||||
public static final String TABLE_TABLE_HEADER_COLUMNS="table:table-header-columns";
|
||||
public static final String TABLE_TABLE_ROW="table:table-row";
|
||||
public static final String TABLE_TABLE_ROWS="table:table-rows";
|
||||
public static final String TABLE_TABLE_ROW_GROUP="table:table-row-group";
|
||||
public static final String TABLE_TABLE_HEADER_ROWS="table:table-header-rows";
|
||||
public static final String TABLE_TABLE_CELL="table:table-cell";
|
||||
public static final String TABLE_COVERED_TABLE_CELL="table:covered-table-cell";
|
||||
// table namespace - attributes
|
||||
public static final String TABLE_NAME="table:name";
|
||||
public static final String TABLE_IS_SUB_TABLE="table:is-sub-table"; // oasis
|
||||
public static final String TABLE_STYLE_NAME="table:style-name";
|
||||
public static final String TABLE_VISIBILITY="table:visibility";
|
||||
public static final String TABLE_DISPLAY="table:display";
|
||||
public static final String TABLE_DEFAULT_CELL_STYLE_NAME="table:default-cell-style-name";
|
||||
public static final String TABLE_VALUE_TYPE="table:value-type";
|
||||
public static final String TABLE_NUMBER_COLUMNS_REPEATED="table:number-columns-repeated";
|
||||
public static final String TABLE_NUMBER_ROWS_REPEATED="table:number-rows-repeated";
|
||||
public static final String TABLE_NUMBER_ROWS_SPANNED="table:number-rows-spanned";
|
||||
public static final String TABLE_NUMBER_COLUMNS_SPANNED="table:number-columns-spanned";
|
||||
public static final String TABLE_ALIGN="table:align";
|
||||
public static final String TABLE_PRINT="table:print";
|
||||
public static final String TABLE_PRINT_RANGES="table:print-ranges";
|
||||
|
||||
// text namespace - elements (declarations)
|
||||
public static final String TEXT_="text:";
|
||||
public static final String TEXT_FOOTNOTES_CONFIGURATION="text:footnotes-configuration";
|
||||
public static final String TEXT_ENDNOTES_CONFIGURATION="text:endnotes-configuration";
|
||||
public static final String TEXT_NOTES_CONFIGURATION="text:notes-configuration"; // oasis
|
||||
public static final String TEXT_BIBLIOGRAPHY_CONFIGURATION="text:bibliography-configuration";
|
||||
public static final String TEXT_SORT_KEY="text:sort-key";
|
||||
public static final String TEXT_SECTION_SOURCE="text:section-source";
|
||||
public static final String TEXT_SEQUENCE_DECLS="text:sequence-decls";
|
||||
public static final String TEXT_SEQUENCE_DECL="text:sequence-decl";
|
||||
public static final String TEXT_OUTLINE_STYLE="text:outline-style";
|
||||
public static final String TEXT_OUTLINE_LEVEL_STYLE="text:outline-level-style";
|
||||
public static final String TEXT_LIST_STYLE="text:list-style";
|
||||
public static final String TEXT_LIST_LEVEL_STYLE_NUMBER="text:list-level-style-number";
|
||||
public static final String TEXT_LIST_LEVEL_STYLE_BULLET="text:list-level-style-bullet";
|
||||
public static final String TEXT_LIST_LEVEL_STYLE_IMAGE="text:list-level-style-image";
|
||||
// text namespace - elements (block text)
|
||||
public static final String TEXT_SECTION="text:section";
|
||||
public static final String TEXT_P="text:p";
|
||||
public static final String TEXT_H="text:h";
|
||||
public static final String TEXT_LIST="text:list"; // oasis
|
||||
public static final String TEXT_ORDERED_LIST="text:ordered-list";
|
||||
public static final String TEXT_UNORDERED_LIST="text:unordered-list";
|
||||
public static final String TEXT_LIST_ITEM="text:list-item";
|
||||
public static final String TEXT_LIST_HEADER="text:list-header";
|
||||
public static final String TEXT_ALPHABETICAL_INDEX="text:alphabetical-index";
|
||||
public static final String TEXT_ALPHABETICAL_INDEX_SOURCE="text:alphabetical-index-source";
|
||||
public static final String TEXT_ALPHABETICAL_INDEX_ENTRY_TEMPLATE="text:alphabetical-index-entry-template";
|
||||
public static final String TEXT_TABLE_OF_CONTENT="text:table-of-content";
|
||||
public static final String TEXT_TABLE_OF_CONTENT_SOURCE="text:table-of-content-source";
|
||||
public static final String TEXT_TABLE_OF_CONTENT_ENTRY_TEMPLATE="text:table-of-content-entry-template";
|
||||
public static final String TEXT_INDEX_SOURCE_STYLES="text:index-source-styles";
|
||||
public static final String TEXT_INDEX_SOURCE_STYLE="text:index-source-style";
|
||||
public static final String TEXT_ILLUSTRATION_INDEX="text:illustration-index";
|
||||
public static final String TEXT_ILLUSTRATION_INDEX_SOURCE="text:illustration-index-source";
|
||||
public static final String TEXT_ILLUSTRATION_INDEX_ENTRY_TEMPLATE="text:illustration-index-entry-template";
|
||||
public static final String TEXT_TABLE_INDEX="text:table-index";
|
||||
public static final String TEXT_TABLE_INDEX_SOURCE="text:table-index-source";
|
||||
public static final String TEXT_TABLE_INDEX_ENTRY_TEMPLATE="text:table-index-entry-template";
|
||||
public static final String TEXT_OBJECT_INDEX="text:object-index";
|
||||
public static final String TEXT_USER_INDEX="text:user-index";
|
||||
public static final String TEXT_BIBLIOGRAPHY="text:bibliography";
|
||||
public static final String TEXT_BIBLIOGRAPHY_SOURCE="text:bibliography-source";
|
||||
public static final String TEXT_BIBLIOGRAPHY_ENTRY_TEMPLATE="text:bibliography-entry-template";
|
||||
public static final String TEXT_INDEX_ENTRY_BIBLIOGRAPHY="text:index-entry-bibliography";
|
||||
public static final String TEXT_INDEX_ENTRY_SPAN="text:index-entry-span";
|
||||
public static final String TEXT_INDEX_TITLE_TEMPLATE="text:index-title-template";
|
||||
public static final String TEXT_INDEX_BODY="text:index-body";
|
||||
public static final String TEXT_INDEX_TITLE="text:index-title";
|
||||
public static final String TEXT_INDEX_SOURCE="text:index-source";
|
||||
// text namespace - elements (inline text)
|
||||
public static final String TEXT_SPAN="text:span";
|
||||
public static final String TEXT_FOOTNOTE="text:footnote";
|
||||
public static final String TEXT_ENDNOTE="text:endnote";
|
||||
public static final String TEXT_NOTE="text:note"; // oasis
|
||||
public static final String TEXT_FOOTNOTE_CITATION="text:footnote-citation";
|
||||
public static final String TEXT_FOOTNOTE_BODY="text:footnote-body";
|
||||
public static final String TEXT_ENDNOTE_CITATION="text:endnote-citation";
|
||||
public static final String TEXT_ENDNOTE_BODY="text:endnote-body";
|
||||
public static final String TEXT_NOTE_CITATION="text:note-citation"; // oasis
|
||||
public static final String TEXT_NOTE_BODY="text:note-body"; // oasis
|
||||
public static final String TEXT_S="text:s";
|
||||
public static final String TEXT_TAB_STOP="text:tab-stop";
|
||||
public static final String TEXT_TAB="text:tab"; // oasis
|
||||
public static final String TEXT_A="text:a";
|
||||
public static final String TEXT_LINE_BREAK="text:line-break";
|
||||
public static final String TEXT_PAGE_NUMBER="text:page-number";
|
||||
public static final String TEXT_PAGE_COUNT="text:page-count";
|
||||
public static final String TEXT_PAGE_ADJUST="text:page-adjust";
|
||||
public static final String TEXT_CHAPTER="text:chapter";
|
||||
public static final String TEXT_SEQUENCE="text:sequence";
|
||||
public static final String TEXT_SEQUENCE_REF="text:sequence-ref";
|
||||
public static final String TEXT_BIBLIOGRAPHY_MARK="text:bibliography-mark";
|
||||
public static final String TEXT_ALPHABETICAL_INDEX_MARK="text:alphabetical-index-mark";
|
||||
public static final String TEXT_ALPHABETICAL_INDEX_MARK_START="text:alphabetical-index-mark-start";
|
||||
public static final String TEXT_ALPHABETICAL_INDEX_MARK_END="text:alphabetical-index-mark-end";
|
||||
public static final String TEXT_TOC_MARK="text:toc-mark";
|
||||
public static final String TEXT_TOC_MARK_START="text:toc-mark-start";
|
||||
public static final String TEXT_TOC_MARK_END="text:toc-mark-end";
|
||||
public static final String TEXT_REFERENCE_MARK="text:reference-mark";
|
||||
public static final String TEXT_REFERENCE_MARK_START="text:reference-mark-start";
|
||||
public static final String TEXT_REFERENCE_MARK_END="text:reference-mark-end";
|
||||
public static final String TEXT_REFERENCE_REF="text:reference-ref";
|
||||
public static final String TEXT_BOOKMARK="text:bookmark";
|
||||
public static final String TEXT_BOOKMARK_START="text:bookmark-start";
|
||||
public static final String TEXT_BOOKMARK_REF="text:bookmark-ref";
|
||||
public static final String TEXT_FOOTNOTE_REF="text:footnote-ref";
|
||||
public static final String TEXT_ENDNOTE_REF="text:endnote-ref";
|
||||
public static final String TEXT_NOTE_REF="text:note-ref"; // oasis
|
||||
public static final String TEXT_SOFT_PAGE_BREAK="text:soft-page-break"; // ODF 1.1
|
||||
|
||||
// text namespace - attributes
|
||||
public static final String TEXT_USE_OUTLINE_LEVEL="text:use-outline-level";
|
||||
public static final String TEXT_USE_INDEX_SOURCE_STYLES="text:use-index-source-styles";
|
||||
public static final String TEXT_USE_INDEX_MARKS="text:use-index-marks";
|
||||
public static final String TEXT_INDEX_SCOPE="text:index-scope";
|
||||
public static final String TEXT_OUTLINE_LEVEL="text:outline-level";
|
||||
public static final String TEXT_IS_LIST_HEADER="text:is-list-header";
|
||||
public static final String TEXT_USE_CAPTION="text:use-caption";
|
||||
public static final String TEXT_CAPTION_SEQUENCE_NAME="text:caption-sequence-name";
|
||||
public static final String TEXT_STRING_VALUE="text:string-value";
|
||||
public static final String TEXT_KEY1="text:key1";
|
||||
public static final String TEXT_KEY2="text:key2";
|
||||
public static final String TEXT_LEVEL="text:level";
|
||||
public static final String TEXT_SPACE_BEFORE="text:space-before";
|
||||
public static final String TEXT_MIN_LABEL_WIDTH="text:min-label-width";
|
||||
public static final String TEXT_MIN_LABEL_DISTANCE="text:min-label-distance";
|
||||
public static final String TEXT_STYLE_NAME="text:style-name";
|
||||
public static final String TEXT_VISITED_STYLE_NAME="text:visited-style-name";
|
||||
public static final String TEXT_DISPLAY_LEVELS="text:display-levels";
|
||||
public static final String TEXT_CONTINUE_NUMBERING="text:continue-numbering";
|
||||
public static final String TEXT_C="text:c";
|
||||
public static final String TEXT_ID="text:id";
|
||||
public static final String TEXT_LABEL="text:label";
|
||||
public static final String TEXT_NAME="text:name";
|
||||
public static final String TEXT_REFERENCE_FORMAT="text:reference-format";
|
||||
public static final String TEXT_REF_NAME="text:ref-name";
|
||||
public static final String TEXT_FORMULA="text:formula";
|
||||
public static final String TEXT_FOOTNOTES_POSITION="text:footnotes-position";
|
||||
public static final String TEXT_NOTE_CLASS="text:note-class";
|
||||
public static final String TEXT_CITATION_BODY_STYLE_NAME="text:citation-body-style-name";
|
||||
public static final String TEXT_CITATION_STYLE_NAME="text:citation-style-name";
|
||||
public static final String TEXT_DEFAULT_STYLE_NAME="text:default-style-name";
|
||||
public static final String TEXT_START_VALUE="text:start-value";
|
||||
public static final String TEXT_START_NUMBERING_AT="text:start-numbering-at";
|
||||
public static final String TEXT_RESTART_NUMBERING="text:restart-numbering";
|
||||
public static final String TEXT_ANCHOR_TYPE="text:anchor-type";
|
||||
public static final String TEXT_BULLET_CHAR="text:bullet-char";
|
||||
public static final String TEXT_DISPLAY="text:display";
|
||||
public static final String TEXT_DISPLAY_OUTLINE_LEVEL="text:display-outline-level";
|
||||
public static final String TEXT_SEPARATION_CHARACTER="text:separation-character";
|
||||
|
||||
public static final String TEXT_LIST_LEVEL_POSITION_AND_SPACE_MODE="text:list-level-position-and-space-mode"; // oasis 1.2
|
||||
public static final String TEXT_LABEL_FOLLOWED_BY="text:label-followed-by"; // oasis 1.2
|
||||
public static final String TEXT_LIST_TAB_STOP_POSITION="text:list-tab-stop-position"; // oasis 1.2
|
||||
|
||||
public static final String TEXT_PREFIX="text:prefix";
|
||||
public static final String TEXT_SUFFIX="text:suffix";
|
||||
public static final String TEXT_NUMBERED_ENTRIES="text:numbered-entries";
|
||||
public static final String TEXT_SORT_BY_POSITION="text:sort-by-position";
|
||||
public static final String TEXT_SORT_ALGORITHM="text:sort-algorithm";
|
||||
public static final String TEXT_KEY="text:key";
|
||||
public static final String TEXT_SORT_ASCENDING="text:sort-ascending";
|
||||
public static final String TEXT_IDENTIFIER="text:identifier";
|
||||
public static final String TEXT_BIBLIOGRAPHY_TYPE="text:bibliography-type";
|
||||
public static final String TEXT_BIBILIOGRAPHIC_TYPE="text:bibiliographic-type"; // bug in OOo 1.0
|
||||
public static final String TEXT_BIBLIOGRAPHY_DATA_FIELD="text:bibliography-data-field";
|
||||
public static final String TEXT_ADDRESS="text:address";
|
||||
public static final String TEXT_ANNOTE="text:annote";
|
||||
public static final String TEXT_AUTHOR="text:author";
|
||||
public static final String TEXT_BOOKTITLE="text:booktitle";
|
||||
//public static final String TEXT_CHAPTER="text:chapter";
|
||||
public static final String TEXT_EDITION="text:edition";
|
||||
public static final String TEXT_EDITOR="text:editor";
|
||||
public static final String TEXT_HOWPUBLISHED="text:howpublished";
|
||||
public static final String TEXT_INSTITUTION="text:institution";
|
||||
public static final String TEXT_JOURNAL="text:journal";
|
||||
public static final String TEXT_MONTH="text:month";
|
||||
// public static final String TEXT_NOTE="text:note"; defined above as an element name
|
||||
public static final String TEXT_NUMBER="text:number";
|
||||
public static final String TEXT_ORGANIZATIONS="text:organizations";
|
||||
public static final String TEXT_PAGES="text:pages";
|
||||
public static final String TEXT_PUBLISHER="text:publisher";
|
||||
public static final String TEXT_SCHOOL="text:school";
|
||||
public static final String TEXT_SERIES="text:series";
|
||||
public static final String TEXT_TITLE="text:title";
|
||||
public static final String TEXT_REPORT_TYPE="text:report-type";
|
||||
public static final String TEXT_VOLUME="text:volume";
|
||||
public static final String TEXT_YEAR="text:year";
|
||||
public static final String TEXT_URL="text:url";
|
||||
public static final String TEXT_CUSTOM1="text:custom1";
|
||||
public static final String TEXT_CUSTOM2="text:custom2";
|
||||
public static final String TEXT_CUSTOM3="text:custom3";
|
||||
public static final String TEXT_CUSTOM4="text:custom4";
|
||||
public static final String TEXT_CUSTOM5="text:custom5";
|
||||
public static final String TEXT_ISBN="text:isbn";
|
||||
|
||||
// fo namespace
|
||||
public static final String FO_LANGUAGE="fo:language";
|
||||
public static final String FO_COUNTRY="fo:country";
|
||||
public static final String FO_TEXT_SHADOW="fo:text-shadow";
|
||||
public static final String FO_COLOR="fo:color";
|
||||
public static final String FO_BACKGROUND_COLOR="fo:background-color";
|
||||
public static final String FO_TEXT_TRANSFORM="fo:text-transform";
|
||||
public static final String FO_FONT_FAMILY="fo:font-family";
|
||||
public static final String FO_FONT_SIZE="fo:font-size";
|
||||
public static final String FO_FONT_WEIGHT="fo:font-weight";
|
||||
public static final String FO_FONT_VARIANT="fo:font-variant";
|
||||
public static final String FO_FONT_STYLE="fo:font-style";
|
||||
public static final String FO_LETTER_SPACING="fo:letter-spacing";
|
||||
public static final String FO_VERTICAL_ALIGN="fo:vertical-align";
|
||||
public static final String FO_TEXT_ALIGN="fo:text-align";
|
||||
public static final String FO_TEXT_ALIGN_LAST="fo:text-align-last";
|
||||
public static final String FO_BREAK_BEFORE="fo:break-before";
|
||||
public static final String FO_BREAK_AFTER="fo:break-after";
|
||||
public static final String FO_MARGIN_LEFT="fo:margin-left";
|
||||
public static final String FO_MARGIN_RIGHT="fo:margin-right";
|
||||
public static final String FO_MARGIN_TOP="fo:margin-top";
|
||||
public static final String FO_MARGIN_BOTTOM="fo:margin-bottom";
|
||||
public static final String FO_PAGE_WIDTH="fo:page-width";
|
||||
public static final String FO_PAGE_HEIGHT="fo:page-height";
|
||||
public static final String FO_MIN_HEIGHT="fo:min-height";
|
||||
public static final String FO_BORDER="fo:border";
|
||||
public static final String FO_BORDER_LEFT="fo:border-left";
|
||||
public static final String FO_BORDER_RIGHT="fo:border-right";
|
||||
public static final String FO_BORDER_TOP="fo:border-top";
|
||||
public static final String FO_BORDER_BOTTOM="fo:border-bottom";
|
||||
public static final String FO_PADDING="fo:padding";
|
||||
public static final String FO_PADDING_LEFT="fo:padding-left";
|
||||
public static final String FO_PADDING_RIGHT="fo:padding-right";
|
||||
public static final String FO_PADDING_TOP="fo:padding-top";
|
||||
public static final String FO_PADDING_BOTTOM="fo:padding-bottom";
|
||||
public static final String FO_LINE_HEIGHT="fo:line-height";
|
||||
public static final String FO_TEXT_INDENT="fo:text-indent";
|
||||
public static final String FO_WRAP_OPTION="fo:wrap-option";
|
||||
public static final String FO_COLUMN_COUNT="fo:column-count";
|
||||
|
||||
// svg namespace
|
||||
public static final String SVG_DESC="svg:desc";
|
||||
public static final String SVG_TITLE="svg:title";
|
||||
|
||||
public static final String SVG_FONT_FAMILY="svg:font-family"; // oasis (font declarations only)
|
||||
public static final String SVG_X="svg:x";
|
||||
public static final String SVG_Y="svg:y";
|
||||
public static final String SVG_HEIGHT="svg:height";
|
||||
public static final String SVG_WIDTH="svg:width";
|
||||
// xlink namespace
|
||||
public static final String XLINK_HREF="xlink:href";
|
||||
// math namespace
|
||||
public static final String MATH_MATH="math:math";
|
||||
public static final String MATH_SEMANTICS="math:semantics";
|
||||
public static final String MATH_ANNOTATION="math:annotation";
|
||||
// math without namespace
|
||||
public static final String MATH="math";
|
||||
public static final String SEMANTICS="semantics";
|
||||
public static final String ANNOTATION="annotation";
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue