diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt index 2ed1e62..c707c02 100644 --- a/source/distro/changelog.txt +++ b/source/distro/changelog.txt @@ -2,9 +2,16 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2 ---------- version 1.1.9 ---------- -[w2l] Added support for cross references to list items +[w2x] The minimum year in the date dialog (EPUB export) has been changed from 1900 to 1800 -[w2l] Do not use string replace or writing direction in math mode for XeTeX backend +[w2x] Bugfix: Do not create an empty footnotes page if footnotes are exported as endnotes, and the document contains no footnotess + +[w2l] Bugfix: Now converts the content of prefix or suffix of a list item correctly + +[w2l] Added support for the bookmark reference types "number", "number-no-superior" and "number-all-superior" (all treated like \ref) + for bookmarks in headings and numbered lists + +[w2l] Bugfix: Do not use string replace or writing direction in math mode for XeTeX backend [w2x] Export date only for dc:date attribute in EPUB meta data (not date+time) diff --git a/source/java/writer2latex/api/ConverterFactory.java b/source/java/writer2latex/api/ConverterFactory.java index 21d2a3c..e52d141 100644 --- a/source/java/writer2latex/api/ConverterFactory.java +++ b/source/java/writer2latex/api/ConverterFactory.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2012-02-27) + * Version 1.2 (2012-03-05) * */ @@ -33,7 +33,7 @@ public class ConverterFactory { // Version information private static final String VERSION = "1.1.9"; - private static final String DATE = "2012-02-27"; + private static final String DATE = "2012-03-05"; /** Return the Writer2LaTeX version in the form * (major version).(minor version).(patch level)
diff --git a/source/java/writer2latex/latex/FieldConverter.java b/source/java/writer2latex/latex/FieldConverter.java index 75873e5..e3b3ad0 100644 --- a/source/java/writer2latex/latex/FieldConverter.java +++ b/source/java/writer2latex/latex/FieldConverter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2012-02-27) + * Version 1.2 (2012-03-05) * */ @@ -40,6 +40,7 @@ import org.w3c.dom.Node; import writer2latex.latex.util.Context; import writer2latex.latex.util.HeadingMap; +import writer2latex.office.ListStyle; import writer2latex.office.OfficeReader; import writer2latex.office.XMLString; import writer2latex.util.CSVList; @@ -789,8 +790,31 @@ public class FieldConverter extends ConverterHelper { ldp.append("\\ref{bkm:"+bookmarknames.getExportName(sName)+"}"); } else if (("number".equals(sFormat) || "number-no-superior".equals(sFormat) || "number-all-superior".equals(sFormat)) && - ofr.bookmarkInList(sName)) { - ldp.append("\\ref{bkm:"+bookmarknames.getExportName(sName)+"}"); + (ofr.bookmarkInHeading(sName) || ofr.bookmarkInList(sName))) { + ListStyle style=null; + int nLevel = 0; + String sPrefix=null; + String sSuffix=null; + // Only convert the prefix and suffix if it is converted at the reference target + if (ofr.bookmarkInHeading(sName)) { + if (config.formatting()>=LaTeXConfig.CONVERT_MOST) { + style = ofr.getOutlineStyle(); + } + nLevel = ofr.getBookmarkHeadingLevel(sName); + } + else { + if (config.formatting()>=LaTeXConfig.CONVERT_BASIC) { + style = ofr.getListStyle(ofr.getBookmarkListStyle(sName)); + } + nLevel = ofr.getBookmarkListLevel(sName); + } + if (style!=null) { + sPrefix = style.getLevelProperty(nLevel, XMLString.STYLE_NUM_PREFIX); + sSuffix = style.getLevelProperty(nLevel, XMLString.STYLE_NUM_SUFFIX); + } + if (sPrefix!=null) ldp.append(palette.getI18n().convert(sPrefix,false,oc.getLang())); + ldp.append("\\ref{bkm:").append(bookmarknames.getExportName(sName)).append("}"); + if (sSuffix!=null) ldp.append(palette.getI18n().convert(sSuffix,false,oc.getLang())); } else { // use current value palette.getInlineCv().traversePCDATA(node,ldp,oc); diff --git a/source/java/writer2latex/latex/HeadingConverter.java b/source/java/writer2latex/latex/HeadingConverter.java index 4d01987..f1dae81 100644 --- a/source/java/writer2latex/latex/HeadingConverter.java +++ b/source/java/writer2latex/latex/HeadingConverter.java @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * - * Copyright: 2002-2011 by Henrik Just + * Copyright: 2002-2012 by Henrik Just * * All Rights Reserved. * - * Version 1.2 (2011-03-29) + * Version 1.2 (2012-03-05) * */ @@ -356,9 +356,9 @@ public class HeadingConverter extends ConverterHelper { ldp.append("\\protect\\makebox[").append(sLabelWidth).append("][").append(sAlignmentChar).append("]{"); } ldp.append(baText.getBefore()) - .append(sPrefix!=null ? sPrefix : "") + .append(sPrefix!=null ? palette.getI18n().convert(sPrefix,false,"en") : "") .append("#1") - .append(sSuffix!=null ? sSuffix : "") + .append(sSuffix!=null ? palette.getI18n().convert(sSuffix,false,"en") : "") .append(sSpaceChar) .append(baText.getAfter()); if (!bOnlyNum && sLabelWidth!=null) { diff --git a/source/java/writer2latex/latex/ListStyleConverter.java b/source/java/writer2latex/latex/ListStyleConverter.java index c6fdedc..b99271a 100644 --- a/source/java/writer2latex/latex/ListStyleConverter.java +++ b/source/java/writer2latex/latex/ListStyleConverter.java @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * - * Copyright: 2002-2011 by Henrik Just + * Copyright: 2002-2012 by Henrik Just * * All Rights Reserved. * - * Version 1.2 (2011-03-22) + * Version 1.2 (2012-03-05) * */ @@ -391,9 +391,9 @@ public class ListStyleConverter extends StyleConverter { String sSuffix = style.getLevelProperty(i,XMLString.STYLE_NUM_SUFFIX); // Apply style ldp.append(baText.getBefore()); - if (sPrefix!=null) { ldp.append(sPrefix); } + if (sPrefix!=null) { ldp.append(palette.getI18n().convert(sPrefix,false,"en")); } ldp.append("\\the").append(sName[i]); - if (sSuffix!=null) { ldp.append(sSuffix); } + if (sSuffix!=null) { ldp.append(palette.getI18n().convert(sSuffix,false,"en")); } ldp.append(baText.getAfter()); } else if (style.isBullet(i)) { diff --git a/source/java/writer2latex/latex/StarMathConverter.java b/source/java/writer2latex/latex/StarMathConverter.java index a4f396c..b0d205b 100644 --- a/source/java/writer2latex/latex/StarMathConverter.java +++ b/source/java/writer2latex/latex/StarMathConverter.java @@ -18,7 +18,7 @@ * * Copyright: 2002-2012 by Henrik Just * - * Version 1.2 (2012-02-24) + * Version 1.2 (2012-02-27) * * All Rights Reserved. */ @@ -1119,7 +1119,7 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert while (tokenInGroup(TGroup.PRODUCT)){ if (curToken.eType==Token.OVER){ nextToken(); - sProduct="\\frac"+groupsp(sProduct)+group(power(fSize,eAlign)); + sProduct="\\frac"+groupsp(sProduct)+groupsp(power(fSize,eAlign)); } else if (curToken.eType==Token.BOPER){ nextToken(); sProduct+=special()+power(fSize,eAlign); diff --git a/source/java/writer2latex/office/OfficeReader.java b/source/java/writer2latex/office/OfficeReader.java index e377faa..6ca2aa6 100644 --- a/source/java/writer2latex/office/OfficeReader.java +++ b/source/java/writer2latex/office/OfficeReader.java @@ -20,15 +20,19 @@ * * All Rights Reserved. * - * Version 1.2 (2012-02-27) + * Version 1.2 (2012-03-05) * */ package writer2latex.office; import java.util.Enumeration; +import java.util.HashMap; import java.util.Hashtable; import java.util.HashSet; +import java.util.Map; +import java.util.Set; + import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -276,33 +280,34 @@ 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 Map indexes = new Hashtable(); + private Set indexSourceStyles = new HashSet(); + private Set figureSequenceNames = new HashSet(); + private Set tableSequenceNames = new HashSet(); private String sAutoFigureSequenceName = null; private String sAutoTableSequenceName = null; // Map paragraphs to sequence names (caption helper) - private Hashtable sequenceNames = new Hashtable(); + private Map sequenceNames = new Hashtable(); // Map sequence reference names to sequence names - private Hashtable seqrefNames = new Hashtable(); + private Map 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 Set footnoteRef = new HashSet(); + private Set endnoteRef = new HashSet(); + private Set referenceRef = new HashSet(); + private Set bookmarkRef = new HashSet(); + private Set sequenceRef = new HashSet(); // Reference marks and bookmarks contained in headings or lists - private HashSet referenceHeading = new HashSet(); - private HashSet bookmarkHeading = new HashSet(); - private HashSet bookmarkList = new HashSet(); + private Map referenceHeading = new HashMap(); + private Map bookmarkHeading = new HashMap(); + private Map bookmarkList = new HashMap(); + private Map bookmarkListLevel = new HashMap(); // All internal hyperlinks - private HashSet links = new HashSet(); + private Set links = new HashSet(); // Forms private FormsReader forms = new FormsReader(); @@ -623,7 +628,7 @@ public class OfficeReader { * @return true if so */ public boolean referenceMarkInHeading(String sName) { - return referenceHeading.contains(sName); + return referenceHeading.containsKey(sName); } /** Is there a reference to this reference mark? @@ -639,7 +644,15 @@ public class OfficeReader { * @return true if so */ public boolean bookmarkInHeading(String sName) { - return bookmarkHeading.contains(sName); + return bookmarkHeading.containsKey(sName); + } + + /** Get the level of the heading associated with this bookmark + * @param sName the name of the bookmark + * @return the level or 0 if the bookmark does not exist + */ + public int getBookmarkHeadingLevel(String sName) { + return bookmarkHeading.get(sName); } /** Is this bookmark contained in a list? @@ -647,7 +660,33 @@ public class OfficeReader { * @return true if so */ public boolean bookmarkInList(String sName) { - return bookmarkList.contains(sName); + return bookmarkList.containsKey(sName); + } + + /** Get the list style name associated with a bookmark in a list + * @param sName the name of the bookmark + * @return the list style name or null if the bookmark does not exist or the list does not have a style name + */ + public String getBookmarkListStyle(String sName) { + if (bookmarkList.containsKey(sName)) { + return bookmarkList.get(sName); + } + else { + return null; + } + } + + /** Get the list level associated with a bookmark in a list + * @param sName the name of the bookmark + * @return the level or 0 if the bookmark does not exist + */ + public int getBookmarkListLevel(String sName) { + if (bookmarkListLevel.containsKey(sName)) { + return bookmarkListLevel.get(sName); + } + else { + return 0; + } } /**

Is there a reference to this bookmark? @@ -1020,7 +1059,7 @@ public class OfficeReader { } } - traverseContent(body); + traverseContent(body,null,0,-1); if (sAutoFigureSequenceName!=null) { addFigureSequenceName(sAutoFigureSequenceName); @@ -1043,10 +1082,11 @@ public class OfficeReader { return getParagraph(parent); } - private void traverseContent(Element node) { + private void traverseContent(Element node, String sListStyleName, int nListLevel, int nParLevel) { // Handle this node first String sName = node.getTagName(); if (sName.equals(XMLString.TEXT_P)) { + nParLevel=0; //collectMasterPage(getParStyle(node.getAttribute(XMLString.TEXT_STYLE_NAME))); } else if (sName.equals(XMLString.TEXT_H)) { @@ -1057,6 +1097,7 @@ public class OfficeReader { else { nLevel = Misc.getPosInteger(node.getAttribute(XMLString.TEXT_LEVEL),1); } + nParLevel = nLevel; StyleWithProperties style = getParStyle(node.getAttribute(XMLString.TEXT_STYLE_NAME)); //collectMasterPage(style); if (1<=nLevel && nLevel<=10 && heading[nLevel]==null) { @@ -1068,6 +1109,20 @@ public class OfficeReader { } } } + else if (sName.equals(XMLString.TEXT_LIST) || + sName.equals(XMLString.TEXT_ORDERED_LIST) || sName.equals(XMLString.TEXT_UNORDERED_LIST)) { + nListLevel++; + String sStyleName = Misc.getAttribute(node, XMLString.TEXT_STYLE_NAME); + if (sStyleName!=null) sListStyleName = sStyleName; + } + else if (sName.equals(XMLString.TEXT_NOTE) || + sName.equals(XMLString.TEXT_FOOTNOTE) || sName.equals(XMLString.TEXT_ENDNOTE) || + sName.equals(XMLString.TABLE_TABLE)) { + // Various block elements; all resetting the list and par level + sListStyleName=null; + nListLevel=0; + nParLevel=-1; + } else if (sName.equals(XMLString.TEXT_SEQUENCE)) { String sSeqName = Misc.getAttribute(node,XMLString.TEXT_NAME); String sRefName = Misc.getAttribute(node,XMLString.TEXT_REF_NAME); @@ -1094,19 +1149,19 @@ public class OfficeReader { else if ("endnote".equals(sClass)) { collectRefName(endnoteRef,node); } } else if (sName.equals(XMLString.TEXT_REFERENCE_MARK)) { - collectMarkByPosition(referenceHeading,null,node); + collectMarkByPosition(referenceHeading,null,null,node,sListStyleName,nListLevel,nParLevel); } else if (sName.equals(XMLString.TEXT_REFERENCE_MARK_START)) { - collectMarkByPosition(referenceHeading,null,node); + collectMarkByPosition(referenceHeading,null,null,node,sListStyleName,nListLevel,nParLevel); } else if (sName.equals(XMLString.TEXT_REFERENCE_REF)) { collectRefName(referenceRef,node); } else if (sName.equals(XMLString.TEXT_BOOKMARK)) { - collectMarkByPosition(bookmarkHeading,bookmarkList,node); + collectMarkByPosition(bookmarkHeading,bookmarkList,bookmarkListLevel,node,sListStyleName,nListLevel,nParLevel); } else if (sName.equals(XMLString.TEXT_BOOKMARK_START)) { - collectMarkByPosition(bookmarkHeading,bookmarkList,node); + collectMarkByPosition(bookmarkHeading,bookmarkList,bookmarkListLevel,node,sListStyleName,nListLevel,nParLevel); } else if (sName.equals(XMLString.TEXT_BOOKMARK_REF)) { collectRefName(bookmarkRef,node); @@ -1152,7 +1207,7 @@ public class OfficeReader { Node child = node.getFirstChild(); while (child!=null) { if (child.getNodeType()==Node.ELEMENT_NODE) { - traverseContent((Element) child); + traverseContent((Element) child, sListStyleName, nListLevel, nParLevel); } child = child.getNextSibling(); } @@ -1175,27 +1230,24 @@ public class OfficeReader { } - private void collectRefName(HashSet ref, Element node) { + private void collectRefName(Set ref, Element node) { String sRefName = node.getAttribute(XMLString.TEXT_REF_NAME); if (sRefName!=null && sRefName.length()>0) { ref.add(sRefName); } } - private void collectMarkByPosition(HashSet headingmarks, HashSet listmarks, Element node) { + private void collectMarkByPosition(Map headingmarklevels, Map listmarknames, + Map listmarklevels, Element node, + String sListStyleName, int nListLevel, int nParLevel) { String sName = node.getAttribute(XMLString.TEXT_NAME); if (sName!=null && sName.length()>0) { - Element par = getParagraph(node); - if (XMLString.TEXT_H.equals(par.getTagName())) { // Mark contained in a heading - headingmarks.add(sName); + if (nParLevel>0) { // Mark contained in a heading + headingmarklevels.put(sName,nParLevel); } - else if (listmarks!=null && XMLString.TEXT_P.equals(par.getTagName())) { - Element parent = (Element) par.getParentNode(); - if (XMLString.TEXT_LIST_ITEM.equals(parent.getTagName())) { // Mark contained in a list - // Note: text:list-header is not relevant here (no number to refer to!) - // TODO: Collect style name and level (necessary to add text before/after) - listmarks.add(sName); - } + else if (listmarknames!=null && nListLevel>0) { + listmarknames.put(sName,sListStyleName); + listmarklevels.put(sName, nListLevel); } } } diff --git a/source/java/writer2latex/xhtml/TextConverter.java b/source/java/writer2latex/xhtml/TextConverter.java index 21a03f2..830dfca 100644 --- a/source/java/writer2latex/xhtml/TextConverter.java +++ b/source/java/writer2latex/xhtml/TextConverter.java @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * - * Copyright: 2002-2011 by Henrik Just + * Copyright: 2002-2012 by Henrik Just * * All Rights Reserved. * - * Version 1.2 (2011-06-16) + * Version 1.2 (2012-03-05) * */ @@ -1748,33 +1748,35 @@ public class TextConverter extends ConverterHelper { private void insertFootnotes(Node hnode, boolean bFinal) { int n = footnotes.size(); - if (n>0 && bFootnotesAtPage) { // Add footnote rule - Element rule = converter.createElement("hr"); - StyleInfo info = new StyleInfo(); - getPageSc().applyFootnoteRuleStyle(info); - getPageSc().applyStyle(info, rule); - hnode.appendChild(rule); - } - else if (bFinal && !bFootnotesAtPage) { // New page if required for footnotes as endnotes - if (nSplit>0) { hnode = converter.nextOutFile(); } - insertNoteHeading(hnode, config.getFootnotesHeading(), "footnotes"); - } - - if (bFinal || bFootnotesAtPage) { // Insert the footnotes - for (int i=0; i0) { + if (bFootnotesAtPage) { // Add footnote rule + Element rule = converter.createElement("hr"); + StyleInfo info = new StyleInfo(); + getPageSc().applyFootnoteRuleStyle(info); + getPageSc().applyStyle(info, rule); + hnode.appendChild(rule); + } + else if (bFinal) { // New page if required for footnotes as endnotes + if (nSplit>0) { hnode = converter.nextOutFile(); } + insertNoteHeading(hnode, config.getFootnotesHeading(), "footnotes"); + } + + if (bFinal || bFootnotesAtPage) { // Insert the footnotes + for (int i=0; i - +