More exquisite bugfixes

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@102 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2011-03-29 10:01:49 +00:00
parent 26de5a45df
commit f19433e716
10 changed files with 95 additions and 43 deletions

View file

@ -2,6 +2,12 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2
---------- version 1.1.7 ---------- ---------- version 1.1.7 ----------
[w2x] Bugfix: Positioning of text boxes (left, right, center, floating) now works correctly
[w2x] Support the value "biggest" for the style:wrap attribute
[w2l] Bugfix: No longer creates run-in headings if bottom margin is zero and formatting>=convert_most
[all] Filter bugfix: Do not exclude surrogate pairs [all] Filter bugfix: Do not exclude surrogate pairs
[w2l] Bugfix: Fixed indentation problem with lists after tables if formatting>=convert_most [w2l] Bugfix: Fixed indentation problem with lists after tables if formatting>=convert_most

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-03-23) * Version 1.2 (2011-03-29)
* *
*/ */
@ -33,7 +33,7 @@ public class ConverterFactory {
// Version information // Version information
private static final String VERSION = "1.1.7"; private static final String VERSION = "1.1.7";
private static final String DATE = "2011-03-23"; private static final String DATE = "2011-03-29";
/** 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

@ -311,7 +311,7 @@ public class BlockConverter extends ConverterHelper {
node.getNodeName().equals(XMLString.TEXT_LIST_HEADER), node.getNodeName().equals(XMLString.TEXT_LIST_HEADER),
"true".equals(node.getAttribute(XMLString.TEXT_RESTART_NUMBERING)), "true".equals(node.getAttribute(XMLString.TEXT_RESTART_NUMBERING)),
Misc.getPosInteger(node.getAttribute(XMLString.TEXT_START_VALUE),1)-1, Misc.getPosInteger(node.getAttribute(XMLString.TEXT_START_VALUE),1)-1,
ba); ba,oc);
// export the list item (note the special treatment of lists in tables) // export the list item (note the special treatment of lists in tables)
if (ba.getBefore().length()>0) { if (ba.getBefore().length()>0) {

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-03-10) * Version 1.2 (2011-03-29)
* *
*/ */
@ -239,7 +239,9 @@ public class HeadingConverter extends ConverterHelper {
// Suppress indentation after heading? currently not.. // Suppress indentation after heading? currently not..
// ldp.append("-"); // ldp.append("-");
ldp.append(sMarginTop) ldp.append(sMarginTop)
.append("}{").append(sMarginBottom).append("}{"); .append("}{")
.append(Misc.isZero(sMarginBottom) ? "0.1mm" : sMarginBottom)
.append("}{");
// Note: decl.getAfter() may include a page break after, which we ignore // Note: decl.getAfter() may include a page break after, which we ignore
ldp.append(decl.getBefore()); ldp.append(decl.getBefore());
if (!comm.isEmpty()) { if (!comm.isEmpty()) {

View file

@ -135,7 +135,7 @@ public class ListStyleConverter extends StyleConverter {
/** <p>Apply a list style to a list item.</p> */ /** <p>Apply a list style to a list item.</p> */
public void applyListItemStyle(String sStyleName, int nLevel, boolean bHeader, public void applyListItemStyle(String sStyleName, int nLevel, boolean bHeader,
boolean bRestart, int nStartValue, BeforeAfter ba) { boolean bRestart, int nStartValue, BeforeAfter ba, Context oc) {
// Step 1. We may have a style map, this always takes precedence // Step 1. We may have a style map, this always takes precedence
String sDisplayName = ofr.getListStyles().getDisplayName(sStyleName); String sDisplayName = ofr.getListStyles().getDisplayName(sStyleName);
if (config.getListItemStyleMap().contains(sDisplayName)) { if (config.getListItemStyleMap().contains(sDisplayName)) {
@ -154,7 +154,9 @@ public class ListStyleConverter extends StyleConverter {
return; return;
} }
// Step 3: Export as default lists (with redefined labels) // Step 3: Export as default lists (with redefined 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 (nLevel<=4) { if (nLevel<=4) {
if (bHeader) { if (bHeader) {
ba.add("\\item[] ",""); ba.add("\\item[] ","");

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-03-22) * Version 1.2 (2011-03-29)
* *
*/ */
@ -232,7 +232,8 @@ public class ParConverter extends StyleConverter {
} }
else { else {
// Export character formatting + alignment only // Export character formatting + alignment only
BeforeAfter baFormat = new BeforeAfter(); BeforeAfter baPar = new BeforeAfter();
BeforeAfter baText = new BeforeAfter();
// Apply hard formatting attributes // Apply hard formatting attributes
// Note: Left justified text is exported as full justified text! // Note: Left justified text is exported as full justified text!
@ -240,25 +241,34 @@ public class ParConverter extends StyleConverter {
if (style!=null) { if (style!=null) {
String sTextAlign = style.getProperty(XMLString.FO_TEXT_ALIGN,true); String sTextAlign = style.getProperty(XMLString.FO_TEXT_ALIGN,true);
if (bLastInBlock && context.isInLastTableColumn()) { // no grouping needed, but need to fix problem with \\ if (bLastInBlock && context.isInLastTableColumn()) { // no grouping needed, but need to fix problem with \\
if ("center".equals(sTextAlign)) { baFormat.add("\\centering\\arraybslash",""); } if ("center".equals(sTextAlign)) { baPar.add("\\centering\\arraybslash",""); }
else if ("end".equals(sTextAlign)) { baFormat.add("\\raggedleft\\arraybslash",""); } else if ("end".equals(sTextAlign)) { baPar.add("\\raggedleft\\arraybslash",""); }
bNeedArrayBslash = true; bNeedArrayBslash = true;
} }
else if (bLastInBlock) { // no \par needed else if (bLastInBlock) { // no \par needed
if ("center".equals(sTextAlign)) { baFormat.add("\\centering",""); } if ("center".equals(sTextAlign)) { baPar.add("\\centering",""); }
else if ("end".equals(sTextAlign)) { baFormat.add("\\raggedleft",""); } else if ("end".equals(sTextAlign)) { baPar.add("\\raggedleft",""); }
} }
else { else {
if ("center".equals(sTextAlign)) { baFormat.add("\\centering","\\par"); } if ("center".equals(sTextAlign)) { baPar.add("\\centering","\\par"); }
else if ("end".equals(sTextAlign)) { baFormat.add("\\raggedleft","\\par"); } else if ("end".equals(sTextAlign)) { baPar.add("\\raggedleft","\\par"); }
} }
palette.getI18n().applyLanguage(style,true,true,baFormat); palette.getI18n().applyLanguage(style,true,true,baText);
palette.getCharSc().applyFont(style,true,true,baFormat,context); palette.getCharSc().applyFont(style,true,true,baText,context);
} }
// If there is any hard character formatting or alignment we must group the contents. // Group the contents if this is not the last paragraph in the cell
if (!baFormat.isEmpty() && !bLastInBlock) { ba.add("{","}"); } boolean bIsGrouped = false;
ba.add(baFormat); if ((!baPar.isEmpty() || !baText.isEmpty()) && !bLastInBlock) {
ba.add("{","}");
bIsGrouped = true;
}
ba.add(baPar);
// Group the text formatting in any case (supertabular needs this)
if (!baText.isEmpty() && !bIsGrouped) {
ba.add("{", "}");
}
ba.add(baText);
if (ba.getBefore().length()>0) { ba.add(" ",""); } if (ba.getBefore().length()>0) { ba.add(" ",""); }
} }

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-03-22) * Version 1.2 (2011-03-29)
* *
*/ */
@ -57,6 +57,19 @@ public class BeforeAfter {
sBefore+=sBefore1; sAfter=sAfter1+sAfter; sBefore+=sBefore1; sAfter=sAfter1+sAfter;
} }
/** <p>Add data to the <code>BeforeAfter</code></p>
* <p>The new data will be be added "outside", thus for example</p>
* <ul><li><code>enclose("\textsf{","}");</code>
* <li><code>enclose("\textit{","}");</code></ul>
* <p>will create the pair <code>\textit{\textsf{</code>, <code>}}</code></p>
*
* @param sBefore1 LaTeX code to put before
* @param sAfter1 LaTeX code to put after
*/
public void enclose(String sBefore1, String sAfter1) {
sBefore=sBefore1+sBefore; sAfter+=sAfter1;
}
/** <p>Add the content of another <code>BeforeAfter</code> to this <code>BeforeAfter</code></p> /** <p>Add the content of another <code>BeforeAfter</code> to this <code>BeforeAfter</code></p>
* <p>The new data will be be added "inside"</p> * <p>The new data will be be added "inside"</p>
* *

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-03-16) * Version 1.2 (2011-03-29)
* *
*/ */
@ -161,8 +161,6 @@ public class Misc{
return n; return n;
} }
//public static int min(int n, int m) { return n<m ? n : m; }
public static String truncateLength(String sValue) { public static String truncateLength(String sValue) {
if (sValue.endsWith("inch")) { if (sValue.endsWith("inch")) {
// Cut of inch to in // Cut of inch to in
@ -173,6 +171,10 @@ public class Misc{
} }
} }
public static boolean isZero(String sValue) {
return Math.abs(getFloat(sValue.substring(0, sValue.length()-2),0))<0.001;
}
// Return units per inch for some unit // Return units per inch for some unit
private static final float getUpi(String sUnit) { private static final float getUpi(String sUnit) {
if ("in".equals(sUnit)) { return 1.0F; } if ("in".equals(sUnit)) { return 1.0F; }

View file

@ -20,7 +20,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Version 1.2 (2011-03-21) * Version 1.2 (2011-03-29)
* *
*/ */
@ -445,17 +445,17 @@ public class DrawConverter extends ConverterHelper {
getFrameSc().applyStyle(sStyleName,info); getFrameSc().applyStyle(sStyleName,info);
} }
// Presentation frame style // Presentation frame style
sStyleName = Misc.getAttribute(frame, XMLString.PRESENTATION_STYLE_NAME); String sPresentationStyleName = Misc.getAttribute(frame, XMLString.PRESENTATION_STYLE_NAME);
if (sStyleName!=null) { if (sPresentationStyleName!=null) {
if ("outline".equals(Misc.getAttribute(frame, XMLString.PRESENTATION_CLASS))) { if ("outline".equals(Misc.getAttribute(frame, XMLString.PRESENTATION_CLASS))) {
getPresentationSc().enterOutline(sStyleName); getPresentationSc().enterOutline(sPresentationStyleName);
} }
getPresentationSc().applyStyle(sStyleName,info); getPresentationSc().applyStyle(sPresentationStyleName,info);
} }
// Additional text formatting // Additional text formatting
sStyleName = Misc.getAttribute(frame, XMLString.DRAW_TEXT_STYLE_NAME); String sTextStyleName = Misc.getAttribute(frame, XMLString.DRAW_TEXT_STYLE_NAME);
if (sStyleName!=null) { if (sTextStyleName!=null) {
//getStyleCv().applyParStyle(sStyleName,info); //getStyleCv().applyParStyle(sTextStyleName,info);
} }
// Apply placement // Apply placement
@ -469,8 +469,8 @@ public class DrawConverter extends ConverterHelper {
applyPosition(frame,info.props); applyPosition(frame,info.props);
break; break;
case CENTERED: case CENTERED:
info.props.addValue("maring-top","2px"); info.props.addValue("margin-top","2px");
info.props.addValue("maring-bottom","2px"); info.props.addValue("margin-bottom","2px");
info.props.addValue("margin-left","auto"); info.props.addValue("margin-left","auto");
info.props.addValue("margin-right","auto"); info.props.addValue("margin-right","auto");
sContentWidth = applyImageSize(frame,info.props,true); sContentWidth = applyImageSize(frame,info.props,true);
@ -481,11 +481,27 @@ public class DrawConverter extends ConverterHelper {
if (style!=null) { if (style!=null) {
String sPos = style.getProperty(XMLString.STYLE_HORIZONTAL_POS); String sPos = style.getProperty(XMLString.STYLE_HORIZONTAL_POS);
String sWrap = style.getProperty(XMLString.STYLE_WRAP); String sWrap = style.getProperty(XMLString.STYLE_WRAP);
if (isLeft(sPos) && mayWrapRight(sWrap)) { if (isLeft(sPos)) {
info.props.addValue("float","left"); if (mayWrapRight(sWrap)) {
info.props.addValue("float","left");
}
else {
// TODO: Remove the margin-right attribute from the existing properties
// and likewise for the other two cases below (requires new CSVList)
info.props.addValue("margin-right", "auto");
}
} }
else if (isRight(sPos) && mayWrapLeft(sWrap)) { else if (isRight(sPos)) {
info.props.addValue("float","right"); if (mayWrapLeft(sWrap)) {
info.props.addValue("float","right");
}
else {
info.props.addValue("margin-left", "auto");
}
}
else if (isCenter(sPos)) {
info.props.addValue("margin-left", "auto");
info.props.addValue("margin-right", "auto");
} }
else if (isFromLeft(sPos)) { else if (isFromLeft(sPos)) {
if (mayWrapRight(sWrap)) { if (mayWrapRight(sWrap)) {
@ -966,9 +982,9 @@ public class DrawConverter extends ConverterHelper {
return "left".equals(sHPos) || "inside".equals(sHPos); return "left".equals(sHPos) || "inside".equals(sHPos);
} }
/*private boolean isCenter(String sHPos) { private boolean isCenter(String sHPos) {
return "center".equals(sHPos); return "center".equals(sHPos);
}*/ }
private boolean isRight(String sHPos) { private boolean isRight(String sHPos) {
return "right".equals(sHPos) || "outside".equals(sHPos); return "right".equals(sHPos) || "outside".equals(sHPos);
@ -979,12 +995,12 @@ public class DrawConverter extends ConverterHelper {
} }
private boolean mayWrapLeft(String sWrap) { private boolean mayWrapLeft(String sWrap) {
return "left".equals(sWrap) || "parallel".equals(sWrap) || return "left".equals(sWrap) || "parallel".equals(sWrap) || "biggest".equals(sWrap) ||
"dynamic".equals(sWrap) || "run-through".equals(sWrap); "dynamic".equals(sWrap) || "run-through".equals(sWrap);
} }
private boolean mayWrapRight(String sWrap) { private boolean mayWrapRight(String sWrap) {
return "right".equals(sWrap) || "parallel".equals(sWrap) || return "right".equals(sWrap) || "parallel".equals(sWrap) || "biggest".equals(sWrap) ||
"dynamic".equals(sWrap) || "run-through".equals(sWrap); "dynamic".equals(sWrap) || "run-through".equals(sWrap);
} }

View file

@ -92,7 +92,8 @@
</listitem> </listitem>
<listitem> <listitem>
<paragraph role="paragraph" xml-lang="en-US"><emph>Use relative size (%)</emph>: Image sizes will be exported as <paragraph role="paragraph" xml-lang="en-US"><emph>Use relative size (%)</emph>: Image sizes will be exported as
percentages. This has the advantage that the image size will adapt to the size of the reader screen.</paragraph> a percentage of the total width.
This has the advantage that the image size will adapt to the size of the reader screen.</paragraph>
</listitem> </listitem>
<listitem> <listitem>
<paragraph role="paragraph" xml-lang="en-US"><emph>Use original image size</emph>: Often images in a %PRODUCTNAME document <paragraph role="paragraph" xml-lang="en-US"><emph>Use original image size</emph>: Often images in a %PRODUCTNAME document