Merge changes from 1.0 final + more config ui work
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@34 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
e8bba32302
commit
a0384669cc
46 changed files with 1671 additions and 90 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-05-31)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -28,7 +28,10 @@ package writer2latex.latex;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -40,6 +43,7 @@ import writer2latex.base.Option;
|
|||
import writer2latex.latex.util.HeadingMap;
|
||||
import writer2latex.latex.i18n.ClassicI18n;
|
||||
import writer2latex.latex.i18n.ReplacementTrie;
|
||||
import writer2latex.latex.i18n.ReplacementTrieNode;
|
||||
import writer2latex.latex.util.StyleMap;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
|
@ -69,6 +73,8 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
public static final int CONVERT_ALL = 4;
|
||||
// Page formatting
|
||||
public static final int CONVERT_HEADER_FOOTER = 5;
|
||||
public static final int CONVERT_GEOMETRY = 6;
|
||||
|
||||
// Handling of other formatting
|
||||
public static final int IGNORE = 0;
|
||||
public static final int ACCEPT = 1;
|
||||
|
@ -224,6 +230,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
super.setString(sValue);
|
||||
if ("convert_all".equals(sValue)) nValue = CONVERT_ALL;
|
||||
else if ("convert_header_footer".equals(sValue)) nValue = CONVERT_HEADER_FOOTER;
|
||||
else if ("convert_geometry".equals(sValue)) nValue = CONVERT_GEOMETRY;
|
||||
else if ("ignore_all".equals(sValue)) nValue = IGNORE_ALL;
|
||||
}
|
||||
};
|
||||
|
@ -295,6 +302,36 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
//stringReplace.put("\u00AB\u00A0","\u00AB ",I18n.readFontencs("any"));
|
||||
//stringReplace.put("\u00A0\u00BB"," \u00BB",I18n.readFontencs("any"));
|
||||
}
|
||||
|
||||
public void setComplexOption(String sGroup, String sName, Map<String,String> attributes) {
|
||||
if ("string-replace".equals(sGroup)) {
|
||||
String sLaTeXCode = attributes.get("latex-code");
|
||||
String sFontencs = attributes.get("fontencs");
|
||||
if (sLaTeXCode!=null) {
|
||||
int nFontencs = ClassicI18n.readFontencs(sFontencs!=null && sFontencs.length()>0 ? sFontencs : "any");
|
||||
stringReplace.put(sName,sLaTeXCode,nFontencs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String,String> getComplexOption(String sGroup, String sName) {
|
||||
if ("string-replace".equals(sGroup)) {
|
||||
ReplacementTrieNode node = stringReplace.get(sName);
|
||||
if (node!=null) {
|
||||
HashMap<String,String> attributes = new HashMap<String,String>();
|
||||
attributes.put("latex-code", node.getLaTeXCode());
|
||||
attributes.put("fontencs", "(todo)");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getComplexOptions(String sGroup) {
|
||||
if ("string-replace".equals(sGroup)) {
|
||||
return stringReplace.getInputStrings();
|
||||
}
|
||||
return new java.util.HashSet<String>();
|
||||
}
|
||||
|
||||
protected void readInner(Element elm) {
|
||||
if (elm.getTagName().equals("style-map")) {
|
||||
|
@ -400,24 +437,21 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
|
|||
hlmNode.setAttribute("level",Integer.toString(headingMap.getLevel(i)));
|
||||
hmNode.appendChild(hlmNode);
|
||||
}
|
||||
|
||||
// TODO: Export string replacements
|
||||
//String[] sInputStrings = stringReplace.getInputStrings();
|
||||
/*
|
||||
int nSize = sInputStrings.size();
|
||||
for (int i=0; i<nSize; i++) {
|
||||
String sInput = sInputStrings[i];
|
||||
|
||||
Set<String> inputStrings = stringReplace.getInputStrings();
|
||||
for (String sInput : inputStrings) {
|
||||
System.out.println("Writing input "+sInput);
|
||||
ReplacementTrieNode node = stringReplace.get(sInput);
|
||||
Element srNode = dom.createElement("string-replace");
|
||||
srNode.setAttribute("input",sInput);
|
||||
srNode.setAttribute("latex-code",node.getLaTeXCode());
|
||||
srNode.setAttribute("fontenc",I18n.writeFontencs(node.getFontencs()));
|
||||
hmNode.appendChild(srNode);
|
||||
srNode.setAttribute("fontenc","(todo)");
|
||||
//srNode.setAttribute("fontenc",ClassicI18n.writeFontencs(node.getFontencs()));
|
||||
dom.getDocumentElement().appendChild(srNode);
|
||||
}
|
||||
*/
|
||||
|
||||
writeContent(dom,customPreamble,"custom-preamble");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void writeStyleMap(Document dom, StyleMap sm, String sFamily) {
|
||||
|
|
|
@ -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-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -171,6 +171,9 @@ public final class MathmlConverter extends ConverterHelper {
|
|||
else if (XMLString.TEXT_TAB_STOP.equals(sName)) { // old
|
||||
// Tab stops are allowed
|
||||
}
|
||||
else if (XMLString.TEXT_SOFT_PAGE_BREAK.equals(sName)) { // since ODF 1.1
|
||||
// Soft page breaks are allowed
|
||||
}
|
||||
else {
|
||||
// Other elements -> not a display
|
||||
return false;
|
||||
|
|
|
@ -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-09-17)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class PageStyleConverter extends StyleConverter {
|
|||
* @param ba the <code>BeforeAfter</code> to add code to.
|
||||
*/
|
||||
private void applyMasterPage(String sName, BeforeAfter ba) {
|
||||
if (config.pageFormatting()==LaTeXConfig.IGNORE_ALL) return;
|
||||
if (config.pageFormatting()==LaTeXConfig.IGNORE_ALL || config.pageFormatting()==LaTeXConfig.CONVERT_GEOMETRY) return;
|
||||
MasterPage style = ofr.getMasterPage(sName);
|
||||
if (style==null) { return; }
|
||||
String sNextName = style.getProperty(XMLString.STYLE_NEXT_STYLE_NAME);
|
||||
|
@ -150,7 +150,7 @@ public class PageStyleConverter extends StyleConverter {
|
|||
* Process header or footer contents
|
||||
*/
|
||||
private void convertMasterPages(LaTeXDocumentPortion ldp) {
|
||||
if (config.pageFormatting()==LaTeXConfig.IGNORE_ALL) { return; }
|
||||
if (config.pageFormatting()==LaTeXConfig.IGNORE_ALL || config.pageFormatting()==LaTeXConfig.CONVERT_GEOMETRY) { return; }
|
||||
|
||||
Context context = new Context();
|
||||
context.resetFormattingFromStyle(ofr.getDefaultParStyle());
|
||||
|
@ -357,7 +357,7 @@ public class PageStyleConverter extends StyleConverter {
|
|||
|
||||
// TODO: Reenable several geometries per document??
|
||||
private void convertPageMasterGeometry(LaTeXDocumentPortion pack, LaTeXDocumentPortion ldp) {
|
||||
if (config.pageFormatting()!=LaTeXConfig.CONVERT_ALL) { return; }
|
||||
if (config.pageFormatting()!=LaTeXConfig.CONVERT_ALL && config.pageFormatting()!=LaTeXConfig.CONVERT_GEOMETRY) { return; }
|
||||
if (mainPageLayout==null) { return; }
|
||||
|
||||
// Set global document options
|
||||
|
|
|
@ -313,6 +313,10 @@ public class ClassicI18n extends I18n {
|
|||
pack.append("\\usepackage[")
|
||||
.append(babelopt.toString())
|
||||
.append("]{babel}").nl();
|
||||
// For Polish we must undefine \lll which is later defined by ams
|
||||
if (languages.contains("pl")) {
|
||||
pack.append("\\let\\lll\\undefined").nl();
|
||||
}
|
||||
}
|
||||
|
||||
// usepackage tipa
|
||||
|
|
|
@ -16,16 +16,19 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2006 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 0.5 (2006-11-02)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.i18n;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/** This class contains a trie of string -> LaTeX code replacements
|
||||
*/
|
||||
public class ReplacementTrie extends ReplacementTrieNode {
|
||||
|
@ -48,8 +51,10 @@ public class ReplacementTrie extends ReplacementTrieNode {
|
|||
else { super.put(sInput,sLaTeXCode,nFontencs); }
|
||||
}
|
||||
|
||||
public String[] getInputStrings() {
|
||||
return null; //TODO
|
||||
public Set<String> getInputStrings() {
|
||||
HashSet<String> strings = new HashSet<String>();
|
||||
collectStrings(strings,"");
|
||||
return strings;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,16 +16,18 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2006 by Henrik Just
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 0.5 (2006-11-02)
|
||||
* Version 1.2 (2009-09-20)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex.i18n;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/** This class contains a node in a trie of string -> LaTeX code replacements
|
||||
*/
|
||||
public class ReplacementTrieNode {
|
||||
|
@ -114,6 +116,18 @@ public class ReplacementTrieNode {
|
|||
child.setFontencs(nFontencs);
|
||||
}
|
||||
}
|
||||
|
||||
protected void collectStrings(Set<String> strings, String sPrefix) {
|
||||
ReplacementTrieNode child = this.getFirstChild();
|
||||
while (child!=null) {
|
||||
if (child.getLaTeXCode()!=null) {
|
||||
strings.add(sPrefix+child.getLetter());
|
||||
System.out.println("Found "+sPrefix+child.getLetter());
|
||||
}
|
||||
child.collectStrings(strings, sPrefix+child.getLetter());
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String s = Character.toString(cLetter);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!-- This is a datafile used by Writer2LaTeX
|
||||
Version 1.0 (2008-12-03)
|
||||
Version 1.0 (2009-09-07)
|
||||
|
||||
The definitions for greek characters are contributed by interzone, info@interzone.gr
|
||||
and extended by Johannis Likos. Additional bugfixes by Alexej Kryukov
|
||||
|
@ -1273,8 +1273,8 @@ PART I: Common symbols, ascii only
|
|||
<symbol char="227D" math="{\succcurlyeq}"/>
|
||||
<symbol char="227E" math="{\precsim}"/>
|
||||
<symbol char="227F" math="{\succsim}"/>
|
||||
<symbol char="2280" math="{\nsucc}"/>
|
||||
<symbol char="2281" math="{\nprec}"/>
|
||||
<symbol char="2280" math="{\nprec}"/>
|
||||
<symbol char="2281" math="{\nsucc}"/>
|
||||
<symbol char="2282" math="{\subset}"/>
|
||||
<symbol char="2283" math="{\supset}"/>
|
||||
<symbol char="2284" math="{\not\subset}"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue