diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt index bff1a61..43566d3 100644 --- a/source/distro/changelog.txt +++ b/source/distro/changelog.txt @@ -2,7 +2,9 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2 ---------- version 1.1.1 ---------- -[w2l] Partial support for the new list formatting of ODT 1.2 (implemented in OOo 3.0) +[w2l] Bugfix: Continued numbering now works correctly for lists that continue at level>1 + +[w2l] Added support for the new list formatting of ODT 1.2 (implemented in OOo 3.0) [all] Filter: Filters out characters that are illegal in xml (this fixes a problem with rtf documents imported in OOo) diff --git a/source/java/writer2latex/api/ConverterFactory.java b/source/java/writer2latex/api/ConverterFactory.java index eff0de2..d8fa5e4 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 (2009-04-25) + * Version 1.2 (2009-04-30) * */ @@ -33,7 +33,7 @@ public class ConverterFactory { // Version information private static final String VERSION = "1.1.1"; - private static final String DATE = "2008-04-25"; + private static final String DATE = "2008-04-30"; /** Return version information * @return the Writer2LaTeX version in the form diff --git a/source/java/writer2latex/latex/BlockConverter.java b/source/java/writer2latex/latex/BlockConverter.java index 182c8c1..c476a2b 100644 --- a/source/java/writer2latex/latex/BlockConverter.java +++ b/source/java/writer2latex/latex/BlockConverter.java @@ -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-04-30) * */ @@ -242,6 +242,7 @@ public class BlockConverter extends ConverterHelper { // 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) { @@ -261,9 +262,7 @@ public class BlockConverter extends ConverterHelper { // Apply the style BeforeAfter ba = new BeforeAfter(); - palette.getListSc().applyListStyle(ic.getListStyleName(),ic.getListLevel(), - bOrdered,"true".equals(node.getAttribute(XMLString.TEXT_CONTINUE_NUMBERING)), - ba); + palette.getListSc().applyListStyle(bOrdered,ba,ic); // Export the list if (ba.getBefore().length()>0) { ldp.append(ba.getBefore()).nl(); } diff --git a/source/java/writer2latex/latex/HeadingConverter.java b/source/java/writer2latex/latex/HeadingConverter.java index 67772b1..8f1b70e 100644 --- a/source/java/writer2latex/latex/HeadingConverter.java +++ b/source/java/writer2latex/latex/HeadingConverter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2009-04-28) + * Version 1.2 (2009-04-30) * */ @@ -202,15 +202,24 @@ public class HeadingConverter extends ConverterHelper { palette.getI18n().applyLanguage(style,false,true,comm); palette.getCharSc().applyFontEffects(style,true,comm); + // Get margin parameters (using first line indent as left margin) String sMarginTop = style.getAbsoluteLength(XMLString.FO_MARGIN_TOP); String sMarginBottom = style.getAbsoluteLength(XMLString.FO_MARGIN_BOTTOM); String sMarginLeft = style.getAbsoluteLength(XMLString.FO_MARGIN_LEFT); + String sTextIndent = style.getAbsoluteLength(XMLString.FO_TEXT_INDENT); - ListStyle outline = ofr.getOutlineStyle(); + // Seems that we should *not* override the paragraph style + /*ListStyle outline = ofr.getOutlineStyle(); if (outline.isNewType(i)) { - // Override left margin with the value from the outline - sMarginLeft = outline.getLevelStyleProperty(i, XMLString.FO_MARGIN_LEFT); - } + String sNumFormat = ListStyleConverter.numFormat(outline.getLevelProperty(i,XMLString.STYLE_NUM_FORMAT)); + if (sNumFormat!=null && !"".equals(sNumFormat)) { + // It there's a numbering, override left margins with the value from the outline + sMarginLeft = outline.getLevelStyleProperty(i, XMLString.FO_MARGIN_LEFT); + if (sMarginLeft==null) { sMarginLeft = "0cm"; } + sTextIndent = outline.getLevelStyleProperty(i, XMLString.FO_TEXT_INDENT); + if (sTextIndent==null) { sTextIndent = "0cm"; } + } + }*/ String sSecName = hm.getName(i); if (!comm.isEmpty()) { // have to create a cs for this heading @@ -218,9 +227,10 @@ public class HeadingConverter extends ConverterHelper { .append(comm.getBefore()).append("#1").append(comm.getAfter()) .append("}").nl(); } + // Note: Use first line as left indent (cannot have separate first line indent) ldp.append("\\renewcommand\\").append(sSecName) .append("{\\@startsection{").append(sSecName).append("}{"+hm.getLevel(i)) - .append("}{"+sMarginLeft+"}{"); + .append("}{"+Misc.add(sMarginLeft,sTextIndent)+"}{"); // Suppress indentation after heading? currently not.. // ldp.append("-"); ldp.append(sMarginTop) @@ -275,10 +285,20 @@ public class HeadingConverter extends ConverterHelper { if (outline.isNewType(i)) { String sFormat = outline.getLevelStyleProperty(i, XMLString.TEXT_LABEL_FOLLOWED_BY); if ("listtab".equals(sFormat)) { - String sMarginLeft = outline.getLevelStyleProperty(i, XMLString.FO_MARGIN_LEFT); + String sMarginLeft="0cm"; + String sTextIndent="0cm"; + if (sHeadingStyles[i]!=null) { + StyleWithProperties style = ofr.getParStyle(sHeadingStyles[i]); + if (style!=null) { + sMarginLeft = style.getAbsoluteLength(XMLString.FO_MARGIN_LEFT); + sTextIndent = style.getAbsoluteLength(XMLString.FO_TEXT_INDENT); + } + } + // Seems that we should *not* override the paragraph style + /*String sMarginLeft = outline.getLevelStyleProperty(i, XMLString.FO_MARGIN_LEFT); if (sMarginLeft==null) { sMarginLeft = "0cm"; } String sTextIndent = outline.getLevelStyleProperty(i, XMLString.FO_TEXT_INDENT); - if (sTextIndent==null) { sTextIndent = "0cm"; } + if (sTextIndent==null) { sTextIndent = "0cm"; }*/ String sTabPos = outline.getLevelStyleProperty(i, XMLString.TEXT_LIST_TAB_STOP_POSITION); if (sTabPos==null) { sTabPos = "0cm"; } sDistance = Misc.sub(sTabPos, Misc.add(sMarginLeft, sTextIndent)); @@ -332,6 +352,7 @@ public class HeadingConverter extends ConverterHelper { .append(sPrefix!=null ? sPrefix : "") .append("#1") .append(sSuffix!=null ? sSuffix : "") + .append(sSpaceChar) .append(baText.getAfter()); if (!bOnlyNum && sLabelWidth!=null) { ldp.append("}"); diff --git a/source/java/writer2latex/latex/ListStyleConverter.java b/source/java/writer2latex/latex/ListStyleConverter.java index 601ca64..05ea57f 100644 --- a/source/java/writer2latex/latex/ListStyleConverter.java +++ b/source/java/writer2latex/latex/ListStyleConverter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2009-04-28) + * Version 1.2 (2009-04-30) * */ @@ -67,10 +67,9 @@ public class ListStyleConverter extends StyleConverter { } /**
Apply a list style to an ordered or unordered list.
*/ - public void applyListStyle(String sStyleName, int nLevel, boolean bOrdered, - boolean bContinue, BeforeAfter ba) { + public 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(sStyleName); + String sDisplayName = ofr.getListStyles().getDisplayName(oc.getListStyleName()); if (config.getListStyleMap().contains(sDisplayName)) { ba.add(config.getListStyleMap().getBefore(sDisplayName), config.getListStyleMap().getAfter(sDisplayName)); @@ -78,9 +77,9 @@ public class ListStyleConverter extends StyleConverter { } // Step 2: The list style may not exist, or the user wants to ignore it. // In this case we create default lists - ListStyle style = ofr.getListStyle(sStyleName); + ListStyle style = ofr.getListStyle(oc.getListStyleName()); if (style==null || config.formatting()<=LaTeXConfig.IGNORE_MOST) { - if (nLevel<=4) { + if (oc.getListLevel()<=4) { if (bOrdered) { ba.add("\\begin{enumerate}","\\end{enumerate}"); } @@ -92,15 +91,15 @@ public class ListStyleConverter extends StyleConverter { } // Step 3: Export as default lists, but redefine labels if (config.formatting()==LaTeXConfig.CONVERT_BASIC) { - if (nLevel==1) { - if (!styleNames.containsName(getDisplayName(sStyleName))) { - createListStyleLabels(sStyleName); + if (oc.getListLevel()==1) { + if (!styleNames.containsName(getDisplayName(oc.getListStyleName()))) { + createListStyleLabels(oc.getListStyleName()); } - ba.add("\\liststyle"+styleNames.getExportName(getDisplayName(sStyleName))+"\n",""); + ba.add("\\liststyle"+styleNames.getExportName(getDisplayName(oc.getListStyleName()))+"\n",""); } - if (nLevel<=4) { - String sCounterName = listStyleLevelNames.get(sStyleName)[nLevel]; - if (bContinue && style.isNumber(nLevel)) { + if (oc.getListLevel()<=4) { + String sCounterName = listStyleLevelNames.get(oc.getListStyleName())[oc.getListLevel()]; + if (oc.isInContinuedList() && style.isNumber(oc.getListLevel())) { bNeedSaveEnumCounter = true; ba.add("\\setcounter{saveenum}{\\value{"+sCounterName+"}}\n",""); } @@ -110,21 +109,21 @@ public class ListStyleConverter extends StyleConverter { else { ba.add("\\begin{itemize}","\\end{itemize}"); } - if (bContinue && style.isNumber(nLevel)) { + if (oc.isInContinuedList() && style.isNumber(oc.getListLevel())) { ba.add("\n\\setcounter{"+sCounterName+"}{\\value{saveenum}}",""); } } return; } // Step 4: Export with formatting, as "Writer style" custom lists - if (nLevel<=4) { // TODO: Max level should not be fixed - if (!styleNames.containsName(getDisplayName(sStyleName))) { - createListStyle(sStyleName); + if (oc.getListLevel()<=4) { // TODO: Max level should not be fixed + if (!styleNames.containsName(getDisplayName(oc.getListStyleName()))) { + createListStyle(oc.getListStyleName()); } - String sTeXName="list"+styleNames.getExportName(getDisplayName(sStyleName)) - +"level"+Misc.int2roman(nLevel); - if (!bContinue && style.isNumber(nLevel)) { - int nStartValue = Misc.getPosInteger(style.getLevelProperty(nLevel,XMLString.TEXT_START_VALUE),1)-1; + String sTeXName="list"+styleNames.getExportName(getDisplayName(oc.getListStyleName())) + +"level"+Misc.int2roman(oc.getListLevel()); + if (!oc.isInContinuedList() && style.isNumber(oc.getListLevel())) { + int nStartValue = Misc.getPosInteger(style.getLevelProperty(oc.getListLevel(),XMLString.TEXT_START_VALUE),1)-1; ba.add("\\setcounter{"+sTeXName+"}{"+Integer.toString(nStartValue)+"}\n",""); } ba.add("\\begin{"+sTeXName+"}","\\end{"+sTeXName+"}"); diff --git a/source/java/writer2latex/latex/util/Context.java b/source/java/writer2latex/latex/util/Context.java index d963e37..cdaba86 100644 --- a/source/java/writer2latex/latex/util/Context.java +++ b/source/java/writer2latex/latex/util/Context.java @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * - * Copyright: 2002-2007 by Henrik Just + * Copyright: 2002-2009 by Henrik Just * * All Rights Reserved. * - * Version 1.0 (2007-11-23) + * Version 1.2 (2009-04-30) * */ @@ -68,6 +68,9 @@ public class Context { // within a list of this level private int nListLevel = 0; + + // within a list that continues numbering + private boolean bInContinuedList = false; // within a section command private boolean bInSection = false; @@ -175,7 +178,11 @@ public class Context { public void incListLevel() { nListLevel++; } public int getListLevel() { return nListLevel; } - + + public void setInContinuedList(boolean bInContinuedList) { this.bInContinuedList=bInContinuedList; } + + public boolean isInContinuedList() { return this.bInContinuedList; } + public void setInSection(boolean bInSection) { this.bInSection = bInSection; } public boolean isInSection() { return bInSection; } @@ -292,6 +299,7 @@ public class Context { newContext.setInSimpleTable(bInSimpleTable); newContext.setInMulticols(bInMulticols); newContext.setListLevel(nListLevel); + newContext.setInContinuedList(bInContinuedList); newContext.setInSection(bInSection); newContext.setInCaption(bInCaption); newContext.setInFigureFloat(bInFigureFloat);