Java 5 + Writer4LaTeX + bugfixes
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@11 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
be54e842f4
commit
9241a44f6c
83 changed files with 2373 additions and 631 deletions
|
@ -42,7 +42,7 @@ public class ControlReader {
|
|||
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 items = new Vector(); // the options/items of a list/combobox
|
||||
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.
|
||||
|
|
|
@ -45,8 +45,8 @@ import org.w3c.dom.Node;
|
|||
public class FormsReader {
|
||||
|
||||
private Element formsElement; // The office:forms element
|
||||
private Hashtable forms = new Hashtable(); // all forms, indexed by name
|
||||
private Hashtable controls = new Hashtable(); // all controls, indexed by id
|
||||
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
|
||||
|
@ -77,7 +77,7 @@ public class FormsReader {
|
|||
/** <p>Get a <code>Iterator</code> over all forms.</p>
|
||||
* @return a <code>Iterator</code> over all forms
|
||||
*/
|
||||
public Iterator getFormsIterator() {
|
||||
public Iterator<FormReader> getFormsIterator() {
|
||||
return forms.values().iterator();
|
||||
}
|
||||
|
||||
|
@ -86,13 +86,13 @@ public class FormsReader {
|
|||
* @return the form as a <code>FormReader</code> object
|
||||
*/
|
||||
public FormReader getForm(String sName) {
|
||||
return (FormReader) forms.get(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 getControlsIterator() {
|
||||
public Iterator<ControlReader> getControlsIterator() {
|
||||
return controls.values().iterator();
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class FormsReader {
|
|||
* @return the control as a <code>ControlReader</code> object
|
||||
*/
|
||||
public ControlReader getControl(String sId) {
|
||||
return (ControlReader) controls.get(sId);
|
||||
return controls.get(sId);
|
||||
}
|
||||
|
||||
/** <p>Add a control</p>
|
||||
|
|
|
@ -65,7 +65,7 @@ public final class ImageLoader {
|
|||
private boolean bAcceptOtherFormats = true;
|
||||
private String sDefaultFormat = null;
|
||||
private String sDefaultVectorFormat = null;
|
||||
private HashSet acceptedFormats = new HashSet();
|
||||
private HashSet<String> acceptedFormats = new HashSet<String>();
|
||||
|
||||
public ImageLoader(OfficeDocument oooDoc, String sOutFileName, boolean bExtractEPS) {
|
||||
this.oooDoc = oooDoc;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-09-22)
|
||||
* Version 1.2 (2008-09-30)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -115,16 +115,10 @@ public class OfficeReader {
|
|||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE) {
|
||||
if (child.getNodeName().equals(XMLString.TEXT_SPAN)) {
|
||||
if (isTextElement(child)) {
|
||||
if (!isWhitespaceContent(child)) { return false; }
|
||||
}
|
||||
else if (child.getNodeName().equals(XMLString.TEXT_A)) {
|
||||
if (!isWhitespaceContent(child)) { return false; }
|
||||
}
|
||||
else if (child.getNodeName().equals(XMLString.TEXT_BIBLIOGRAPHY_MARK)) {
|
||||
if (!isWhitespaceContent(child)) { return false; }
|
||||
}
|
||||
else if (!isTextElement(child)) {
|
||||
else {
|
||||
return false; // found non-text content!
|
||||
}
|
||||
}
|
||||
|
@ -282,32 +276,32 @@ public class OfficeReader {
|
|||
//private String sFirstMasterPageName = null;
|
||||
|
||||
// All indexes
|
||||
private Hashtable indexes = new Hashtable();
|
||||
private HashSet indexSourceStyles = new HashSet();
|
||||
private HashSet figureSequenceNames = new HashSet();
|
||||
private HashSet tableSequenceNames = new HashSet();
|
||||
private Hashtable<Element, Object> indexes = new Hashtable<Element, Object>();
|
||||
private HashSet<String> indexSourceStyles = new HashSet<String>();
|
||||
private HashSet<String> figureSequenceNames = new HashSet<String>();
|
||||
private HashSet<String> tableSequenceNames = new HashSet<String>();
|
||||
private String sAutoFigureSequenceName = null;
|
||||
private String sAutoTableSequenceName = null;
|
||||
|
||||
// Map paragraphs to sequence names (caption helper)
|
||||
private Hashtable sequenceNames = new Hashtable();
|
||||
private Hashtable<Element, String> sequenceNames = new Hashtable<Element, String>();
|
||||
|
||||
// Map sequence reference names to sequence names
|
||||
private Hashtable seqrefNames = new Hashtable();
|
||||
private Hashtable<String, String> seqrefNames = new Hashtable<String, String>();
|
||||
|
||||
// All references
|
||||
private HashSet footnoteRef = new HashSet();
|
||||
private HashSet endnoteRef = new HashSet();
|
||||
private HashSet referenceRef = new HashSet();
|
||||
private HashSet bookmarkRef = new HashSet();
|
||||
private HashSet sequenceRef = new HashSet();
|
||||
private HashSet<String> footnoteRef = new HashSet<String>();
|
||||
private HashSet<String> endnoteRef = new HashSet<String>();
|
||||
private HashSet<String> referenceRef = new HashSet<String>();
|
||||
private HashSet<String> bookmarkRef = new HashSet<String>();
|
||||
private HashSet<String> sequenceRef = new HashSet<String>();
|
||||
|
||||
// Reference marks and bookmarks contained in headings
|
||||
private HashSet referenceHeading = new HashSet();
|
||||
private HashSet bookmarkHeading = new HashSet();
|
||||
private HashSet<String> referenceHeading = new HashSet<String>();
|
||||
private HashSet<String> bookmarkHeading = new HashSet<String>();
|
||||
|
||||
// All internal hyperlinks
|
||||
private HashSet links = new HashSet();
|
||||
private HashSet<String> links = new HashSet<String>();
|
||||
|
||||
// Forms
|
||||
private FormsReader forms = new FormsReader();
|
||||
|
@ -468,7 +462,7 @@ public class OfficeReader {
|
|||
* @return the iso language
|
||||
*/
|
||||
public String getMajorityLanguage() {
|
||||
Hashtable langs = new Hashtable();
|
||||
Hashtable<Object, Integer> langs = new Hashtable<Object, Integer>();
|
||||
|
||||
// Read the default language from the default paragraph style
|
||||
String sDefaultLang = null;
|
||||
|
@ -478,7 +472,7 @@ public class OfficeReader {
|
|||
}
|
||||
|
||||
// Collect languages from paragraph styles
|
||||
Enumeration enumeration = getParStyles().getStylesEnumeration();
|
||||
Enumeration<Object> enumeration = getParStyles().getStylesEnumeration();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
style = (StyleWithProperties) enumeration.nextElement();
|
||||
String sLang = style.getProperty(XMLString.FO_LANGUAGE);
|
||||
|
@ -486,7 +480,7 @@ public class OfficeReader {
|
|||
if (sLang!=null) {
|
||||
int nCount = 1;
|
||||
if (langs.containsKey(sLang)) {
|
||||
nCount = ((Integer) langs.get(sLang)).intValue()+1;
|
||||
nCount = langs.get(sLang).intValue()+1;
|
||||
}
|
||||
langs.put(sLang,new Integer(nCount));
|
||||
}
|
||||
|
@ -498,7 +492,7 @@ public class OfficeReader {
|
|||
enumeration = langs.keys();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
String sLang = (String) enumeration.nextElement();
|
||||
int nCount = ((Integer) langs.get(sLang)).intValue();
|
||||
int nCount = langs.get(sLang).intValue();
|
||||
if (nCount>nMaxCount) {
|
||||
nMaxCount = nCount;
|
||||
sMajorityLanguage = sLang;
|
||||
|
@ -571,7 +565,7 @@ public class OfficeReader {
|
|||
* @return the sequence name or null
|
||||
*/
|
||||
public String getSequenceName(Element par) {
|
||||
return sequenceNames.containsKey(par) ? (String) sequenceNames.get(par) : null;
|
||||
return sequenceNames.containsKey(par) ? sequenceNames.get(par) : null;
|
||||
}
|
||||
|
||||
/** <p>Get the sequence name associated with a reference name</p>
|
||||
|
@ -579,7 +573,7 @@ public class OfficeReader {
|
|||
* @return the sequence name or null
|
||||
*/
|
||||
public String getSequenceFromRef(String sRefName) {
|
||||
return (String) seqrefNames.get(sRefName);
|
||||
return seqrefNames.get(sRefName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1129,14 +1123,14 @@ public class OfficeReader {
|
|||
|
||||
}
|
||||
|
||||
private void collectRefName(HashSet ref, Element node) {
|
||||
private void collectRefName(HashSet<String> ref, Element node) {
|
||||
String sRefName = node.getAttribute(XMLString.TEXT_REF_NAME);
|
||||
if (sRefName!=null && sRefName.length()>0) {
|
||||
ref.add(sRefName);
|
||||
}
|
||||
}
|
||||
|
||||
private void collectMarkInHeading(HashSet marks, Element node) {
|
||||
private void collectMarkInHeading(HashSet<String> marks, Element node) {
|
||||
String sName = node.getAttribute(XMLString.TEXT_NAME);
|
||||
if (sName!=null && sName.length()>0) {
|
||||
Element par = getParagraph(node);
|
||||
|
|
|
@ -33,10 +33,10 @@ import writer2latex.util.Misc;
|
|||
|
||||
/** Container class representing a style family in OOo */
|
||||
public class OfficeStyleFamily {
|
||||
private Hashtable styles = new Hashtable();
|
||||
private Hashtable<String, Object> styles = new Hashtable<String, Object>();
|
||||
private Class styleClass;
|
||||
|
||||
private Hashtable displayNames = new Hashtable();
|
||||
private Hashtable<String, String> displayNames = new Hashtable<String, String>();
|
||||
|
||||
private OfficeStyle defaultStyle = null;
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class OfficeStyleFamily {
|
|||
*/
|
||||
public OfficeStyle getStyleByDisplayName(String sDisplayName) {
|
||||
if (sDisplayName==null) { return null; }
|
||||
else { return getStyle((String) displayNames.get(sDisplayName)); }
|
||||
else { return getStyle(displayNames.get(sDisplayName)); }
|
||||
}
|
||||
|
||||
/** Get the display name for the style with the specified name.
|
||||
|
@ -101,7 +101,7 @@ public class OfficeStyleFamily {
|
|||
/** Get all named styles in the family (ie. excluding the default style)
|
||||
* @return an enumeration of all styles represented by OfficeStyle objects
|
||||
*/
|
||||
public Enumeration getStylesEnumeration(){
|
||||
public Enumeration<Object> getStylesEnumeration(){
|
||||
return styles.elements();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,17 +35,17 @@ import java.util.Hashtable;
|
|||
is simply the set of attributes of an element). </p>
|
||||
*/
|
||||
public class PropertySet {
|
||||
private Hashtable properties = new Hashtable();
|
||||
private Hashtable<String, String> properties = new Hashtable<String, String>();
|
||||
private String sName;
|
||||
|
||||
public PropertySet() {
|
||||
properties = new Hashtable();
|
||||
properties = new Hashtable<String, String>();
|
||||
sName="";
|
||||
}
|
||||
|
||||
public String getProperty(String sPropName) {
|
||||
if (sPropName!=null) {
|
||||
String sValue = (String) properties.get(sPropName);
|
||||
String sValue = properties.get(sPropName);
|
||||
if (sValue!=null && sValue.endsWith("inch")) {
|
||||
// Cut of inch to in
|
||||
return sValue.substring(0,sValue.length()-2);
|
||||
|
@ -86,10 +86,10 @@ public class PropertySet {
|
|||
|
||||
public String toString() {
|
||||
String s="";
|
||||
Enumeration keys = properties.keys();
|
||||
Enumeration<String> keys = properties.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String sKey = (String) keys.nextElement();
|
||||
String sValue = (String) properties.get(sKey);
|
||||
String sKey = keys.nextElement();
|
||||
String sValue = properties.get(sKey);
|
||||
s += sKey+"="+sValue+" ";
|
||||
}
|
||||
return s;
|
||||
|
|
|
@ -42,16 +42,16 @@ import writer2latex.util.Misc;
|
|||
public class TableReader {
|
||||
//private OfficeReader ofr;
|
||||
private Element tableNode;
|
||||
private LinkedList cols = new LinkedList();
|
||||
private LinkedList rows = new LinkedList();
|
||||
private LinkedList cells = new LinkedList();
|
||||
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 printRanges;
|
||||
private Vector<TableRange> printRanges;
|
||||
|
||||
/**
|
||||
* <p> The constructor reads a table from a table:table or table:sub-table
|
||||
|
@ -111,7 +111,7 @@ public class TableReader {
|
|||
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(((TableLine) cols.get(nCol)).getStyleName());
|
||||
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);
|
||||
|
@ -136,7 +136,7 @@ public class TableReader {
|
|||
// (Calc exports a lot of empty rows at columns bottom/right)
|
||||
int nRows = cells.size();
|
||||
for (int nRow=0; nRow<nRows; nRow++) {
|
||||
LinkedList row = (LinkedList) cells.get(nRow);
|
||||
LinkedList row = cells.get(nRow);
|
||||
nCols = row.size();
|
||||
int nMaxCol = 0;
|
||||
int nMaxRow = 0;
|
||||
|
@ -154,7 +154,7 @@ public class TableReader {
|
|||
}
|
||||
|
||||
// Finally get the print ranges, if any
|
||||
printRanges = new Vector();
|
||||
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()) {
|
||||
|
@ -228,7 +228,7 @@ public class TableReader {
|
|||
rows.add(new TableLine(node,bHeader,bDisplay));
|
||||
|
||||
// Read the cells in the row
|
||||
LinkedList row = new LinkedList();
|
||||
LinkedList<Element> row = new LinkedList<Element>();
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList nl = node.getChildNodes();
|
||||
int nLen = nl.getLength();
|
||||
|
@ -344,7 +344,7 @@ public class TableReader {
|
|||
|
||||
public Element getCell(int nRow, int nCol) {
|
||||
if (nRow<0 || nRow>=cells.size()) { return null; }
|
||||
LinkedList row = (LinkedList) cells.get(nRow);
|
||||
LinkedList row = cells.get(nRow);
|
||||
if (nCol<0 || nCol>=row.size()) { return null; }
|
||||
return (Element) row.get(nCol);
|
||||
}
|
||||
|
@ -373,19 +373,19 @@ public class TableReader {
|
|||
|
||||
public TableLine getRow(int nRow) {
|
||||
if (nRow<0 || nRow>=rows.size()) { return null; }
|
||||
return (TableLine) rows.get(nRow);
|
||||
return rows.get(nRow);
|
||||
}
|
||||
|
||||
public TableLine getCol(int nCol) {
|
||||
if (nCol<0 || nCol>=cols.size()) { return null; }
|
||||
return (TableLine) cols.get(nCol);
|
||||
return cols.get(nCol);
|
||||
}
|
||||
|
||||
public int getPrintRangeCount() { return printRanges.size(); }
|
||||
|
||||
public TableRange getPrintRange(int nIndex) {
|
||||
if (0<=nIndex && nIndex<printRanges.size()) {
|
||||
return (TableRange) printRanges.get(nIndex);
|
||||
return printRanges.get(nIndex);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TocReader {
|
|||
|
||||
Element indexTitleTemplate = null;
|
||||
Element[] tocEntryTemplate = new Element[11];
|
||||
Hashtable indexSourceStyles = new Hashtable();
|
||||
Hashtable<String, Integer> indexSourceStyles = new Hashtable<String, Integer>();
|
||||
|
||||
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class TocReader {
|
|||
/** <p>Get a set view of all index source styles</p>
|
||||
* @return a set of all index source style names
|
||||
*/
|
||||
public Set getIndexSourceStyles() { return indexSourceStyles.keySet(); }
|
||||
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
|
||||
|
@ -171,7 +171,7 @@ public class TocReader {
|
|||
*/
|
||||
public int getIndexSourceStyleLevel(String sStyleName) {
|
||||
if (indexSourceStyles.containsKey(sStyleName)) {
|
||||
return ((Integer) indexSourceStyles.get(sStyleName)).intValue();
|
||||
return indexSourceStyles.get(sStyleName).intValue();
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-11-10)
|
||||
* Version 1.2 (2009-03-26)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -204,6 +204,10 @@ public class XMLString {
|
|||
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:";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue