W2L display equations + W2X list numbering enhancements

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@61 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2010-05-04 08:25:15 +00:00
parent 0e243c0ad7
commit 54a7c265f2
11 changed files with 231 additions and 103 deletions

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.2 (2010-03-01)
* Version 1.2 (2010-05-04)
*
*/
@ -102,6 +102,18 @@ public class ListStyleConverter extends StyleConverterHelper {
buf.append(props.toString());
buf.append("}");
buf.append(config.prettyPrint() ? "\n" : " ");
if (config.useHardListNumbering()) {
// Apply left margin and text indent to the paragraphs contained in the list
CSVList parProps = new CSVList(";");
cssListParMargins(style,nLevel,parProps);
if (!parProps.isEmpty()) {
buf.append(sIndent)
.append(".listlevel")
.append(nLevel)
.append(styleNames.getExportName(sDisplayName))
.append(" p {").append(parProps.toString()).append("}").append(config.prettyPrint() ? "\n" : " ");
}
}
}
}
}
@ -125,33 +137,73 @@ public class ListStyleConverter extends StyleConverterHelper {
// so we will stick with the simpler CSS1-like list style properties
props.addValue("margin-top","0");
props.addValue("margin-bottom","0");
String sLevelType = style.getLevelType(nLevel);
if (XMLString.TEXT_LIST_LEVEL_STYLE_NUMBER.equals(sLevelType)) {
// Numbering style, get number format
String sNumFormat = style.getLevelProperty(nLevel,XMLString.STYLE_NUM_FORMAT);
if ("1".equals(sNumFormat)) { props.addValue("list-style-type","decimal"); }
else if ("i".equals(sNumFormat)) { props.addValue("list-style-type","lower-roman"); }
else if ("I".equals(sNumFormat)) { props.addValue("list-style-type","upper-roman"); }
else if ("a".equals(sNumFormat)) { props.addValue("list-style-type","lower-alpha"); }
else if ("A".equals(sNumFormat)) { props.addValue("list-style-type","upper-alpha"); }
if (!config.useHardListNumbering()) {
// Export the numbering to CSS1
String sLevelType = style.getLevelType(nLevel);
if (XMLString.TEXT_LIST_LEVEL_STYLE_NUMBER.equals(sLevelType)) {
// Numbering style, get number format
String sNumFormat = style.getLevelProperty(nLevel,XMLString.STYLE_NUM_FORMAT);
if ("1".equals(sNumFormat)) { props.addValue("list-style-type","decimal"); }
else if ("i".equals(sNumFormat)) { props.addValue("list-style-type","lower-roman"); }
else if ("I".equals(sNumFormat)) { props.addValue("list-style-type","upper-roman"); }
else if ("a".equals(sNumFormat)) { props.addValue("list-style-type","lower-alpha"); }
else if ("A".equals(sNumFormat)) { props.addValue("list-style-type","upper-alpha"); }
}
else if (XMLString.TEXT_LIST_LEVEL_STYLE_BULLET.equals(sLevelType)) {
// Bullet. We can only choose from disc, bullet and square
switch (nLevel % 3) {
case 1: props.addValue("list-style-type","disc"); break;
case 2: props.addValue("list-style-type","bullet"); break;
case 0: props.addValue("list-style-type","square"); break;
}
}
else if (XMLString.TEXT_LIST_LEVEL_STYLE_IMAGE.equals(sLevelType)) {
// Image. TODO: Handle embedded images
String sHref = style.getLevelProperty(nLevel,XMLString.XLINK_HREF);
if (sHref!=null) { props.addValue("list-style-image","url('"+sHref+"')"); }
}
}
else if (XMLString.TEXT_LIST_LEVEL_STYLE_BULLET.equals(sLevelType)) {
// Bullet. We can only choose from disc, bullet and square
switch (nLevel % 3) {
case 1: props.addValue("list-style-type","disc"); break;
case 2: props.addValue("list-style-type","bullet"); break;
case 0: props.addValue("list-style-type","square"); break;
}
}
else if (XMLString.TEXT_LIST_LEVEL_STYLE_IMAGE.equals(sLevelType)) {
// Image. TODO: Handle embedded images
String sHref = style.getLevelProperty(nLevel,XMLString.XLINK_HREF);
if (sHref!=null) { props.addValue("list-style-image","url('"+sHref+"')"); }
else {
// No numbering generated by the list; we add hard numbering to the paragraph
props.addValue("list-style-type:none");
// In this case we also set the left margin for the list
// For real styles the margins are applied to the paragraphs
// This is more tricky for hard styles, so we use a default left margin on the list
if (style.isAutomatic() && nLevel>1) {
props.addValue("margin-left", "2em");
}
else {
props.addValue("margin-left","0");
}
// Also reset the padding (some browsers use a non-zero default value)
props.addValue("padding-left", "0");
}
// We don't want floats to pass a list to the left (Mozilla and IE both
//handles this terribly!)
props.addValue("clear:left");
}
private void cssListParMargins(ListStyle style, int nLevel, CSVList props){
// Instead margin is applied to the paragraphs in the list, more precisely the list style defines a
// left margin and a text indent to *replace* the values from the paragraph style
String sMarginLeft = style.getLevelStyleProperty(nLevel, XMLString.FO_MARGIN_LEFT);
if (sMarginLeft!=null) {
props.addValue("margin-left", sMarginLeft);
}
else {
props.addValue("margin-left", "0");
}
String sTextIndent = style.getLevelStyleProperty(nLevel, XMLString.FO_TEXT_INDENT);
if (sTextIndent!=null) {
props.addValue("text-indent", sTextIndent);
}
else {
props.addValue("text-indent", "0");
}
}