Some minor bugfixes and improvements (border width, StarMath color, hidden text)

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@173 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2014-09-09 18:18:24 +00:00
parent a0b76b3729
commit 5d82772d91
11 changed files with 136 additions and 80 deletions

View file

@ -2,6 +2,15 @@ Changelog for Writer2LaTeX version 1.2 -> 1.4
---------- version 1.3.2 alpha ---------- ---------- version 1.3.2 alpha ----------
[w2l] New option display_hidden_text (default false) to toggle whether or not hidden text should be included in
the export (there is currently no user interface for this option)
[w2l] Bugfix (StarMath conversion): The five colors red, green, blue, magenta and yellow is now exported to the
correct dark colors rather than the previous bright colors (the colors white, black and yellow are unchanged)
[w2x] If a border has a width which is equivalent to less that 1px, it is now exported with the width 1px.
This fixes an issue with some browsers, that would render the border invisible.
[w2x] Two or more span elements in a row with identical attributes are now merged [w2x] Two or more span elements in a row with identical attributes are now merged
[all] Filters: Appended [Writer2LaTeX] or [Writer2xhtml] to all filter UI names to make them more visible [all] Filters: Appended [Writer2LaTeX] or [Writer2xhtml] to all filter UI names to make them more visible
@ -12,9 +21,10 @@ Changelog for Writer2LaTeX version 1.2 -> 1.4
[w2x] Bugfix: Text boxes are no longer lost if within a paragraph [w2x] Bugfix: Text boxes are no longer lost if within a paragraph
[w2x] SVG support in HTML5 is now finished: Vector graphics is converted to SVG (does not work in older versions of LO). [w2x] SVG support in HTML5 is now finished: Images in SVG format are kept in the original format.
The option use_svg has been renamed to inline_svg. If set to true (default) inline SVG is used, if set to false, Other vector images are converted to SVG (filter only). This only works with recent versions of the office
external SVG-files are used. (LO 4.2 and AOO 4.1 are known to work). The option use_svg has been renamed to inline_svg. If set to
true (default) inline SVG is used, if set to false, external SVG-files (img-elements) are used.
[all] If an image image cannot be converted to an acceptable format, the optional alternative image will now be tried [all] If an image image cannot be converted to an acceptable format, the optional alternative image will now be tried

Binary file not shown.

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-06) * Version 1.4 (2014-09-08)
* *
*/ */
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information // Version information
private static final String VERSION = "1.3.2"; private static final String VERSION = "1.3.2";
private static final String DATE = "2014-09-06"; private static final String DATE = "2014-09-08";
/** Return the Writer2LaTeX version in the form /** Return the Writer2LaTeX version in the form
* (major version).(minor version).(patch level)<br/> * (major version).(minor version).(patch level)<br/>

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* version 1.4 (2014-08-27) * version 1.4 (2014-09-07)
* *
*/ */
@ -116,11 +116,12 @@ public class EPUBWriter implements OutputFile {
} }
private void writeZipEntry(OutputFile file, ZipOutputStream zos) throws IOException { private void writeZipEntry(OutputFile file, ZipOutputStream zos) throws IOException {
// TODO: Fix this waste of memory :-) // Unfortunately we cannot simply do file.write(zos) because the write method of OutputFile
// closes the OutputStream. Hence this suboptimal solution
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
file.write(baos); file.write(baos);
byte[] content = baos.toByteArray(); byte[] content = baos.toByteArray();
zos.write(content, 0, content.length); zos.write(content, 0, content.length);
} }
} }

View file

@ -16,28 +16,28 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2012 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2012-03-05) * Version 1.4 (2014-09-08)
* *
*/ */
package writer2latex.latex; package writer2latex.latex;
//import java.util.Hashtable;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import writer2latex.util.*;
import writer2latex.office.*;
import writer2latex.latex.util.BeforeAfter; import writer2latex.latex.util.BeforeAfter;
import writer2latex.latex.util.Context; import writer2latex.latex.util.Context;
import writer2latex.latex.util.HeadingMap; import writer2latex.latex.util.HeadingMap;
//import writer2latex.latex.util.StyleMap; import writer2latex.office.ListStyle;
import writer2latex.office.OfficeReader;
import writer2latex.office.StyleWithProperties;
import writer2latex.office.XMLString;
import writer2latex.util.Misc;
/* This class converts OpenDocument headings (<code>text:h</code>) and /* This class converts OpenDocument headings (<code>text:h</code>) and
* paragraph styles/formatting into LaTeX * paragraph styles/formatting into LaTeX
@ -52,12 +52,15 @@ import writer2latex.latex.util.HeadingMap;
*/ */
public class HeadingConverter extends ConverterHelper { public class HeadingConverter extends ConverterHelper {
private String[] sHeadingStyles = new String[11]; private String[] sHeadingStyles = new String[11];
// Display hidden text?
private boolean bDisplayHiddenText = false;
/** Constructs a new <code>HeadingConverter</code>. /** Constructs a new <code>HeadingConverter</code>.
*/ */
public HeadingConverter(OfficeReader ofr, LaTeXConfig config, public HeadingConverter(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
ConverterPalette palette) {
super(ofr,config,palette); super(ofr,config,palette);
this.bDisplayHiddenText = config.displayHiddenText();
} }
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) { public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
@ -70,18 +73,27 @@ public class HeadingConverter extends ConverterHelper {
* @param oc The current context * @param oc The current context
*/ */
public void handleHeading(Element node, LaTeXDocumentPortion ldp, Context oc) { public void handleHeading(Element node, LaTeXDocumentPortion ldp, Context oc) {
// Get the level, the heading map and the style name // Get the style
String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
StyleWithProperties style = ofr.getParStyle(sStyleName);
// Check for hidden text
if (!bDisplayHiddenText && style!=null && "none".equals(style.getProperty(XMLString.TEXT_DISPLAY))) {
return;
}
// Get the level
int nLevel = ofr.isOpenDocument() ? int nLevel = ofr.isOpenDocument() ?
Misc.getPosInteger(Misc.getAttribute(node, XMLString.TEXT_OUTLINE_LEVEL),1) : Misc.getPosInteger(Misc.getAttribute(node, XMLString.TEXT_OUTLINE_LEVEL),1) :
Misc.getPosInteger(Misc.getAttribute(node, XMLString.TEXT_LEVEL),1); Misc.getPosInteger(Misc.getAttribute(node, XMLString.TEXT_LEVEL),1);
boolean bUnNumbered = "true".equals(Misc.getAttribute(node,XMLString.TEXT_IS_LIST_HEADER)); boolean bUnNumbered = "true".equals(Misc.getAttribute(node,XMLString.TEXT_IS_LIST_HEADER));
// Get the heading map
HeadingMap hm = config.getHeadingMap(); HeadingMap hm = config.getHeadingMap();
String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
if (nLevel<=hm.getMaxLevel()) { if (nLevel<=hm.getMaxLevel()) {
// Always push the font used // Always push the font used
palette.getI18n().pushSpecialTable(palette.getCharSc().getFontName(ofr.getParStyle(sStyleName))); palette.getI18n().pushSpecialTable(palette.getCharSc().getFontName(style));
Context ic = (Context) oc.clone(); Context ic = (Context) oc.clone();
ic.setInSection(true); ic.setInSection(true);
@ -126,7 +138,6 @@ public class HeadingConverter extends ConverterHelper {
} }
} }
/** Use a paragraph style on a heading. If hard paragraph formatting /** Use a paragraph style on a heading. If hard paragraph formatting
* is applied to a heading, page break and font is converted - other * is applied to a heading, page break and font is converted - other
* hard formatting is ignored. * hard formatting is ignored.
@ -416,5 +427,4 @@ public class HeadingConverter extends ConverterHelper {
} }
} }
} }

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2011 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-02-01) * Version 1.4 (2014-09-08)
* *
*/ */
@ -42,6 +42,9 @@ import writer2latex.latex.util.HeadingMap;
* <p>This class handles basic inline text.</p> * <p>This class handles basic inline text.</p>
*/ */
public class InlineConverter extends ConverterHelper { public class InlineConverter extends ConverterHelper {
// Display hidden text?
private boolean bDisplayHiddenText = false;
private boolean bIncludeOriginalCitations = false; private boolean bIncludeOriginalCitations = false;
private String sTabstop = "\\ \\ "; private String sTabstop = "\\ \\ ";
@ -54,6 +57,7 @@ public class InlineConverter extends ConverterHelper {
if (config.getTabstop().length()>0) { if (config.getTabstop().length()>0) {
sTabstop = config.getTabstop(); sTabstop = config.getTabstop();
} }
this.bDisplayHiddenText = config.displayHiddenText();
} }
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) { public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
@ -78,6 +82,11 @@ public class InlineConverter extends ConverterHelper {
// TODO: Handle a selection of formatting attributes: color, supscript... // TODO: Handle a selection of formatting attributes: color, supscript...
String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME); String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
StyleWithProperties style = ofr.getTextStyle(sStyleName); StyleWithProperties style = ofr.getTextStyle(sStyleName);
// Check for hidden text
if (!bDisplayHiddenText && style!=null && "none".equals(style.getProperty(XMLString.TEXT_DISPLAY))) {
return;
}
// Always push the font used // Always push the font used
palette.getI18n().pushSpecialTable(palette.getCharSc().getFontName(style)); palette.getI18n().pushSpecialTable(palette.getCharSc().getFontName(style));
@ -105,10 +114,16 @@ public class InlineConverter extends ConverterHelper {
} }
private void handleTextSpanText(Element node, LaTeXDocumentPortion ldp, Context oc) { private void handleTextSpanText(Element node, LaTeXDocumentPortion ldp, Context oc) {
String styleName = node.getAttribute(XMLString.TEXT_STYLE_NAME); String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
StyleWithProperties style = ofr.getTextStyle(sStyleName);
// Check for hidden text
if (!bDisplayHiddenText && style!=null && "none".equals(style.getProperty(XMLString.TEXT_DISPLAY))) {
return;
}
// Check for strict handling of styles // Check for strict handling of styles
String sDisplayName = ofr.getTextStyles().getDisplayName(styleName); String sDisplayName = ofr.getTextStyles().getDisplayName(sStyleName);
if (config.otherStyles()!=LaTeXConfig.ACCEPT && !config.getTextStyleMap().contains(sDisplayName)) { if (config.otherStyles()!=LaTeXConfig.ACCEPT && !config.getTextStyleMap().contains(sDisplayName)) {
if (config.otherStyles()==LaTeXConfig.WARNING) { if (config.otherStyles()==LaTeXConfig.WARNING) {
System.err.println("Warning: Text with style "+sDisplayName+" was ignored"); System.err.println("Warning: Text with style "+sDisplayName+" was ignored");
@ -133,12 +148,12 @@ public class InlineConverter extends ConverterHelper {
boolean bNoFootnotes = false; boolean bNoFootnotes = false;
// Always push the font used // Always push the font used
palette.getI18n().pushSpecialTable(palette.getCharSc().getFontName(ofr.getTextStyle(styleName))); palette.getI18n().pushSpecialTable(palette.getCharSc().getFontName(ofr.getTextStyle(sStyleName)));
// Apply the style // Apply the style
BeforeAfter ba = new BeforeAfter(); BeforeAfter ba = new BeforeAfter();
Context ic = (Context) oc.clone(); Context ic = (Context) oc.clone();
if (styled) { palette.getCharSc().applyTextStyle(styleName,ba,ic); } if (styled) { palette.getCharSc().applyTextStyle(sStyleName,ba,ic); }
// Footnote problems: // Footnote problems:
// No footnotes in sub/superscript (will disappear) // No footnotes in sub/superscript (will disappear)
@ -148,7 +163,6 @@ public class InlineConverter extends ConverterHelper {
// Temp solution: Ignore hard formatting in header/footer (name clash problem) // Temp solution: Ignore hard formatting in header/footer (name clash problem)
// only in package format. // only in package format.
StyleWithProperties style = ofr.getTextStyle(styleName);
if (ofr.isPackageFormat() && (style!=null && style.isAutomatic()) && ic.isInHeaderFooter()) { if (ofr.isPackageFormat() && (style!=null && style.isAutomatic()) && ic.isInHeaderFooter()) {
styled = false; styled = false;
} }

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-08-05) * Version 1.4 (2014-09-08)
* *
*/ */
@ -49,7 +49,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// I. Define items needed by ConfigBase // I. Define items needed by ConfigBase
protected int getOptionCount() { return 70; } protected int getOptionCount() { return 71; }
protected String getDefaultConfigPath() { return "/writer2latex/latex/config/"; } protected String getDefaultConfigPath() { return "/writer2latex/latex/config/"; }
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
@ -163,24 +163,25 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
private static final int IGNORE_HARD_LINE_BREAKS = 49; private static final int IGNORE_HARD_LINE_BREAKS = 49;
private static final int IGNORE_EMPTY_PARAGRAPHS =50; private static final int IGNORE_EMPTY_PARAGRAPHS =50;
private static final int IGNORE_DOUBLE_SPACES = 51; private static final int IGNORE_DOUBLE_SPACES = 51;
private static final int ALIGN_FRAMES = 52; private static final int DISPLAY_HIDDEN_TEXT = 52;
private static final int FLOAT_FIGURES = 53; private static final int ALIGN_FRAMES = 53;
private static final int FLOAT_TABLES = 54; private static final int FLOAT_FIGURES = 54;
private static final int FLOAT_OPTIONS = 55; private static final int FLOAT_TABLES = 55;
private static final int FIGURE_SEQUENCE_NAME = 56; private static final int FLOAT_OPTIONS = 56;
private static final int TABLE_SEQUENCE_NAME = 57; private static final int FIGURE_SEQUENCE_NAME = 57;
private static final int IMAGE_OPTIONS = 58; private static final int TABLE_SEQUENCE_NAME = 58;
private static final int REMOVE_GRAPHICS_EXTENSION = 59; private static final int IMAGE_OPTIONS = 59;
private static final int ORIGINAL_IMAGE_SIZE = 60; private static final int REMOVE_GRAPHICS_EXTENSION = 60;
private static final int SIMPLE_TABLE_LIMIT = 61; private static final int ORIGINAL_IMAGE_SIZE = 61;
private static final int NOTES = 62; private static final int SIMPLE_TABLE_LIMIT = 62;
private static final int METADATA = 63; private static final int NOTES = 63;
private static final int TABSTOP = 64; private static final int METADATA = 64;
private static final int WRAP_LINES_AFTER = 65; private static final int TABSTOP = 65;
private static final int SPLIT_LINKED_SECTIONS = 66; private static final int WRAP_LINES_AFTER = 66;
private static final int SPLIT_TOPLEVEL_SECTIONS = 67; private static final int SPLIT_LINKED_SECTIONS = 67;
private static final int SAVE_IMAGES_IN_SUBDIR = 68; private static final int SPLIT_TOPLEVEL_SECTIONS = 68;
private static final int DEBUG = 69; private static final int SAVE_IMAGES_IN_SUBDIR = 69;
private static final int DEBUG = 70;
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// IV. Our options data // IV. Our options data
@ -288,6 +289,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
options[IGNORE_HARD_LINE_BREAKS] = new BooleanOption("ignore_hard_line_breaks","false"); options[IGNORE_HARD_LINE_BREAKS] = new BooleanOption("ignore_hard_line_breaks","false");
options[IGNORE_EMPTY_PARAGRAPHS] = new BooleanOption("ignore_empty_paragraphs","false"); options[IGNORE_EMPTY_PARAGRAPHS] = new BooleanOption("ignore_empty_paragraphs","false");
options[IGNORE_DOUBLE_SPACES] = new BooleanOption("ignore_double_spaces","false"); options[IGNORE_DOUBLE_SPACES] = new BooleanOption("ignore_double_spaces","false");
options[DISPLAY_HIDDEN_TEXT] = new BooleanOption("display_hidden_text","false");
options[ALIGN_FRAMES] = new BooleanOption("align_frames","true"); options[ALIGN_FRAMES] = new BooleanOption("align_frames","true");
options[FLOAT_FIGURES] = new BooleanOption("float_figures","false"); options[FLOAT_FIGURES] = new BooleanOption("float_figures","false");
options[FLOAT_TABLES] = new BooleanOption("float_tables","false"); options[FLOAT_TABLES] = new BooleanOption("float_tables","false");
@ -700,6 +702,7 @@ public class LaTeXConfig extends writer2latex.base.ConfigBase {
public boolean ignoreHardLineBreaks() { return ((BooleanOption) options[IGNORE_HARD_LINE_BREAKS]).getValue(); } public boolean ignoreHardLineBreaks() { return ((BooleanOption) options[IGNORE_HARD_LINE_BREAKS]).getValue(); }
public boolean ignoreEmptyParagraphs() { return ((BooleanOption) options[IGNORE_EMPTY_PARAGRAPHS]).getValue(); } public boolean ignoreEmptyParagraphs() { return ((BooleanOption) options[IGNORE_EMPTY_PARAGRAPHS]).getValue(); }
public boolean ignoreDoubleSpaces() { return ((BooleanOption) options[IGNORE_DOUBLE_SPACES]).getValue(); } public boolean ignoreDoubleSpaces() { return ((BooleanOption) options[IGNORE_DOUBLE_SPACES]).getValue(); }
public boolean displayHiddenText() { return ((BooleanOption) options[DISPLAY_HIDDEN_TEXT]).getValue(); }
// Graphics options // Graphics options
public boolean alignFrames() { return ((BooleanOption) options[ALIGN_FRAMES]).getValue(); } public boolean alignFrames() { return ((BooleanOption) options[ALIGN_FRAMES]).getValue(); }

View file

@ -20,25 +20,22 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.4 (2014-09-02) * Version 1.4 (2014-09-08)
* *
*/ */
package writer2latex.latex; package writer2latex.latex;
//import java.util.Hashtable;
import org.w3c.dom.Element; import org.w3c.dom.Element;
//import org.w3c.dom.Node;
//import org.w3c.dom.NodeList;
import writer2latex.util.*;
import writer2latex.office.*;
import writer2latex.latex.util.BeforeAfter; import writer2latex.latex.util.BeforeAfter;
import writer2latex.latex.util.Context; import writer2latex.latex.util.Context;
import writer2latex.latex.util.StyleMapItem; import writer2latex.latex.util.StyleMapItem;
//import writer2latex.latex.util.HeadingMap;
import writer2latex.latex.util.StyleMap; import writer2latex.latex.util.StyleMap;
import writer2latex.office.OfficeReader;
import writer2latex.office.StyleWithProperties;
import writer2latex.office.XMLString;
import writer2latex.util.Misc;
/* <p>This class converts OpenDocument paragraphs (<code>text:p</code>) and /* <p>This class converts OpenDocument paragraphs (<code>text:p</code>) and
* paragraph styles/formatting into LaTeX</p> * paragraph styles/formatting into LaTeX</p>
@ -55,12 +52,15 @@ import writer2latex.latex.util.StyleMap;
public class ParConverter extends StyleConverter { public class ParConverter extends StyleConverter {
private boolean bNeedArrayBslash = false; private boolean bNeedArrayBslash = false;
// Display hidden text?
private boolean bDisplayHiddenText = false;
/** <p>Constructs a new <code>ParConverter</code>.</p> /** <p>Constructs a new <code>ParConverter</code>.</p>
*/ */
public ParConverter(OfficeReader ofr, LaTeXConfig config, public ParConverter(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
ConverterPalette palette) {
super(ofr,config,palette); super(ofr,config,palette);
this.bDisplayHiddenText = config.displayHiddenText();
} }
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) { public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
@ -90,7 +90,7 @@ public class ParConverter extends StyleConverter {
/** /**
* <p> Process a text:p tag</p> * <p> Process a text:p tag</p>
* @param node The text:h element node containing the heading * @param node The text:p element node containing the paragraph
* @param ldp The <code>LaTeXDocumentPortion</code> to add LaTeX code to * @param ldp The <code>LaTeXDocumentPortion</code> to add LaTeX code to
* @param oc The current context * @param oc The current context
* @param bLastInBlock If this is true, the paragraph is the * @param bLastInBlock If this is true, the paragraph is the
@ -101,9 +101,15 @@ public class ParConverter extends StyleConverter {
// Check for display equation (except in table cells) // Check for display equation (except in table cells)
if ((!oc.isInTable()) && palette.getMathCv().handleDisplayEquation(node,ldp)) { return; } if ((!oc.isInTable()) && palette.getMathCv().handleDisplayEquation(node,ldp)) { return; }
// Get the style name for this paragraph // Get the style for this paragraph
String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME); String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
StyleWithProperties style = ofr.getParStyle(sStyleName);
String sDisplayName = ofr.getParStyles().getDisplayName(sStyleName); String sDisplayName = ofr.getParStyles().getDisplayName(sStyleName);
// Check for hidden text
if (!bDisplayHiddenText && style!=null && "none".equals(style.getProperty(XMLString.TEXT_DISPLAY))) {
return;
}
// Check for strict handling of styles // Check for strict handling of styles
if (config.otherStyles()!=LaTeXConfig.ACCEPT && !config.getParStyleMap().contains(sDisplayName)) { if (config.otherStyles()!=LaTeXConfig.ACCEPT && !config.getParStyleMap().contains(sDisplayName)) {
@ -128,7 +134,6 @@ public class ParConverter extends StyleConverter {
if (OfficeReader.isWhitespaceContent(node)) { if (OfficeReader.isWhitespaceContent(node)) {
// Always add page break; other formatting is ignored // Always add page break; other formatting is ignored
BeforeAfter baPage = new BeforeAfter(); BeforeAfter baPage = new BeforeAfter();
StyleWithProperties style = ofr.getParStyle(sStyleName);
palette.getPageSc().applyPageBreak(style,true,baPage); palette.getPageSc().applyPageBreak(style,true,baPage);
if (!oc.isInTable()) { ldp.append(baPage.getBefore()); } if (!oc.isInTable()) { ldp.append(baPage.getBefore()); }
if (!config.ignoreEmptyParagraphs()) { if (!config.ignoreEmptyParagraphs()) {

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2011 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-01-24) * Version 1.4 (2014-09-08)
* *
*/ */
@ -45,15 +45,18 @@ public class SectionConverter extends ConverterHelper {
// Do we need multicols.sty? // Do we need multicols.sty?
private boolean bNeedMulticol = false; private boolean bNeedMulticol = false;
// Display hidden text?
private boolean bDisplayHiddenText = false;
// Filenames for external sections // Filenames for external sections
private ExportNameCollection fileNames = new ExportNameCollection(true); private ExportNameCollection fileNames = new ExportNameCollection(true);
/** <p>Constructs a new <code>SectionStyleConverter</code>.</p> /** <p>Constructs a new <code>SectionStyleConverter</code>.</p>
*/ */
public SectionConverter(OfficeReader ofr, LaTeXConfig config, public SectionConverter(OfficeReader ofr, LaTeXConfig config, ConverterPalette palette) {
ConverterPalette palette) {
super(ofr,config,palette); super(ofr,config,palette);
this.bDisplayHiddenText = config.displayHiddenText();
} }
public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) { public void appendDeclarations(LaTeXDocumentPortion pack, LaTeXDocumentPortion decl) {
@ -143,6 +146,11 @@ public class SectionConverter extends ConverterHelper {
* @param oc the current context * @param oc the current context
*/ */
public void handleSection(Element node, LaTeXDocumentPortion ldp, Context oc) { public void handleSection(Element node, LaTeXDocumentPortion ldp, Context oc) {
// Unlike headings, paragraphs and spans, text:display is not attached to the style:
if (!bDisplayHiddenText && "none".equals(Misc.getAttribute(node,XMLString.TEXT_DISPLAY))) {
return;
}
// We may need a hyperlink target, add this first // We may need a hyperlink target, add this first
palette.getFieldCv().addTarget(node,"|region",ldp); palette.getFieldCv().addTarget(node,"|region",ldp);

View file

@ -18,7 +18,7 @@
* *
* Copyright: 2002-2014 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* Version 1.4 (2014-09-03) * Version 1.4 (2014-09-08)
* *
* All Rights Reserved. * All Rights Reserved.
*/ */
@ -421,8 +421,8 @@ class SmTokenTable{
new SmTokenTableEntry( "backepsilon" , Token.BACKEPSILON, "\\backepsilon ", TGroup.STANDALONE, 5), new SmTokenTableEntry( "backepsilon" , Token.BACKEPSILON, "\\backepsilon ", TGroup.STANDALONE, 5),
new SmTokenTableEntry( "bar", Token.BAR, "\\bar", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "bar", Token.BAR, "\\bar", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "binom", Token.BINOM, "" , 5 ), new SmTokenTableEntry( "binom", Token.BINOM, "" , 5 ),
new SmTokenTableEntry( "black", Token.BLACK, "black", TGroup.COLOR, 0), new SmTokenTableEntry( "black", Token.BLACK, "\\textcolor{black}", TGroup.COLOR, 0),
new SmTokenTableEntry( "blue", Token.BLUE, "blue", TGroup.COLOR, 0), new SmTokenTableEntry( "blue", Token.BLUE, "\\textcolor[rgb]{0,0,0.5}", TGroup.COLOR, 0),
new SmTokenTableEntry( "bold", Token.BOLD, "\\boldsubformula", TGroup.FONTATTR, 5), new SmTokenTableEntry( "bold", Token.BOLD, "\\boldsubformula", TGroup.FONTATTR, 5),
new SmTokenTableEntry( "boper", Token.BOPER, "", TGroup.PRODUCT, 0), new SmTokenTableEntry( "boper", Token.BOPER, "", TGroup.PRODUCT, 0),
new SmTokenTableEntry( "breve", Token.BREVE, "\\breve", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "breve", Token.BREVE, "\\breve", TGroup.ATTRIBUT, 5),
@ -439,7 +439,7 @@ class SmTokenTable{
new SmTokenTableEntry( "coth", Token.COTH, "\\coth ", TGroup.FUNCTION, 5), new SmTokenTableEntry( "coth", Token.COTH, "\\coth ", TGroup.FUNCTION, 5),
new SmTokenTableEntry( "csub", Token.CSUB, "", TGroup.POWER, 0), new SmTokenTableEntry( "csub", Token.CSUB, "", TGroup.POWER, 0),
new SmTokenTableEntry( "csup", Token.CSUP, "", TGroup.POWER, 0), new SmTokenTableEntry( "csup", Token.CSUP, "", TGroup.POWER, 0),
new SmTokenTableEntry( "cyan", Token.CYAN, "cyan", TGroup.COLOR, 0), new SmTokenTableEntry( "cyan", Token.CYAN, "\\textcolor[rgb]{0,0.5,0.5}", TGroup.COLOR, 0),
new SmTokenTableEntry( "dddot", Token.DDDOT, "\\dddot", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "dddot", Token.DDDOT, "\\dddot", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "ddot", Token.DDOT, "\\ddot", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "ddot", Token.DDOT, "\\ddot", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "def", Token.DEF, "\\defeq ", TGroup.RELATION, 0), new SmTokenTableEntry( "def", Token.DEF, "\\defeq ", TGroup.RELATION, 0),
@ -471,7 +471,7 @@ class SmTokenTable{
new SmTokenTableEntry( "geslant", Token.GESLANT, "\\geqslant ", TGroup.RELATION, 0 ), new SmTokenTableEntry( "geslant", Token.GESLANT, "\\geqslant ", TGroup.RELATION, 0 ),
new SmTokenTableEntry( "gg", Token.GG, "\\gg ", TGroup.RELATION, 0), new SmTokenTableEntry( "gg", Token.GG, "\\gg ", TGroup.RELATION, 0),
new SmTokenTableEntry( "grave", Token.GRAVE, "\\grave", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "grave", Token.GRAVE, "\\grave", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "green", Token.GREEN, "green", TGroup.COLOR, 0), new SmTokenTableEntry( "green", Token.GREEN, "\\textcolor[rgb]{0,0.5,0}", TGroup.COLOR, 0),
new SmTokenTableEntry( "gt", Token.GT, ">", TGroup.RELATION, 0), new SmTokenTableEntry( "gt", Token.GT, ">", TGroup.RELATION, 0),
new SmTokenTableEntry( "hat", Token.HAT, "\\hat", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "hat", Token.HAT, "\\hat", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "hbar" , Token.HBAR, "\\hbar ", TGroup.STANDALONE, 5), new SmTokenTableEntry( "hbar" , Token.HBAR, "\\hbar ", TGroup.STANDALONE, 5),
@ -508,7 +508,7 @@ class SmTokenTable{
new SmTokenTableEntry( "lsub", Token.LSUB, "", TGroup.POWER, 0), new SmTokenTableEntry( "lsub", Token.LSUB, "", TGroup.POWER, 0),
new SmTokenTableEntry( "lsup", Token.LSUP, "", TGroup.POWER, 0), new SmTokenTableEntry( "lsup", Token.LSUP, "", TGroup.POWER, 0),
new SmTokenTableEntry( "lt", Token.LT, "<", TGroup.RELATION, 0), new SmTokenTableEntry( "lt", Token.LT, "<", TGroup.RELATION, 0),
new SmTokenTableEntry( "magenta", Token.MAGENTA, "magenta", TGroup.COLOR, 0), new SmTokenTableEntry( "magenta", Token.MAGENTA, "\\textcolor[rgb]{0.5,0,0.5}", TGroup.COLOR, 0),
new SmTokenTableEntry( "matrix", Token.MATRIX, "", 5), new SmTokenTableEntry( "matrix", Token.MATRIX, "", 5),
new SmTokenTableEntry( "minusplus", Token.MINUSPLUS, "\\mp ", TGroup.UNOPER, TGroup.SUM, 5), new SmTokenTableEntry( "minusplus", Token.MINUSPLUS, "\\mp ", TGroup.UNOPER, TGroup.SUM, 5),
new SmTokenTableEntry( "mline", Token.MLINE, "", 0), new SmTokenTableEntry( "mline", Token.MLINE, "", 0),
@ -551,7 +551,7 @@ class SmTokenTable{
new SmTokenTableEntry( "rceil", Token.RCEIL, "\\rceil ", TGroup.RBRACES, 0), new SmTokenTableEntry( "rceil", Token.RCEIL, "\\rceil ", TGroup.RBRACES, 0),
new SmTokenTableEntry( "rdbracket", Token.RDBRACKET, "\\rrbracket ", TGroup.RBRACES, 0), new SmTokenTableEntry( "rdbracket", Token.RDBRACKET, "\\rrbracket ", TGroup.RBRACES, 0),
new SmTokenTableEntry( "rdline", Token.RDLINE, "\\|", TGroup.RBRACES, 0), new SmTokenTableEntry( "rdline", Token.RDLINE, "\\|", TGroup.RBRACES, 0),
new SmTokenTableEntry( "red", Token.RED, "red", TGroup.COLOR, 0), new SmTokenTableEntry( "red", Token.RED, "\\textcolor[rgb]{0.5,0,0}", TGroup.COLOR, 0),
new SmTokenTableEntry( "rfloor", Token.RFLOOR, "\\rfloor", TGroup.RBRACES, 0), new SmTokenTableEntry( "rfloor", Token.RFLOOR, "\\rfloor", TGroup.RBRACES, 0),
new SmTokenTableEntry( "right", Token.RIGHT, "", 0), new SmTokenTableEntry( "right", Token.RIGHT, "", 0),
new SmTokenTableEntry( "rightarrow" , Token.RIGHTARROW, "\\rightarrow ", TGroup.STANDALONE, 5), new SmTokenTableEntry( "rightarrow" , Token.RIGHTARROW, "\\rightarrow ", TGroup.STANDALONE, 5),
@ -595,14 +595,14 @@ class SmTokenTable{
new SmTokenTableEntry( "uoper", Token.UOPER, "", TGroup.UNOPER, 5), new SmTokenTableEntry( "uoper", Token.UOPER, "", TGroup.UNOPER, 5),
new SmTokenTableEntry( "uparrow" , Token.UPARROW, "\\uparrow ", TGroup.STANDALONE, 5), new SmTokenTableEntry( "uparrow" , Token.UPARROW, "\\uparrow ", TGroup.STANDALONE, 5),
new SmTokenTableEntry( "vec", Token.VEC, "\\vec", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "vec", Token.VEC, "\\vec", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "white", Token.WHITE, "white", TGroup.COLOR, 0), new SmTokenTableEntry( "white", Token.WHITE, "\\textcolor{white}", TGroup.COLOR, 0),
new SmTokenTableEntry( "widebslash", Token.WIDEBACKSLASH, "", TGroup.PRODUCT, 0 ), new SmTokenTableEntry( "widebslash", Token.WIDEBACKSLASH, "", TGroup.PRODUCT, 0 ),
new SmTokenTableEntry( "widehat", Token.WIDEHAT, "\\widehat ", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "widehat", Token.WIDEHAT, "\\widehat ", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "widetilde", Token.WIDETILDE, "\\widetilde", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "widetilde", Token.WIDETILDE, "\\widetilde", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "wideslash", Token.WIDESLASH, "", TGroup.PRODUCT, 0 ), new SmTokenTableEntry( "wideslash", Token.WIDESLASH, "", TGroup.PRODUCT, 0 ),
new SmTokenTableEntry( "widevec", Token.WIDEVEC, "\\overrightarrow", TGroup.ATTRIBUT, 5), new SmTokenTableEntry( "widevec", Token.WIDEVEC, "\\overrightarrow", TGroup.ATTRIBUT, 5),
new SmTokenTableEntry( "wp" , Token.WP, "\\wp ", TGroup.STANDALONE, 5), new SmTokenTableEntry( "wp" , Token.WP, "\\wp ", TGroup.STANDALONE, 5),
new SmTokenTableEntry( "yellow", Token.YELLOW, "yellow", TGroup.COLOR, 0), new SmTokenTableEntry( "yellow", Token.YELLOW, "\\textcolor{yellow}", TGroup.COLOR, 0),
new SmTokenTableEntry( "nospace", Token.NOSPACE, "", TGroup.ATTRIBUT, 0), new SmTokenTableEntry( "nospace", Token.NOSPACE, "", TGroup.ATTRIBUT, 0),
// nospace is flagged as standalone in parse.cxx for some reason, but is really treated like an attribute // nospace is flagged as standalone in parse.cxx for some reason, but is really treated like an attribute
new SmTokenTableEntry( "prec", Token.PREC, "\\prec ", TGroup.RELATION, 0), new SmTokenTableEntry( "prec", Token.PREC, "\\prec ", TGroup.RELATION, 0),
@ -1442,8 +1442,10 @@ public final class StarMathConverter implements writer2latex.api.StarMathConvert
sAttribute=curToken.sLaTeX; // the color name sAttribute=curToken.sLaTeX; // the color name
nextToken(); nextToken();
if (bUseColor) { if (bUseColor) {
return "\\textcolor{"+sAttribute+"}"+group(term(fSize,eAlign)); // The attribute contains the appropriate \textcolor command
// note: despite the name, \textcolor also works in math mode! // Note: 5 of the 8 colors are in a dark variant
// Note: despite the name, \textcolor also works in math mode!
return sAttribute+group(term(fSize,eAlign));
} }
else { else {
return term(fSize,eAlign); return term(fSize,eAlign);

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
* Copyright: 2002-2010 by Henrik Just * Copyright: 2002-2014 by Henrik Just
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2010-03-01) * Version 1.4 (2014-09-07)
* *
*/ */
@ -33,6 +33,7 @@ import writer2latex.office.OfficeStyleFamily;
import writer2latex.office.StyleWithProperties; import writer2latex.office.StyleWithProperties;
import writer2latex.office.XMLString; import writer2latex.office.XMLString;
import writer2latex.util.CSVList; import writer2latex.util.CSVList;
import writer2latex.util.Misc;
//import writer2latex.util.Misc; //import writer2latex.util.Misc;
import writer2latex.util.SimpleInputBuffer; import writer2latex.util.SimpleInputBuffer;
@ -272,7 +273,9 @@ public class FrameStyleConverter extends StyleWithPropertiesConverterHelper {
while(in.peekChar()==' ') { out.append(" "); in.getChar(); } while(in.peekChar()==' ') { out.append(" "); in.getChar(); }
// If it's a number it must be a unit -> convert it // If it's a number it must be a unit -> convert it
if ('0'<=in.peekChar() && in.peekChar()<='9') { if ('0'<=in.peekChar() && in.peekChar()<='9') {
out.append(scale(in.getNumber()+in.getIdentifier())); String sDim = scale(in.getNumber()+in.getIdentifier());
// Do not output a border less than 1px wide - some browsers will render it invisible
out.append(Misc.isLessThan(sDim, "1px") ? "1px" : sDim);
} }
// skip other characters // skip other characters
while (in.peekChar()!=' ' && in.peekChar()!='\0') { while (in.peekChar()!=' ' && in.peekChar()!='\0') {