diff --git a/build.xml b/build.xml index 9262896..d5f9133 100644 --- a/build.xml +++ b/build.xml @@ -2,14 +2,15 @@ ############################################################################ # This is the Ant build file for writer2latex # Original: Sep 2004 (mgn) - # version 1.0 (2009-03-02) + # version 1.2 (2009-03-30) ############################################################################ --> - + + writer2latex - build file @@ -34,8 +35,8 @@ - - + + @@ -48,8 +49,10 @@ + + files="unoil.jar"/> @@ -67,7 +70,7 @@ @@ -185,11 +188,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + - + - @@ -208,7 +236,7 @@ + includes="${jarfile}.jar,writer2latex.oxt,writer2xhtml.oxt,writer4latex.oxt,xhtml-config-sample.oxt"/> diff --git a/source/distro/Readme.txt b/source/distro/Readme.txt index f51a633..2ba8f34 100644 --- a/source/distro/Readme.txt +++ b/source/distro/Readme.txt @@ -1,7 +1,7 @@ -Writer2LaTeX version 1.0 beta -============================= +Writer2LaTeX version 1.1.1 (development release) +================================================ -This is the distribution of Writer2LaTeX version 1.0 beta +This is the distribution of Writer2LaTeX version 1.1.1 Latest version can be found at the web site http://writer2latex.sourceforge.net diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt index 1eba147..d7e239b 100644 --- a/source/distro/changelog.txt +++ b/source/distro/changelog.txt @@ -1,342 +1,15 @@ -Changelog for Writer2LaTeX version 0.5 -> 1.0 +Changelog for Writer2LaTeX version 1.0 -> 1.2 ----------- version 1.0 beta ---------- +---------- version 1.1.1 ---------- -[w2x] Added german translation from Raphael Fetzer +[all] Bugfix: Paragraphs containing only fields are no longer lost -[w2x] Do not export character formatting in toc +[w4l] Added Writer4LaTeX extension -[w2l] Bugfix: Added missing hyperlink targets for frames and graphics +[all] Buildfile is adapted to work with separated ure and office (OOo 3.0+) -[w2x] Bugfix: Fixed null pointer exception for text frames without height attribute +[all] Bugfix: Corrected path to descriptions in oxt -[w2l] Added spanish translation from Emilio José Juárez Pérez +[w2x] Bugfix: Corrected typo in german translation of navigation bar -[w2l] Added support for bitmap graphics with backend=dvips - -[all] No longer create source distribution (SourceForge provides tarballs generated - directly from SVN) - -[all] Added german description to filters - -[w2l] Bugfix: Fixed crash for tables with fewer columns than rows - ----------- version 0.9.4 ----------- - -[w2l] Added sample LaTeX configuration for Google Docs from Elefterios Stamatogiannakis - -[w2x] Added MathML named entites table from Bruno Mascret - -[all] Bugfix: Locked controls are now updated correctly when the dialog is displayed - -[w2l] New backed xetex (initial prototype) - -[c2x] Bugfix: Corrected wrong calculation of column number for columns with two letters - (affected apply_print_ranges=true) - -[c2x] Bugfix: Ensure that we always export a document, even if there are no defined - print ranges (affected apply_print_ranges=true) - -[c2x] Bugfix: Now also exports uplink for spreadsheets - -[w2l] Bugfix: No longer incorrectly assume math mode when exporting plain text - -[all] Added support for the new Writer notes/annotations (which now can contain several - formatted paragraphs rather than a single, plain text paragraph) - -[all] Added russian and ukrainian translations from Volodymyr Volkov - -[all] Bugfix: Removed PreferredFilter propery from type definitions (makes sense - only for import filters) - -[all] Changed unix startscript: By default assume that w2l and writer2latex are - in the same directory (thus using dirname $0), and assume that the java executable - is either in the PATH or the location is defined by JAVA_HOME - (which these assumptions manual editing of the script is usually not required) - -[all] Added french translation from Jacques Lamoine - -[w2l] The option simple_table_limit now refers to the *total* width of the table - measured in characters rather than the width of individual cells - -[w2x] Bugfix: The position and dimensions of a frame is now calculated correctly - (previously the size of margins, borders and padding was not taken into account) - -[w2l] The inputencoding utf8 now uses the LaTeX standard rather than ucs.sty - (which only supports latin and cyrillic alphabets) - -[w2l] New style map family "text-attribute" to map text formatting to LaTeX code - currently only the values "bold", "italic", "small-caps", "subscript" and - "superscript" are supported, and the verbatim attribute is not supported - ----------- version 0.9.3 ----------- - -[all] All source files are now US ASCII; added encoding of source files to build file - -[all] Added more File-based methods to the API - -[w2l] The paper sizes defined by standard LaTeX document classes are now - identified and added as global options (a4paper, a5paper, b5paper, - letterpaper, legalpaper, executivepaper, including landscape variants) - -[w2x] Bugfix: Now only exports the name of a text box if it actually exists! - -[w2l] Removed option "pagecolor" from \hypersetup (this option has been removed - from the hyperref package) - -[all] Filter bugfix: The new option name "ConfigURL" is now used in the dialogs - -[all] Added (partial) german localization from Martin Friedrich - -[w2x] New option use_named_entities: When set to true, named character entities - as defined in xhtml 1.0 are used (currently only those within ISO latin 1) - -[w2x] Characters not supported by the encoding are now exported as numeric - character entities - -[w2x] Bugfix: Internal hyperlinks to tables, sections, frames and graphics now - works correctly - -[w2x] Bugfix: Subtables are no longer exported with an id attribute - -[all] Bugfix: table:number-rows-repeated is now treated correctly - -[c2x] New option: apply_print_ranges - ----------- version 0.9.2 ----------- - -[c2x] No longer exports for tables without - -[all] Renamed "class" to "family" in style maps to avoid confusion - with css classes (old name is still accepted) - -[all] Filter: Renamed template and config options to the more - descriptive TemplateURL and ConfigURL - -[all] API: Added convenience method convert(File) to Converterer - -[all] API: Added convenience method write(File) to ConverterResult - -[all] New option: save_images_in_subdir - -[all] Use Robert Harders public domain Base64 decoder (replacing - the non-standard decoder in sun.misc) - -[all] MIMETypes used in the API are now defined in writer2latex.api.MIMETypes - -[all] Renamed the option keep_image_size to original_image_size (the meaning of - this option was confusing). The old name is still recognized. - -[all] OOo now saves SVM files with a MIME type in the package format. - This is now recognized by w2l, which implies that GraphicConverter - implementations can use SVM files from a package - -[w2x] New uno service org.openoffice.da.writer2xhtml.BatchConverter - provides batch conversion via uno. Interaction with the user can be implemented - using the interface org.openoffice.da.writer2xhtml.XBatchHandler - -[w2x] Batch processing from the command line can now be cancelled (using the Enter key) - -[all] API: Created new API for batch conversion - -[w2l] Bugfix: Tables were in rare cases exported with invalid row alignment - (null character) - -[w2x] Filter ui bugfix: Default value for RepeatLevels changed from - 6 to 5 (6 was not valid) - -[w2x] Filter: The xhtml export now uses it's own custom configuration - (writer2xhtml.xml, also stored in the user configuration of OOo) - -[w2l] Tabstops are now exported as \ \ , which usually is closer to - the expectations of the user (and is not ignored at the beginning of a par.) - -[w2x] Empty paragraphs are now (again!) exported with a   - (otherwise they are ignored by the browser) - -[w2x] Xhtml specific options no longer starts with the prefix xhtml_ - (is still accepted for backwards compatibility) - -[all] Filter: Added display name and description to the extensions - -[w2x] BatchConverter: Localized alternative text for icons - -[w2b] Bugfix: Replace ";" with "and" also in in editor field - -[w2x] Added new options xslt_path to give the path to the XSL - transformation from w3c (also in the ui) - -[all] Filter: Optimized the size of the extensions by excluding code not - relevant for the format(s) supported by the extension - -[all] Separated LaTeX and xhtml code. As a consequence, it is possible to build - and run Writer2LaTeX with support for only one format - -[c2x] New options display_hiddens_rows_cols and display_filtered_rows_cols. If - set to false (default), rows and columns that are hidden or filtered are not - exported - -[all] Filter: Translated dialogs to Danish - -[all] Filter: Raised requirement in description.xml to OOo 2.2 - (needs support for localized dialogs) - -[w2l] Added ui option "Support additional symbols". This sets all the - options use_pifont, use_ifsym, use_wasysym, use_eurosym and use_tipa. - The pseudo-option additional_symbols can be used in the LockedOptions list - -[all] Bugfix: The class w2l.xmerge.DOMDocument did not throw IOException when - trying to read a non-xml document - -[w2x] Bugfix: The convert method did not restart document enumeration - (relevant if it's called several times for the same converter instance) - -[w2x] API: Created new API for batch conversion, which is also moved - from Application to a separate class - -[all] API: The API now uses a interface to the configuration rather than using - the class writer2latex.util.Config - -[w2x] Style of header/footer in index pages (batch conversion) aligned with - document header/footer - -[all] Added package descriptions to the javadoc - -[w2l] Always export non-breaking space as ~ even if inputenc supports it - directly - non-breaking spaces are usually not easy to identify in text editors - ----------- version 0.9.1 ----------- - -[w2x] New option: xhtml_add_bom (default false), if set to true - a BOM will be added at the start of generated xhtml files - -[w2x] Fixed typo in filter name: XHTML 1.0 + MathML 2.0 should be - XHTML 1.1 + MathML 2.0 - -[w2l] Added support for the latin language - -[w2l] Removed article.xml from w2l - it now belongs to Writer4LaTeX - -[all] The distribution now includes a sample configuration - package: xhtml-config-sample.oxt - -[all] Filter: Split the filter component into two extensions: - writer2latex.oxt for LaTeX and BibTeX, writer2xhtml.oxt for xhtml - The build file now produces optimized jars for each application, and the - standalone jar does not contain any uno code - -[w2l] Added (imcomplete) support for some of the Euclid fonts from Design Science - -[w2b] Replace ";" with "and" in author field (multiple authors) - -[w2l] Added support for formulas inserted by OOoLaTeX - -[w2x] Now adds mini-toc to the element with id "panel" if it exists in the xhtml - template - -[w2l] API: Added new api for standalone StarMath converter - Writer2LaTeX api: writer2latex.api.StarMathConverter - Uno service: org.openoffice.da.writer2latex.StarMathConverter - -[all] Filter: Added dialogs to all filters (w2l, w2x and c2x) - -[w2l] Vector graphics (except wmf) is now exported as pdf if backend is pdftex - -[all] API: In the GraphicConverter interface, the method - supportsFormat has been replaced with the method supportsConversion - -[w2l] Added support for *numbered* display equations: If paragraph - contains exactly one equation and exactly one sequence field (and otherwise - only whitespace and brackets), it treated as a numbered equation - -[w2l] I18n: If several characters in a row are converted using math mode, they - are now combined (ie. ${\alpha}{\beta}$ rather than ${\alpha}$${\beta}$) - -[all] Extended FilterData to support the property AutoCreate. If set to true, - the configuration file will be created if it does not exist - -[w2l] Even if formatting=IGNORE_ALL, we should still obey character style maps - from the configuration - -[w2x] Added german translation of navigation pane (w2l.util.L10n) - -[all] Bugfix: A paragraph with a bibliographic reference as the only - content was considered empty (and the reference was lost) - -[w2l] Use url decoding when creating file names for linked sections - (in order to obtain more readable file names) - -[w2l] Avoid redundant \mathit in StarMathConverter in some rare - cases (such as greek letters pasted into Math) - -[w2l] Support formulas for sequence fields (only the most common - cases oow:Name, oow:Name+Number, oow:Name-Number and oow:Number) - -[c2x] New options xhtml_display_hidden_sheets, xhtml_use_title_as_heading and - xhtml_use_sheet_names_as_headings - -[o2x] New option xhtml_notes. If true notes (annotations) are exported to xhtml - comments, if false they are ignored - -[c2x] Convert notes (annotations) - -[w2l] Heading formatting: The prefix and suffix to the counter should not be - included in \thesection, but rather in the formatting. This means that the - prefix and suffix no longer will be exported if formatting=CONVERT_BASIC - -[w2l] Added support for chapter references to reference marks and bookmarks - (if the marks are contained in a heading) - -[w2l] New option external_bibtex_files gives a list of BibTeX files. If nonempty, - these files will be used instead of converting the actual bibliography marks - -[w2l] New option metadata. If true, export metadata as \author, - \date and pdf metadata, as well as pdf metadata (if use_hyperref is true) - -[all] Filters/API: Changed filternames to the more obvious - org.openoffice.da.writer2latex etc. - -[w2l] Updated clean.xml and ultraclean.xml. Both configurations - now exports predefined Writer styles (like article.xml) - -[w2x] New option: xhtml_repeat_levels defines the number of heading - levels to repeat when splitting a file (0 means no levels are repeated) - -[w2x] Allow xhtml templates without header and footer elements - -[w2x] Bugfix (w2l.office.ListCounter): OpenDocument does not use - numberings like 1.0.1 if a list level is missing, but rather 1.1.1 - -[all] Command line application now uses internal standard configurations - (*ultraclean.xml etc.) - -[all] Command line application now accepts several configuration - files (by using the -config option more than once) - -[w2x] Use text style for label when applying numbering to heading - -[w2x] Added support for other list styes applied to headings - -[w2x] Added support for text:restart-numbering, text:is-list-header on headings - -[w2x] No longer add hr and [] to links in navigation (the template and style - sheet should take care of this) - -[all] New filter configuration concept: Configuration packages containing an OOo - template, a w2l configuration and registry information to bind these together: - When a configuration package is installed in OOo, the configuration is added - to the filter ui, and is preselected for documents based on the OOo template - -[all] Repackaging: Distribution files are included in source, build - file is extended to create the distribution; source distribution is separated - -[all] Changed to new extension format (.oxt) - -[all] Filter: Added messagebox to display the error in case an - exception happens during conversion - -[all] Moved default configurations to jar; the FilterData property - can refer to these using the special url *filename.xml - -[all] The filter now reads the FilterData property, which can be - used to specify options, configuration fil (url) and xhtml template (url) \ No newline at end of file +[all] Raised requirement from Java 1.4 to Java 5 \ No newline at end of file diff --git a/source/distro/doc/user-manual.odt b/source/distro/doc/user-manual.odt index 5e48e3d..0e82b28 100644 Binary files a/source/distro/doc/user-manual.odt and b/source/distro/doc/user-manual.odt differ diff --git a/source/distro/doc/w4l-user-manual.odt b/source/distro/doc/w4l-user-manual.odt new file mode 100644 index 0000000..f016fb2 Binary files /dev/null and b/source/distro/doc/w4l-user-manual.odt differ diff --git a/source/java/org/openoffice/da/comp/w2lcommon/filter/ExportFilterBase.java b/source/java/org/openoffice/da/comp/w2lcommon/filter/ExportFilterBase.java index 3899deb..91f944a 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/filter/ExportFilterBase.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/filter/ExportFilterBase.java @@ -378,7 +378,7 @@ public abstract class ExportFilterBase implements } // Write out files - Iterator docEnum = dataOut.iterator(); + Iterator 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 diff --git a/source/java/org/openoffice/da/comp/w2lcommon/filter/FilterDataParser.java b/source/java/org/openoffice/da/comp/w2lcommon/filter/FilterDataParser.java index 765dd6b..31fa970 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/filter/FilterDataParser.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/filter/FilterDataParser.java @@ -232,9 +232,9 @@ public class FilterDataParser { } // Read further configuration properties - Enumeration keys = props.keys(); + Enumeration 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)) { diff --git a/source/java/org/openoffice/da/comp/w2lcommon/filter/GraphicConverterImpl2.java b/source/java/org/openoffice/da/comp/w2lcommon/filter/GraphicConverterImpl2.java index f1364a3..e08f022 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/filter/GraphicConverterImpl2.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/filter/GraphicConverterImpl2.java @@ -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 importFilter; + private Hashtable exportFilter; private EPSCleaner epsCleaner; public GraphicConverterImpl2(XComponentContext xComponentContext) { this.xComponentContext = xComponentContext; - importFilter = new Hashtable(); + importFilter = new Hashtable(); 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(); exportFilter.put(MIMETypes.BMP,"draw_bmp_Export"); //exportFilter.put(MIMETypes.EMF,"draw_emf_Export"); exportFilter.put(MIMETypes.EPS,"draw_eps_Export"); diff --git a/source/java/org/openoffice/da/comp/w2lcommon/filter/OptionsDialogBase.java b/source/java/org/openoffice/da/comp/w2lcommon/filter/OptionsDialogBase.java index e1d0424..52c5db7 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/filter/OptionsDialogBase.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/filter/OptionsDialogBase.java @@ -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(); } ////////////////////////////////////////////////////////////////////////// @@ -163,7 +163,7 @@ public abstract class OptionsDialogBase extends DialogBase implements private String[] sConfigNames; // Set of locked controls - private HashSet lockedOptions; + private HashSet lockedOptions; ////////////////////////////////////////////////////////////////////////// diff --git a/source/java/org/openoffice/da/comp/w2lcommon/helper/PropertyHelper.java b/source/java/org/openoffice/da/comp/w2lcommon/helper/PropertyHelper.java index 647f37c..bc79722 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/helper/PropertyHelper.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/helper/PropertyHelper.java @@ -35,14 +35,14 @@ import com.sun.star.beans.PropertyValue; */ public class PropertyHelper { - private Hashtable data; + private Hashtable data; public PropertyHelper() { - data = new Hashtable(); + data = new Hashtable(); } public PropertyHelper(PropertyValue[] props) { - data = new Hashtable(); + data = new Hashtable(); int nLen = props.length; for (int i=0; i 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 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); diff --git a/source/java/org/openoffice/da/comp/writer4latex/ConfigurationDialog.java b/source/java/org/openoffice/da/comp/writer4latex/ConfigurationDialog.java new file mode 100644 index 0000000..d02577c --- /dev/null +++ b/source/java/org/openoffice/da/comp/writer4latex/ConfigurationDialog.java @@ -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; + } + } + + + + + +} + + + diff --git a/source/java/org/openoffice/da/comp/writer4latex/ExternalApps.java b/source/java/org/openoffice/da/comp/writer4latex/ExternalApps.java new file mode 100644 index 0000000..a92d57c --- /dev/null +++ b/source/java/org/openoffice/da/comp/writer4latex/ExternalApps.java @@ -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 apps; + + /** Construct a new ExternalApps object, with empty definitions */ + public ExternalApps(XComponentContext xContext) { + this.xContext = xContext; + apps = new HashMap(); + for (int i=0; i command = new Vector(); + 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 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 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(); + } + +} + + + diff --git a/source/java/org/openoffice/da/comp/writer4latex/StreamGobbler.java b/source/java/org/openoffice/da/comp/writer4latex/StreamGobbler.java new file mode 100644 index 0000000..c8e802e --- /dev/null +++ b/source/java/org/openoffice/da/comp/writer4latex/StreamGobbler.java @@ -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(); + } + } +} + diff --git a/source/java/org/openoffice/da/comp/writer4latex/TeXify.java b/source/java/org/openoffice/da/comp/writer4latex/TeXify.java new file mode 100644 index 0000000..58ada66 --- /dev/null +++ b/source/java/org/openoffice/da/comp/writer4latex/TeXify.java @@ -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; i0) { + //throw new IOException("Error executing "+sAppList[i]); + } + } + } + +} \ No newline at end of file diff --git a/source/java/org/openoffice/da/comp/writer4latex/W4LRegistration.java b/source/java/org/openoffice/da/comp/writer4latex/W4LRegistration.java new file mode 100644 index 0000000..5c5b424 --- /dev/null +++ b/source/java/org/openoffice/da/comp/writer4latex/W4LRegistration.java @@ -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 JavaLoader + * + * @return returns a XSingleServiceFactory 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 JavaLoader + *

+ * @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); + } +} + diff --git a/source/java/org/openoffice/da/comp/writer4latex/Writer4LaTeX.java b/source/java/org/openoffice/da/comp/writer4latex/Writer4LaTeX.java new file mode 100644 index 0000000..7658ee2 --- /dev/null +++ b/source/java/org/openoffice/da/comp/writer4latex/Writer4LaTeX.java @@ -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 TeXify, + * LaTeXImporter and BibTeXImporter + */ +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='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 "."; + } + }*/ + +} \ No newline at end of file diff --git a/source/java/writer2latex/Application.java b/source/java/writer2latex/Application.java index 2e8f213..e1185e9 100644 --- a/source/java/writer2latex/Application.java +++ b/source/java/writer2latex/Application.java @@ -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 configFileNames = new Vector(); private String sTemplateFileName = null; - private Hashtable options = new Hashtable(); + private Hashtable options = new Hashtable(); 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 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) { diff --git a/source/java/writer2latex/api/ConverterFactory.java b/source/java/writer2latex/api/ConverterFactory.java index 877cd4c..7369869 100644 --- a/source/java/writer2latex/api/ConverterFactory.java +++ b/source/java/writer2latex/api/ConverterFactory.java @@ -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 diff --git a/source/java/writer2latex/api/ConverterResult.java b/source/java/writer2latex/api/ConverterResult.java index eba2e97..69528c5 100644 --- a/source/java/writer2latex/api/ConverterResult.java +++ b/source/java/writer2latex/api/ConverterResult.java @@ -44,7 +44,7 @@ public interface ConverterResult { * ConverterResult. This includes the master document. * @return an Iterator of all files */ - public Iterator iterator(); + public Iterator iterator(); /** Write all files of the ConverterResult to a directory. * Subdirectories are created as required by the individual diff --git a/source/java/writer2latex/bibtex/BibTeXDocument.java b/source/java/writer2latex/bibtex/BibTeXDocument.java index b2f061e..6625ad8 100644 --- a/source/java/writer2latex/bibtex/BibTeXDocument.java +++ b/source/java/writer2latex/bibtex/BibTeXDocument.java @@ -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 entries = new Hashtable(); 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 enumeration = entries.elements(); while (enumeration.hasMoreElements()) { - BibMark entry = (BibMark) enumeration.nextElement(); + BibMark entry = enumeration.nextElement(); osw.write("@"); osw.write(entry.getEntryType().toUpperCase()); osw.write("{"); diff --git a/source/java/writer2latex/latex/CharStyleConverter.java b/source/java/writer2latex/latex/CharStyleConverter.java index f3f1305..8607a0a 100644 --- a/source/java/writer2latex/latex/CharStyleConverter.java +++ b/source/java/writer2latex/latex/CharStyleConverter.java @@ -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 fontDecls = new Hashtable(); // 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 diff --git a/source/java/writer2latex/latex/ConverterPalette.java b/source/java/writer2latex/latex/ConverterPalette.java index 8522f9f..4c2c52d 100644 --- a/source/java/writer2latex/latex/ConverterPalette.java +++ b/source/java/writer2latex/latex/ConverterPalette.java @@ -226,10 +226,10 @@ public final class ConverterPalette extends ConverterBase { mathmlCv.appendDeclarations(packages,declarations); // Add custom preamble - LinkedList customPreamble = config.getCustomPreamble(); + LinkedList customPreamble = config.getCustomPreamble(); int nCPLen = customPreamble.size(); for (int i=0; i> floatingFramesStack = new Stack>(); 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()); } 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()); 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; itext:sequence-decl element) - private Hashtable seqDecl = new Hashtable(); + private Hashtable seqDecl = new Hashtable(); // first usage of sequence (maps name->text:sequence element) - private Hashtable seqFirst = new Hashtable(); + private Hashtable seqFirst = new Hashtable(); - private Vector postponedReferenceMarks = new Vector(); - private Vector postponedBookmarks = new Vector(); + private Vector postponedReferenceMarks = new Vector(); + private Vector postponedBookmarks = new Vector(); 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 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 postponedIndexMarks = new Vector(); /**

Construct a new IndexConverter. * @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 customPreamble = new LinkedList(); 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 mathSymbols = new Hashtable(); 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 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 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 list, String sElement) { Element node = dom.createElement(sElement); int nLen = list.size(); for (int i=0; i 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 getCustomPreamble() { return customPreamble; } } diff --git a/source/java/writer2latex/latex/LaTeXDocumentPortion.java b/source/java/writer2latex/latex/LaTeXDocumentPortion.java index 32d7ed0..5f4ec33 100644 --- a/source/java/writer2latex/latex/LaTeXDocumentPortion.java +++ b/source/java/writer2latex/latex/LaTeXDocumentPortion.java @@ -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 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(); curText = new StringBuffer(); bEmpty = true; } diff --git a/source/java/writer2latex/latex/ListStyleConverter.java b/source/java/writer2latex/latex/ListStyleConverter.java index c6dab0c..5c19c47 100644 --- a/source/java/writer2latex/latex/ListStyleConverter.java +++ b/source/java/writer2latex/latex/ListStyleConverter.java @@ -37,7 +37,7 @@ import writer2latex.latex.util.Context; */ public class ListStyleConverter extends StyleConverter { boolean bNeedSaveEnumCounter = false; - private Hashtable listStyleLevelNames = new Hashtable(); + private Hashtable listStyleLevelNames = new Hashtable(); /**

Constructs a new ListStyleConverter.

*/ @@ -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",""); diff --git a/source/java/writer2latex/latex/NoteConverter.java b/source/java/writer2latex/latex/NoteConverter.java index eb618a5..c5260d6 100644 --- a/source/java/writer2latex/latex/NoteConverter.java +++ b/source/java/writer2latex/latex/NoteConverter.java @@ -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 postponedFootnotes = new LinkedList(); 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 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 masters = ofr.getMasterPages().getStylesEnumeration(); while (masters.hasMoreElements()) { MasterPage master = (MasterPage) masters.nextElement(); if (styleNames.containsName(getDisplayName(master.getName()))) { diff --git a/source/java/writer2latex/latex/StarMathConverter.java b/source/java/writer2latex/latex/StarMathConverter.java index 2eb6a50..3784e93 100644 --- a/source/java/writer2latex/latex/StarMathConverter.java +++ b/source/java/writer2latex/latex/StarMathConverter.java @@ -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 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); diff --git a/source/java/writer2latex/latex/i18n/ClassicI18n.java b/source/java/writer2latex/latex/i18n/ClassicI18n.java index cc4a2a8..8cd2f9d 100644 --- a/source/java/writer2latex/latex/i18n/ClassicI18n.java +++ b/source/java/writer2latex/latex/i18n/ClassicI18n.java @@ -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 babelLanguages; // mappings iso->babel language // Unicode translation - private Hashtable tableSet; // all tables + private Hashtable tableSet; // all tables private UnicodeTable table; // currently active table (top of stack) - private Stack tableStack; // stack of active tables + private Stack 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(); 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(); + 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(); babelLanguages.put("en", "english"); // latin1 babelLanguages.put("bg", "bulgarian"); // cp1251? babelLanguages.put("cs", "czech"); // latin2 diff --git a/source/java/writer2latex/latex/i18n/I18n.java b/source/java/writer2latex/latex/i18n/I18n.java index ac514ac..68fb2ab 100644 --- a/source/java/writer2latex/latex/i18n/I18n.java +++ b/source/java/writer2latex/latex/i18n/I18n.java @@ -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 languages = new HashSet(); // All languages used // **** Constructors **** diff --git a/source/java/writer2latex/latex/i18n/UnicodeTableHandler.java b/source/java/writer2latex/latex/i18n/UnicodeTableHandler.java index 6a4a940..0f7af58 100644 --- a/source/java/writer2latex/latex/i18n/UnicodeTableHandler.java +++ b/source/java/writer2latex/latex/i18n/UnicodeTableHandler.java @@ -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 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 UnicodeTableHandler + * + * @param tableSet the Hashtable to fill with tables read from the file + * @param sSymbolSets string containing table names to read (separated by |) + */ + public UnicodeTableHandler(Hashtable 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 diff --git a/source/java/writer2latex/latex/i18n/XeTeXI18n.java b/source/java/writer2latex/latex/i18n/XeTeXI18n.java index 6e9679a..cb95f73 100644 --- a/source/java/writer2latex/latex/i18n/XeTeXI18n.java +++ b/source/java/writer2latex/latex/i18n/XeTeXI18n.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.0 (2009-02-17) + * Version 1.2 (2009-03-26) * */ diff --git a/source/java/writer2latex/latex/util/StyleMap.java b/source/java/writer2latex/latex/util/StyleMap.java index d4469ef..eae5aac 100644 --- a/source/java/writer2latex/latex/util/StyleMap.java +++ b/source/java/writer2latex/latex/util/StyleMap.java @@ -30,7 +30,7 @@ import java.util.Hashtable; import java.util.Enumeration; public class StyleMap { - private Hashtable items = new Hashtable(); + private Hashtable items = new Hashtable(); 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 getNames() { return items.keys(); } diff --git a/source/java/writer2latex/office/ControlReader.java b/source/java/writer2latex/office/ControlReader.java index a7f0f8a..c150696 100644 --- a/source/java/writer2latex/office/ControlReader.java +++ b/source/java/writer2latex/office/ControlReader.java @@ -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 items = new Vector(); // the options/items of a list/combobox /**

The constructor reads the content of a control element

* The representation in OpenDocument differs slightly from OOo 1.x. diff --git a/source/java/writer2latex/office/FormsReader.java b/source/java/writer2latex/office/FormsReader.java index 978f5cb..0052d20 100644 --- a/source/java/writer2latex/office/FormsReader.java +++ b/source/java/writer2latex/office/FormsReader.java @@ -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 forms = new Hashtable(); // all forms, indexed by name + private Hashtable controls = new Hashtable(); // all controls, indexed by id /**

Read the content of an office:forms element

* @param formsElement a DOM element, which must be office:forms node @@ -77,7 +77,7 @@ public class FormsReader { /**

Get a Iterator over all forms.

* @return a Iterator over all forms */ - public Iterator getFormsIterator() { + public Iterator getFormsIterator() { return forms.values().iterator(); } @@ -86,13 +86,13 @@ public class FormsReader { * @return the form as a FormReader object */ public FormReader getForm(String sName) { - return (FormReader) forms.get(sName); + return forms.get(sName); } /**

Get a Iterator over all controls.

* @return a Iterator over all controls */ - public Iterator getControlsIterator() { + public Iterator getControlsIterator() { return controls.values().iterator(); } @@ -101,7 +101,7 @@ public class FormsReader { * @return the control as a ControlReader object */ public ControlReader getControl(String sId) { - return (ControlReader) controls.get(sId); + return controls.get(sId); } /**

Add a control

diff --git a/source/java/writer2latex/office/ImageLoader.java b/source/java/writer2latex/office/ImageLoader.java index 68c6f42..22b189c 100644 --- a/source/java/writer2latex/office/ImageLoader.java +++ b/source/java/writer2latex/office/ImageLoader.java @@ -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 acceptedFormats = new HashSet(); public ImageLoader(OfficeDocument oooDoc, String sOutFileName, boolean bExtractEPS) { this.oooDoc = oooDoc; diff --git a/source/java/writer2latex/office/OfficeReader.java b/source/java/writer2latex/office/OfficeReader.java index 1b64924..9e48bde 100644 --- a/source/java/writer2latex/office/OfficeReader.java +++ b/source/java/writer2latex/office/OfficeReader.java @@ -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 indexes = new Hashtable(); + private HashSet indexSourceStyles = new HashSet(); + private HashSet figureSequenceNames = new HashSet(); + private HashSet tableSequenceNames = new HashSet(); private String sAutoFigureSequenceName = null; private String sAutoTableSequenceName = null; // Map paragraphs to sequence names (caption helper) - private Hashtable sequenceNames = new Hashtable(); + private Hashtable sequenceNames = new Hashtable(); // Map sequence reference names to sequence names - private Hashtable seqrefNames = new Hashtable(); + private Hashtable seqrefNames = new Hashtable(); // 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 footnoteRef = new HashSet(); + private HashSet endnoteRef = new HashSet(); + private HashSet referenceRef = new HashSet(); + private HashSet bookmarkRef = new HashSet(); + private HashSet sequenceRef = new HashSet(); // Reference marks and bookmarks contained in headings - private HashSet referenceHeading = new HashSet(); - private HashSet bookmarkHeading = new HashSet(); + private HashSet referenceHeading = new HashSet(); + private HashSet bookmarkHeading = new HashSet(); // All internal hyperlinks - private HashSet links = new HashSet(); + private HashSet links = new HashSet(); // 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 langs = new Hashtable(); // 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 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; } /**

Get the sequence name associated with a reference name

@@ -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 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 marks, Element node) { String sName = node.getAttribute(XMLString.TEXT_NAME); if (sName!=null && sName.length()>0) { Element par = getParagraph(node); diff --git a/source/java/writer2latex/office/OfficeStyleFamily.java b/source/java/writer2latex/office/OfficeStyleFamily.java index 36426e3..c9cc939 100644 --- a/source/java/writer2latex/office/OfficeStyleFamily.java +++ b/source/java/writer2latex/office/OfficeStyleFamily.java @@ -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 styles = new Hashtable(); private Class styleClass; - private Hashtable displayNames = new Hashtable(); + private Hashtable displayNames = new Hashtable(); 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 getStylesEnumeration(){ return styles.elements(); } diff --git a/source/java/writer2latex/office/PropertySet.java b/source/java/writer2latex/office/PropertySet.java index 0c67af0..80a612e 100644 --- a/source/java/writer2latex/office/PropertySet.java +++ b/source/java/writer2latex/office/PropertySet.java @@ -35,17 +35,17 @@ import java.util.Hashtable; is simply the set of attributes of an element).

*/ public class PropertySet { - private Hashtable properties = new Hashtable(); + private Hashtable properties = new Hashtable(); private String sName; public PropertySet() { - properties = new Hashtable(); + properties = new Hashtable(); 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 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; diff --git a/source/java/writer2latex/office/TableReader.java b/source/java/writer2latex/office/TableReader.java index 58153f1..1df4f6b 100644 --- a/source/java/writer2latex/office/TableReader.java +++ b/source/java/writer2latex/office/TableReader.java @@ -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 cols = new LinkedList(); + private LinkedList rows = new LinkedList(); + private LinkedList> cells = new LinkedList>(); 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 printRanges; /** *

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(); 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 row = new LinkedList(); 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 indexSourceStyles = new Hashtable(); @@ -163,7 +163,7 @@ public class TocReader { /**

Get a set view of all index source styles

* @return a set of all index source style names */ - public Set getIndexSourceStyles() { return indexSourceStyles.keySet(); } + public Set getIndexSourceStyles() { return indexSourceStyles.keySet(); } /**

Get the level associated with a specific index source style

* @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; diff --git a/source/java/writer2latex/office/XMLString.java b/source/java/writer2latex/office/XMLString.java index 6ab3167..bd68b4f 100644 --- a/source/java/writer2latex/office/XMLString.java +++ b/source/java/writer2latex/office/XMLString.java @@ -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:"; diff --git a/source/java/writer2latex/util/ExportNameCollection.java b/source/java/writer2latex/util/ExportNameCollection.java index 50110d1..4203219 100644 --- a/source/java/writer2latex/util/ExportNameCollection.java +++ b/source/java/writer2latex/util/ExportNameCollection.java @@ -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 exportNames = new Hashtable(); private String sPrefix; private boolean bAcceptNumbers; @@ -45,7 +45,7 @@ public class ExportNameCollection{ this("",b); } - public Enumeration keys() { + public Enumeration 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) { diff --git a/source/java/writer2latex/xhtml/Converter.java b/source/java/writer2latex/xhtml/Converter.java index cbacd5e..aaa6ddd 100644 --- a/source/java/writer2latex/xhtml/Converter.java +++ b/source/java/writer2latex/xhtml/Converter.java @@ -81,15 +81,15 @@ public class Converter extends ConverterBase { // The xhtml output file(s) protected int nType = XhtmlDocument.XHTML10; // the doctype - Vector outFiles; + Vector 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 targets = new Hashtable(); + LinkedList links = new LinkedList(); // 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(); 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 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; j0) { 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 iter = textCv.sections.iterator(); while (iter.hasNext()) { Element section = (Element) iter.next(); String sStyleName = Misc.getAttribute(section,XMLString.TEXT_STYLE_NAME); diff --git a/source/java/writer2latex/xhtml/DrawConverter.java b/source/java/writer2latex/xhtml/DrawConverter.java index 93d7363..1bc9060 100644 --- a/source/java/writer2latex/xhtml/DrawConverter.java +++ b/source/java/writer2latex/xhtml/DrawConverter.java @@ -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 frames = new Vector(); // 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 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 names = styleNames.keys(); while (names.hasMoreElements()) { - String sDisplayName = (String) names.nextElement(); + String sDisplayName = names.nextElement(); StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName); if (!style.isAutomatic()) { diff --git a/source/java/writer2latex/xhtml/L10n.java b/source/java/writer2latex/xhtml/L10n.java index d9f8f75..c268af3 100644 --- a/source/java/writer2latex/xhtml/L10n.java +++ b/source/java/writer2latex/xhtml/L10n.java @@ -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"; diff --git a/source/java/writer2latex/xhtml/ListStyleConverter.java b/source/java/writer2latex/xhtml/ListStyleConverter.java index ff40aee..4203f09 100644 --- a/source/java/writer2latex/xhtml/ListStyleConverter.java +++ b/source/java/writer2latex/xhtml/ListStyleConverter.java @@ -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 names = styleNames.keys(); while (names.hasMoreElements()) { - String sDisplayName = (String) names.nextElement(); + String sDisplayName = names.nextElement(); ListStyle style = (ListStyle) getStyles().getStyleByDisplayName(sDisplayName); if (!style.isAutomatic()) { diff --git a/source/java/writer2latex/xhtml/PageStyleConverter.java b/source/java/writer2latex/xhtml/PageStyleConverter.java index 67adc28..5ce2d13 100644 --- a/source/java/writer2latex/xhtml/PageStyleConverter.java +++ b/source/java/writer2latex/xhtml/PageStyleConverter.java @@ -83,10 +83,10 @@ public class PageStyleConverter extends StyleConverterHelper { */ public String getStyleDeclarations(String sIndent) { StringBuffer buf = new StringBuffer(); - Enumeration names = styleNames.keys(); + Enumeration 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(); diff --git a/source/java/writer2latex/xhtml/PresentationStyleConverter.java b/source/java/writer2latex/xhtml/PresentationStyleConverter.java index e2312a4..f4551f0 100644 --- a/source/java/writer2latex/xhtml/PresentationStyleConverter.java +++ b/source/java/writer2latex/xhtml/PresentationStyleConverter.java @@ -45,7 +45,7 @@ public class PresentationStyleConverter extends FrameStyleConverter { // Data about outline styles String sCurrentOutlineStyle = null; - Hashtable outlineStyles = new Hashtable(); + Hashtable outlineStyles = new Hashtable(); ExportNameCollection outlineStyleNames = new ExportNameCollection(true); /** Create a new PresentationStyleConverter @@ -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 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]); } } } diff --git a/source/java/writer2latex/xhtml/StyleWithPropertiesConverterHelper.java b/source/java/writer2latex/xhtml/StyleWithPropertiesConverterHelper.java index 133ddfd..c00d981 100644 --- a/source/java/writer2latex/xhtml/StyleWithPropertiesConverterHelper.java +++ b/source/java/writer2latex/xhtml/StyleWithPropertiesConverterHelper.java @@ -93,9 +93,9 @@ public abstract class StyleWithPropertiesConverterHelper public String getStyleDeclarations(String sIndent) { if (bConvertStyles) { StringBuffer buf = new StringBuffer(); - Enumeration names = styleNames.keys(); + Enumeration names = styleNames.keys(); while (names.hasMoreElements()) { - String sDisplayName = (String) names.nextElement(); + String sDisplayName = names.nextElement(); StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName); if (!style.isAutomatic()) { diff --git a/source/java/writer2latex/xhtml/TableConverter.java b/source/java/writer2latex/xhtml/TableConverter.java index 474efea..55b8f41 100644 --- a/source/java/writer2latex/xhtml/TableConverter.java +++ b/source/java/writer2latex/xhtml/TableConverter.java @@ -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 sheetNames = new Vector(); public TableConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) { super(ofr,config,converter); diff --git a/source/java/writer2latex/xhtml/TextConverter.java b/source/java/writer2latex/xhtml/TextConverter.java index 58337b3..bcd603b 100644 --- a/source/java/writer2latex/xhtml/TextConverter.java +++ b/source/java/writer2latex/xhtml/TextConverter.java @@ -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 sections = new Stack(); // 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 listCounters = new Hashtable(); 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 indexes = new Vector(); // Data used to handle Alphabetical Index - Vector index = new Vector(); // All words for the index + Vector index = new Vector(); // 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 tocEntries = new Vector(); // 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 footnotes = new LinkedList(); + private LinkedList endnotes = new LinkedList(); // 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=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; inPrevFileIndex+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 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; i0 && n>0) { hnode = converter.nextOutFile(); } for (int i=0; i anchorCombinedStyleNames = new Hashtable(); + private Hashtable orgAnchorStyleNames = new Hashtable(); + private Hashtable orgAnchorVisitedStyleNames = new Hashtable(); /** Create a new TextStyleConverter * @param ofr an OfficeReader 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); } /**

Convert style information for used styles

@@ -144,11 +144,11 @@ public class TextStyleConverter extends StyleWithPropertiesConverterHelper { } // Remaining link styles... - Enumeration enumer = anchorCombinedStyleNames.elements(); + Enumeration 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); diff --git a/source/java/writer2latex/xhtml/XhtmlConfig.java b/source/java/writer2latex/xhtml/XhtmlConfig.java index 2b93bad..06896f6 100644 --- a/source/java/writer2latex/xhtml/XhtmlConfig.java +++ b/source/java/writer2latex/xhtml/XhtmlConfig.java @@ -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 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); diff --git a/source/java/writer2latex/xhtml/XhtmlStyleMap.java b/source/java/writer2latex/xhtml/XhtmlStyleMap.java index 8bd3d03..1d3ca80 100644 --- a/source/java/writer2latex/xhtml/XhtmlStyleMap.java +++ b/source/java/writer2latex/xhtml/XhtmlStyleMap.java @@ -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 blockElement = new Hashtable(); + private Hashtable blockCss = new Hashtable(); + private Hashtable element = new Hashtable(); + private Hashtable css = new Hashtable(); 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 getNames() { return element.keys(); } diff --git a/source/java/writer2latex/xmerge/ConvertData.java b/source/java/writer2latex/xmerge/ConvertData.java index c28dbe5..34c702b 100644 --- a/source/java/writer2latex/xmerge/ConvertData.java +++ b/source/java/writer2latex/xmerge/ConvertData.java @@ -64,7 +64,7 @@ public class ConvertData implements ConverterResult { /** * Vector of OutputFile objects. */ - private Vector v = new Vector(); + private Vector v = new Vector(); /** Master doc */ private OutputFile masterDoc = null; @@ -137,7 +137,7 @@ public class ConvertData implements ConverterResult { * @return The Iterator to access the * Vector of OutputFile objects. */ - public Iterator iterator() { + public Iterator 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 docEnum = iterator(); while (docEnum.hasNext()) { - OutputFile docOut = (OutputFile) docEnum.next(); + OutputFile docOut = docEnum.next(); String sDirName = ""; String sFileName = docOut.getFileName(); File subdir = dir; diff --git a/source/java/writer2latex/xmerge/OfficeDocument.java b/source/java/writer2latex/xmerge/OfficeDocument.java index 1b2ee49..b43fee5 100644 --- a/source/java/writer2latex/xmerge/OfficeDocument.java +++ b/source/java/writer2latex/xmerge/OfficeDocument.java @@ -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 embeddedObjects = null; /** * Default constructor. @@ -320,10 +320,10 @@ public class OfficeDocument * * @return An Iterator of EmbeddedObject objects. */ - public Iterator getEmbeddedObjects() { + public Iterator getEmbeddedObjects() { if (embeddedObjects == null && manifestDoc != null) { - embeddedObjects = new HashMap(); + embeddedObjects = new HashMap(); // 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(); } embeddedObjects.put(embObj.getName(), embObj); @@ -734,9 +734,9 @@ public class OfficeDocument Element manifestRoot = manifestDoc.getDocumentElement(); // The EmbeddedObjects come first. - Iterator embObjs = getEmbeddedObjects(); + Iterator embObjs = getEmbeddedObjects(); while (embObjs.hasNext()) { - EmbeddedObject obj = (EmbeddedObject)embObjs.next(); + EmbeddedObject obj = embObjs.next(); obj.writeManifestData(manifestDoc); obj.write(zip); diff --git a/source/java/writer2latex/xmerge/OfficeZip.java b/source/java/writer2latex/xmerge/OfficeZip.java index 6de0010..a9abe1d 100644 --- a/source/java/writer2latex/xmerge/OfficeZip.java +++ b/source/java/writer2latex/xmerge/OfficeZip.java @@ -75,7 +75,7 @@ class OfficeZip { private final static int BUFFERSIZE = 1024; - private List entryList = null; + private List 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(); } @@ -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 iterator = entryList.listIterator(); while (iterator.hasNext()) { - Entry entry = (Entry) iterator.next(); + Entry entry = iterator.next(); ZipEntry ze = entry.zipEntry; //String name = ze.getName(); diff --git a/source/oxt/writer2latex/description.xml b/source/oxt/writer2latex/description.xml index c5b1f47..1ed0fba 100644 --- a/source/oxt/writer2latex/description.xml +++ b/source/oxt/writer2latex/description.xml @@ -5,7 +5,7 @@ - + @@ -22,13 +22,13 @@ - - - - - - - + + + + + + + diff --git a/source/oxt/writer2xhtml/description.xml b/source/oxt/writer2xhtml/description.xml index 4a90699..a5becfd 100644 --- a/source/oxt/writer2xhtml/description.xml +++ b/source/oxt/writer2xhtml/description.xml @@ -4,7 +4,7 @@ - + @@ -21,13 +21,13 @@ - - - - - - - + + + + + + + diff --git a/source/oxt/writer4latex/Addons.xcu b/source/oxt/writer4latex/Addons.xcu new file mode 100644 index 0000000..c676b65 --- /dev/null +++ b/source/oxt/writer4latex/Addons.xcu @@ -0,0 +1,142 @@ + + + + + + + + com.sun.star.text.TextDocument + + + Writer4LaTeX + + + _self + + + + + + + + com.sun.star.text.TextDocument + + + Run LaTeX... + Kør LaTeX... + + + _self + + + org.openoffice.da.writer4latex:ProcessDocument + + + + + + + + com.sun.star.text.TextDocument + + + Run LaTeX directly + Kør LaTeX direkte + + + _self + + + org.openoffice.da.writer4latex:ProcessDirectly + + + + + + + + com.sun.star.text.TextDocument + + + View Log files + Vis logfiler + + + _self + + + org.openoffice.da.writer4latex:ViewLog + + + + + + + + + private:separator + + + + + com.sun.star.text.TextDocument + + + Import LaTeX... + Importer LaTeX... + + + _self + + + org.openoffice.da.writer4latex:ImportLaTeX + + + + + + + + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/META-INF/manifest.xml b/source/oxt/writer4latex/META-INF/manifest.xml new file mode 100644 index 0000000..e2f136d --- /dev/null +++ b/source/oxt/writer4latex/META-INF/manifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/Options.xcs b/source/oxt/writer4latex/Options.xcs new file mode 100644 index 0000000..a1a5012 --- /dev/null +++ b/source/oxt/writer4latex/Options.xcs @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/Options.xcu b/source/oxt/writer4latex/Options.xcu new file mode 100644 index 0000000..8ccfcbf --- /dev/null +++ b/source/oxt/writer4latex/Options.xcu @@ -0,0 +1,89 @@ + + + + + + latex + + + --interaction=batchmode %s + + + + + pdflatex + + + --interaction=batchmode %s + + + + + xelatex + + + --interaction=batchmode %s + + + + + bibtex + + + %s + + + + + makeindex + + + %s + + + + + oolatex + + + %s + + + + + dvips + + + %s + + + + + evince + + + %s + + + + + evince + + + %s + + + + + evince + + + %s + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/OptionsDialog.xcu b/source/oxt/writer4latex/OptionsDialog.xcu new file mode 100644 index 0000000..131fe19 --- /dev/null +++ b/source/oxt/writer4latex/OptionsDialog.xcu @@ -0,0 +1,29 @@ + + + + + + + + + + org.openoffice.da.writer4latex.oxt + + + Writer4LaTeX + + + %origin%/W4LDialogs/Configuration.xdl + + + org.openoffice.da.writer4latex.ConfigurationDialog + + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/Paths.xcu b/source/oxt/writer4latex/Paths.xcu new file mode 100644 index 0000000..119ccd1 --- /dev/null +++ b/source/oxt/writer4latex/Paths.xcu @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/source/oxt/writer4latex/ProtocolHandler.xcu b/source/oxt/writer4latex/ProtocolHandler.xcu new file mode 100644 index 0000000..863586b --- /dev/null +++ b/source/oxt/writer4latex/ProtocolHandler.xcu @@ -0,0 +1,12 @@ + + + + + + + + org.openoffice.da.writer4latex:* + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/W2LOptions.xcu b/source/oxt/writer4latex/W2LOptions.xcu new file mode 100644 index 0000000..192da2c --- /dev/null +++ b/source/oxt/writer4latex/W2LOptions.xcu @@ -0,0 +1,36 @@ + + + + + + + + + + + W4L: LaTeX article + + + %origin%/config/article.xml + + + + + + + LaTeX-article + + + w4l-article + + + + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/W4LDialogs/Configuration.xdl b/source/oxt/writer4latex/W4LDialogs/Configuration.xdl new file mode 100644 index 0000000..92675de --- /dev/null +++ b/source/oxt/writer4latex/W4LDialogs/Configuration.xdl @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/W4LDialogs/LogViewer.xdl b/source/oxt/writer4latex/W4LDialogs/LogViewer.xdl new file mode 100644 index 0000000..2bd9f8f --- /dev/null +++ b/source/oxt/writer4latex/W4LDialogs/LogViewer.xdl @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/W4LDialogs/Module1.xba b/source/oxt/writer4latex/W4LDialogs/Module1.xba new file mode 100644 index 0000000..9c46f60 --- /dev/null +++ b/source/oxt/writer4latex/W4LDialogs/Module1.xba @@ -0,0 +1,10 @@ + + +REM ***** BASIC ***** + +Sub Main + +End Sub + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/W4LDialogs/dialog.xlb b/source/oxt/writer4latex/W4LDialogs/dialog.xlb new file mode 100644 index 0000000..719e888 --- /dev/null +++ b/source/oxt/writer4latex/W4LDialogs/dialog.xlb @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/W4LDialogs/script.xlb b/source/oxt/writer4latex/W4LDialogs/script.xlb new file mode 100644 index 0000000..76fa668 --- /dev/null +++ b/source/oxt/writer4latex/W4LDialogs/script.xlb @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/source/oxt/writer4latex/config/article.xml b/source/oxt/writer4latex/config/article.xml new file mode 100644 index 0000000..c41a711 --- /dev/null +++ b/source/oxt/writer4latex/config/article.xml @@ -0,0 +1,170 @@ + + + + + + + diff --git a/source/oxt/writer4latex/description.xml b/source/oxt/writer4latex/description.xml new file mode 100644 index 0000000..eaf83e3 --- /dev/null +++ b/source/oxt/writer4latex/description.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/source/oxt/writer4latex/template/Writer4LaTeX/LaTeX-article.ott b/source/oxt/writer4latex/template/Writer4LaTeX/LaTeX-article.ott new file mode 100644 index 0000000..9944af2 Binary files /dev/null and b/source/oxt/writer4latex/template/Writer4LaTeX/LaTeX-article.ott differ diff --git a/source/oxt/xhtml-config-sample/description.xml b/source/oxt/xhtml-config-sample/description.xml index b45afb0..1a01d80 100644 --- a/source/oxt/xhtml-config-sample/description.xml +++ b/source/oxt/xhtml-config-sample/description.xml @@ -2,5 +2,5 @@ - + diff --git a/source/readme-source.txt b/source/readme-source.txt index 1e878d4..3a5dabb 100644 --- a/source/readme-source.txt +++ b/source/readme-source.txt @@ -1,5 +1,5 @@ -Writer2LaTeX source version 1.0 beta -==================================== +Writer2LaTeX source version 1.1.1 +================================= Writer2LaTeX is (c) 2002-2009 by Henrik Just. The source is available under the terms and conditions of the