Unnumbered headings & a few language bugfixes
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@98 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
7df46da38c
commit
028e30afb6
8 changed files with 85 additions and 57 deletions
|
@ -1,8 +1,17 @@
|
||||||
Changelog for Writer2LaTeX version 1.0 -> 1.2
|
Changelog for Writer2LaTeX version 1.0 -> 1.2
|
||||||
|
|
||||||
|
|
||||||
---------- version 1.1.7 ----------
|
---------- version 1.1.7 ----------
|
||||||
|
|
||||||
|
[w2l] Polyglossia bugfix: Now sets the default language correctly
|
||||||
|
|
||||||
|
[w2l] Babel bugfix: No language is now ignored rather than exported as English
|
||||||
|
|
||||||
|
[w2x] Bugfix: No language is now exported as zxx rather than zxx-none
|
||||||
|
|
||||||
|
[w2l] Added support for unnumbered headings
|
||||||
|
|
||||||
|
[w2x] Bugfix: Unnumbered headings are now exported correctly
|
||||||
|
|
||||||
[w2x] Bugfix: Do not add space to empty labels (e.g. heading numbering)
|
[w2x] Bugfix: Do not add space to empty labels (e.g. heading numbering)
|
||||||
|
|
||||||
[w2x] Export line breaks as spaces in annotations and EPUB table of content
|
[w2x] Export line breaks as spaces in annotations and EPUB table of content
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2011-03-05)
|
* Version 1.2 (2011-03-10)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class ConverterFactory {
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
private static final String VERSION = "1.1.7";
|
private static final String VERSION = "1.1.7";
|
||||||
private static final String DATE = "2011-03-05";
|
private static final String DATE = "2011-03-10";
|
||||||
|
|
||||||
/** Return the Writer2LaTeX version in the form
|
/** Return the Writer2LaTeX version in the form
|
||||||
* (major version).(minor version).(patch level)<br/>
|
* (major version).(minor version).(patch level)<br/>
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||||
* MA 02111-1307 USA
|
* MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* Copyright: 2002-2009 by Henrik Just
|
* Copyright: 2002-2011 by Henrik Just
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2009-04-30)
|
* Version 1.2 (2011-03-10)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -74,6 +74,8 @@ public class HeadingConverter extends ConverterHelper {
|
||||||
int nLevel = ofr.isOpenDocument() ?
|
int nLevel = ofr.isOpenDocument() ?
|
||||||
Misc.getPosInteger(Misc.getAttribute(node, XMLString.TEXT_OUTLINE_LEVEL),1) :
|
Misc.getPosInteger(Misc.getAttribute(node, XMLString.TEXT_OUTLINE_LEVEL),1) :
|
||||||
Misc.getPosInteger(Misc.getAttribute(node, XMLString.TEXT_LEVEL),1);
|
Misc.getPosInteger(Misc.getAttribute(node, XMLString.TEXT_LEVEL),1);
|
||||||
|
boolean bUnNumbered = "true".equals(Misc.getAttribute(node,XMLString.TEXT_IS_LIST_HEADER));
|
||||||
|
|
||||||
HeadingMap hm = config.getHeadingMap();
|
HeadingMap hm = config.getHeadingMap();
|
||||||
String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
|
String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
|
||||||
|
|
||||||
|
@ -96,6 +98,7 @@ public class HeadingConverter extends ConverterHelper {
|
||||||
// Export the heading
|
// Export the heading
|
||||||
ldp.append(baHardPage.getBefore());
|
ldp.append(baHardPage.getBefore());
|
||||||
ldp.append("\\"+hm.getName(nLevel));
|
ldp.append("\\"+hm.getName(nLevel));
|
||||||
|
if (bUnNumbered) { ldp.append("*"); }
|
||||||
// If this heading contains formatting, add optional argument:
|
// If this heading contains formatting, add optional argument:
|
||||||
if (baHardChar.getBefore().length()>0 || containsElements(node)) {
|
if (baHardChar.getBefore().length()>0 || containsElements(node)) {
|
||||||
ldp.append("[");
|
ldp.append("[");
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||||
* MA 02111-1307 USA
|
* MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* Copyright: 2002-2010 by Henrik Just
|
* Copyright: 2002-2011 by Henrik Just
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2010-12-15)
|
* Version 1.2 (2011-03-10)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -181,11 +181,44 @@ public class ClassicI18n extends I18n {
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of static part of I18n!
|
|
||||||
|
|
||||||
|
private static Hashtable<String,String> babelLanguages; // mappings iso->babel language
|
||||||
|
|
||||||
|
static {
|
||||||
|
babelLanguages = new Hashtable<String,String>();
|
||||||
|
babelLanguages.put("en", "english"); // latin1
|
||||||
|
babelLanguages.put("bg", "bulgarian"); // cp1251?
|
||||||
|
babelLanguages.put("cs", "czech"); // latin2
|
||||||
|
babelLanguages.put("da", "danish"); // latin1
|
||||||
|
babelLanguages.put("de", "ngerman"); // latin1
|
||||||
|
babelLanguages.put("el", "greek"); // iso-8859-7
|
||||||
|
babelLanguages.put("es", "spanish"); // latin1
|
||||||
|
babelLanguages.put("fi", "finnish"); // latin1 (latin9?)
|
||||||
|
babelLanguages.put("fr", "french"); // latin1 (latin9?)
|
||||||
|
babelLanguages.put("ga", "irish"); // latin1
|
||||||
|
babelLanguages.put("hr", "croatian"); // latin2
|
||||||
|
babelLanguages.put("hu", "magyar"); // latin2
|
||||||
|
babelLanguages.put("la", "latin"); // ascii
|
||||||
|
babelLanguages.put("is", "icelandic"); // latin1
|
||||||
|
babelLanguages.put("it", "italian"); // latin1
|
||||||
|
babelLanguages.put("nl", "dutch"); // latin1
|
||||||
|
babelLanguages.put("nb", "norsk"); // latin1
|
||||||
|
babelLanguages.put("nn", "nynorsk"); // latin1
|
||||||
|
babelLanguages.put("pl", "polish"); // latin2
|
||||||
|
babelLanguages.put("pt", "portuges"); // latin1
|
||||||
|
babelLanguages.put("ro", "romanian"); // latin2
|
||||||
|
babelLanguages.put("ru", "russian"); // cp1251?
|
||||||
|
babelLanguages.put("sk", "slovak"); // latin2
|
||||||
|
babelLanguages.put("sl", "slovene"); // latin2
|
||||||
|
babelLanguages.put("sr", "serbian"); // cp1251?
|
||||||
|
babelLanguages.put("sv", "swedish"); // latin1
|
||||||
|
babelLanguages.put("tr", "turkish");
|
||||||
|
babelLanguages.put("uk", "ukrainian"); // cp1251?
|
||||||
|
}
|
||||||
|
|
||||||
|
// End of static part of I18n!
|
||||||
|
|
||||||
// **** Global variables ****
|
// **** Global variables ****
|
||||||
private Hashtable<String,String> babelLanguages; // mappings iso->babel language
|
|
||||||
|
|
||||||
// Unicode translation
|
// Unicode translation
|
||||||
private Hashtable<String,UnicodeTable> tableSet; // all tables
|
private Hashtable<String,UnicodeTable> tableSet; // all tables
|
||||||
|
@ -211,9 +244,6 @@ public class ClassicI18n extends I18n {
|
||||||
// We don't need the palette and the office reader is only used to
|
// We don't need the palette and the office reader is only used to
|
||||||
// identify the default language
|
// identify the default language
|
||||||
|
|
||||||
// Set up table for iso->babel translation
|
|
||||||
prepareBabelLanguages();
|
|
||||||
|
|
||||||
nDefaultFontenc = getFontenc(sDefaultLanguage);
|
nDefaultFontenc = getFontenc(sDefaultLanguage);
|
||||||
|
|
||||||
// Unicode stuff
|
// Unicode stuff
|
||||||
|
@ -294,7 +324,10 @@ public class ClassicI18n extends I18n {
|
||||||
babelopt.addValue("polutonikogreek");
|
babelopt.addValue("polutonikogreek");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
babelopt.addValue(getBabelLanguage(sLang));
|
String sBabelLang = getBabelLanguage(sLang);
|
||||||
|
if (sBabelLang!=null) {
|
||||||
|
babelopt.addValue(sBabelLang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,7 +338,10 @@ public class ClassicI18n extends I18n {
|
||||||
babelopt.addValue("polutonikogreek");
|
babelopt.addValue("polutonikogreek");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
babelopt.addValue(getBabelLanguage(sDefaultLanguage));
|
String sBabelLang = getBabelLanguage(sDefaultLanguage);
|
||||||
|
if (sBabelLang!=null) {
|
||||||
|
babelopt.addValue(sBabelLang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,42 +676,10 @@ public class ClassicI18n extends I18n {
|
||||||
return babelLanguages.get(sLang);
|
return babelLanguages.get(sLang);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "english"; // interpret unknown languages as English
|
return null; // Unknown language
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareBabelLanguages() {
|
|
||||||
babelLanguages = new Hashtable<String,String>();
|
|
||||||
babelLanguages.put("en", "english"); // latin1
|
|
||||||
babelLanguages.put("bg", "bulgarian"); // cp1251?
|
|
||||||
babelLanguages.put("cs", "czech"); // latin2
|
|
||||||
babelLanguages.put("da", "danish"); // latin1
|
|
||||||
babelLanguages.put("de", "ngerman"); // latin1
|
|
||||||
babelLanguages.put("el", "greek"); // iso-8859-7
|
|
||||||
babelLanguages.put("es", "spanish"); // latin1
|
|
||||||
babelLanguages.put("fi", "finnish"); // latin1 (latin9?)
|
|
||||||
babelLanguages.put("fr", "french"); // latin1 (latin9?)
|
|
||||||
babelLanguages.put("ga", "irish"); // latin1
|
|
||||||
babelLanguages.put("hr", "croatian"); // latin2
|
|
||||||
babelLanguages.put("hu", "magyar"); // latin2
|
|
||||||
babelLanguages.put("la", "latin"); // ascii
|
|
||||||
babelLanguages.put("is", "icelandic"); // latin1
|
|
||||||
babelLanguages.put("it", "italian"); // latin1
|
|
||||||
babelLanguages.put("nl", "dutch"); // latin1
|
|
||||||
babelLanguages.put("nb", "norsk"); // latin1
|
|
||||||
babelLanguages.put("nn", "nynorsk"); // latin1
|
|
||||||
babelLanguages.put("pl", "polish"); // latin2
|
|
||||||
babelLanguages.put("pt", "portuges"); // latin1
|
|
||||||
babelLanguages.put("ro", "romanian"); // latin2
|
|
||||||
babelLanguages.put("ru", "russian"); // cp1251?
|
|
||||||
babelLanguages.put("sk", "slovak"); // latin2
|
|
||||||
babelLanguages.put("sl", "slovene"); // latin2
|
|
||||||
babelLanguages.put("sr", "serbian"); // cp1251?
|
|
||||||
babelLanguages.put("sv", "swedish"); // latin1
|
|
||||||
babelLanguages.put("tr", "turkish");
|
|
||||||
babelLanguages.put("uk", "ukrainian"); // cp1251?
|
|
||||||
}
|
|
||||||
|
|
||||||
// **** Helpers to collect various information ****
|
// **** Helpers to collect various information ****
|
||||||
|
|
||||||
// Did we use cyrillic?
|
// Did we use cyrillic?
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||||
* MA 02111-1307 USA
|
* MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* Copyright: 2002-2010 by Henrik Just
|
* Copyright: 2002-2011 by Henrik Just
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2010-12-14)
|
* Version 1.2 (2011-03-10)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ public abstract class I18n {
|
||||||
|
|
||||||
// Collected data
|
// Collected data
|
||||||
protected String sDefaultLanguage; // The default ISO language to use
|
protected String sDefaultLanguage; // The default ISO language to use
|
||||||
|
protected String sDefaultCountry; // The default ISO country to use
|
||||||
protected HashSet<String> languages = new HashSet<String>(); // All languages used
|
protected HashSet<String> languages = new HashSet<String>(); // All languages used
|
||||||
|
|
||||||
// **** Constructors ****
|
// **** Constructors ****
|
||||||
|
@ -75,6 +76,7 @@ public abstract class I18n {
|
||||||
StyleWithProperties style = ofr.getDefaultParStyle();
|
StyleWithProperties style = ofr.getDefaultParStyle();
|
||||||
if (style!=null) {
|
if (style!=null) {
|
||||||
sDefaultLanguage = style.getProperty(XMLString.FO_LANGUAGE);
|
sDefaultLanguage = style.getProperty(XMLString.FO_LANGUAGE);
|
||||||
|
sDefaultCountry = style.getProperty(XMLString.FO_COUNTRY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -123,4 +125,12 @@ public abstract class I18n {
|
||||||
public String getDefaultLanguage() {
|
public String getDefaultLanguage() {
|
||||||
return sDefaultLanguage;
|
return sDefaultLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the default country
|
||||||
|
*
|
||||||
|
* @return the default country
|
||||||
|
*/
|
||||||
|
public String getDefaultCountry() {
|
||||||
|
return sDefaultCountry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||||
* MA 02111-1307 USA
|
* MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* Copyright: 2002-2010 by Henrik Just
|
* Copyright: 2002-2011 by Henrik Just
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.2 (2010-12-15)
|
* Version 1.2 (2011-03-10)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ public class XeTeXI18n extends I18n {
|
||||||
public XeTeXI18n(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
|
public XeTeXI18n(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
|
||||||
super(ofr,config,palette);
|
super(ofr,config,palette);
|
||||||
polyglossia = new Polyglossia();
|
polyglossia = new Polyglossia();
|
||||||
|
polyglossia.applyLanguage(sDefaultLanguage, sDefaultCountry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add declarations to the preamble to load the required packages
|
/** Add declarations to the preamble to load the required packages
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||||
* MA 02111-1307 USA
|
* MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* Copyright: 2002-2008 by Henrik Just
|
* Copyright: 2002-2011 by Henrik Just
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Version 1.0 (2008-09-08)
|
* Version 1.2 (2011-03-10)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public abstract class StyleConverterHelper extends ConverterHelper {
|
||||||
String sLang = style.getProperty(XMLString.FO_LANGUAGE);
|
String sLang = style.getProperty(XMLString.FO_LANGUAGE);
|
||||||
String sCountry = style.getProperty(XMLString.FO_COUNTRY);
|
String sCountry = style.getProperty(XMLString.FO_COUNTRY);
|
||||||
if (sLang!=null) {
|
if (sLang!=null) {
|
||||||
if (sCountry==null) { info.sLang = sLang; }
|
if (sCountry==null || sCountry.equals("none")) { info.sLang = sLang; }
|
||||||
else { info.sLang = sLang+"-"+sCountry; }
|
else { info.sLang = sLang+"-"+sCountry; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
*
|
*
|
||||||
|
* TextConverter.java
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -596,11 +597,11 @@ public class TextConverter extends ConverterHelper {
|
||||||
|
|
||||||
private void handleHeading(Element onode, Node hnode, boolean bAfterSplit) {
|
private void handleHeading(Element onode, Node hnode, boolean bAfterSplit) {
|
||||||
int nListLevel = getOutlineLevel((Element)onode);
|
int nListLevel = getOutlineLevel((Element)onode);
|
||||||
//boolean bUnNumbered = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_IS_LIST_HEADER));
|
boolean bUnNumbered = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_IS_LIST_HEADER));
|
||||||
boolean bRestart = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_RESTART_NUMBERING));
|
boolean bRestart = "true".equals(Misc.getAttribute(onode,XMLString.TEXT_RESTART_NUMBERING));
|
||||||
int nStartValue = Misc.getPosInteger(Misc.getAttribute(onode,XMLString.TEXT_START_VALUE),1)-1;
|
int nStartValue = Misc.getPosInteger(Misc.getAttribute(onode,XMLString.TEXT_START_VALUE),1)-1;
|
||||||
handleHeading(onode, hnode, bAfterSplit, ofr.getOutlineStyle(),
|
handleHeading(onode, hnode, bAfterSplit, ofr.getOutlineStyle(),
|
||||||
nListLevel, false, bRestart, nStartValue);
|
nListLevel, bUnNumbered, bRestart, nStartValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue