Rearrange w2l list code
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@237 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
188effe5c6
commit
fcd9c12304
12 changed files with 206 additions and 205 deletions
|
@ -186,9 +186,7 @@ public class ConfigurationDialog extends ConfigurationDialogBase implements XSer
|
|||
}
|
||||
|
||||
@Override protected void setControls(DialogAccess dlg) {
|
||||
System.out.println("set controls");
|
||||
super.setControls(dlg);
|
||||
System.out.println("done setting controls");
|
||||
String[] sCustomIds = config.getOption("template_ids").split(",");
|
||||
if (sCustomIds.length>0) { dlg.setComboBoxText("ContentId", sCustomIds[0]); }
|
||||
if (sCustomIds.length>1) { dlg.setComboBoxText("HeaderId", sCustomIds[1]); }
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2015-04-09)
|
||||
* Version 1.6 (2015-04-14)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class ConverterFactory {
|
|||
|
||||
// Version information
|
||||
private static final String VERSION = "1.5.2";
|
||||
private static final String DATE = "2015-04-09";
|
||||
private static final String DATE = "2015-04-14";
|
||||
|
||||
/** Return the Writer2LaTeX version in the form
|
||||
* (major version).(minor version).(patch level)<br/>
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-04-30)
|
||||
* Version 1.6 (2015-04-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -30,18 +30,14 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import writer2latex.latex.util.BeforeAfter;
|
||||
import writer2latex.latex.util.Context;
|
||||
//import writer2latex.latex.util.HeadingMap;
|
||||
import writer2latex.latex.util.StyleMap;
|
||||
import writer2latex.office.ListStyle;
|
||||
import writer2latex.office.OfficeReader;
|
||||
//import writer2latex.office.TableReader;
|
||||
import writer2latex.office.XMLString;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
* <p>This class handles basic block content, including the main text body,
|
||||
* This class handles basic block content, such as the main text body,
|
||||
* sections, tables, lists, headings and paragraphs.</p>
|
||||
*/
|
||||
public class BlockConverter extends ConverterHelper {
|
||||
|
@ -144,15 +140,15 @@ public class BlockConverter extends ConverterHelper {
|
|||
}
|
||||
|
||||
else if (sTagName.equals(XMLString.TEXT_LIST)) { // oasis
|
||||
handleList(child,ldp,ic);
|
||||
palette.getListCv().handleList(child,ldp,ic);
|
||||
}
|
||||
|
||||
else if (sTagName.equals(XMLString.TEXT_UNORDERED_LIST)) {
|
||||
handleList(child,ldp,ic);
|
||||
palette.getListCv().handleList(child,ldp,ic);
|
||||
}
|
||||
|
||||
else if (sTagName.equals(XMLString.TEXT_ORDERED_LIST)) {
|
||||
handleList(child,ldp,ic);
|
||||
palette.getListCv().handleList(child,ldp,ic);
|
||||
}
|
||||
else if (sTagName.equals(XMLString.TABLE_TABLE)) {
|
||||
// Next node *could* be a caption
|
||||
|
@ -230,148 +226,5 @@ public class BlockConverter extends ConverterHelper {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** <p> Process a list (text:ordered-lst or text:unordered-list tag)</p>
|
||||
* @param node The element containing the list
|
||||
* @param ldp the <code>LaTeXDocumentPortion</code> to which
|
||||
* LaTeX code should be added
|
||||
* @param oc the current context
|
||||
*/
|
||||
public void handleList(Element node, LaTeXDocumentPortion ldp, Context oc) {
|
||||
// Set up new context
|
||||
Context ic = (Context) oc.clone();
|
||||
ic.incListLevel();
|
||||
if ("true".equals(node.getAttribute(XMLString.TEXT_CONTINUE_NUMBERING))) { ic.setInContinuedList(true); }
|
||||
|
||||
// Get the style name, if we don't know it already
|
||||
if (ic.getListStyleName()==null) {
|
||||
ic.setListStyleName(node.getAttribute(XMLString.TEXT_STYLE_NAME));
|
||||
}
|
||||
|
||||
// Use the style to determine the type of list
|
||||
ListStyle style = ofr.getListStyle(ic.getListStyleName());
|
||||
boolean bOrdered = style!=null && style.isNumber(ic.getListLevel());
|
||||
|
||||
// If the list contains headings, ignore it!
|
||||
if (ic.isIgnoreLists() || listContainsHeadings(node)) {
|
||||
ic.setIgnoreLists(true);
|
||||
traverseList(node,ldp,ic);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply the style
|
||||
BeforeAfter ba = new BeforeAfter();
|
||||
palette.getListSc().applyListStyle(bOrdered,ba,ic);
|
||||
|
||||
// Export the list
|
||||
if (ba.getBefore().length()>0) { ldp.append(ba.getBefore()).nl(); }
|
||||
traverseList(node,ldp,ic);
|
||||
if (ba.getAfter().length()>0) { ldp.append(ba.getAfter()).nl(); }
|
||||
}
|
||||
|
||||
/*
|
||||
* Process the contents of a list
|
||||
*/
|
||||
private void traverseList (Element node, LaTeXDocumentPortion ldp, Context oc) {
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList list = node.getChildNodes();
|
||||
int nLen = list.getLength();
|
||||
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Node child = list.item(i);
|
||||
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String nodeName = child.getNodeName();
|
||||
|
||||
palette.getInfo().addDebugInfo((Element)child,ldp);
|
||||
|
||||
if (nodeName.equals(XMLString.TEXT_LIST_ITEM)) {
|
||||
handleListItem((Element)child,ldp,oc);
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_LIST_HEADER)) {
|
||||
handleListItem((Element)child,ldp,oc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleListItem(Element node, LaTeXDocumentPortion ldp, Context oc) {
|
||||
// Are we ignoring this list?
|
||||
if (oc.isIgnoreLists()) {
|
||||
traverseBlockText(node,ldp,oc);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply the style
|
||||
BeforeAfter ba = new BeforeAfter();
|
||||
palette.getListSc().applyListItemStyle(
|
||||
oc.getListStyleName(), oc.getListLevel(),
|
||||
node.getNodeName().equals(XMLString.TEXT_LIST_HEADER),
|
||||
"true".equals(node.getAttribute(XMLString.TEXT_RESTART_NUMBERING)),
|
||||
Misc.getPosInteger(node.getAttribute(XMLString.TEXT_START_VALUE),1)-1,
|
||||
ba,oc);
|
||||
|
||||
// export the list item (note the special treatment of lists in tables)
|
||||
if (ba.getBefore().length()>0) {
|
||||
ldp.append(ba.getBefore());
|
||||
if (config.formatting()>=LaTeXConfig.CONVERT_MOST && !oc.isInTable()) { ldp.nl(); }
|
||||
}
|
||||
traverseBlockText(node,ldp,oc);
|
||||
if (ba.getAfter().length()>0 || oc.isInTable()) { ldp.append(ba.getAfter()).nl(); }
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper: Check to see, if this list contains headings
|
||||
* (in that case we will ignore the list!)
|
||||
*/
|
||||
private boolean listContainsHeadings (Node node) {
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList nList = node.getChildNodes();
|
||||
int len = nList.getLength();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node child = nList.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String nodeName = child.getNodeName();
|
||||
if (nodeName.equals(XMLString.TEXT_LIST_ITEM)) {
|
||||
if (listItemContainsHeadings(child)) return true;
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_LIST_HEADER)) {
|
||||
if (listItemContainsHeadings(child)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean listItemContainsHeadings(Node node) {
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList nList = node.getChildNodes();
|
||||
int len = nList.getLength();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node child = nList.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String nodeName = child.getNodeName();
|
||||
if(nodeName.equals(XMLString.TEXT_H)) {
|
||||
return true;
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_LIST)) {
|
||||
if (listContainsHeadings(child)) return true;
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_ORDERED_LIST)) {
|
||||
if (listContainsHeadings(child)) return true;
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_UNORDERED_LIST)) {
|
||||
if (listContainsHeadings(child)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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-2016 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-09-08)
|
||||
* Version 1.6 (2015-04-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -43,7 +43,6 @@ public abstract class ConverterHelper {
|
|||
this.palette = palette;
|
||||
}
|
||||
|
||||
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
|
||||
}
|
||||
public abstract void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl);
|
||||
|
||||
}
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-19)
|
||||
* Version 1.6 (2015-04-14)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -65,7 +65,6 @@ public final class ConverterPalette extends ConverterBase {
|
|||
private I18n i18n;
|
||||
private ColorConverter colorCv;
|
||||
private CharStyleConverter charSc;
|
||||
private ListStyleConverter listSc;
|
||||
private PageStyleConverter pageSc;
|
||||
private BlockConverter blockCv;
|
||||
private ParConverter parCv;
|
||||
|
@ -74,6 +73,7 @@ public final class ConverterPalette extends ConverterBase {
|
|||
private BibConverter bibCv;
|
||||
private SectionConverter sectionCv;
|
||||
private TableConverter tableCv;
|
||||
private ListConverter listCv;
|
||||
private NoteConverter noteCv;
|
||||
private CaptionConverter captionCv;
|
||||
private InlineConverter inlineCv;
|
||||
|
@ -102,7 +102,6 @@ public final class ConverterPalette extends ConverterBase {
|
|||
public I18n getI18n() { return i18n; }
|
||||
public ColorConverter getColorCv() { return colorCv; }
|
||||
public CharStyleConverter getCharSc() { return charSc; }
|
||||
public ListStyleConverter getListSc() { return listSc; }
|
||||
public PageStyleConverter getPageSc() { return pageSc; }
|
||||
public BlockConverter getBlockCv() { return blockCv; }
|
||||
public ParConverter getParCv() { return parCv; }
|
||||
|
@ -111,6 +110,7 @@ public final class ConverterPalette extends ConverterBase {
|
|||
public BibConverter getBibCv() { return bibCv; }
|
||||
public SectionConverter getSectionCv() { return sectionCv; }
|
||||
public TableConverter getTableCv() { return tableCv; }
|
||||
public ListConverter getListCv() { return listCv; }
|
||||
public NoteConverter getNoteCv() { return noteCv; }
|
||||
public CaptionConverter getCaptionCv() { return captionCv; }
|
||||
public InlineConverter getInlineCv() { return inlineCv; }
|
||||
|
@ -157,7 +157,6 @@ public final class ConverterPalette extends ConverterBase {
|
|||
}
|
||||
colorCv = new ColorConverter(ofr,config,this);
|
||||
charSc = new CharStyleConverter(ofr,config,this);
|
||||
listSc = new ListStyleConverter(ofr,config,this);
|
||||
pageSc = new PageStyleConverter(ofr,config,this);
|
||||
blockCv = new BlockConverter(ofr,config,this);
|
||||
parCv = new ParConverter(ofr,config,this);
|
||||
|
@ -166,6 +165,7 @@ public final class ConverterPalette extends ConverterBase {
|
|||
bibCv = new BibConverter(ofr,config,this);
|
||||
sectionCv = new SectionConverter(ofr,config,this);
|
||||
tableCv = new TableConverter(ofr,config,this);
|
||||
listCv = new ListConverter(ofr,config,this);
|
||||
noteCv = new NoteConverter(ofr,config,this);
|
||||
captionCv = new CaptionConverter(ofr,config,this);
|
||||
inlineCv = new InlineConverter(ofr,config,this);
|
||||
|
@ -211,13 +211,13 @@ public final class ConverterPalette extends ConverterBase {
|
|||
charSc.appendDeclarations(packages,declarations);
|
||||
headingCv.appendDeclarations(packages,declarations);
|
||||
parCv.appendDeclarations(packages,declarations);
|
||||
listSc.appendDeclarations(packages,declarations);
|
||||
pageSc.appendDeclarations(packages,declarations);
|
||||
blockCv.appendDeclarations(packages,declarations);
|
||||
indexCv.appendDeclarations(packages,declarations);
|
||||
bibCv.appendDeclarations(packages,declarations);
|
||||
sectionCv.appendDeclarations(packages,declarations);
|
||||
tableCv.appendDeclarations(packages,declarations);
|
||||
listCv.appendDeclarations(packages,declarations);
|
||||
captionCv.appendDeclarations(packages,declarations);
|
||||
inlineCv.appendDeclarations(packages,declarations);
|
||||
fieldCv.appendDeclarations(packages,declarations);
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-18)
|
||||
* Version 1.6 (2015-04-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -182,7 +182,7 @@ public class FieldConverter extends ConverterHelper {
|
|||
.append("\\renewcommand\\the")
|
||||
.append(seqnames.getExportName(sName))
|
||||
.append("{").append(sPrefix)
|
||||
.append(ListStyleConverter.numFormat(sNumFormat))
|
||||
.append(ListConverter.numFormat(sNumFormat))
|
||||
.append("{").append(seqnames.getExportName(sName))
|
||||
.append("}}").nl();
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-15)
|
||||
* Version 1.6 (2015-04-14)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -277,7 +277,7 @@ public class HeadingConverter extends ConverterHelper {
|
|||
ListStyle outline = ofr.getOutlineStyle();
|
||||
String[] sNumFormat = new String[6];
|
||||
for (int i=nMaxLevel; i>=1; i--) {
|
||||
sNumFormat[i] = ListStyleConverter.numFormat(outline.getLevelProperty(i,
|
||||
sNumFormat[i] = ListConverter.numFormat(outline.getLevelProperty(i,
|
||||
XMLString.STYLE_NUM_FORMAT));
|
||||
if (sNumFormat[i]==null || "".equals(sNumFormat[i])) {
|
||||
nSecnumdepth = i-1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* ListStyleConverter.java
|
||||
* ListConverter.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -16,37 +16,40 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-06)
|
||||
* Version 1.6 (2015-04-14)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.latex;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import writer2latex.util.*;
|
||||
import writer2latex.office.*;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import writer2latex.latex.util.BeforeAfter;
|
||||
import writer2latex.latex.util.Context;
|
||||
import writer2latex.office.ListStyle;
|
||||
import writer2latex.office.OfficeReader;
|
||||
import writer2latex.office.XMLString;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/* This class creates LaTeX code from OOo list styles
|
||||
*/
|
||||
public class ListStyleConverter extends StyleConverter {
|
||||
public class ListConverter extends StyleConverter {
|
||||
boolean bNeedSaveEnumCounter = false;
|
||||
private Hashtable<String, String[]> listStyleLevelNames = new Hashtable<String, String[]>();
|
||||
|
||||
/** <p>Constructs a new <code>ListStyleConverter</code>.</p>
|
||||
*/
|
||||
public ListStyleConverter(OfficeReader ofr, LaTeXConfig config,
|
||||
ConverterPalette palette) {
|
||||
super(ofr,config,palette);
|
||||
}
|
||||
|
||||
/** Construct a new <code>ListConverter</code>
|
||||
*/
|
||||
public ListConverter(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
|
||||
super(ofr,config,palette);
|
||||
}
|
||||
|
||||
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
|
||||
@Override public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
|
||||
if (config.formatting()>=LaTeXConfig.CONVERT_MOST || !styleNames.isEmpty()) {
|
||||
decl.append("% List styles").nl();
|
||||
// May need an extra counter to handle continued numbering in lists
|
||||
|
@ -66,8 +69,149 @@ public class ListStyleConverter extends StyleConverter {
|
|||
}
|
||||
}
|
||||
|
||||
/** <p> Process a list (text:ordered-lst or text:unordered-list tag)</p>
|
||||
* @param node The element containing the list
|
||||
* @param ldp the <code>LaTeXDocumentPortion</code> to which
|
||||
* LaTeX code should be added
|
||||
* @param oc the current context
|
||||
*/
|
||||
public void handleList(Element node, LaTeXDocumentPortion ldp, Context oc) {
|
||||
// Set up new context
|
||||
Context ic = (Context) oc.clone();
|
||||
ic.incListLevel();
|
||||
if ("true".equals(node.getAttribute(XMLString.TEXT_CONTINUE_NUMBERING))) { ic.setInContinuedList(true); }
|
||||
|
||||
// Get the style name, if we don't know it already
|
||||
if (ic.getListStyleName()==null) {
|
||||
ic.setListStyleName(node.getAttribute(XMLString.TEXT_STYLE_NAME));
|
||||
}
|
||||
|
||||
// Use the style to determine the type of list
|
||||
ListStyle style = ofr.getListStyle(ic.getListStyleName());
|
||||
boolean bOrdered = style!=null && style.isNumber(ic.getListLevel());
|
||||
|
||||
// If the list contains headings, ignore it!
|
||||
if (ic.isIgnoreLists() || listContainsHeadings(node)) {
|
||||
ic.setIgnoreLists(true);
|
||||
traverseList(node,ldp,ic);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply the style
|
||||
BeforeAfter ba = new BeforeAfter();
|
||||
applyListStyle(bOrdered,ba,ic);
|
||||
|
||||
// Export the list
|
||||
if (ba.getBefore().length()>0) { ldp.append(ba.getBefore()).nl(); }
|
||||
traverseList(node,ldp,ic);
|
||||
if (ba.getAfter().length()>0) { ldp.append(ba.getAfter()).nl(); }
|
||||
}
|
||||
|
||||
/*
|
||||
* Process the contents of a list
|
||||
*/
|
||||
private void traverseList (Element node, LaTeXDocumentPortion ldp, Context oc) {
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList list = node.getChildNodes();
|
||||
int nLen = list.getLength();
|
||||
|
||||
for (int i = 0; i < nLen; i++) {
|
||||
Node child = list.item(i);
|
||||
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String nodeName = child.getNodeName();
|
||||
|
||||
palette.getInfo().addDebugInfo((Element)child,ldp);
|
||||
|
||||
if (nodeName.equals(XMLString.TEXT_LIST_ITEM)) {
|
||||
handleListItem((Element)child,ldp,oc);
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_LIST_HEADER)) {
|
||||
handleListItem((Element)child,ldp,oc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleListItem(Element node, LaTeXDocumentPortion ldp, Context oc) {
|
||||
// Are we ignoring this list?
|
||||
if (oc.isIgnoreLists()) {
|
||||
palette.getBlockCv().traverseBlockText(node,ldp,oc);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply the style
|
||||
BeforeAfter ba = new BeforeAfter();
|
||||
applyListItemStyle(
|
||||
oc.getListStyleName(), oc.getListLevel(),
|
||||
node.getNodeName().equals(XMLString.TEXT_LIST_HEADER),
|
||||
"true".equals(node.getAttribute(XMLString.TEXT_RESTART_NUMBERING)),
|
||||
Misc.getPosInteger(node.getAttribute(XMLString.TEXT_START_VALUE),1)-1,
|
||||
ba,oc);
|
||||
|
||||
// export the list item (note the special treatment of lists in tables)
|
||||
if (ba.getBefore().length()>0) {
|
||||
ldp.append(ba.getBefore());
|
||||
if (config.formatting()>=LaTeXConfig.CONVERT_MOST && !oc.isInTable()) { ldp.nl(); }
|
||||
}
|
||||
palette.getBlockCv().traverseBlockText(node,ldp,oc);
|
||||
if (ba.getAfter().length()>0 || oc.isInTable()) { ldp.append(ba.getAfter()).nl(); }
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper: Check to see, if this list contains headings
|
||||
* (in that case we will ignore the list!)
|
||||
*/
|
||||
private boolean listContainsHeadings (Node node) {
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList nList = node.getChildNodes();
|
||||
int len = nList.getLength();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node child = nList.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String nodeName = child.getNodeName();
|
||||
if (nodeName.equals(XMLString.TEXT_LIST_ITEM)) {
|
||||
if (listItemContainsHeadings(child)) return true;
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_LIST_HEADER)) {
|
||||
if (listItemContainsHeadings(child)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean listItemContainsHeadings(Node node) {
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList nList = node.getChildNodes();
|
||||
int len = nList.getLength();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node child = nList.item(i);
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
String nodeName = child.getNodeName();
|
||||
if(nodeName.equals(XMLString.TEXT_H)) {
|
||||
return true;
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_LIST)) {
|
||||
if (listContainsHeadings(child)) return true;
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_ORDERED_LIST)) {
|
||||
if (listContainsHeadings(child)) return true;
|
||||
}
|
||||
if (nodeName.equals(XMLString.TEXT_UNORDERED_LIST)) {
|
||||
if (listContainsHeadings(child)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert style information
|
||||
/** <p>Apply a list style to an ordered or unordered list.</p> */
|
||||
public void applyListStyle(boolean bOrdered, BeforeAfter ba, Context oc) {
|
||||
private void applyListStyle(boolean bOrdered, BeforeAfter ba, Context oc) {
|
||||
// Step 1. We may have a style map, this always takes precedence
|
||||
String sDisplayName = ofr.getListStyles().getDisplayName(oc.getListStyleName());
|
||||
if (config.getListStyleMap().contains(sDisplayName)) {
|
||||
|
@ -134,7 +278,7 @@ public class ListStyleConverter extends StyleConverter {
|
|||
}
|
||||
|
||||
/** <p>Apply a list style to a list item.</p> */
|
||||
public void applyListItemStyle(String sStyleName, int nLevel, boolean bHeader,
|
||||
private void applyListItemStyle(String sStyleName, int nLevel, boolean bHeader,
|
||||
boolean bRestart, int nStartValue, BeforeAfter ba, Context oc) {
|
||||
// Step 1. We may have a style map, this always takes precedence
|
||||
String sDisplayName = ofr.getListStyles().getDisplayName(sStyleName);
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-18)
|
||||
* Version 1.6 (2015-04-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -298,15 +298,15 @@ public class NoteConverter extends ConverterHelper {
|
|||
}
|
||||
|
||||
else if (nodeName.equals(XMLString.TEXT_LIST)) { // oasis
|
||||
palette.getBlockCv().handleList(child,ldp,oc);
|
||||
palette.getListCv().handleList(child,ldp,oc);
|
||||
}
|
||||
|
||||
if (nodeName.equals(XMLString.TEXT_ORDERED_LIST)) {
|
||||
palette.getBlockCv().handleList(child,ldp,oc);
|
||||
palette.getListCv().handleList(child,ldp,oc);
|
||||
}
|
||||
|
||||
if (nodeName.equals(XMLString.TEXT_UNORDERED_LIST)) {
|
||||
palette.getBlockCv().handleList(child,ldp,oc);
|
||||
palette.getListCv().handleList(child,ldp,oc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ public class NoteConverter extends ConverterHelper {
|
|||
String sFormat = notes.getProperty(XMLString.STYLE_NUM_FORMAT);
|
||||
if (sFormat!=null) {
|
||||
ldp.append("\\renewcommand\\the").append(sType).append("note{")
|
||||
.append(ListStyleConverter.numFormat(sFormat))
|
||||
.append(ListConverter.numFormat(sFormat))
|
||||
.append("{").append(sType).append("note}}").nl();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-19
|
||||
* Version 1.6 (2015-04-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -271,7 +271,7 @@ public class PageStyleConverter extends StyleConverter {
|
|||
String sNumFormat = pageLayout.getProperty(XMLString.STYLE_NUM_FORMAT);
|
||||
if (sNumFormat!=null) {
|
||||
ldp.append(" \\renewcommand\\thepage{")
|
||||
.append(ListStyleConverter.numFormat(sNumFormat))
|
||||
.append(ListConverter.numFormat(sNumFormat))
|
||||
.append("{page}}").nl();
|
||||
}
|
||||
String sPageNumber = pageLayout.getProperty(XMLString.STYLE_FIRST_PAGE_NUMBER);
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-16)
|
||||
* Version 1.6 (2015-04-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -293,6 +293,9 @@ public class TableFormatter extends ConverterHelper {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@Override public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
|
||||
}
|
||||
|
||||
/** is this a longtable? */
|
||||
public boolean isLongtable() { return bIsLongtable; }
|
||||
|
@ -467,4 +470,5 @@ public class TableFormatter extends ConverterHelper {
|
|||
palette.getColorCv().applyBgColor("\\cellcolor",sCellColor[nRow][nCol],ba,context);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-09-08)
|
||||
* Version 1.6 (2015-04-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -43,6 +43,10 @@ import writer2latex.latex.ConverterPalette;
|
|||
*/
|
||||
public class Info extends ConverterHelper {
|
||||
|
||||
@Override public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
|
||||
// Currently nothing
|
||||
}
|
||||
|
||||
public Info(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
|
||||
super(ofr,config,palette);
|
||||
}
|
||||
|
@ -72,5 +76,4 @@ public class Info extends ConverterHelper {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue