From 26de5a45dfdd26d14688b771f6b3348d6aafd2da Mon Sep 17 00:00:00 2001 From: henrikjust Date: Thu, 24 Mar 2011 07:26:28 +0000 Subject: [PATCH] Assorted bugfixes git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@101 f0f2a975-2e09-46c8-9428-3b39399b9f3c --- source/distro/changelog.txt | 10 ++++-- .../w2lcommon/filter/ExportFilterBase.java | 6 ++-- .../da/comp/writer4latex/Writer4LaTeX.java | 4 +-- .../writer2latex/api/ConverterFactory.java | 4 +-- .../writer2latex/latex/BlockConverter.java | 6 ++-- .../latex/ListStyleConverter.java | 11 ++++--- .../java/writer2latex/latex/ParConverter.java | 31 +++++++++---------- .../writer2latex/latex/util/BeforeAfter.java | 13 ++++++-- .../xhtml/PageStyleConverter.java | 6 ++-- source/oxt/writer2xhtml/Options.xcs | 2 +- source/oxt/writer2xhtml/Options.xcu | 2 +- .../writer2xhtml/W2XDialogs2/EpubOptions.xdl | 2 +- .../epub_export.xhp | 1 + 13 files changed, 59 insertions(+), 39 deletions(-) diff --git a/source/distro/changelog.txt b/source/distro/changelog.txt index 71147be..3909e3a 100644 --- a/source/distro/changelog.txt +++ b/source/distro/changelog.txt @@ -2,6 +2,14 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2 ---------- version 1.1.7 ---------- +[all] Filter bugfix: Do not exclude surrogate pairs + +[w2l] Bugfix: Fixed indentation problem with lists after tables if formatting>=convert_most + +[w2l] Bugfix: Lists in tables are now exported as standard lists even if formatting>=convert_most + +[w2l] Bugfix: Corrected export of centered and right justified paragraphs in tables + [w2x] Renamed the option original_image_size to image_size with extended values: absolute (default, former false), relative (new value: Export images and text boxes using relative width, i.e. as a percentage of the current text width) and none/original_image_size (former true). The old option name is still recognized. @@ -33,8 +41,6 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2 [w2x] Export footnotes as endnotes (if text:footnotes-position="document"). A new option footnotes_heading is added: The value of this (if non-empty) is used as heading for the footnotes in this case -[w2x] EPUB: Set body margin to zero - [w2x] Export footnote rule (using first master page) [w2x] Export page background color (using first master page) diff --git a/source/java/org/openoffice/da/comp/w2lcommon/filter/ExportFilterBase.java b/source/java/org/openoffice/da/comp/w2lcommon/filter/ExportFilterBase.java index 74fcb70..489cbac 100644 --- a/source/java/org/openoffice/da/comp/w2lcommon/filter/ExportFilterBase.java +++ b/source/java/org/openoffice/da/comp/w2lcommon/filter/ExportFilterBase.java @@ -149,14 +149,16 @@ public abstract class ExportFilterBase implements else if (c=='>'){ buf.append(">"); } - else if (c=='\u0009' || c=='\n' || c=='\r' || (c>='\u0020' && c<='\uD7FF') || (c>='\uE000' && c<'\uFFFD')) { + //else if (c=='\u0009' || c=='\n' || c=='\r' || (c>='\u0020' && c<='\uD7FF') || (c>='\uE000' && c<'\uFFFD')) { + else if (c=='\u0009' || c=='\n' || c=='\r' || (c>='\u0020' && c<'\uFFFD')) { // Valid characters found at xml.com // Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] + // (the latter are represented as surrogate pairs (#xD800-#xDFFF) buf.append(c); } else { // Found illegal character - System.out.println("Illegal character : "+Integer.toHexString(c)); + //System.out.println("Illegal character : "+Integer.toHexString(c)); } } return buf.toString(); diff --git a/source/java/org/openoffice/da/comp/writer4latex/Writer4LaTeX.java b/source/java/org/openoffice/da/comp/writer4latex/Writer4LaTeX.java index 8f900f5..9bb432f 100644 --- a/source/java/org/openoffice/da/comp/writer4latex/Writer4LaTeX.java +++ b/source/java/org/openoffice/da/comp/writer4latex/Writer4LaTeX.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2011-03-10) + * Version 1.2 (2011-03-23) * */ @@ -551,7 +551,7 @@ public final class Writer4LaTeX extends WeakBase if (sDocumentUrl.length()!=0) { if (sDocumentUrl.startsWith("file:")) { if (System.getProperty("os.name").startsWith("Windows")) { - Pattern windowsPattern = Pattern.compile("^file:///[A-Za-z][|:]"); + Pattern windowsPattern = Pattern.compile("^file:///[A-Za-z][|:].*"); if (!windowsPattern.matcher(sDocumentUrl).matches()) { MessageBox msgBox = new MessageBox(m_xContext, m_xFrame); msgBox.showMessage("Please save the document on a location with a drive name!", diff --git a/source/java/writer2latex/api/ConverterFactory.java b/source/java/writer2latex/api/ConverterFactory.java index 64077cd..9ba11ac 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 (2011-03-21) + * Version 1.2 (2011-03-23) * */ @@ -33,7 +33,7 @@ public class ConverterFactory { // Version information private static final String VERSION = "1.1.7"; - private static final String DATE = "2011-03-21"; + private static final String DATE = "2011-03-23"; /** Return the Writer2LaTeX version in the form * (major version).(minor version).(patch level)
diff --git a/source/java/writer2latex/latex/BlockConverter.java b/source/java/writer2latex/latex/BlockConverter.java index c476a2b..90d6ffa 100644 --- a/source/java/writer2latex/latex/BlockConverter.java +++ b/source/java/writer2latex/latex/BlockConverter.java @@ -313,13 +313,13 @@ public class BlockConverter extends ConverterHelper { Misc.getPosInteger(node.getAttribute(XMLString.TEXT_START_VALUE),1)-1, ba); - // export the list item + // 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) { ldp.nl(); } + if (config.formatting()>=LaTeXConfig.CONVERT_MOST && !oc.isInTable()) { ldp.nl(); } } traverseBlockText(node,ldp,oc); - if (ba.getAfter().length()>0) { ldp.append(ba.getAfter()).nl(); } + if (ba.getAfter().length()>0 || oc.isInTable()) { ldp.append(ba.getAfter()).nl(); } } /* diff --git a/source/java/writer2latex/latex/ListStyleConverter.java b/source/java/writer2latex/latex/ListStyleConverter.java index eadbc27..45d7edc 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-2010 by Henrik Just + * Copyright: 2002-2011 by Henrik Just * * All Rights Reserved. * - * Version 1.2 (2010-03-03) + * Version 1.2 (2011-03-22) * */ @@ -90,7 +90,9 @@ public class ListStyleConverter extends StyleConverter { return; } // Step 3: Export as default lists, but redefine labels - if (config.formatting()==LaTeXConfig.CONVERT_BASIC) { + // (for list in tables this is the maximum formatting we export) + if (config.formatting()==LaTeXConfig.CONVERT_BASIC || + (config.formatting()>=LaTeXConfig.CONVERT_MOST && oc.isInTable())) { if (oc.getListLevel()==1) { if (!styleNames.containsName(getDisplayName(oc.getListStyleName()))) { createListStyleLabels(oc.getListStyleName()); @@ -124,7 +126,8 @@ public class ListStyleConverter extends StyleConverter { +"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",""); + // Note that we need a blank line after certain constructions to get proper indentation + ba.add("\n\\setcounter{"+sTeXName+"}{"+Integer.toString(nStartValue)+"}\n",""); } ba.add("\\begin{"+sTeXName+"}","\\end{"+sTeXName+"}"); } diff --git a/source/java/writer2latex/latex/ParConverter.java b/source/java/writer2latex/latex/ParConverter.java index 092b890..fa32f4e 100644 --- a/source/java/writer2latex/latex/ParConverter.java +++ b/source/java/writer2latex/latex/ParConverter.java @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * - * Copyright: 2002-2010 by Henrik Just + * Copyright: 2002-2011 by Henrik Just * * All Rights Reserved. * - * Version 1.2 (2010-03-12) + * Version 1.2 (2011-03-22) * */ @@ -232,7 +232,7 @@ public class ParConverter extends StyleConverter { } else { // Export character formatting + alignment only - BeforeAfter baText = new BeforeAfter(); + BeforeAfter baFormat = new BeforeAfter(); // Apply hard formatting attributes // Note: Left justified text is exported as full justified text! @@ -240,27 +240,26 @@ public class ParConverter extends StyleConverter { if (style!=null) { String sTextAlign = style.getProperty(XMLString.FO_TEXT_ALIGN,true); if (bLastInBlock && context.isInLastTableColumn()) { // no grouping needed, but need to fix problem with \\ - if ("center".equals(sTextAlign)) { ba.add("\\centering\\arraybslash ",""); } - else if ("end".equals(sTextAlign)) { ba.add("\\raggedleft\\arraybslash ",""); } + if ("center".equals(sTextAlign)) { baFormat.add("\\centering\\arraybslash",""); } + else if ("end".equals(sTextAlign)) { baFormat.add("\\raggedleft\\arraybslash",""); } bNeedArrayBslash = true; } else if (bLastInBlock) { // no \par needed - if ("center".equals(sTextAlign)) { ba.add("\\centering ",""); } - else if ("end".equals(sTextAlign)) { ba.add("\\raggedleft ",""); } + if ("center".equals(sTextAlign)) { baFormat.add("\\centering",""); } + else if ("end".equals(sTextAlign)) { baFormat.add("\\raggedleft",""); } } else { - if ("center".equals(sTextAlign)) { ba.add("\\centering ","\\par"); } - else if ("end".equals(sTextAlign)) { ba.add("\\raggedleft ","\\par"); } + if ("center".equals(sTextAlign)) { baFormat.add("\\centering","\\par"); } + else if ("end".equals(sTextAlign)) { baFormat.add("\\raggedleft","\\par"); } } - palette.getI18n().applyLanguage(style,true,true,baText); - palette.getCharSc().applyFont(style,true,true,baText,context); + palette.getI18n().applyLanguage(style,true,true,baFormat); + palette.getCharSc().applyFont(style,true,true,baFormat,context); } - // Assemble the bits. If there is any hard character formatting - // or alignment we must group the contents. - if (!baText.isEmpty() && !bLastInBlock) { ba.add("{","}"); } - ba.add(baText.getBefore(),baText.getAfter()); - if (baText.getBefore().length()>0) { ba.add(" ",""); } + // If there is any hard character formatting or alignment we must group the contents. + if (!baFormat.isEmpty() && !bLastInBlock) { ba.add("{","}"); } + ba.add(baFormat); + if (ba.getBefore().length()>0) { ba.add(" ",""); } } // Update context diff --git a/source/java/writer2latex/latex/util/BeforeAfter.java b/source/java/writer2latex/latex/util/BeforeAfter.java index c87c8c1..d337b84 100644 --- a/source/java/writer2latex/latex/util/BeforeAfter.java +++ b/source/java/writer2latex/latex/util/BeforeAfter.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-2011 by Henrik Just * * All Rights Reserved. * - * Version 1.0 (2008-12-02) + * Version 1.2 (2011-03-22) * */ @@ -56,6 +56,15 @@ public class BeforeAfter { public void add(String sBefore1, String sAfter1) { sBefore+=sBefore1; sAfter=sAfter1+sAfter; } + + /**

Add the content of another BeforeAfter to this BeforeAfter

+ *

The new data will be be added "inside"

+ * + * @param ba the code to add + */ + public void add(BeforeAfter ba) { + add(ba.getBefore(), ba.getAfter()); + } /** Get LaTeX code to put before * @return then LaTeX code diff --git a/source/java/writer2latex/xhtml/PageStyleConverter.java b/source/java/writer2latex/xhtml/PageStyleConverter.java index 0688c92..d649db5 100644 --- a/source/java/writer2latex/xhtml/PageStyleConverter.java +++ b/source/java/writer2latex/xhtml/PageStyleConverter.java @@ -20,7 +20,7 @@ * * All Rights Reserved. * - * Version 1.2 (2011-03-16) + * Version 1.2 (2011-03-21) * */ @@ -168,9 +168,9 @@ public class PageStyleConverter extends StyleConverterHelper { // Background color StyleInfo pageInfo = new StyleInfo(); getFrameSc().cssBackground(pageLayout,pageInfo.props,true); - if (converter.isOPS()) { // Use zero margin for EPUB and default margins for XHTML + /*if (converter.isOPS()) { // Use zero margin for EPUB and default margins for XHTML pageInfo.props.addValue("margin", "0"); - } + }*/ if (pageInfo.hasAttributes()) { buf.append(sIndent).append("body {").append(pageInfo.props.toString()).append("}") .append(config.prettyPrint() ? "\n" : " "); diff --git a/source/oxt/writer2xhtml/Options.xcs b/source/oxt/writer2xhtml/Options.xcs index 4fc7e82..0745c0e 100644 --- a/source/oxt/writer2xhtml/Options.xcs +++ b/source/oxt/writer2xhtml/Options.xcs @@ -61,7 +61,7 @@ - + diff --git a/source/oxt/writer2xhtml/Options.xcu b/source/oxt/writer2xhtml/Options.xcu index 7315009..c3d06e6 100644 --- a/source/oxt/writer2xhtml/Options.xcu +++ b/source/oxt/writer2xhtml/Options.xcu @@ -70,7 +70,7 @@ 100 - + 1 diff --git a/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl b/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl index 41495da..98f22fe 100755 --- a/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl +++ b/source/oxt/writer2xhtml/W2XDialogs2/EpubOptions.xdl @@ -96,7 +96,7 @@ - + diff --git a/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/epub_export.xhp b/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/epub_export.xhp index 769d27d..9e49349 100644 --- a/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/epub_export.xhp +++ b/source/oxt/writer2xhtml/help/en/org.openoffice.da.writer2xhtml.oxt/epub_export.xhp @@ -82,6 +82,7 @@ + Image size Select how to set the image size in the EPUB document Select how to set the image size in the EPUB document