Merge changes from 1.0beta3 + Export XHTML without MathML

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@24 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2009-05-29 10:44:38 +00:00
parent 1bbf6241a4
commit 839483be11
29 changed files with 927 additions and 27 deletions

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2009-04-30)
* Version 1.2 (2009-05-29)
*
*/
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information
private static final String VERSION = "1.1.1";
private static final String DATE = "2008-05-18";
private static final String DATE = "2008-05-29";
/** Return version information
* @return the Writer2LaTeX version in the form
@ -53,6 +53,10 @@ public class ConverterFactory {
* <li><code>application/x-latex</code> for LaTeX format</li>
* <li><code>application/x-bibtex</code> for BibTeX format</li>
* <li><code>text/html</code> for XHTML 1.0 strict format</li>
* <li><code>application/xhtml11</code> for XHTML 1.1 format
* Note that this is <em>not</em> the recommended media type for XHTML 1.1
* (see http://www.w3.org/TR/xhtml-media-types/), but it is used internally
* by Writer2xhtml to distinguish from XHTML+MathML</li>
* <li><code>application/xhtml+xml</code> for XHTML+MathML</li>
* <li><code>application/xml</code> for XHTML+MathML using stylesheets from w3c's
* math working group</li>
@ -73,6 +77,9 @@ public class ConverterFactory {
else if (MIMETypes.XHTML.equals(sMIME)) {
converter = createInstance("writer2latex.xhtml.Xhtml10Converter");
}
else if (MIMETypes.XHTML11.equals(sMIME)) {
converter = createInstance("writer2latex.xhtml.Xhtml11Converter");
}
else if (MIMETypes.XHTML_MATHML.equals(sMIME)) {
converter = createInstance("writer2latex.xhtml.XhtmlMathMLConverter");
}

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2008 by Henrik Just
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.0 (2008-11-23)
* Version 1.2 (2009-05-29)
*
*/
@ -46,6 +46,8 @@ public class MIMETypes {
// Desitination formats
public static final String XHTML="text/html";
/** This is a fake Mime type, for internal use only */
public static final String XHTML11="application/xhtml11";
public static final String XHTML_MATHML="application/xhtml+xml";
public static final String XHTML_MATHML_XSL="application/xml";
public static final String LATEX="application/x-latex";

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-26)
* Version 1.2 (2009-05-29)
*
*/
@ -228,7 +228,14 @@ public class DrawConverter extends ConverterHelper {
}
if (!oc.isInFrame() && config.alignFrames()) {
// Avoid nesting center environment
ba.add("\\begin{center}\n","\n\\end{center}\n");
if (config.floatFigures()) {
// Inside floats we don't want the extra glue added by the center environment
ba.add("\\centering\n","\n");
}
else {
// Outside a float we certainly want it
ba.add("\\begin{center}\n","\n\\end{center}\n");
}
}
}

View file

@ -18,7 +18,7 @@
*
* Copyright: 2002-2009 by Henrik Just
*
* Version 1.0 (2009-02-17)
* Version 1.0 (2009-04-08)
*
* All Rights Reserved.
*/
@ -1007,12 +1007,12 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
private String table(float fSize, Token eAlign){
StringBuffer bufTable=new StringBuffer();
String sLine=line(fSize,eAlign);
String sLine=line(fSize,eAlign,true);
if (curToken.eType==Token.NEWLINE){ // more than one line
bufTable.append("\\begin{gathered}").append(sLine);
while (curToken.eType==Token.NEWLINE){
nextToken();
bufTable.append("\\\\").append(line(fSize,eAlign));
bufTable.append("\\\\").append(line(fSize,eAlign,false));
}
return bufTable.append("\\end{gathered}").toString();
}
@ -1052,12 +1052,19 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
}
}
private String line(float fSize, Token eAlign){
private String line(float fSize, Token eAlign, boolean bFirstLine){
if (curToken.eType!=Token.NEWLINE && curToken.eType!=Token.END){
// Add implicit left alignment for expressions starting with text
// (Note: Don't pass on this alignment to subexpressions!)
// This alignment is only added if there's more than one line!
if (curToken.eType==Token.TEXT) {
return expression(fSize,eAlign)+"\\hfill ";
String sExpression = expression(fSize,eAlign);
if (!bFirstLine || curToken.eType==Token.NEWLINE) {
return sExpression+"\\hfill ";
}
else {
return sExpression;
}
}
else {
return align(fSize,eAlign,true,false);

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2008 by Henrik Just
* Copyright: 2002-2009 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.0 (2008-11-23)
* Version 1.0 (2009-05-22)
*
*/
@ -149,7 +149,7 @@ public class TableConverter extends ConverterHelper {
// Get table declarations
baTable = new BeforeAfter();
baTableAlign = new BeforeAfter();
formatter.applyTableStyle(baTable,baTableAlign);
formatter.applyTableStyle(baTable,baTableAlign,config.floatTables() && !ic.isInFrame() && !table.isSubTable());
// Convert table
if (formatter.isSupertabular()) {
@ -181,7 +181,7 @@ public class TableConverter extends ConverterHelper {
// Table head
ldp.append("\\tablehead{");
handleHeaderRows(ldp,oc);
ldp.append("}");
ldp.append("}\n");
// The table
handleHyperTarget(ldp);

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-02-19)
* Version 1.0 (2009-05-22)
*
*/
@ -307,8 +307,11 @@ public class TableFormatter extends ConverterHelper {
/**
* <p>Create table environment based on table style.</p>
* <p>Returns eg. "\begin{longtable}{m{2cm}|m{4cm}}", "\end{longtable}".</p>
* @param ba the <code>BeforeAfter</code> to contain the table code
* @param baAlign the <code>BeforeAfter</code> to contain the alignment code, if it's separate
* @param bInFloat true if the table should be floating
*/
public void applyTableStyle(BeforeAfter ba, BeforeAfter baAlign) {
public void applyTableStyle(BeforeAfter ba, BeforeAfter baAlign, boolean bInFloat) {
// Read formatting info from table style
// Only supported properties are alignment and may-break-between-rows.
String sStyleName = table.getTableStyleName();
@ -328,7 +331,18 @@ public class TableFormatter extends ConverterHelper {
// Create table alignment (for supertabular, tabular and tabulary)
if (!bIsLongtable && !table.isSubTable()) {
baAlign.add("\\begin{"+sAlign+"}\n","\\end{"+sAlign+"}\n");
if (bInFloat & !bIsSupertabular) {
// Inside a float we don't want the extra glue added by the flushleft/center/flushright environment
switch (cAlign) {
case 'c' : baAlign.add("\\centering\n", ""); break;
case 'r' : baAlign.add("\\raggedleft\n", ""); break;
case 'l' : baAlign.add("\\raggedright\n", "");
}
}
else {
// But outside floats we do want it
baAlign.add("\\begin{"+sAlign+"}\n","\\end{"+sAlign+"}\n");
}
}
// Create table declaration

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-02)
* Version 1.2 (2009-05-29)
*
*/
@ -153,7 +153,7 @@ public class Converter extends ConverterBase {
textCv = new TextConverter(ofr,config,this);
tableCv = new TableConverter(ofr,config,this);
drawCv = new DrawConverter(ofr,config,this);
mathCv = new MathConverter(ofr,config,this,nType!=XhtmlDocument.XHTML10);
mathCv = new MathConverter(ofr,config,this,nType!=XhtmlDocument.XHTML10 && nType!=XhtmlDocument.XHTML11);
// Set locale to document language
StyleWithProperties style = ofr.isSpreadsheet() ? ofr.getDefaultCellStyle() : ofr.getDefaultParStyle();

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2009-03-27)
* Version 1.2 (2009-05-29)
*
*/
@ -95,6 +95,20 @@ public class L10n {
case DOCUMENT: return "Documento";
}
}
if (sLocale.startsWith("it")) { // italian
switch (nString) {
case UP: return "Su";
case FIRST : return "Inizio";
case PREVIOUS : return "Precedente";
case NEXT : return "Successivo";
case LAST : return "Fine";
case CONTENTS : return "Sommario";
case INDEX : return "Indice";
case HOME : return "Home";
case DIRECTORY: return "Cartella";
case DOCUMENT: return "Documento";
}
}
if (sLocale.startsWith("da")) { // danish
switch (nString) {
case UP: return "Op";
@ -109,6 +123,20 @@ public class L10n {
case DOCUMENT: return "Dokument";
}
}
if (sLocale.startsWith("pl")) { // polish
switch (nString) {
case UP: return "W g\u00f3r\u0119";
case FIRST : return "Pierwsza";
case PREVIOUS : return "Poprzednia";
case NEXT : return "Nast\u0119pna";
case LAST : return "Ostatnia";
case CONTENTS : return "Spis tre\u015bci";
case INDEX : return "Indeks";
case HOME : return "Pocz\u0105tek";
case DIRECTORY: return "Katalog";
case DOCUMENT: return "Dokument";
}
}
if (sLocale.startsWith("ru")) { // russian
switch (nString) {
case UP: return "\u0412\u0432\u0435\u0440\u0445";
@ -137,6 +165,20 @@ public class L10n {
case DOCUMENT: return "\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442";
}
}
if (sLocale.startsWith("tr")) { // turkish
switch (nString) {
case UP: return "Yukar\u0131";
case FIRST : return "\u0130lk";
case PREVIOUS : return "\u00d6nceki";
case NEXT : return "Sonraki";
case LAST : return "Son";
case CONTENTS : return "\u0130\u00e7indekiler";
case INDEX : return "\u0130ndeks";
case HOME : return "Ev";
case DIRECTORY: return "Klas\u00f6r";
case DOCUMENT: return "D\u00f6k\u00fcman";
}
}
if (sLocale.startsWith("hr")) { // croatian
switch (nString) {
case UP: return "Up";

View file

@ -0,0 +1,35 @@
/************************************************************************
*
* Xhtml11Converter.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-05-29)
*
*/
package writer2latex.xhtml;
public class Xhtml11Converter extends Converter {
public Xhtml11Converter() {
super(XhtmlDocument.XHTML11);
}
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.0 (2009-02-19)
* Version 1.0 (2009-05-29)
*
*/
@ -59,7 +59,7 @@ public class XhtmlDocument extends DOMDocument {
/** Constant to identify XHTML 1.0 strict documents */
public static final int XHTML10 = 0;
/** Constant to identify XHTML 1.1 documents (not used currently) */
/** Constant to identify XHTML 1.1 documents */
public static final int XHTML11 = 1;
/** Constant to identify XHTML + MathML documents */
@ -70,7 +70,7 @@ public class XhtmlDocument extends DOMDocument {
*/
public static final int XHTML_MATHML_XSL = 3;
private static final String[] sExtension = { ".html", ".html", ".xhtml", ".xml" };
private static final String[] sExtension = { ".html", ".xhtml", ".xhtml", ".xml" };
private static final String[] sEmpty = { "base", "meta", "link", "hr", "br", "param", "img", "area", "input", "col" };

View file

@ -568,7 +568,6 @@ public class OfficeDocument
else{
try{
//contentDoc= builder.parse((InputStream)is);
Reader r = secondHack(is);
InputSource ins = new InputSource(r);
org.w3c.dom.Document newDoc = builder.parse(ins);
@ -670,7 +669,7 @@ public class OfficeDocument
}
}
catch (SAXException ex) {
throw new OfficeDocumentException(ex);
throw new OfficeDocumentException(ex);
}
}