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

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