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:
henrikjust 2009-03-30 07:38:37 +00:00
parent be54e842f4
commit 9241a44f6c
83 changed files with 2373 additions and 631 deletions

View file

@ -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-22)
* Version 1.2 (2009-03-26)
*
*/
@ -68,9 +68,9 @@ public final class Application {
/* Based on command-line parameters. */
private String sTargetMIME = MIMETypes.LATEX;
private boolean bRecurse = false;
private Vector configFileNames = new Vector();
private Vector<String> configFileNames = new Vector<String>();
private String sTemplateFileName = null;
private Hashtable options = new Hashtable();
private Hashtable<String,String> options = new Hashtable<String,String>();
private String sSource = null;
private String sTarget = null;
@ -208,9 +208,9 @@ public final class Application {
}
// Step 7: Set options from command line
Enumeration keys = options.keys();
Enumeration<String> keys = options.keys();
while (keys.hasMoreElements()) {
String sKey = (String) keys.nextElement();
String sKey = keys.nextElement();
String sValue = (String) options.get(sKey);
converter.getConfig().setOption(sKey,sValue);
if (batchCv!=null) {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-03-25)
* Version 1.2 (2009-03-30)
*
*/
@ -32,8 +32,8 @@ package writer2latex.api;
public class ConverterFactory {
// Version information
private static final String VERSION = "1.0 beta";
private static final String DATE = "2008-03-25";
private static final String VERSION = "1.1.1";
private static final String DATE = "2008-03-30";
/** Return version information
* @return the Writer2LaTeX version in the form

View file

@ -44,7 +44,7 @@ public interface ConverterResult {
* <code>ConverterResult</code>. This <em>includes</em> the master document.
* @return an <code>Iterator</code> of all files
*/
public Iterator iterator();
public Iterator<OutputFile> iterator();
/** Write all files of the <code>ConverterResult</code> to a directory.
* Subdirectories are created as required by the individual

View file

@ -51,7 +51,7 @@ public class BibTeXDocument implements Document {
private static final String FILE_EXTENSION = ".bib";
private String sName;
private Hashtable entries = new Hashtable();
private Hashtable<String, BibMark> entries = new Hashtable<String, BibMark>();
private ExportNameCollection exportNames = new ExportNameCollection(true);
private I18n i18n;
@ -122,9 +122,9 @@ public class BibTeXDocument implements Document {
osw.write("%% This file was converted to BibTeX by Writer2BibTeX ver. "+ConverterFactory.getVersion()+".\n");
osw.write("%% See http://writer2latex.sourceforge.net for more info.\n");
osw.write("\n");
Enumeration enumeration = entries.elements();
Enumeration<BibMark> enumeration = entries.elements();
while (enumeration.hasMoreElements()) {
BibMark entry = (BibMark) enumeration.nextElement();
BibMark entry = enumeration.nextElement();
osw.write("@");
osw.write(entry.getEntryType().toUpperCase());
osw.write("{");

View file

@ -43,7 +43,7 @@ import writer2latex.latex.util.StyleMap;
public class CharStyleConverter extends StyleConverter {
// Cache of converted font declarations
private Hashtable fontDecls = new Hashtable();
private Hashtable<String, String> fontDecls = new Hashtable<String, String>();
// Which formatting should we export?
private boolean bIgnoreHardFontsize;
@ -434,7 +434,7 @@ public class CharStyleConverter extends StyleConverter {
String sFontFamilyGeneric = fd.getFontFamilyGeneric();
fontDecls.put(sName,nfssFamily(sFontFamily,sFontFamilyGeneric,sFontPitch));
}
return (String) fontDecls.get(sName);
return fontDecls.get(sName);
}
// The remaining methods are static helpers to convert single style properties

View file

@ -226,10 +226,10 @@ public final class ConverterPalette extends ConverterBase {
mathmlCv.appendDeclarations(packages,declarations);
// Add custom preamble
LinkedList customPreamble = config.getCustomPreamble();
LinkedList<String> customPreamble = config.getCustomPreamble();
int nCPLen = customPreamble.size();
for (int i=0; i<nCPLen; i++) {
declarations.append( (String) customPreamble.get(i) ).nl();
declarations.append( customPreamble.get(i) ).nl();
}
// Set \title, \author and \date (for \maketitle)

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-03-08)
* Version 1.2 (2009-03-26)
*
*/
@ -56,7 +56,7 @@ public class DrawConverter extends ConverterHelper {
private boolean bNeedOOoLaTeXPreamble = false;
// Keep track of floating frames (images, textboxes...)
private Stack floatingFramesStack = new Stack();
private Stack<LinkedList<Element>> floatingFramesStack = new Stack<LinkedList<Element>>();
private Element getFrame(Element onode) {
if (ofr.isOpenDocument()) return (Element) onode.getParentNode();
@ -65,7 +65,7 @@ public class DrawConverter extends ConverterHelper {
public DrawConverter(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
super(ofr,config,palette);
floatingFramesStack.push(new LinkedList());
floatingFramesStack.push(new LinkedList<Element>());
}
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
@ -301,7 +301,7 @@ public class DrawConverter extends ConverterHelper {
handleDrawImageAsChar(node,ldp,oc);
}
else {
((LinkedList) floatingFramesStack.peek()).add(node);
floatingFramesStack.peek().add(node);
}
}
@ -429,7 +429,7 @@ public class DrawConverter extends ConverterHelper {
makeDrawTextBox(node, ldp, oc);
}
else {
((LinkedList) floatingFramesStack.peek()).add(node);
floatingFramesStack.peek().add(node);
}
}
@ -461,7 +461,7 @@ public class DrawConverter extends ConverterHelper {
if (!bIsCaption) {
ldp.append("\\begin{minipage}{").append(sWidth).append("}").nl();
}
floatingFramesStack.push(new LinkedList());
floatingFramesStack.push(new LinkedList<Element>());
palette.getBlockCv().traverseBlockText(node,ldp,ic);
flushFloatingFrames(ldp,ic);
floatingFramesStack.pop();
@ -477,7 +477,7 @@ public class DrawConverter extends ConverterHelper {
public void flushFloatingFrames(LaTeXDocumentPortion ldp, Context oc) {
// todo: fix language
LinkedList floatingFrames = (LinkedList) floatingFramesStack.peek();
LinkedList floatingFrames = floatingFramesStack.peek();
int n = floatingFrames.size();
if (n==0) { return; }
for (int i=0; i<n; i++) {

View file

@ -60,12 +60,12 @@ public class FieldConverter extends ConverterHelper {
private ExportNameCollection seqrefnames = new ExportNameCollection(true);
// sequence declarations (maps name->text:sequence-decl element)
private Hashtable seqDecl = new Hashtable();
private Hashtable<String, Node> seqDecl = new Hashtable<String, Node>();
// first usage of sequence (maps name->text:sequence element)
private Hashtable seqFirst = new Hashtable();
private Hashtable<String, Element> seqFirst = new Hashtable<String, Element>();
private Vector postponedReferenceMarks = new Vector();
private Vector postponedBookmarks = new Vector();
private Vector<Element> postponedReferenceMarks = new Vector<Element>();
private Vector<Element> postponedBookmarks = new Vector<Element>();
private boolean bUseHyperref = false;
private boolean bUsesPageCount = false;
@ -128,11 +128,11 @@ public class FieldConverter extends ConverterHelper {
// The number format is fetched from the first occurence of the
// sequence in the text, while the outline level and the separation
// character are fetched from the declaration
Enumeration names = seqFirst.keys();
Enumeration<String> names = seqFirst.keys();
while (names.hasMoreElements()) {
// Get first text:sequence element
String sName = (String) names.nextElement();
Element first = (Element) seqFirst.get(sName);
String sName = names.nextElement();
Element first = seqFirst.get(sName);
// Collect data
String sNumFormat = Misc.getAttribute(first,XMLString.STYLE_NUM_FORMAT);
if (sNumFormat==null) { sNumFormat="1"; }
@ -525,13 +525,13 @@ public class FieldConverter extends ConverterHelper {
// Type out all postponed reference marks
int n = postponedReferenceMarks.size();
for (int i=0; i<n; i++) {
handleReferenceMark((Element) postponedReferenceMarks.get(i),ldp,oc);
handleReferenceMark(postponedReferenceMarks.get(i),ldp,oc);
}
postponedReferenceMarks.clear();
// Type out all postponed bookmarks
n = postponedBookmarks.size();
for (int i=0; i<n; i++) {
handleBookmark((Element) postponedBookmarks.get(i),ldp,oc);
handleBookmark(postponedBookmarks.get(i),ldp,oc);
}
postponedBookmarks.clear();
}

View file

@ -48,7 +48,7 @@ public class IndexConverter extends ConverterHelper {
private boolean bContainsAlphabeticalIndex = false;
private Vector postponedIndexMarks = new Vector();
private Vector<Element> postponedIndexMarks = new Vector<Element>();
/** <p>Construct a new <code>IndexConverter</code>.
* @param config the configuration to use
@ -201,7 +201,7 @@ public class IndexConverter extends ConverterHelper {
// Type out all postponed index marks
int n = postponedIndexMarks.size();
for (int i=0; i<n; i++) {
handleAlphabeticalIndexMark((Element) postponedIndexMarks.get(i),ldp,oc);
handleAlphabeticalIndexMark(postponedIndexMarks.get(i),ldp,oc);
}
postponedIndexMarks.clear();
}

View file

@ -145,7 +145,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
private static final int SAVE_IMAGES_IN_SUBDIR = 57;
private static final int DEBUG = 58;
protected LinkedList customPreamble = new LinkedList();
protected LinkedList<String> customPreamble = new LinkedList<String>();
protected StyleMap par = new StyleMap();
protected StyleMap parBlock = new StyleMap();
protected StyleMap text = new StyleMap();
@ -153,7 +153,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
protected StyleMap listItem = new StyleMap();
protected StyleMap textAttr = new StyleMap();
protected HeadingMap headingMap = new HeadingMap(5);
protected Hashtable mathSymbols = new Hashtable();
protected Hashtable<String, String> mathSymbols = new Hashtable<String, String>();
protected ReplacementTrie stringReplace = new ReplacementTrie();
public LaTeXConfig() {
@ -365,10 +365,10 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
protected void writeInner(Document dom) {
// Write math symbol map
Enumeration msEnum = mathSymbols.keys();
Enumeration<String> msEnum = mathSymbols.keys();
while (msEnum.hasMoreElements()) {
String sName = (String) msEnum.nextElement();
String sLatex = (String) mathSymbols.get(sName);
String sName = msEnum.nextElement();
String sLatex = mathSymbols.get(sName);
Element msNode = dom.createElement("math-symbol-map");
msNode.setAttribute("name",sName);
msNode.setAttribute("latex",sLatex);
@ -413,9 +413,9 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
}
private void writeStyleMap(Document dom, StyleMap sm, String sFamily) {
Enumeration smEnum = sm.getNames();
Enumeration<String> smEnum = sm.getNames();
while (smEnum.hasMoreElements()) {
String sName = (String) smEnum.nextElement();
String sName = smEnum.nextElement();
Element smNode = dom.createElement("style-map");
smNode.setAttribute("name",sName);
smNode.setAttribute("family",sFamily);
@ -434,11 +434,11 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
}
}
private void writeContent(Document dom, LinkedList list, String sElement) {
private void writeContent(Document dom, LinkedList<String> list, String sElement) {
Element node = dom.createElement(sElement);
int nLen = list.size();
for (int i=0; i<nLen; i++) {
node.appendChild( dom.createTextNode( (String) list.get(i) ) );
node.appendChild( dom.createTextNode( list.get(i) ) );
}
dom.getDocumentElement().appendChild(node);
}
@ -528,7 +528,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
public boolean splitToplevelSections() { return ((BooleanOption) options[SPLIT_TOPLEVEL_SECTIONS]).getValue(); }
public boolean saveImagesInSubdir() { return ((BooleanOption) options[SAVE_IMAGES_IN_SUBDIR]).getValue(); }
public Hashtable getMathSymbols() { return mathSymbols; }
public Hashtable<String, String> getMathSymbols() { return mathSymbols; }
public StyleMap getParStyleMap() { return par; }
public StyleMap getParBlockStyleMap() { return parBlock; }
@ -537,7 +537,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
public StyleMap getListItemStyleMap() { return listItem; }
public StyleMap getTextAttributeStyleMap() { return textAttr; }
public HeadingMap getHeadingMap() { return headingMap; }
public LinkedList getCustomPreamble() { return customPreamble; }
public LinkedList<String> getCustomPreamble() { return customPreamble; }
}

View file

@ -36,7 +36,7 @@ import writer2latex.util.Misc;
number of lines, and may include subportions. */
public class LaTeXDocumentPortion {
private Vector nodes; // The collection of all nodes in this portion
private Vector<Object> nodes; // The collection of all nodes in this portion
private StringBuffer curText; // The currently active node (always the last node)
private boolean bEmpty; // Is the active node empty?
@ -45,7 +45,7 @@ public class LaTeXDocumentPortion {
public LaTeXDocumentPortion(boolean bWrap){
this.bWrap = bWrap;
nodes = new Vector();
nodes = new Vector<Object>();
curText = new StringBuffer();
bEmpty = true;
}

View file

@ -37,7 +37,7 @@ import writer2latex.latex.util.Context;
*/
public class ListStyleConverter extends StyleConverter {
boolean bNeedSaveEnumCounter = false;
private Hashtable listStyleLevelNames = new Hashtable();
private Hashtable<String, String[]> listStyleLevelNames = new Hashtable<String, String[]>();
/** <p>Constructs a new <code>ListStyleConverter</code>.</p>
*/
@ -99,7 +99,7 @@ public class ListStyleConverter extends StyleConverter {
ba.add("\\liststyle"+styleNames.getExportName(getDisplayName(sStyleName))+"\n","");
}
if (nLevel<=4) {
String sCounterName = ((String[]) listStyleLevelNames.get(sStyleName))[nLevel];
String sCounterName = listStyleLevelNames.get(sStyleName)[nLevel];
if (bContinue && style.isNumber(nLevel)) {
bNeedSaveEnumCounter = true;
ba.add("\\setcounter{saveenum}{\\value{"+sCounterName+"}}\n","");

View file

@ -53,7 +53,7 @@ public class NoteConverter extends ConverterHelper {
private boolean bContainsEndnotes = false;
private boolean bContainsFootnotes = false;
// Keep track of footnotes (inside minipage etc.), that should be typeset later
private LinkedList postponedFootnotes = new LinkedList();
private LinkedList<Element> postponedFootnotes = new LinkedList<Element>();
public NoteConverter(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
super(ofr,config,palette);
@ -115,7 +115,7 @@ public class NoteConverter extends ConverterHelper {
int n = postponedFootnotes.size();
if (n==1) {
ldp.append("\\footnotetext{");
traverseNoteBody((Element) postponedFootnotes.get(0),ldp,ic);
traverseNoteBody(postponedFootnotes.get(0),ldp,ic);
ldp.append("}").nl();
postponedFootnotes.clear();
}
@ -124,7 +124,7 @@ public class NoteConverter extends ConverterHelper {
ldp.append("\\addtocounter{footnote}{-"+n+"}").nl();
for (int i=0; i<n; i++) {
ldp.append("\\stepcounter{footnote}\\footnotetext{");
traverseNoteBody((Element) postponedFootnotes.get(i),ldp,ic);
traverseNoteBody(postponedFootnotes.get(i),ldp,ic);
ldp.append("}").nl();
}
postponedFootnotes.clear();

View file

@ -157,7 +157,7 @@ public class PageStyleConverter extends StyleConverter {
context.setInHeaderFooter(true);
Enumeration styles = ofr.getMasterPages().getStylesEnumeration();
Enumeration<Object> styles = ofr.getMasterPages().getStylesEnumeration();
ldp.append("% Pages styles").nl();
if (!config.useFancyhdr()) {
ldp.append("\\makeatletter").nl();
@ -385,7 +385,7 @@ public class PageStyleConverter extends StyleConverter {
boolean bIncludeHead = false;
boolean bIncludeFoot = false;
// Look through all applied page layouts and use largest heights
Enumeration masters = ofr.getMasterPages().getStylesEnumeration();
Enumeration<Object> masters = ofr.getMasterPages().getStylesEnumeration();
while (masters.hasMoreElements()) {
MasterPage master = (MasterPage) masters.nextElement();
if (styleNames.containsName(getDisplayName(master.getName()))) {

View file

@ -698,7 +698,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
private SmTokenTable keywords=new SmTokenTable(SmTokenTable.keywords);
private SmTokenTable symbols=new SmTokenTable(SmTokenTable.symbols);
private LaTeXConfig config;
private Hashtable configSymbols;
private Hashtable<String, String> configSymbols;
private boolean bUseColor;
private SmToken curToken=new SmToken(); // contains the data of the current token
private SimpleInputBuffer buffer; // contains the starmath formula
@ -860,7 +860,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
buffer.getChar();
String sIdent=buffer.getIdentifier();
if (configSymbols.containsKey(sIdent)) { // symbol defined in configuration
curToken.assign(Token.SPECIAL, (String) configSymbols.get(sIdent), 5);
curToken.assign(Token.SPECIAL, configSymbols.get(sIdent), 5);
}
else if (!symbols.lookup(sIdent,false,curToken))
curToken.assign(Token.IDENT, i18n.convert(sIdent,true,"en"), 5);

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-02-16)
* Version 1.2 (2009-03-26)
*
*/
@ -185,12 +185,12 @@ public class ClassicI18n extends I18n {
// End of static part of I18n!
// **** Global variables ****
private Hashtable babelLanguages; // mappings iso->babel language
private Hashtable<String,String> babelLanguages; // mappings iso->babel language
// Unicode translation
private Hashtable tableSet; // all tables
private Hashtable<String,UnicodeTable> tableSet; // all tables
private UnicodeTable table; // currently active table (top of stack)
private Stack tableStack; // stack of active tables
private Stack<UnicodeTable> tableStack; // stack of active tables
private UnicodeStringParser ucparser; // Unicode string parser
// Collected data
@ -231,7 +231,7 @@ public class ClassicI18n extends I18n {
if (config.useEurosym()) sSymbols+="|eurosym";
if (config.useTipa()) sSymbols+="|tipa";
tableSet = new Hashtable();
tableSet = new Hashtable<String,UnicodeTable>();
UnicodeTableHandler handler=new UnicodeTableHandler(tableSet, sSymbols);
SAXParserFactory factory=SAXParserFactory.newInstance();
InputStream is = this.getClass().getResourceAsStream("symbols.xml");
@ -244,9 +244,9 @@ public class ClassicI18n extends I18n {
t.printStackTrace();
}
// put root table at top of stack
tableStack = new Stack();
tableStack.push((UnicodeTable) tableSet.get("root"));
table = (UnicodeTable) tableSet.get("root");
tableStack = new Stack<UnicodeTable>();
tableStack.push(tableSet.get("root"));
table = tableSet.get("root");
}
/** Construct a new I18n for general use
@ -386,8 +386,8 @@ public class ClassicI18n extends I18n {
// If no name is specified we should keep the current table
// Otherwise try to find the table, and use root if it's not available
if (sName!=null) {
table = (UnicodeTable) tableSet.get(sName);
if (table==null) { table = (UnicodeTable) tableSet.get("root"); }
table = tableSet.get(sName);
if (table==null) { table = tableSet.get("root"); }
}
tableStack.push(table);
}
@ -396,7 +396,7 @@ public class ClassicI18n extends I18n {
*/
public void popSpecialTable() {
tableStack.pop();
table = (UnicodeTable) tableStack.peek();
table = tableStack.peek();
}
/** Get the number of characters defined in the current table
@ -632,7 +632,7 @@ public class ClassicI18n extends I18n {
// todo: support automatic choice of inputenc (see comments)?
private String getBabelLanguage(String sLang) {
if (babelLanguages.containsKey(sLang)) {
return (String) babelLanguages.get(sLang);
return babelLanguages.get(sLang);
}
else {
return "english"; // interpret unknown languages as English
@ -640,7 +640,7 @@ public class ClassicI18n extends I18n {
}
private void prepareBabelLanguages() {
babelLanguages = new Hashtable();
babelLanguages = new Hashtable<String,String>();
babelLanguages.put("en", "english"); // latin1
babelLanguages.put("bg", "bulgarian"); // cp1251?
babelLanguages.put("cs", "czech"); // latin2

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-02-16)
* Version 1.2 (2009-03-26)
*
*/
@ -49,7 +49,7 @@ public abstract class I18n {
// Collected data
protected String sDefaultLanguage; // The default iso language to use
protected HashSet languages = new HashSet(); // All languages used
protected HashSet<String> languages = new HashSet<String>(); // All languages used
// **** Constructors ****

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-02-17)
* Version 1.2 (2009-03-26)
*
*/
@ -31,9 +31,10 @@ import java.util.Hashtable;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
// Helper classs: SAX handler to parse symbols.xml from jar
class UnicodeTableHandler extends DefaultHandler{
private Hashtable tableSet; // collection of all tables
/** Helper classs: SAX handler to parse symbols.xml from jar
*/
public class UnicodeTableHandler extends DefaultHandler{
private Hashtable<String,UnicodeTable> tableSet; // collection of all tables
private UnicodeTable table; // the current table
private String sSymbolSets;
private boolean bGlobalReadThisSet;
@ -42,7 +43,12 @@ class UnicodeTableHandler extends DefaultHandler{
private int nFontencs = 0; // The currently active fontencodings
private boolean b8bit = false;
UnicodeTableHandler(Hashtable tableSet, String sSymbolSets){
/** Create a new <code>UnicodeTableHandler</code>
*
* @param tableSet the <code>Hashtable</code> to fill with tables read from the file
* @param sSymbolSets string containing table names to read (separated by |)
*/
public UnicodeTableHandler(Hashtable<String,UnicodeTable> tableSet, String sSymbolSets){
this.sSymbolSets = sSymbolSets;
this.tableSet = tableSet;
}
@ -63,7 +69,7 @@ class UnicodeTableHandler extends DefaultHandler{
}
else if (qName.equals("special-symbol-set")) {
// start a new special symbol set; this requires a new table
table = new UnicodeTable((UnicodeTable) tableSet.get("root"));
table = new UnicodeTable(tableSet.get("root"));
tableSet.put(attributes.getValue("name"),table);
// Read it if it requires nothing, or something we read

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-02-17)
* Version 1.2 (2009-03-26)
*
*/

View file

@ -30,7 +30,7 @@ import java.util.Hashtable;
import java.util.Enumeration;
public class StyleMap {
private Hashtable items = new Hashtable();
private Hashtable<String, StyleMapItem> items = new Hashtable<String, StyleMapItem>();
public void put(String sName, String sBefore, String sAfter, boolean bLineBreak, boolean bVerbatim) {
StyleMapItem item = new StyleMapItem();
@ -67,32 +67,32 @@ public class StyleMap {
}
public String getBefore(String sName) {
return ((StyleMapItem) items.get(sName)).sBefore;
return items.get(sName).sBefore;
}
public String getAfter(String sName) {
return ((StyleMapItem) items.get(sName)).sAfter;
return items.get(sName).sAfter;
}
public String getNext(String sName) {
String sNext = ((StyleMapItem) items.get(sName)).sNext;
String sNext = items.get(sName).sNext;
return sNext.substring(1,sNext.length()-1);
}
public boolean isNext(String sName, String sNext) {
String sNext1 = ((StyleMapItem) items.get(sName)).sNext;
String sNext1 = items.get(sName).sNext;
return sNext1.indexOf(";"+sNext+";")>-1;
}
public boolean getLineBreak(String sName) {
return contains(sName) && ((StyleMapItem) items.get(sName)).bLineBreak;
return contains(sName) && items.get(sName).bLineBreak;
}
public boolean getVerbatim(String sName) {
return contains(sName) && ((StyleMapItem) items.get(sName)).bVerbatim;
return contains(sName) && items.get(sName).bVerbatim;
}
public Enumeration getNames() {
public Enumeration<String> getNames() {
return items.keys();
}

View file

@ -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.

View file

@ -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>

View file

@ -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;

View file

@ -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);

View file

@ -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();
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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:";

View file

@ -32,7 +32,7 @@ import java.util.Hashtable;
// Collection of export names
// Used for mapping named collections to simpler names (only A-Z, a-z and 0-9)
public class ExportNameCollection{
private Hashtable exportNames = new Hashtable();
private Hashtable<String, String> exportNames = new Hashtable<String, String>();
private String sPrefix;
private boolean bAcceptNumbers;
@ -45,7 +45,7 @@ public class ExportNameCollection{
this("",b);
}
public Enumeration keys() {
public Enumeration<String> keys() {
return exportNames.keys();
}
@ -89,7 +89,7 @@ public class ExportNameCollection{
public String getExportName(String sName) {
// add the name, if it does not exist
if (!containsName(sName)) { addName(sName); }
return sPrefix + (String) exportNames.get(sName);
return sPrefix + exportNames.get(sName);
}
public boolean containsName(String sName) {

View file

@ -81,15 +81,15 @@ public class Converter extends ConverterBase {
// The xhtml output file(s)
protected int nType = XhtmlDocument.XHTML10; // the doctype
Vector outFiles;
Vector<XhtmlDocument> outFiles;
private int nOutFileIndex;
private XhtmlDocument htmlDoc; // current outfile
private Document htmlDOM; // current DOM, usually within htmlDoc
private boolean bNeedHeaderFooter = false;
// Hyperlinks
Hashtable targets = new Hashtable();
LinkedList links = new LinkedList();
Hashtable<String, Integer> targets = new Hashtable<String, Integer>();
LinkedList<LinkDescriptor> links = new LinkedList<LinkDescriptor>();
// Strip illegal characters from internal hyperlink targets
private ExportNameCollection targetNames = new ExportNameCollection(true);
@ -136,7 +136,7 @@ public class Converter extends ConverterBase {
public void convertInner() throws IOException {
sTargetFileName = Misc.trimDocumentName(sTargetFileName,XhtmlDocument.getExtension(nType));
outFiles = new Vector();
outFiles = new Vector<XhtmlDocument>();
nOutFileIndex = -1;
bNeedHeaderFooter = ofr.isSpreadsheet() || ofr.isPresentation() || config.getXhtmlSplitLevel()>0 || config.getXhtmlUplink().length()>0;
@ -178,10 +178,10 @@ public class Converter extends ConverterBase {
textCv.insertEndnotes(htmlDoc.getContentNode());
// Resolve links
ListIterator iter = links.listIterator();
ListIterator<LinkDescriptor> iter = links.listIterator();
while (iter.hasNext()) {
LinkDescriptor ld = (LinkDescriptor) iter.next();
Integer targetIndex = (Integer) targets.get(ld.sId);
LinkDescriptor ld = iter.next();
Integer targetIndex = targets.get(ld.sId);
if (targetIndex!=null) {
int nTargetIndex = targetIndex.intValue();
if (nTargetIndex == ld.nIndex) { // same file
@ -196,7 +196,7 @@ public class Converter extends ConverterBase {
// Export styles (temp.)
for (int i=0; i<=nOutFileIndex; i++) {
Document dom = ((XhtmlDocument) outFiles.get(i)).getContentDOM();
Document dom = outFiles.get(i).getContentDOM();
NodeList hlist = dom.getElementsByTagName("head");
Node styles = styleCv.exportStyles(dom);
if (styles!=null) {
@ -208,7 +208,7 @@ public class Converter extends ConverterBase {
if (ofr.isSpreadsheet()) {
for (int i=0; i<=nOutFileIndex; i++) {
XhtmlDocument doc = (XhtmlDocument) outFiles.get(i);
XhtmlDocument doc = outFiles.get(i);
Document dom = doc.getContentDOM();
Element header = doc.getHeaderNode();
Element footer = doc.getFooterNode();
@ -233,12 +233,12 @@ public class Converter extends ConverterBase {
int nSheets = tableCv.sheetNames.size();
for (int j=0; j<nSheets; j++) {
if (config.xhtmlCalcSplit()) {
addNavigationLink(dom,headerPar,(String) tableCv.sheetNames.get(j),j);
addNavigationLink(dom,footerPar,(String) tableCv.sheetNames.get(j),j);
addNavigationLink(dom,headerPar,tableCv.sheetNames.get(j),j);
addNavigationLink(dom,footerPar,tableCv.sheetNames.get(j),j);
}
else {
addInternalNavigationLink(dom,headerPar,(String) tableCv.sheetNames.get(j),"tableheading"+j);
addInternalNavigationLink(dom,footerPar,(String) tableCv.sheetNames.get(j),"tableheading"+j);
addInternalNavigationLink(dom,headerPar,tableCv.sheetNames.get(j),"tableheading"+j);
addInternalNavigationLink(dom,footerPar,tableCv.sheetNames.get(j),"tableheading"+j);
}
}
@ -248,7 +248,7 @@ public class Converter extends ConverterBase {
}
else if (ofr.isPresentation() || config.getXhtmlSplitLevel()>0) {
for (int i=0; i<=nOutFileIndex; i++) {
XhtmlDocument doc = (XhtmlDocument) outFiles.get(i);
XhtmlDocument doc = outFiles.get(i);
Document dom = doc.getContentDOM();
//Element content = doc.getContentNode();
@ -304,7 +304,7 @@ public class Converter extends ConverterBase {
}
else if (config.getXhtmlUplink().length()>0) {
for (int i=0; i<=nOutFileIndex; i++) {
XhtmlDocument doc = (XhtmlDocument) outFiles.get(i);
XhtmlDocument doc = outFiles.get(i);
Document dom = doc.getContentDOM();
//Element content = doc.getContentNode();
@ -430,7 +430,7 @@ public class Converter extends ConverterBase {
// Use another document. TODO: This is very ugly; clean it up!!!
public void changeOutFile(int nIndex) {
nOutFileIndex = nIndex;
htmlDoc = (XhtmlDocument) outFiles.get(nIndex);
htmlDoc = outFiles.get(nIndex);
htmlDOM = htmlDoc.getContentDOM();
}
@ -537,7 +537,7 @@ public class Converter extends ConverterBase {
// Recreate nested sections, if any
if (!textCv.sections.isEmpty()) {
Iterator iter = textCv.sections.iterator();
Iterator<Node> iter = textCv.sections.iterator();
while (iter.hasNext()) {
Element section = (Element) iter.next();
String sStyleName = Misc.getAttribute(section,XMLString.TEXT_STYLE_NAME);

View file

@ -94,7 +94,7 @@ public class DrawConverter extends ConverterHelper {
private boolean bOriginalImageSize;
// Frames in spreadsheet documents are collected here
private Vector frames = new Vector();
private Vector<Element> frames = new Vector<Element>();
// This flag determines wether to collect frames or insert them immediately
private boolean bCollectFrames = false;
@ -102,9 +102,9 @@ public class DrawConverter extends ConverterHelper {
super(ofr,config,converter);
// We can only handle one form; pick an arbitrary one.
// Also we cannot split a form over several files.
Iterator formsIterator = ofr.getForms().getFormsIterator();
Iterator<FormReader> formsIterator = ofr.getForms().getFormsIterator();
if (formsIterator.hasNext() && config.getXhtmlSplitLevel()==0) {
form = (FormReader) formsIterator.next();
form = formsIterator.next();
}
bCollectFrames = ofr.isSpreadsheet();
sScale = config.getXhtmlScaling();
@ -222,7 +222,7 @@ public class DrawConverter extends ConverterHelper {
bCollectFrames = false;
int nCount = frames.size();
for (int i=0; i<nCount; i++) {
handleDrawElement((Element) frames.get(i),hnode,null,CENTERED);
handleDrawElement(frames.get(i),hnode,null,CENTERED);
}
frames.clear();
bCollectFrames = true;

View file

@ -63,9 +63,9 @@ public class FrameStyleConverter extends StyleWithPropertiesConverterHelper {
if (bConvertStyles) {
StringBuffer buf = new StringBuffer();
buf.append(super.getStyleDeclarations(sIndent));
Enumeration names = styleNames.keys();
Enumeration<String> names = styleNames.keys();
while (names.hasMoreElements()) {
String sDisplayName = (String) names.nextElement();
String sDisplayName = names.nextElement();
StyleWithProperties style = (StyleWithProperties)
getStyles().getStyleByDisplayName(sDisplayName);
if (!style.isAutomatic()) {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-03-05)
* Version 1.2 (2009-03-27)
*
*/
@ -58,7 +58,7 @@ public class L10n {
case UP: return "Nach oben";
case FIRST : return "Anfang";
case PREVIOUS : return "Vorheriges";
case NEXT : return "N\u00ccchstes";
case NEXT : return "N\u00e4chstes";
case LAST : return "Ende";
case CONTENTS : return "Inhalte";
case INDEX : return "Index";

View file

@ -85,9 +85,9 @@ public class ListStyleConverter extends StyleConverterHelper {
public String getStyleDeclarations(String sIndent) {
if (bConvertStyles) {
StringBuffer buf = new StringBuffer();
Enumeration names = styleNames.keys();
Enumeration<String> names = styleNames.keys();
while (names.hasMoreElements()) {
String sDisplayName = (String) names.nextElement();
String sDisplayName = names.nextElement();
ListStyle style = (ListStyle)
getStyles().getStyleByDisplayName(sDisplayName);
if (!style.isAutomatic()) {

View file

@ -83,10 +83,10 @@ public class PageStyleConverter extends StyleConverterHelper {
*/
public String getStyleDeclarations(String sIndent) {
StringBuffer buf = new StringBuffer();
Enumeration names = styleNames.keys();
Enumeration<String> names = styleNames.keys();
while (names.hasMoreElements()) {
// This will be master pages for presentations only
String sDisplayName = (String) names.nextElement();
String sDisplayName = names.nextElement();
MasterPage style = (MasterPage)
getStyles().getStyleByDisplayName(sDisplayName);
StyleInfo info = new StyleInfo();

View file

@ -45,7 +45,7 @@ public class PresentationStyleConverter extends FrameStyleConverter {
// Data about outline styles
String sCurrentOutlineStyle = null;
Hashtable outlineStyles = new Hashtable();
Hashtable<String, String[]> outlineStyles = new Hashtable<String, String[]>();
ExportNameCollection outlineStyleNames = new ExportNameCollection(true);
/** Create a new <code>PresentationStyleConverter</code>
@ -87,9 +87,9 @@ public class PresentationStyleConverter extends FrameStyleConverter {
if (bConvertStyles) {
StringBuffer buf = new StringBuffer();
buf.append(super.getStyleDeclarations(sIndent));
Enumeration names = outlineStyleNames.keys();
Enumeration<String> names = outlineStyleNames.keys();
while (names.hasMoreElements()) {
String sDisplayName = (String) names.nextElement();
String sDisplayName = names.nextElement();
StyleWithProperties style = (StyleWithProperties)
getStyles().getStyleByDisplayName(sDisplayName);
if (!style.isAutomatic()) {
@ -147,7 +147,7 @@ public class PresentationStyleConverter extends FrameStyleConverter {
public void applyOutlineStyle(int nLevel, StyleInfo info) {
if (2<=nLevel && nLevel<=9 && sCurrentOutlineStyle!=null) {
if (outlineStyles.containsKey(sCurrentOutlineStyle)) {
info.sClass = "outline"+outlineStyleNames.getExportName(((String[]) outlineStyles.get(sCurrentOutlineStyle))[nLevel]);
info.sClass = "outline"+outlineStyleNames.getExportName(outlineStyles.get(sCurrentOutlineStyle)[nLevel]);
}
}
}

View file

@ -93,9 +93,9 @@ public abstract class StyleWithPropertiesConverterHelper
public String getStyleDeclarations(String sIndent) {
if (bConvertStyles) {
StringBuffer buf = new StringBuffer();
Enumeration names = styleNames.keys();
Enumeration<String> names = styleNames.keys();
while (names.hasMoreElements()) {
String sDisplayName = (String) names.nextElement();
String sDisplayName = names.nextElement();
StyleWithProperties style = (StyleWithProperties)
getStyles().getStyleByDisplayName(sDisplayName);
if (!style.isAutomatic()) {

View file

@ -46,7 +46,7 @@ public class TableConverter extends ConverterHelper {
// The collection of all table names
// TODO: Navigation should be handled here rather than in Converter.java
protected Vector sheetNames = new Vector();
protected Vector<String> sheetNames = new Vector<String>();
public TableConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) {
super(ofr,config,converter);

View file

@ -83,27 +83,27 @@ public class TextConverter extends ConverterHelper {
private int nLastSplitLevel = 1; // The outline level at which the last split occured
private int nDontSplitLevel = 0; // if > 0 splitting is forbidden
boolean bAfterHeading=false; // last element was a top level heading
protected Stack sections = new Stack(); // stack of nested sections
protected Stack<Node> sections = new Stack<Node>(); // stack of nested sections
Element[] currentHeading = new Element[7]; // Last headings (repeated when splitting)
// Counters for generated numbers
private ListCounter outlineNumbering;
private Hashtable listCounters = new Hashtable();
private Hashtable<String, ListCounter> listCounters = new Hashtable<String, ListCounter>();
private String sCurrentListLabel = null;
// Mode used to handle floats (depends on source doc type and config)
private int nFloatMode;
// Data used for index bookkeeping
private Vector indexes = new Vector();
private Vector<IndexData> indexes = new Vector<IndexData>();
// Data used to handle Alphabetical Index
Vector index = new Vector(); // All words for the index
Vector<AlphabeticalEntry> index = new Vector<AlphabeticalEntry>(); // All words for the index
private int nIndexIndex = -1; // Current index used for id's (of form idxN)
private int nAlphabeticalIndex = -1; // File containing alphabetical index
// Data used to handle Table of Contents
private Vector tocEntries = new Vector(); // All potential(!) toc items
private Vector<TocEntry> tocEntries = new Vector<TocEntry>(); // All potential(!) toc items
private int nTocFileIndex = -1; // file index for main toc
private Element currentChapter = null; // Node for the current chapter (level 1) heading
private int nTocIndex = -1; // Current index for id's (of form tocN)
@ -116,8 +116,8 @@ public class TextConverter extends ConverterHelper {
private String sEntCitStyle = null;
// Gather the footnotes and endnotes
private LinkedList footnotes = new LinkedList();
private LinkedList endnotes = new LinkedList();
private LinkedList<Node> footnotes = new LinkedList<Node>();
private LinkedList<Node> endnotes = new LinkedList<Node>();
// Sometimes we have to create an inlinenode in a block context
// (labels for footnotes and endnotes)
@ -169,7 +169,7 @@ public class TextConverter extends ConverterHelper {
// Generate all indexes
int nIndexCount = indexes.size();
for (int i=0; i<nIndexCount; i++) {
generateToc((IndexData) indexes.get(i));
generateToc(indexes.get(i));
}
// Generate navigation links
@ -214,7 +214,7 @@ public class TextConverter extends ConverterHelper {
// Get the last heading of level <= split level for this file
TocEntry entryCurrent = null;
for (int i=nLen-1; i>=0; i--) {
TocEntry entry = (TocEntry) tocEntries.get(i);
TocEntry entry = tocEntries.get(i);
if (XMLString.TEXT_H.equals(entry.onode.getTagName()) && entry.nFileIndex==nIndex && entry.nOutlineLevel<=nSplit) {
entryCurrent = entry; break;
}
@ -237,7 +237,7 @@ public class TextConverter extends ConverterHelper {
int nPrevFileIndex = 0;
for (int i=0; i<nLen; i++) {
TocEntry entry = (TocEntry) tocEntries.get(i);
TocEntry entry = tocEntries.get(i);
if (entry.nFileIndex>nPrevFileIndex+1) {
// Skipping a file index means we have passed an index
@ -660,7 +660,7 @@ public class TextConverter extends ConverterHelper {
else if (style!=null) {
// Get existing or create new counter
if (listCounters.containsKey(style.getName())) {
return (ListCounter) listCounters.get(style.getName());
return listCounters.get(style.getName());
}
else {
ListCounter counter = new ListCounter(style);
@ -1066,7 +1066,7 @@ public class TextConverter extends ConverterHelper {
// Find the chapter
if (tocReader.isByChapter() && chapter!=null) {
for (int i=0; i<nLen; i++) {
TocEntry entry = (TocEntry) tocEntries.get(i);
TocEntry entry = tocEntries.get(i);
if (entry.onode==chapter) { nStart=i; break; }
}
@ -1074,7 +1074,7 @@ public class TextConverter extends ConverterHelper {
// Generate entries
for (int i=nStart; i<nLen; i++) {
TocEntry entry = (TocEntry) tocEntries.get(i);
TocEntry entry = tocEntries.get(i);
String sNodeName = entry.onode.getTagName();
if (XMLString.TEXT_H.equals(sNodeName)) {
int nLevel = getOutlineLevel(entry.onode);
@ -1219,8 +1219,8 @@ public class TextConverter extends ConverterHelper {
}
for (int i = 0; i<=nIndexIndex; i++) {
for (int j = i+1; j<=nIndexIndex ; j++) {
AlphabeticalEntry entryi = (AlphabeticalEntry) index.get(i);
AlphabeticalEntry entryj = (AlphabeticalEntry) index.get(j);
AlphabeticalEntry entryi = index.get(i);
AlphabeticalEntry entryj = index.get(j);
if (collator.compare(entryi.sWord, entryj.sWord) > 0) {
index.set(i,entryj);
index.set(j,entryi);
@ -1243,7 +1243,7 @@ public class TextConverter extends ConverterHelper {
int nColIndex = -1;
for (int i=0; i<=nIndexIndex; i++) {
if (i%nColEntries==0) { nColIndex++; }
AlphabeticalEntry entry = (AlphabeticalEntry) index.get(i);
AlphabeticalEntry entry = index.get(i);
Element p = createParagraph(td[nColIndex],sEntryStyleName);
Element a = converter.createLink("idx"+entry.nIndex);
p.appendChild(a);
@ -1517,7 +1517,7 @@ public class TextConverter extends ConverterHelper {
public void insertFootnotes(Node hnode) {
int n = footnotes.size();
for (int i=0; i<n; i++) {
Node footnote = (Node) footnotes.get(i);
Node footnote = footnotes.get(i);
String sId = Misc.getAttribute(footnote,XMLString.TEXT_ID);
Node citation = Misc.getChildByTagName(footnote,XMLString.TEXT_FOOTNOTE_CITATION);
if (citation==null) { // try oasis
@ -1552,7 +1552,7 @@ public class TextConverter extends ConverterHelper {
int n = endnotes.size();
if (nSplit>0 && n>0) { hnode = converter.nextOutFile(); }
for (int i=0; i<n; i++) {
Node endnote = (Node) endnotes.get(i);
Node endnote = endnotes.get(i);
String sId = Misc.getAttribute(endnote,XMLString.TEXT_ID);
Node citation = Misc.getChildByTagName(endnote,XMLString.TEXT_ENDNOTE_CITATION);
if (citation==null) { // try oasis

View file

@ -60,9 +60,9 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
// Bookkeeping for anchors
private ExportNameCollection anchorStyleNames = new ExportNameCollection(true);
private ExportNameCollection anchorVisitedStyleNames = new ExportNameCollection(true);
private Hashtable anchorCombinedStyleNames = new Hashtable();
private Hashtable orgAnchorStyleNames = new Hashtable();
private Hashtable orgAnchorVisitedStyleNames = new Hashtable();
private Hashtable<String, String> anchorCombinedStyleNames = new Hashtable<String, String>();
private Hashtable<String, String> orgAnchorStyleNames = new Hashtable<String, String>();
private Hashtable<String, String> orgAnchorVisitedStyleNames = new Hashtable<String, String>();
/** Create a new <code>TextStyleConverter</code>
* @param ofr an <code>OfficeReader</code> to read style information from
@ -111,7 +111,7 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
orgAnchorStyleNames.put(sExportName,sStyleName);
orgAnchorVisitedStyleNames.put(sExportName,sVisitedStyleName);
}
info.sClass = (String)anchorCombinedStyleNames.get(sName);
info.sClass = anchorCombinedStyleNames.get(sName);
}
/** <p>Convert style information for used styles</p>
@ -144,11 +144,11 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper {
}
// Remaining link styles...
Enumeration enumer = anchorCombinedStyleNames.elements();
Enumeration<String> enumer = anchorCombinedStyleNames.elements();
while (enumer.hasMoreElements()) {
String sExportName = (String) enumer.nextElement();
String sStyleName = (String) orgAnchorStyleNames.get(sExportName);
String sVisitedStyleName = (String) orgAnchorVisitedStyleNames.get(sExportName);
String sExportName = enumer.nextElement();
String sStyleName = orgAnchorStyleNames.get(sExportName);
String sVisitedStyleName = orgAnchorVisitedStyleNames.get(sExportName);
StyleWithProperties style = ofr.getTextStyle(sStyleName);

View file

@ -191,9 +191,9 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
}
private void writeXStyleMap(Document dom, XhtmlStyleMap sm, String sFamily) {
Enumeration smEnum = sm.getNames();
Enumeration<String> smEnum = sm.getNames();
while (smEnum.hasMoreElements()) {
String sName = (String) smEnum.nextElement();
String sName = smEnum.nextElement();
Element smNode = dom.createElement("xhtml-style-map");
smNode.setAttribute("name",sName);
smNode.setAttribute("family",sFamily);

View file

@ -30,10 +30,10 @@ import java.util.Hashtable;
import java.util.Enumeration;
public class XhtmlStyleMap {
private Hashtable blockElement = new Hashtable();
private Hashtable blockCss = new Hashtable();
private Hashtable element = new Hashtable();
private Hashtable css = new Hashtable();
private Hashtable<String, String> blockElement = new Hashtable<String, String>();
private Hashtable<String, String> blockCss = new Hashtable<String, String>();
private Hashtable<String, String> element = new Hashtable<String, String>();
private Hashtable<String, String> css = new Hashtable<String, String>();
public void put(String sName, String sBlockElement, String sBlockCss, String sElement, String sCss) {
blockElement.put(sName,sBlockElement);
@ -47,22 +47,22 @@ public class XhtmlStyleMap {
}
public String getBlockElement(String sName) {
return (String) blockElement.get(sName);
return blockElement.get(sName);
}
public String getBlockCss(String sName) {
return (String) blockCss.get(sName);
return blockCss.get(sName);
}
public String getElement(String sName) {
return (String) element.get(sName);
return element.get(sName);
}
public String getCss(String sName) {
return (String) css.get(sName);
return css.get(sName);
}
public Enumeration getNames() {
public Enumeration<String> getNames() {
return element.keys();
}

View file

@ -64,7 +64,7 @@ public class ConvertData implements ConverterResult {
/**
* Vector of <code>OutputFile</code> objects.
*/
private Vector v = new Vector();
private Vector<OutputFile> v = new Vector<OutputFile>();
/** Master doc */
private OutputFile masterDoc = null;
@ -137,7 +137,7 @@ public class ConvertData implements ConverterResult {
* @return The <code>Iterator</code> to access the
* <code>Vector</code> of <code>OutputFile</code> objects.
*/
public Iterator iterator() {
public Iterator<OutputFile> iterator() {
return v.iterator();
}
@ -154,9 +154,9 @@ public class ConvertData implements ConverterResult {
public void write(File dir) throws IOException {
if (dir!=null && !dir.exists()) throw new IOException("Directory does not exist");
Iterator docEnum = iterator();
Iterator<OutputFile> docEnum = iterator();
while (docEnum.hasNext()) {
OutputFile docOut = (OutputFile) docEnum.next();
OutputFile docOut = docEnum.next();
String sDirName = "";
String sFileName = docOut.getFileName();
File subdir = dir;

View file

@ -120,7 +120,7 @@ public class OfficeDocument
private OfficeZip zip = null;
/** Collection to keep track of the embedded objects in the document. */
private Map embeddedObjects = null;
private Map<String, EmbeddedObject> embeddedObjects = null;
/**
* Default constructor.
@ -320,10 +320,10 @@ public class OfficeDocument
*
* @return An <code>Iterator</code> of <code>EmbeddedObject</code> objects.
*/
public Iterator getEmbeddedObjects() {
public Iterator<EmbeddedObject> getEmbeddedObjects() {
if (embeddedObjects == null && manifestDoc != null) {
embeddedObjects = new HashMap();
embeddedObjects = new HashMap<String, EmbeddedObject>();
// Need to read the manifest file and construct a list of objects
NodeList nl = manifestDoc.getElementsByTagName(TAG_MANIFEST_FILE);
@ -400,7 +400,7 @@ public class OfficeDocument
}
if (embeddedObjects.containsKey(name)) {
return (EmbeddedObject)embeddedObjects.get(name);
return embeddedObjects.get(name);
}
else {
return null;
@ -419,7 +419,7 @@ public class OfficeDocument
}
if (embeddedObjects == null) {
embeddedObjects = new HashMap();
embeddedObjects = new HashMap<String, EmbeddedObject>();
}
embeddedObjects.put(embObj.getName(), embObj);
@ -734,9 +734,9 @@ public class OfficeDocument
Element manifestRoot = manifestDoc.getDocumentElement();
// The EmbeddedObjects come first.
Iterator embObjs = getEmbeddedObjects();
Iterator<EmbeddedObject> embObjs = getEmbeddedObjects();
while (embObjs.hasNext()) {
EmbeddedObject obj = (EmbeddedObject)embObjs.next();
EmbeddedObject obj = embObjs.next();
obj.writeManifestData(manifestDoc);
obj.write(zip);

View file

@ -75,7 +75,7 @@ class OfficeZip {
private final static int BUFFERSIZE = 1024;
private List entryList = null;
private List<Entry> entryList = null;
private int contentIndex = -1;
private int styleIndex = -1;
@ -86,7 +86,7 @@ class OfficeZip {
/** Default constructor. */
OfficeZip() {
entryList = new LinkedList();
entryList = new LinkedList<Entry>();
}
@ -229,7 +229,7 @@ class OfficeZip {
// Could improve performance by caching the name and index when
// iterating through the ZipFile in read().
for (int i = 0; i < entryList.size(); i++) {
Entry e = (Entry)entryList.get(i);
Entry e = entryList.get(i);
if (e.zipEntry.getName().equals(name)) {
return getEntryBytes(i);
@ -252,7 +252,7 @@ class OfficeZip {
*/
void setNamedBytes(String name, byte[] bytes) {
for (int i = 0; i < entryList.size(); i++) {
Entry e = (Entry)entryList.get(i);
Entry e = entryList.get(i);
if (e.zipEntry.getName().equals(name)) {
setEntryBytes(i, bytes, name);
@ -283,7 +283,7 @@ class OfficeZip {
byte[] bytes = null;
if (index > -1) {
Entry entry = (Entry) entryList.get(index);
Entry entry = entryList.get(index);
bytes = entry.bytes;
}
return bytes;
@ -373,7 +373,7 @@ class OfficeZip {
// replace existing entry in entryList
Entry entry = (Entry) entryList.get(index);
Entry entry = entryList.get(index);
name = entry.zipEntry.getName();
int method = entry.zipEntry.getMethod();
@ -409,11 +409,11 @@ class OfficeZip {
ZipOutputStream zos = new ZipOutputStream(os);
ListIterator iterator = entryList.listIterator();
ListIterator<Entry> iterator = entryList.listIterator();
while (iterator.hasNext()) {
Entry entry = (Entry) iterator.next();
Entry entry = iterator.next();
ZipEntry ze = entry.zipEntry;
//String name = ze.getName();