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

@ -378,7 +378,7 @@ public abstract class ExportFilterBase implements
}
// Write out files
Iterator docEnum = dataOut.iterator();
Iterator<OutputFile> docEnum = dataOut.iterator();
// Remove the file name part of the url
String sNewURL = null;
@ -393,7 +393,7 @@ public abstract class ExportFilterBase implements
}
while (docEnum.hasNext() && sURL.startsWith("file:")) {
OutputFile docOut = (OutputFile)docEnum.next();
OutputFile docOut = docEnum.next();
if (dataOut.getMasterDocument()==docOut) {
// The master document is written to the XOutStream supplied

View file

@ -232,9 +232,9 @@ public class FilterDataParser {
}
// Read further configuration properties
Enumeration keys = props.keys();
Enumeration<String> keys = props.keys();
while (keys.hasMoreElements()) {
String sKey = (String) keys.nextElement();
String sKey = keys.nextElement();
if (!"ConfigURL".equals(sKey) && !"TemplateURL".equals(sKey) && !"AutoCreate".equals(sKey)) {
Object value = props.get(sKey);
if (AnyConverter.isString(value)) {

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-03-08)
* Version 1.2 (2009-03-26)
*
*/
@ -58,14 +58,14 @@ import writer2latex.api.MIMETypes;
public class GraphicConverterImpl2 implements GraphicConverter {
private XComponentContext xComponentContext;
private Hashtable importFilter;
private Hashtable exportFilter;
private Hashtable<String,String> importFilter;
private Hashtable<String,String> exportFilter;
private EPSCleaner epsCleaner;
public GraphicConverterImpl2(XComponentContext xComponentContext) {
this.xComponentContext = xComponentContext;
importFilter = new Hashtable();
importFilter = new Hashtable<String,String>();
importFilter.put(MIMETypes.BMP, "BMP - MS Windows");
//importFilter.put(MIMETypes.EMF, "EMF - MS Windows Metafile");
importFilter.put(MIMETypes.EPS, "EPS - Encapsulated PostScript");
@ -76,7 +76,7 @@ public class GraphicConverterImpl2 implements GraphicConverter {
importFilter.put(MIMETypes.TIFF, "TIF - Tag Image File");
importFilter.put(MIMETypes.WMF, "WMF - MS Windows Metafile");
exportFilter = new Hashtable();
exportFilter = new Hashtable<String,String>();
exportFilter.put(MIMETypes.BMP,"draw_bmp_Export");
//exportFilter.put(MIMETypes.EMF,"draw_emf_Export");
exportFilter.put(MIMETypes.EPS,"draw_eps_Export");

View file

@ -87,7 +87,7 @@ public abstract class OptionsDialogBase extends DialogBase implements
this.xMSF = null; // must be set properly by subclass
mediaProps = null;
sConfigNames = null;
lockedOptions = new HashSet();
lockedOptions = new HashSet<String>();
}
//////////////////////////////////////////////////////////////////////////
@ -163,7 +163,7 @@ public abstract class OptionsDialogBase extends DialogBase implements
private String[] sConfigNames;
// Set of locked controls
private HashSet lockedOptions;
private HashSet<String> lockedOptions;
//////////////////////////////////////////////////////////////////////////

View file

@ -35,14 +35,14 @@ import com.sun.star.beans.PropertyValue;
*/
public class PropertyHelper {
private Hashtable data;
private Hashtable<String, Object> data;
public PropertyHelper() {
data = new Hashtable();
data = new Hashtable<String, Object>();
}
public PropertyHelper(PropertyValue[] props) {
data = new Hashtable();
data = new Hashtable<String, Object>();
int nLen = props.length;
for (int i=0; i<nLen; i++) {
data.put(props[i].Name,props[i].Value);
@ -57,7 +57,7 @@ public class PropertyHelper {
return data.get(sName);
}
public Enumeration keys() {
public Enumeration<String> keys() {
return data.keys();
}
@ -65,9 +65,9 @@ public class PropertyHelper {
int nSize = data.size();
PropertyValue[] props = new PropertyValue[nSize];
int i=0;
Enumeration keys = keys();
Enumeration<String> keys = keys();
while (keys.hasMoreElements()) {
String sKey = (String) keys.nextElement();
String sKey = keys.nextElement();
props[i] = new PropertyValue();
props[i].Name = sKey;
props[i++].Value = get(sKey);

View file

@ -0,0 +1,304 @@
/************************************************************************
*
* ConfigurationDialog.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-30)
*
*/
package org.openoffice.da.comp.writer4latex;
import java.io.File;
import java.net.URI;
import com.sun.star.awt.XControl;
import com.sun.star.awt.XControlContainer;
import com.sun.star.awt.XControlModel;
import com.sun.star.awt.XContainerWindowEventHandler;
import com.sun.star.awt.XWindow;
import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.ui.dialogs.ExecutableDialogResults;
import com.sun.star.ui.dialogs.XExecutableDialog;
import com.sun.star.ui.dialogs.XFilePicker;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.lib.uno.helper.WeakBase;
/** This class provides a uno component which implements the configuration
* of Writer4LaTeX
*/
public final class ConfigurationDialog
extends WeakBase
implements XServiceInfo, XContainerWindowEventHandler {
private XComponentContext xContext;
private ExternalApps externalApps;
/** The component will be registered under this name.
*/
public static String __serviceName = "org.openoffice.da.writer4latex.ConfigurationDialog";
/** The component should also have an implementation name.
*/
public static String __implementationName = "org.openoffice.da.comp.writer4latex.ConfigurationDialog";
/** Create a new ConfigurationDialog */
public ConfigurationDialog(XComponentContext xContext) {
this.xContext = xContext;
externalApps = new ExternalApps(xContext);
}
// Implement XContainerWindowEventHandler
public boolean callHandlerMethod(XWindow xWindow, Object event, String sMethod)
throws com.sun.star.lang.WrappedTargetException {
try {
if (sMethod.equals("external_event") ){
return handleExternalEvent(xWindow, event);
}
else if (sMethod.equals("ApplicationChange")) {
return changeApplication(xWindow);
}
else if (sMethod.equals("BrowseClick")) {
return browseForExecutable(xWindow);
}
else if (sMethod.equals("ExecutableUnfocus")) {
return updateApplication(xWindow);
}
else if (sMethod.equals("OptionsUnfocus")) {
return updateApplication(xWindow);
}
else if (sMethod.equals("AutomaticClick")) {
return autoConfigure(xWindow);
}
}
catch (com.sun.star.uno.RuntimeException e) {
throw e;
}
catch (com.sun.star.uno.Exception e) {
throw new com.sun.star.lang.WrappedTargetException(sMethod, this, e);
}
return false;
}
public String[] getSupportedMethodNames() {
String[] sNames = { "external_event", "ApplicationChange", "BrowseClick", "ExecutableUnfocus", "OptionsUnfocus", "AutomaticClick" };
return sNames;
}
// Implement the interface XServiceInfo
public boolean supportsService(String sServiceName) {
return sServiceName.equals(__serviceName);
}
public String getImplementationName() {
return __implementationName;
}
public String[] getSupportedServiceNames() {
String[] sSupportedServiceNames = { __serviceName };
return sSupportedServiceNames;
}
// Private stuff
private boolean handleExternalEvent(com.sun.star.awt.XWindow xWindow, Object aEventObject)
throws com.sun.star.uno.Exception {
try {
String sMethod = AnyConverter.toString(aEventObject);
if (sMethod.equals("ok")) {
externalApps.save();
return true;
} else if (sMethod.equals("back") || sMethod.equals("initialize")) {
externalApps.load();
return changeApplication(xWindow);
}
}
catch (com.sun.star.lang.IllegalArgumentException e) {
throw new com.sun.star.lang.IllegalArgumentException(
"Method external_event requires a string in the event object argument.", this,(short) -1);
}
return false;
}
private boolean changeApplication(XWindow xWindow) {
String sAppName = getSelectedAppName(xWindow);
if (sAppName!=null) {
String[] s = externalApps.getApplication(sAppName);
setComboBoxText(xWindow, "Executable", s[0]);
setComboBoxText(xWindow, "Options", s[1]);
}
return true;
}
private boolean browseForExecutable(XWindow xWindow) {
XComponent xComponent = null;
try {
// Create FilePicker
Object filePicker = xContext.getServiceManager()
.createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker", xContext);
XFilePicker xFilePicker = (XFilePicker)
UnoRuntime.queryInterface(XFilePicker.class, filePicker);
xComponent = (XComponent)
UnoRuntime.queryInterface(XComponent.class, xFilePicker);
// Display the FilePicker
XExecutableDialog xExecutable = (XExecutableDialog)
UnoRuntime.queryInterface(XExecutableDialog.class, xFilePicker);
// Get the path
if (xExecutable.execute() == ExecutableDialogResults.OK) {
String[] sPathList = xFilePicker.getFiles();
if (sPathList.length > 0) {
setComboBoxText(xWindow, "Executable", new File(new URI(sPathList[0])).getCanonicalPath());
updateApplication(xWindow);
}
}
}
catch (com.sun.star.uno.Exception e) {
}
catch (java.net.URISyntaxException e) {
}
catch (java.io.IOException e) {
}
finally{
// Always dispose the FilePicker component
if (xComponent!=null) {
xComponent.dispose();
}
}
return true;
}
private boolean updateApplication(XWindow xWindow) {
String sAppName = getSelectedAppName(xWindow);
if (sAppName!=null) {
externalApps.setApplication(sAppName, getComboBoxText(xWindow, "Executable"), getComboBoxText(xWindow, "Options"));
}
return true;
}
private boolean autoConfigure(XWindow xWindow) {
externalApps.setApplication(ExternalApps.LATEX, "latex", "--interaction=batchmode %s");
externalApps.setApplication(ExternalApps.PDFLATEX, "pdflatex", "--interaction=batchmode %s");
externalApps.setApplication(ExternalApps.XELATEX, "xelatex", "--interaction=batchmode %s");
externalApps.setApplication(ExternalApps.DVIPS, "dvips", "%s");
externalApps.setApplication(ExternalApps.BIBTEX, "bibtex", "%s");
externalApps.setApplication(ExternalApps.MAKEINDEX, "makeindex", "%s");
externalApps.setApplication(ExternalApps.OOLATEX, "oolatex", "%s");
String sOsName = System.getProperty("os.name");
if ("Linux".equals(sOsName)) {
// TODO: Search for applications (which...)
// Viewers may be evince, okular, xdvi, xpdf, ghostview or...
externalApps.setApplication(ExternalApps.DVIVIEWER, "evince", "%s");
externalApps.setApplication(ExternalApps.PDFVIEWER, "evince", "%s");
externalApps.setApplication(ExternalApps.POSTSCRIPTVIEWER, "evince", "%s");
}
else if ("Windows".equals(sOsName)) {
// Assume MikTeX
externalApps.setApplication(ExternalApps.DVIVIEWER, "yap", "--single-instance %s");
// And assume gsview for pdf and ps
// gsview32 may not be in the path, but at least this helps a bit
externalApps.setApplication(ExternalApps.PDFVIEWER, "gsview32.exe", "-e \"%s\"");
externalApps.setApplication(ExternalApps.POSTSCRIPTVIEWER, "gsview32.exe", "-e \"%s\"");
}
changeApplication(xWindow);
return true;
}
private String getSelectedAppName(XWindow xWindow) {
short nItem = getListBoxSelectedItem(xWindow, "Application");
//String sAppName = null;
switch (nItem) {
case 0: return ExternalApps.LATEX;
case 1: return ExternalApps.PDFLATEX;
case 2: return ExternalApps.XELATEX;
case 3: return ExternalApps.DVIPS;
case 4: return ExternalApps.BIBTEX;
case 5: return ExternalApps.MAKEINDEX;
case 6: return ExternalApps.OOLATEX;
case 7: return ExternalApps.DVIVIEWER;
case 8: return ExternalApps.PDFVIEWER;
case 9: return ExternalApps.POSTSCRIPTVIEWER;
}
return "???";
}
// Some helpers copied from DialogBase
private XPropertySet getControlProperties(XWindow xWindow, String sControlName) {
XControlContainer xContainer = (XControlContainer)
UnoRuntime.queryInterface(XControlContainer.class, xWindow);
XControl xControl = xContainer.getControl(sControlName);
XControlModel xModel = xControl.getModel();
XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xModel);
return xPropertySet;
}
private String getComboBoxText(XWindow xWindow, String sControlName) {
// Returns the text of a combobox
XPropertySet xPropertySet = getControlProperties(xWindow, sControlName);
try {
return (String) xPropertySet.getPropertyValue("Text");
}
catch (Exception e) {
// Will fail if the control does not exist or is not a combo
return "";
}
}
private void setComboBoxText(XWindow xWindow, String sControlName, String sText) {
XPropertySet xPropertySet = getControlProperties(xWindow, sControlName);
try {
xPropertySet.setPropertyValue("Text", sText);
}
catch (Exception e) {
// Will fail if the control does not exist or is not a combo box or
// nText is an illegal value
}
}
private short getListBoxSelectedItem(XWindow xWindow, String sControlName) {
// Returns the first selected element in case of a multiselection
XPropertySet xPropertySet = getControlProperties(xWindow, sControlName);
try {
short[] selection = (short[]) xPropertySet.getPropertyValue("SelectedItems");
return selection[0];
}
catch (Exception e) {
// Will fail if the control does not exist or is not a list box
return -1;
}
}
}

View file

@ -0,0 +1,250 @@
/************************************************************************
*
* ExternalApps.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-30)
*
*/
package org.openoffice.da.comp.writer4latex;
import java.io.File;
import java.io.IOException;
import java.lang.Process;
import java.lang.ProcessBuilder;
import java.util.HashMap;
import java.util.Vector;
//import java.util.Map;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XMultiHierarchicalPropertySet;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XChangesBatch;
/** This class manages and executes external applications used by Writer4LaTeX.
* These include TeX and friends as well as viewers for the various backend
* formats. The registry is used for persistent storage of the settings.
*/
public class ExternalApps {
public final static String LATEX = "LaTeX";
public final static String PDFLATEX = "PdfLaTeX";
public final static String XELATEX = "XeLaTeX";
public final static String BIBTEX = "BibTeX";
public final static String MAKEINDEX = "Makeindex";
public final static String OOLATEX = "Oolatex";
public final static String DVIPS = "Dvips";
public final static String DVIVIEWER = "DVIViewer";
public final static String POSTSCRIPTVIEWER = "PostscriptViewer";
public final static String PDFVIEWER = "PdfViewer";
private final static String[] sApps = { LATEX, PDFLATEX, XELATEX, BIBTEX, MAKEINDEX, OOLATEX, DVIPS, DVIVIEWER, POSTSCRIPTVIEWER, PDFVIEWER };
private XComponentContext xContext;
private HashMap<String,String[]> apps;
/** Construct a new ExternalApps object, with empty definitions */
public ExternalApps(XComponentContext xContext) {
this.xContext = xContext;
apps = new HashMap<String,String[]>();
for (int i=0; i<sApps.length; i++) {
setApplication(sApps[i], "?", "?");
}
}
/** Define an external application
* @param sAppName the name of the application to define
* @param sExecutable the system dependent path to the executable file
* @param sOptions the options to the external application; %s will be
* replaced by the filename on execution
*/
public void setApplication(String sAppName, String sExecutable, String sOptions) {
String[] sValue = { sExecutable, sOptions };
apps.put(sAppName, sValue);
}
/** Get the definition for an external application
* @param sAppName the name of the application to get
* @return a String array containg the system dependent path to the
* executable file as entry 0, and the parameters as entry 1
* returns null if the application is unknown
*/
public String[] getApplication(String sAppName) {
return apps.get(sAppName);
}
/** Execute an external application
* @param sAppName the name of the application to execute
* @param sFileName the file name to use
* @param workDir the working directory to use
* @param bWaitFor true if the method should wait for the execution to finish
* @return error code
*/
public int execute(String sAppName, String sFileName, File workDir, boolean bWaitFor) {
// Assemble the command
String[] sApp = getApplication(sAppName);
if (sApp==null) { return 1; }
try {
Vector<String> command = new Vector<String>();
command.add(sApp[0]);
String[] sArguments = sApp[1].split(" ");
for (String s : sArguments) {
command.add(s.replace("%s",sFileName));
}
ProcessBuilder pb = new ProcessBuilder(command);
//Map<String, String> env = pb.environment();
//env.put("VAR1", "myValue");
pb.directory(workDir);
Process proc = pb.start();
//Runtime rt = Runtime.getRuntime();
//Process proc = rt.exec(sCommand, new String[0], workDir);
// Gobble the error stream of the application
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
// Gooble the output stream of the application
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// Kick them off
errorGobbler.start();
outputGobbler.start();
// Any error?
return bWaitFor ? proc.waitFor() : 0;
}
catch (InterruptedException e) {
return 1;
}
catch (IOException e) {
return 1;
}
}
/** Load the external applications from the registry
*/
public void load() {
Object view;
try {
view = getRegistryView(false);
}
catch (com.sun.star.uno.Exception e) {
// Give up...
//setApplication(LATEX,"Error!",e.getMessage());
return;
}
XMultiHierarchicalPropertySet xProps = (XMultiHierarchicalPropertySet)
UnoRuntime.queryInterface(XMultiHierarchicalPropertySet.class, view);
for (int i=0; i<sApps.length; i++) {
String[] sNames = new String[2];
sNames[0] = sApps[i]+"/Executable";
sNames[1] = sApps[i]+"/Options";
try {
Object[] values = xProps.getHierarchicalPropertyValues(sNames);
setApplication(sApps[i], (String) values[0], (String) values[1]);
}
catch (com.sun.star.uno.Exception e) {
// Ignore...
}
}
disposeRegistryView(view);
}
/** Save the external applications to the registry
*/
public void save() {
Object view;
try {
view = getRegistryView(true);
}
catch (com.sun.star.uno.Exception e) {
// Give up...
return;
}
XMultiHierarchicalPropertySet xProps = (XMultiHierarchicalPropertySet)
UnoRuntime.queryInterface(XMultiHierarchicalPropertySet.class, view);
for (int i=0; i<sApps.length; i++) {
String[] sNames = new String[2];
sNames[0] = sApps[i]+"/Executable";
sNames[1] = sApps[i]+"/Options";
String[] sValues = getApplication(sApps[i]);
try {
xProps.setHierarchicalPropertyValues(sNames, sValues);
}
catch (com.sun.star.uno.Exception e) {
// Ignore...
}
}
// Commit registry changes
XChangesBatch xUpdateContext = (XChangesBatch)
UnoRuntime.queryInterface(XChangesBatch.class, view);
try {
xUpdateContext.commitChanges();
}
catch (Exception e) {
// ignore
}
disposeRegistryView(view);
}
// Get a view of the options root in the registry
private Object getRegistryView(boolean bUpdate)
throws com.sun.star.uno.Exception {
//Object provider = xMSF.createInstance(
Object provider = xContext.getServiceManager().createInstanceWithContext(
"com.sun.star.configuration.ConfigurationProvider", xContext);
XMultiServiceFactory xProvider = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class,provider);
PropertyValue[] args = new PropertyValue[1];
args[0] = new PropertyValue();
args[0].Name = "nodepath";
args[0].Value = "/org.openoffice.da.Writer4LaTeX.Options/Applications";
String sServiceName = bUpdate ?
"com.sun.star.configuration.ConfigurationUpdateAccess" :
"com.sun.star.configuration.ConfigurationAccess";
Object view = xProvider.createInstanceWithArguments(sServiceName,args);
return view;
}
// Dispose a previously obtained registry view
private void disposeRegistryView(Object view) {
XComponent xComponent = (XComponent)
UnoRuntime.queryInterface(XComponent.class,view);
xComponent.dispose();
}
}

View file

@ -0,0 +1,146 @@
/************************************************************************
*
* LogViewerDialog.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-26)
*
*/
package org.openoffice.da.comp.writer4latex;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.sun.star.awt.XDialog;
import com.sun.star.uno.XComponentContext;
import org.openoffice.da.comp.w2lcommon.helper.DialogBase;
/** This class provides a uno component which displays logfiles
*/
public class LogViewerDialog extends DialogBase
implements com.sun.star.lang.XInitialization {
/** The component will be registered under this name.
*/
public static String __serviceName = "org.openoffice.da.writer4latex.LogViewerDialog";
/** The component should also have an implementation name.
*/
public static String __implementationName = "org.openoffice.da.comp.writer4latex.LogViewerDialog";
/** Return the name of the library containing the dialog
*/
public String getDialogLibraryName() {
return "W4LDialogs";
}
private String sBaseUrl = null;
private String sLaTeXLog = null;
private String sBibTeXLog = null;
private String sMakeindexLog = null;
/** Return the name of the dialog within the library
*/
public String getDialogName() {
return "LogViewer";
}
public void initialize() {
if (sBaseUrl!=null) {
sLaTeXLog = readTextFile(sBaseUrl+".log");
sBibTeXLog = readTextFile(sBaseUrl+".blg");
sMakeindexLog = readTextFile(sBaseUrl+".ilg");
setComboBoxText("LogContents",sLaTeXLog);
}
}
public void finalize() {
}
/** Create a new LogViewerDialog */
public LogViewerDialog(XComponentContext xContext) {
super(xContext);
}
// Implement com.sun.star.lang.XInitialization
public void initialize( Object[] object )
throws com.sun.star.uno.Exception {
if ( object.length > 0 ) {
if (object[0] instanceof String) {
sBaseUrl = (String) object[0];
}
}
}
// Implement XDialogEventHandler
public boolean callHandlerMethod(XDialog xDialog, Object event, String sMethod) {
if (sMethod.equals("ViewLaTeXLog")) {
setComboBoxText("LogContents", sLaTeXLog);
}
else if (sMethod.equals("ViewBibTeXLog")) {
setComboBoxText("LogContents", sBibTeXLog);
}
else if (sMethod.equals("ViewMakeindexLog")) {
setComboBoxText("LogContents", sMakeindexLog);
}
return true;
}
public String[] getSupportedMethodNames() {
String[] sNames = { "ViewLaTeXLog", "ViewBibTeXLog", "ViewMakeindexLog" };
return sNames;
}
// Utility methods
private String readTextFile(String sUrl) {
StringBuffer buf = new StringBuffer();
try {
File file = new File(new URI(sUrl));
if (file.exists() && file.isFile()) {
InputStreamReader isr = new InputStreamReader(new FileInputStream(file));
int n;
do {
n = isr.read();
if (n>-1) { buf.append((char)n); }
}
while (n>-1);
isr.close();
}
}
catch (URISyntaxException e) {
return "";
}
catch (IOException e) {
return "";
}
return buf.toString();
}
}

View file

@ -0,0 +1,56 @@
/************************************************************************
*
* StreamGobbler.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-30)
*
*/
package org.openoffice.da.comp.writer4latex;
import java.io.*;
class StreamGobbler extends Thread {
InputStream is;
String type;
StreamGobbler(InputStream is, String type) {
this.is = is;
this.type = type;
}
public void run() {
try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null) {
//while ( br.readLine() != null) {
// Do nothing...
System.out.println(type + ">" + line);
}
}
catch (IOException ioe) {
ioe.printStackTrace();
}
}
}

View file

@ -0,0 +1,124 @@
/************************************************************************
*
* TeXify.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-30)
*
*/
package org.openoffice.da.comp.writer4latex;
import java.io.File;
import java.io.IOException;
import com.sun.star.uno.XComponentContext;
/** This class builds LaTeX documents into dvi, postscript or pdf and displays
* the result.
*/
public final class TeXify {
/** Backend format generic (dvi) */
public static final short GENERIC = 1;
/** Backend format dvips (postscript) */
public static final short DVIPS = 2;
/** Backend format pdfTeX (pdf) */
public static final short PDFTEX = 3;
// Define the applications to run for each backend
private static final String[] genericTexify = {
ExternalApps.LATEX, ExternalApps.BIBTEX, ExternalApps.MAKEINDEX,
ExternalApps.LATEX, ExternalApps.MAKEINDEX, ExternalApps.LATEX };
private static final String[] pdfTexify = {
ExternalApps.PDFLATEX, ExternalApps.BIBTEX, ExternalApps.MAKEINDEX,
ExternalApps.PDFLATEX, ExternalApps.MAKEINDEX, ExternalApps.PDFLATEX };
private static final String[] dvipsTexify = {
ExternalApps.LATEX, ExternalApps.BIBTEX, ExternalApps.MAKEINDEX,
ExternalApps.LATEX, ExternalApps.MAKEINDEX, ExternalApps.LATEX,
ExternalApps.DVIPS };
// Global objects
//private XComponentContext xContext;
private ExternalApps externalApps;
public TeXify(XComponentContext xContext) {
//this.xContext = xContext;
externalApps = new ExternalApps(xContext);
}
/** Process a document
* @param file the LaTeX file to process
* @param nBackend the desired backend format (generic, dvips, pdftex)
* @param bView set the true if the result should be displayed in the viewer
* @throws IOException if the document cannot be read
*/
public void process(File file, short nBackend, boolean bView) throws IOException {
// Remove extension from file
if (file.getName().endsWith(".tex")) {
file = new File(file.getParentFile(),
file.getName().substring(0,file.getName().length()-4));
}
// Update external apps from registry
externalApps.load();
// Process LaTeX document
if (nBackend==GENERIC) {
doTeXify(genericTexify, file);
if (externalApps.execute(ExternalApps.DVIVIEWER,
new File(file.getParentFile(),file.getName()+".dvi").getPath(),
file.getParentFile(), false)>0) {
throw new IOException("Error executing dvi viewer");
}
}
else if (nBackend==PDFTEX) {
doTeXify(pdfTexify, file);
if (externalApps.execute(ExternalApps.PDFVIEWER,
new File(file.getParentFile(),file.getName()+".pdf").getPath(),
file.getParentFile(), false)>0) {
throw new IOException("Error executing pdf viewer");
}
}
else if (nBackend==DVIPS) {
doTeXify(dvipsTexify, file);
if (externalApps.execute(ExternalApps.POSTSCRIPTVIEWER,
new File(file.getParentFile(),file.getName()+".ps").getPath(),
file.getParentFile(), false)>0) {
throw new IOException("Error executing postscript viewer");
}
}
}
private void doTeXify(String[] sAppList, File file) throws IOException {
for (int i=0; i<sAppList.length; i++) {
// Execute external application
int nReturnCode = externalApps.execute(
sAppList[i], file.getName(), file.getParentFile(), true);
if (nReturnCode>0) {
//throw new IOException("Error executing "+sAppList[i]);
}
}
}
}

View file

@ -0,0 +1,103 @@
/************************************************************************
*
* W4LRegistration.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-26)
*
*/
package org.openoffice.da.comp.writer4latex;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XSingleServiceFactory;
import com.sun.star.registry.XRegistryKey;
import com.sun.star.comp.loader.FactoryHelper;
/** This class provides a static method to instantiate our uno components
* on demand (__getServiceFactory()), and a static method to give
* information about the components (__writeRegistryServiceInfo()).
* Furthermore, it saves the XMultiServiceFactory provided to the
* __getServiceFactory method for future reference by the componentes.
*/
public class W4LRegistration {
public static XMultiServiceFactory xMultiServiceFactory;
/**
* Returns a factory for creating the service.
* This method is called by the <code>JavaLoader</code>
*
* @return returns a <code>XSingleServiceFactory</code> for creating the
* component
*
* @param implName the name of the implementation for which a
* service is desired
* @param multiFactory the service manager to be used if needed
* @param regKey the registryKey
*
* @see com.sun.star.comp.loader.JavaLoader
*/
public static XSingleServiceFactory __getServiceFactory(String implName,
XMultiServiceFactory multiFactory, XRegistryKey regKey) {
xMultiServiceFactory = multiFactory;
XSingleServiceFactory xSingleServiceFactory = null;
if (implName.equals(Writer4LaTeX.__implementationName) ) {
xSingleServiceFactory = FactoryHelper.getServiceFactory(Writer4LaTeX.class,
Writer4LaTeX.__serviceName,
multiFactory,
regKey);
}
else if (implName.equals(ConfigurationDialog.__implementationName) ) {
xSingleServiceFactory = FactoryHelper.getServiceFactory(ConfigurationDialog.class,
ConfigurationDialog.__serviceName,
multiFactory,
regKey);
}
else if (implName.equals(LogViewerDialog.__implementationName) ) {
xSingleServiceFactory = FactoryHelper.getServiceFactory(LogViewerDialog.class,
LogViewerDialog.__serviceName,
multiFactory,
regKey);
}
return xSingleServiceFactory;
}
/**
* Writes the service information into the given registry key.
* This method is called by the <code>JavaLoader</code>
* <p>
* @return returns true if the operation succeeded
* @param regKey the registryKey
* @see com.sun.star.comp.loader.JavaLoader
*/
public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
return
FactoryHelper.writeRegistryServiceInfo(Writer4LaTeX.__implementationName,
Writer4LaTeX.__serviceName, regKey) &
FactoryHelper.writeRegistryServiceInfo(ConfigurationDialog.__implementationName,
ConfigurationDialog.__serviceName, regKey) &
FactoryHelper.writeRegistryServiceInfo(LogViewerDialog.__implementationName,
LogViewerDialog.__serviceName, regKey);
}
}

View file

@ -0,0 +1,408 @@
/************************************************************************
*
* Writer4LaTeX.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-30)
*
*/
package org.openoffice.da.comp.writer4latex;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertyAccess;
import com.sun.star.frame.XController;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XModel;
import com.sun.star.frame.XStorable;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.task.XStatusIndicator;
import com.sun.star.task.XStatusIndicatorFactory;
import com.sun.star.ui.dialogs.ExecutableDialogResults;
import com.sun.star.ui.dialogs.XExecutableDialog;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import org.openoffice.da.comp.w2lcommon.helper.MessageBox;
import org.openoffice.da.comp.w2lcommon.helper.PropertyHelper;
/** This class implements the ui (dispatch) commands provided by Writer4LaTeX.
* The actual processing is done by the three core classes <code>TeXify</code>,
* <code>LaTeXImporter</code> and <code>BibTeXImporter</code>
*/
public final class Writer4LaTeX extends WeakBase
implements com.sun.star.lang.XServiceInfo,
com.sun.star.frame.XDispatchProvider,
com.sun.star.lang.XInitialization,
com.sun.star.frame.XDispatch {
private static final String PROTOCOL = "org.openoffice.da.writer4latex:";
// From constructor+initialization
private final XComponentContext m_xContext;
private XFrame m_xFrame;
private XModel xModel = null;
// Global data
private TeXify texify = null;
private PropertyValue[] mediaProps = null;
private String sBasePath = null;
private String sBaseFileName = null;
public static final String __implementationName = Writer4LaTeX.class.getName();
public static final String __serviceName = "com.sun.star.frame.ProtocolHandler";
private static final String[] m_serviceNames = { __serviceName };
public Writer4LaTeX( XComponentContext xContext ) {
m_xContext = xContext;
}
// com.sun.star.lang.XInitialization:
public void initialize( Object[] object )
throws com.sun.star.uno.Exception {
if ( object.length > 0 ) {
// The first item is the current frame
m_xFrame = (com.sun.star.frame.XFrame) UnoRuntime.queryInterface(
com.sun.star.frame.XFrame.class, object[0]);
// Get the model for the document from the frame
XController xController = m_xFrame.getController();
if (xController!=null) {
xModel = xController.getModel();
}
}
}
// com.sun.star.lang.XServiceInfo:
public String getImplementationName() {
return __implementationName;
}
public boolean supportsService( String sService ) {
int len = m_serviceNames.length;
for( int i=0; i < len; i++) {
if (sService.equals(m_serviceNames[i]))
return true;
}
return false;
}
public String[] getSupportedServiceNames() {
return m_serviceNames;
}
// com.sun.star.frame.XDispatchProvider:
public com.sun.star.frame.XDispatch queryDispatch( com.sun.star.util.URL aURL,
String sTargetFrameName, int iSearchFlags ) {
if ( aURL.Protocol.compareTo(PROTOCOL) == 0 ) {
if ( aURL.Path.compareTo("ProcessDocument") == 0 )
return this;
else if ( aURL.Path.compareTo("ProcessDirectly") == 0 )
return this;
else if ( aURL.Path.compareTo("ViewLog") == 0 )
return this;
else if ( aURL.Path.compareTo("UseBibTeX") == 0 )
return this;
else if ( aURL.Path.compareTo("ImportBibTeX") == 0 )
return this;
else if ( aURL.Path.compareTo("ImportLaTeX") == 0 )
return this;
}
return null;
}
public com.sun.star.frame.XDispatch[] queryDispatches(
com.sun.star.frame.DispatchDescriptor[] seqDescriptors ) {
int nCount = seqDescriptors.length;
com.sun.star.frame.XDispatch[] seqDispatcher =
new com.sun.star.frame.XDispatch[seqDescriptors.length];
for( int i=0; i < nCount; ++i ) {
seqDispatcher[i] = queryDispatch(seqDescriptors[i].FeatureURL,
seqDescriptors[i].FrameName,
seqDescriptors[i].SearchFlags );
}
return seqDispatcher;
}
// com.sun.star.frame.XDispatch:
public void dispatch( com.sun.star.util.URL aURL,
com.sun.star.beans.PropertyValue[] aArguments ) {
if ( aURL.Protocol.compareTo(PROTOCOL) == 0 ) {
if ( aURL.Path.compareTo("ProcessDocument") == 0 ) {
if (updateLocation()) {
if (updateMediaProperties()) {
process();
}
}
else {
warnNotSaved();
}
return;
}
else if ( aURL.Path.compareTo("ProcessDirectly") == 0 ) {
if (updateLocation()) {
if (mediaProps!=null || updateMediaProperties()) {
process();
}
}
else {
warnNotSaved();
}
return;
}
else if ( aURL.Path.compareTo("ViewLog") == 0 ) {
viewLog();
return;
}
else if ( aURL.Path.compareTo("UseBibTeX") == 0 ) {
org.openoffice.da.comp.w2lcommon.helper.MessageBox msgBox = new org.openoffice.da.comp.w2lcommon.helper.MessageBox(m_xContext);
msgBox.showMessage("Writer4LaTeX", "This feature has not been implemented yet");
return;
}
else if ( aURL.Path.compareTo("ImportBibTeX") == 0 ) {
org.openoffice.da.comp.w2lcommon.helper.MessageBox msgBox = new org.openoffice.da.comp.w2lcommon.helper.MessageBox(m_xContext);
msgBox.showMessage("Writer4LaTeX", "This feature has not been implemented yet");
return;
}
else if ( aURL.Path.compareTo("ImportLaTeX") == 0 ) {
org.openoffice.da.comp.w2lcommon.helper.MessageBox msgBox = new org.openoffice.da.comp.w2lcommon.helper.MessageBox(m_xContext);
msgBox.showMessage("Writer4LaTeX", "This feature has not been implemented yet");
return;
}
}
}
public void addStatusListener( com.sun.star.frame.XStatusListener xControl,
com.sun.star.util.URL aURL ) {
}
public void removeStatusListener( com.sun.star.frame.XStatusListener xControl,
com.sun.star.util.URL aURL ) {
}
// The actual commands...
private void process() {
// Create a (somewhat coarse grained) status indicator/progress bar
XStatusIndicatorFactory xFactory = (com.sun.star.task.XStatusIndicatorFactory)
UnoRuntime.queryInterface(com.sun.star.task.XStatusIndicatorFactory.class, m_xFrame);
XStatusIndicator xStatus = xFactory.createStatusIndicator();
xStatus.start("Writer4LaTeX",10);
xStatus.setValue(1); // At least we have started, that's 10% :-)
try {
// Convert to LaTeX
String sTargetUrl = sBasePath+sBaseFileName+".tex";
XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xModel);
xStorable.storeToURL(sTargetUrl, mediaProps);
}
catch (com.sun.star.io.IOException e) {
xStatus.end();
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
msgBox.showMessage("Writer4LaTeX Error","Failed to export document to LaTeX");
return;
}
xStatus.setValue(6); // Export is finished, that's more than half :-)
// Get the backend from the media properties
String sBackend = "generic";
Object filterData = (new PropertyHelper(mediaProps)).get("FilterData");
if (filterData instanceof PropertyValue[]) {
Object backend = (new PropertyHelper((PropertyValue[])filterData)).get("backend");
if (backend instanceof String) {
sBackend = (String) backend;
}
}
if (texify==null) { texify = new TeXify(m_xContext); }
File file = new File(urlToFile(sBasePath),sBaseFileName);
try {
if (sBackend=="pdftex") {
texify.process(file, TeXify.PDFTEX, true);
}
else if (sBackend=="dvips") {
texify.process(file, TeXify.DVIPS, true);
}
else if (sBackend=="generic") {
texify.process(file, TeXify.GENERIC, true);
}
}
catch (IOException e) {
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
msgBox.showMessage("Writer4LaTeX Error",e.getMessage());
}
xStatus.setValue(10); // The user will not really see this...
xStatus.end();
}
private void viewLog() {
if (updateLocation()) {
// Execute the log viewer dialog
try {
Object[] args = new Object[1];
args[0] = sBasePath+sBaseFileName;
Object dialog = m_xContext.getServiceManager()
.createInstanceWithArgumentsAndContext(
"org.openoffice.da.writer4latex.LogViewerDialog", args, m_xContext);
XExecutableDialog xDialog = (XExecutableDialog)
UnoRuntime.queryInterface(XExecutableDialog.class, dialog);
if (xDialog.execute()==ExecutableDialogResults.OK) {
// Closed with the close button
}
}
catch (com.sun.star.uno.Exception e) {
}
}
else {
warnNotSaved();
}
}
// Some utility methods
private boolean updateMediaProperties() {
// Create inital media properties
mediaProps = new PropertyValue[2];
mediaProps[0] = new PropertyValue();
mediaProps[0].Name = "FilterName";
mediaProps[0].Value = "org.openoffice.da.writer2latex";
mediaProps[1] = new PropertyValue();
mediaProps[1].Name = "Overwrite";
mediaProps[1].Value = "true";
try {
// Display options dialog
Object dialog = m_xContext.getServiceManager()
.createInstanceWithContext("org.openoffice.da.writer2latex.LaTeXOptionsDialog", m_xContext);
XPropertyAccess xPropertyAccess = (XPropertyAccess)
UnoRuntime.queryInterface(XPropertyAccess.class, dialog);
xPropertyAccess.setPropertyValues(mediaProps);
XExecutableDialog xDialog = (XExecutableDialog)
UnoRuntime.queryInterface(XExecutableDialog.class, dialog);
if (xDialog.execute()==ExecutableDialogResults.OK) {
mediaProps = xPropertyAccess.getPropertyValues();
return true;
}
else {
mediaProps = null;
return false;
}
}
catch (com.sun.star.beans.UnknownPropertyException e) {
// setPropertyValues will not fail..
mediaProps = null;
return false;
}
catch (com.sun.star.uno.Exception e) {
// getServiceManager will not fail..
mediaProps = null;
return false;
}
}
private boolean updateLocation() {
String sDocumentUrl = xModel.getURL();
if (sDocumentUrl.length()!=0) {
// Get the file name (without extension)
File f = urlToFile(sDocumentUrl);
sBaseFileName = f.getName();
int iDot = sBaseFileName.lastIndexOf(".");
if (iDot>-1) { // remove extension
sBaseFileName = sBaseFileName.substring(0,iDot);
}
sBaseFileName=makeTeXSafe(sBaseFileName);
// Get the path
int iSlash = sDocumentUrl.lastIndexOf("/");
if (iSlash>-1) {
sBasePath = sDocumentUrl.substring(0,iSlash+1);
}
else {
sBasePath = "";
}
return true;
}
else {
return false;
}
}
private void warnNotSaved() {
MessageBox msgBox = new MessageBox(m_xContext, m_xFrame);
msgBox.showMessage("Document not saved!","Please save the document before processing the file");
}
private String makeTeXSafe(String sArgument) {
String sResult = "";
for (int i=0; i<sArgument.length(); i++) {
char c = sArgument.charAt(i);
if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='-' || c=='.') {
sResult += Character.toString(c);
}
// TODO: Create replacement table for other latin characters..
else if (c==' ') { sResult += "-"; }
else if (c=='\u00c6') { sResult += "AE"; }
else if (c=='\u00d8') { sResult += "OE"; }
else if (c=='\u00c5') { sResult += "AA"; }
else if (c=='\u00e6') { sResult += "ae"; }
else if (c=='\u00f8') { sResult += "oe"; }
else if (c=='\u00e5') { sResult += "aa"; }
}
if (sResult.length()==0) { return "writer4latex"; }
else { return sResult; }
}
private File urlToFile(String sUrl) {
try {
return new File(new URI(sUrl));
}
catch (URISyntaxException e) {
return new File(".");
}
}
/*private String urlToPath(String sUrl) {
try {
return (new File(new URI(sUrl))).getCanonicalPath();
}
catch (URISyntaxException e) {
return ".";
}
catch (IOException e) {
return ".";
}
}*/
}

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