diff --git a/src/main/java/writer2latex/office/StyleWithProperties.java b/src/main/java/writer2latex/office/StyleWithProperties.java
index aa8280f..e9c2b1a 100644
--- a/src/main/java/writer2latex/office/StyleWithProperties.java
+++ b/src/main/java/writer2latex/office/StyleWithProperties.java
@@ -221,6 +221,13 @@ public class StyleWithProperties extends OfficeStyle {
}
return null; // no value
}
+
+ public boolean hasProperty(String propertyName) {
+ if (getProperty(propertyName) == null) {
+ return false;
+ }
+ return true;
+ }
// TODO: Remove this method
public String getProperty(String sProperty){
diff --git a/src/main/java/writer2latex/xhtml/Converter.java b/src/main/java/writer2latex/xhtml/Converter.java
index 38638e3..0d8fd3b 100644
--- a/src/main/java/writer2latex/xhtml/Converter.java
+++ b/src/main/java/writer2latex/xhtml/Converter.java
@@ -887,8 +887,8 @@ public class Converter extends BasicConverter {
String sStyleName = onode.getAttribute(XMLString.TEXT_STYLE_NAME);
String sVisitedStyleName = onode.getAttribute(XMLString.TEXT_VISITED_STYLE_NAME);
StyleInfo anchorInfo = new StyleInfo();
- styles.getTextSc().applyAnchorStyle(sStyleName,sVisitedStyleName,anchorInfo);
- styles.getTextSc().writeStyle(anchorInfo,anchor);
+ styles.getTextSP().applyAnchorStyle(sStyleName,sVisitedStyleName,anchorInfo);
+ styles.getTextSP().writeStyle(anchorInfo,anchor);
return anchor;
}
diff --git a/src/main/java/writer2latex/xhtml/Parser.java b/src/main/java/writer2latex/xhtml/Parser.java
index 6d0ecb7..1d2482b 100644
--- a/src/main/java/writer2latex/xhtml/Parser.java
+++ b/src/main/java/writer2latex/xhtml/Parser.java
@@ -70,9 +70,9 @@ public class Parser {
protected Styles getStyleCv() { return converter.getStylesParser(); }
- protected TextStyleParser getTextSc() { return converter.getStylesParser().getTextSc(); }
+ protected TextStyleParser getTextSP() { return converter.getStylesParser().getTextSP(); }
- protected ParStyleParser getParSc() { return converter.getStylesParser().getParSc(); }
+ protected ParStyleParser getParSP() { return converter.getStylesParser().getParSP(); }
protected HeadingStyleParser getHeadingSc() { return converter.getStylesParser().getHeadingSc(); }
diff --git a/src/main/java/writer2latex/xhtml/StyleInfo.java b/src/main/java/writer2latex/xhtml/StyleInfo.java
index 4783b7f..effca07 100644
--- a/src/main/java/writer2latex/xhtml/StyleInfo.java
+++ b/src/main/java/writer2latex/xhtml/StyleInfo.java
@@ -25,12 +25,12 @@
package writer2latex.xhtml;
-import writer2latex.util.CSVList;
+import writer2latex.xhtml.style.properties.Properties;
public class StyleInfo {
public String sTagName = null;
public String sClass = null;
- public CSVList props = new CSVList(";");
+ public Properties props = new Properties(";");
public String sLang = null;
public String sDir = null;
diff --git a/src/main/java/writer2latex/xhtml/content/DrawParser.java b/src/main/java/writer2latex/xhtml/content/DrawParser.java
index dbfbab4..a473d34 100644
--- a/src/main/java/writer2latex/xhtml/content/DrawParser.java
+++ b/src/main/java/writer2latex/xhtml/content/DrawParser.java
@@ -65,6 +65,7 @@ import writer2latex.xhtml.Parser;
import writer2latex.xhtml.StyleInfo;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlDocument;
+import writer2latex.xhtml.style.properties.Properties;
import writer2latex.base.BinaryGraphicsDocument;
import writer2latex.office.EmbeddedObject;
import writer2latex.office.EmbeddedXMLObject;
@@ -167,9 +168,9 @@ public class DrawParser extends Parser {
// Style it (TODO: Apply hard drawing-page (background) style)
StyleInfo info = new StyleInfo();
getPageSc().applyStyle(onode.getAttribute(XMLString.DRAW_MASTER_PAGE_NAME),info);
- info.props.addValue("top","40px"); // Somewhat arbitrary
- info.props.addValue("left","0");
- info.props.addValue("position","absolute");
+ info.props.addProperty("top","40px"); // Somewhat arbitrary
+ info.props.addProperty("left","0");
+ info.props.addProperty("position","absolute");
writeStyle(info,div);
// Traverse the draw:page
@@ -463,7 +464,7 @@ public class DrawParser extends Parser {
Element elementWithFont = (Element) convertedMath;
String styleAttr = elementWithFont.getAttribute("style");
if (styleAttr == null) { styleAttr = "";}
- String fontValue = getStyleCv().getTextSc().scale(fontSize+"pt");
+ String fontValue = getStyleCv().getTextSP().scale(fontSize+"pt");
elementWithFont.setAttribute("style", "font-size:"+ fontValue);
}
}
@@ -678,15 +679,15 @@ public class DrawParser extends Parser {
break;
case ABSOLUTE:
sContentWidth = applyImageSize(frame,info.props,nMode,false);
- info.props.addValue("margin-left","auto");
- info.props.addValue("margin-right","auto");
+ info.props.addProperty("margin-left","auto");
+ info.props.addProperty("margin-right","auto");
applyPosition(frame,info.props);
break;
case CENTERED:
- info.props.addValue("margin-top","2px");
- info.props.addValue("margin-bottom","2px");
- info.props.addValue("margin-left","auto");
- info.props.addValue("margin-right","auto");
+ info.props.addProperty("margin-top","2px");
+ info.props.addProperty("margin-bottom","2px");
+ info.props.addProperty("margin-left","auto");
+ info.props.addProperty("margin-right","auto");
sContentWidth = applyImageSize(frame,info.props,nMode,true);
break;
case FLOATING:
@@ -697,33 +698,33 @@ public class DrawParser extends Parser {
String sWrap = style.getProperty(XMLString.STYLE_WRAP);
if (isLeft(sPos)) {
if (mayWrapRight(sWrap)) {
- info.props.addValue("float","left");
+ info.props.addProperty("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");
+ info.props.addProperty("margin-right", "auto");
}
}
else if (isRight(sPos)) {
if (mayWrapLeft(sWrap)) {
- info.props.addValue("float","right");
+ info.props.addProperty("float","right");
}
else {
- info.props.addValue("margin-left", "auto");
+ info.props.addProperty("margin-left", "auto");
}
}
else if (isCenter(sPos)) {
- info.props.addValue("margin-left", "auto");
- info.props.addValue("margin-right", "auto");
+ info.props.addProperty("margin-left", "auto");
+ info.props.addProperty("margin-right", "auto");
}
else if (isFromLeft(sPos)) {
if (mayWrapRight(sWrap)) {
- info.props.addValue("float","left");
+ info.props.addProperty("float","left");
}
String sX = frame.getAttribute(XMLString.SVG_X);
if (sX!=null && sX.length()>0) {
- info.props.addValue("margin-left",scale(sX));
+ info.props.addProperty("margin-left",scale(sX));
}
}
}
@@ -1062,18 +1063,18 @@ public class DrawParser extends Parser {
}
// Return the (unscaled) content width, or null if it's unknown
- private String applySize(Element node, CSVList props, boolean bOnlyWidth) {
+ private String applySize(Element node, Properties props, boolean bOnlyWidth) {
StyleWithProperties style = ofr.getFrameStyle(node.getAttribute(XMLString.DRAW_STYLE_NAME));
String sWidth = getFrameWidth(node, style);
if (sWidth!=null) {
- props.addValue("width",scale(sWidth));
+ props.addProperty("width",scale(sWidth));
}
if (!bOnlyWidth) {
String sHeight = getFrameHeight(node,style);
if (sHeight!=null) {
- props.addValue("height",scale(sHeight));
+ props.addProperty("height",scale(sHeight));
}
}
@@ -1082,19 +1083,19 @@ public class DrawParser extends Parser {
// TODO: For absolute placement, only absolute size makes sense
// TODO: How to handle NONE in case of text boxes? (currently using browser default, usually 100% width)
- private String applyImageSize(Element node, CSVList props, int nMode, boolean bOnlyWidth) {
+ private String applyImageSize(Element node, Properties props, int nMode, boolean bOnlyWidth) {
switch (nImageSize) {
case XhtmlConfig.ABSOLUTE:
return applySize(node, props, bOnlyWidth);
case XhtmlConfig.RELATIVE:
if (nMode==FULL_SCREEN) {
- props.addValue("max-width","100%");
- props.addValue("height","100%");
+ props.addProperty("max-width","100%");
+ props.addProperty("height","100%");
}
else {
String sWidth = getFrameWidth(node, ofr.getFrameStyle(node.getAttribute(XMLString.DRAW_STYLE_NAME)));
if (sWidth!=null) {
- props.addValue("width", Calc.divide(Calc.multiply(sScale,Calc.truncateLength(sWidth)),converter.getContentWidth()));
+ props.addProperty("width", Calc.divide(Calc.multiply(sScale,Calc.truncateLength(sWidth)),converter.getContentWidth()));
}
return sWidth;
}
@@ -1105,7 +1106,7 @@ public class DrawParser extends Parser {
return null;
}
- private void applyPosition(Element node, CSVList props) {
+ private void applyPosition(Element node, Properties props) {
// The left and top attributes in css refers to the entire box, including margins
// We thus have to subtract the margins to get correct placement
String sX = node.getAttribute(XMLString.SVG_X);
@@ -1120,9 +1121,9 @@ public class DrawParser extends Parser {
if (s!=null) sY=Calc.sub(sY,s);
}
- props.addValue("position","absolute");
- if (sX!=null && sX.length()>0) { props.addValue("left",scale(sX)); }
- if (sY!=null && sY.length()>0) { props.addValue("top",scale(sY)); }
+ props.addProperty("position","absolute");
+ if (sX!=null && sX.length()>0) { props.addProperty("left",scale(sX)); }
+ if (sY!=null && sY.length()>0) { props.addProperty("top",scale(sY)); }
}
@@ -1182,8 +1183,8 @@ public class DrawParser extends Parser {
}
if (bWrap) {
- info.props.addValue("float",sAlign);
- if (sX!=null && sX.length()>0) { info.props.addValue("margin-left",sX); }
+ info.props.addProperty("float",sAlign);
+ if (sX!=null && sX.length()>0) { info.props.addProperty("margin-left",sX); }
if (hnodeInline!=null) {
hnodeInline.appendChild(object);
}
diff --git a/src/main/java/writer2latex/xhtml/content/NoteParser.java b/src/main/java/writer2latex/xhtml/content/NoteParser.java
index 4833218..dda5574 100644
--- a/src/main/java/writer2latex/xhtml/content/NoteParser.java
+++ b/src/main/java/writer2latex/xhtml/content/NoteParser.java
@@ -186,7 +186,7 @@ class NoteParser extends Parser {
// Style it
String sCitStyle = noteConfig.getProperty(XMLString.TEXT_CITATION_STYLE_NAME);
StyleInfo linkInfo = new StyleInfo();
- getTextSc().readStyle(sCitStyle,linkInfo);
+ getTextSP().readStyle(sCitStyle,linkInfo);
writeStyle(linkInfo,link);
// Add prefix
diff --git a/src/main/java/writer2latex/xhtml/content/TOCParser.java b/src/main/java/writer2latex/xhtml/content/TOCParser.java
index 6f84d20..3834e54 100644
--- a/src/main/java/writer2latex/xhtml/content/TOCParser.java
+++ b/src/main/java/writer2latex/xhtml/content/TOCParser.java
@@ -138,7 +138,7 @@ class TOCParser extends IndexParser {
void handleParagraph(Element onode, Element par, String sCurrentListLabel) {
String sStyleName = Misc.getAttribute(onode,XMLString.TEXT_STYLE_NAME);
- if (ofr.isIndexSourceStyle(getParSc().getRealParStyleName(sStyleName))) {
+ if (ofr.isIndexSourceStyle(getParSP().getRealParStyleName(sStyleName))) {
converter.addTarget(par,TOC_LINK_PREFIX+(++nTocIndex));
TocEntry entry = new TocEntry();
entry.onode = (Element) onode;
@@ -251,7 +251,7 @@ class TOCParser extends IndexParser {
getTextCv().traverseInlineText(entry.onode,a);
}
else {
- String sStyleName = getParSc().getRealParStyleName(entry.onode.getAttribute(XMLString.TEXT_STYLE_NAME));
+ String sStyleName = getParSP().getRealParStyleName(entry.onode.getAttribute(XMLString.TEXT_STYLE_NAME));
nLevel = tocReader.getIndexSourceStyleLevel(sStyleName);
if (tocReader.useIndexSourceStyles() && 1<=nLevel && nLevel<=tocReader.getOutlineLevel()) {
Element p = getTextCv().createParagraph(li,sEntryStyleName[nLevel]);
@@ -265,7 +265,7 @@ class TOCParser extends IndexParser {
}
}
else if (XMLString.TEXT_P.equals(sNodeName)) {
- String sStyleName = getParSc().getRealParStyleName(entry.onode.getAttribute(XMLString.TEXT_STYLE_NAME));
+ String sStyleName = getParSP().getRealParStyleName(entry.onode.getAttribute(XMLString.TEXT_STYLE_NAME));
int nLevel = tocReader.getIndexSourceStyleLevel(sStyleName);
if (tocReader.useIndexSourceStyles() && 1<=nLevel && nLevel<=tocReader.getOutlineLevel()) {
Element p = getTextCv().createParagraph(li,sEntryStyleName[nLevel]);
diff --git a/src/main/java/writer2latex/xhtml/content/TableParser.java b/src/main/java/writer2latex/xhtml/content/TableParser.java
index 6c2156f..d6afb4b 100644
--- a/src/main/java/writer2latex/xhtml/content/TableParser.java
+++ b/src/main/java/writer2latex/xhtml/content/TableParser.java
@@ -349,7 +349,7 @@ public class TableParser extends Parser {
// Set table width
String sWidth = style.getProperty(XMLString.STYLE_REL_WIDTH);
if (sWidth!=null) {
- info.props.addValue("width",sWidth);
+ info.props.addProperty("width",sWidth);
}
else {
sWidth = style.getProperty(XMLString.STYLE_WIDTH);
@@ -357,10 +357,10 @@ public class TableParser extends Parser {
if (config.tableSize()==XhtmlConfig.RELATIVE){
// Force relative width
sWidth=Calc.divide(sWidth, converter.getContentWidth(), true);
- info.props.addValue("width",sWidth);
+ info.props.addProperty("width",sWidth);
}
else {
- info.props.addValue("width",getTableSc().colScale(sWidth));
+ info.props.addProperty("width",getTableSc().colScale(sWidth));
}
}
}
@@ -370,19 +370,19 @@ public class TableParser extends Parser {
// Writer uses a separating border model, Calc a collapsing:
// props.addValue("border-collapse", bCalc ? "collapse" : "separate");
// For now always use separating model:
- info.props.addValue("border-collapse", "separate");
- info.props.addValue("border-spacing", "0");
+ info.props.addProperty("border-collapse", "separate");
+ info.props.addProperty("border-spacing", "0");
- info.props.addValue("table-layout","fixed");
+ info.props.addProperty("table-layout","fixed");
//info.props.addValue("empty-cells","show"); use instead...
- if (ofr.isSpreadsheet()) { info.props.addValue("white-space","nowrap"); }
+ if (ofr.isSpreadsheet()) { info.props.addProperty("white-space","nowrap"); }
if (bIsSubTable) {
// Should try to fill the cell; hence:
- info.props.addValue("width","100%");
- info.props.addValue("margin","0");
+ info.props.addProperty("width","100%");
+ info.props.addProperty("margin","0");
}
writeStyle(info,table);
}
@@ -401,7 +401,7 @@ public class TableParser extends Parser {
String s = style.getAbsoluteProperty(XMLString.STYLE_ROW_HEIGHT);
// Do not export minimal row height; causes trouble with ie
//if (s==null) { s = style.getAbsoluteProperty(XMLString.STYLE_MIN_ROW_HEIGHT); }
- if (s!=null) { info.props.addValue("height",getRowSc().scale(s)); }
+ if (s!=null) { info.props.addProperty("height",getRowSc().scale(s)); }
}
}
@@ -445,7 +445,7 @@ public class TableParser extends Parser {
}
if (sTotalWidth!=null) {
- info.props.addValue("width",Calc.sub(getTableSc().colScale(sTotalWidth),sEdge));
+ info.props.addProperty("width",Calc.sub(getTableSc().colScale(sTotalWidth),sEdge));
}
}
@@ -453,7 +453,7 @@ public class TableParser extends Parser {
if (ofr.isSpreadsheet() && !"fix".equals(style.getProperty(XMLString.STYLE_TEXT_ALIGN_SOURCE))) {
// Strings go left, other types (float, time, date, percentage, currency, boolean) go right
// The default is string
- info.props.addValue("text-align", sValueType==null || "string".equals(sValueType) ? "left" : "right");
+ info.props.addProperty("text-align", sValueType==null || "string".equals(sValueType) ? "left" : "right");
}
}
@@ -465,9 +465,9 @@ public class TableParser extends Parser {
if (bIsSubTable) {
// Cannot set height of a subtable, if the subtable does not fill
// the entire cell it is placed at the top
- info.props.addValue("vertical-align","top");
+ info.props.addProperty("vertical-align","top");
// Don't add padding if there's a subtable in the cell!
- info.props.addValue("padding","0");
+ info.props.addProperty("padding","0");
}
writeStyle(info,cell);
diff --git a/src/main/java/writer2latex/xhtml/content/TextParser.java b/src/main/java/writer2latex/xhtml/content/TextParser.java
index 84f986d..44737a4 100644
--- a/src/main/java/writer2latex/xhtml/content/TextParser.java
+++ b/src/main/java/writer2latex/xhtml/content/TextParser.java
@@ -712,7 +712,7 @@ public class TextParser extends Parser {
traverseInlineText(onode, content);
// Add before/after text if required
- addBeforeAfter(heading, ofr.getParStyle(getParSc().getRealParStyleName(sStyleName)), config.getXHeadingStyleMap());
+ addBeforeAfter(heading, ofr.getParStyle(getParSP().getRealParStyleName(sStyleName)), config.getXHeadingStyleMap());
// Keep track of current headings for split output
currentHeading[nLevel] = heading;
@@ -782,7 +782,7 @@ public class TextParser extends Parser {
}
else {
// Otherwise, add before/after text if required
- addBeforeAfter(par,ofr.getParStyle(getParSc().getRealParStyleName(styleName)),config.getXParStyleMap());
+ addBeforeAfter(par,ofr.getParStyle(getParSP().getRealParStyleName(styleName)),config.getXParStyleMap());
}
}
@@ -836,14 +836,14 @@ public class TextParser extends Parser {
StyleInfo info = new StyleInfo();
if (style!=null) {
String sTextStyleName = style.getLevelProperty(nLevel,TEXT_STYLE_NAME);
- getTextSc().readStyle(sTextStyleName, info);
+ getTextSP().readStyle(sTextStyleName, info);
}
if (info.sTagName==null) { info.sTagName = "span"; }
if (info.sClass==null) { info.sClass = sDefaultStyle; }
Element content = converter.createElement(info.sTagName);
- getTextSc().writeStyle(info, content);
+ getTextSP().writeStyle(info, content);
hnode.appendChild(content);
content.appendChild( converter.createTextNode(sLabel) );
}
@@ -1642,10 +1642,11 @@ public class TextParser extends Parser {
}
/* Create a styled paragraph node */
- protected Element createParagraph(Element node, String sStyleName) {
+ protected Element createParagraph(Element node, String styleName) {
StyleInfo info = new StyleInfo();
- StyleWithProperties style = ofr.getParStyle(sStyleName);
- getParSc().readStyle(sStyleName,info);
+ StyleWithProperties style = ofr.getParStyle(styleName);
+ getParSP().readStyle(styleName,info);
+
Element para = converter.createElement(info.sTagName);
node.appendChild(para);
@@ -1663,7 +1664,7 @@ public class TextParser extends Parser {
if (config.xhtmlFormatting()==XhtmlConfig.IGNORE_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD) {
return node;
}
- String sBack = getParSc().getTextBackground(sStyleName);
+ String sBack = getParSP().getTextBackground(sStyleName);
if (sBack.length()>0) {
Element span = converter.createElement("span");
span.setAttribute("style",sBack);
@@ -1678,7 +1679,8 @@ public class TextParser extends Parser {
/* Create a styled inline node */
protected Element createInline(Element node, String sStyleName) {
StyleInfo info = new StyleInfo();
- getTextSc().readStyle(sStyleName,info);
+ getTextSP().readStyle(sStyleName,info);
+
Element newNode = node;
if (info.hasAttributes() || !"span".equals(info.sTagName)) {
// We (probably) need to create a new element
diff --git a/src/main/java/writer2latex/xhtml/style/CellStyleParser.java b/src/main/java/writer2latex/xhtml/style/CellStyleParser.java
index c8d64c9..3cb43a7 100644
--- a/src/main/java/writer2latex/xhtml/style/CellStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/CellStyleParser.java
@@ -33,6 +33,7 @@ import writer2latex.util.CSVList;
import writer2latex.xhtml.Converter;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMap;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument cell styles to CSS2 styles.
@@ -75,31 +76,31 @@ public class CellStyleParser extends StyleWithPropertiesParser {
* @param props the CSVList
object to add information to
* @param bInherit true if properties should be inherited from parent style(s)
*/
- public void applyProperties(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void applyProperties(StyleWithProperties style, Properties props, boolean bInherit) {
// Apply "inner" box properties (no margins)
getFrameSc().cssBorder(style,props,bInherit);
getFrameSc().cssPadding(style,props,bInherit);
getFrameSc().cssBackground(style,props,bInherit);
// only relevant for spreadsheets
- getParSc().cssPar(style,props,bInherit);
- getTextSc().cssTextCommon(style,props,bInherit);
+ getParSP().cssPar(style,props,bInherit);
+ getTextSP().cssTextCommon(style,props,bInherit);
// Cell-specific properties (vertical alignment)
cssCell(style,props,bInherit);
}
- private void cssCell(StyleWithProperties style, CSVList props, boolean bInherit){
+ private void cssCell(StyleWithProperties style, Properties props, boolean bInherit){
// Vertical align: Some values fit with css
String s = ofr.isOpenDocument() ?
style.getProperty(XMLString.STYLE_VERTICAL_ALIGN,bInherit) :
style.getProperty(XMLString.FO_VERTICAL_ALIGN,bInherit);
- if ("middle".equals(s)) { props.addValue("vertical-align","middle"); }
- else if ("bottom".equals(s)) { props.addValue("vertical-align","bottom"); }
- else if ("top".equals(s)) { props.addValue("vertical-align","top"); }
+ if ("middle".equals(s)) { props.addProperty("vertical-align","middle"); }
+ else if ("bottom".equals(s)) { props.addProperty("vertical-align","bottom"); }
+ else if ("top".equals(s)) { props.addProperty("vertical-align","top"); }
else {
// No value or "automatic" means, according to the spec,
//"The application decide how to align the text."
// We treat this case like OOo does:
- props.addValue("vertical-align", ofr.isSpreadsheet() ? "bottom" : "top");
+ props.addProperty("vertical-align", ofr.isSpreadsheet() ? "bottom" : "top");
}
}
diff --git a/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java b/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java
index f79be7e..bd02688 100644
--- a/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/FrameStyleParser.java
@@ -37,6 +37,7 @@ import writer2latex.util.Calc;
import writer2latex.util.SimpleInputBuffer;
import writer2latex.xhtml.Converter;
import writer2latex.xhtml.XhtmlConfig;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument graphic (frame) styles to CSS2 styles.
@@ -94,10 +95,10 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
public String composeDeclarationBlock( String sDisplayName) {
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName);
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
getFrameSc().cssMargins(style, props, true);
- getParSc().cssPar(style, props, true);
- getTextSc().cssTextCommon(style, props, true);
+ getParSP().cssPar(style, props, true);
+ getTextSP().cssTextCommon(style, props, true);
return props.toString();
}
@@ -126,57 +127,52 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
* @param props the CSVList
object to add information to
* @param bInherit true if properties should be inherited from parent style(s)
*/
- public void applyProperties(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void applyProperties(StyleWithProperties style, Properties props, boolean bInherit) {
cssBox(style,props,bInherit);
- getTextSc().cssTextCommon(style,props,bInherit); // only in presentations
+ getTextSP().cssTextCommon(style,props,bInherit); // only in presentations
}
////////////////////////////////////////////////////////////////////////////
// OpenDocument frame properties
- public void cssBox(StyleWithProperties style, CSVList props, boolean bInherit){
+ public void cssBox(StyleWithProperties style, Properties props, boolean bInherit){
// translates "box" style properties.
// these can be applied to paragraph styles, frame styles and page styles.
// The following properties are not supported by CSS2:
// style:border-line-width and style:border-line-width-*
// TODO: What about shadow?
- cssMargins(style,props,bInherit);
+ cssMargins(style,props,bInherit);
cssBorder(style,props,bInherit);
cssPadding(style,props,bInherit);
cssBackground(style,props,bInherit);
- cssColumns(style,props,bInherit);
}
- private void cssColumns(StyleWithProperties style, CSVList props, boolean bInherit) {
- String columnCount = style.getAbsoluteProperty(XMLString.FO_COLUMN_COUNT);
- }
-
- public void cssMargins(StyleWithProperties style, CSVList props, boolean bInherit){
+ public void cssMargins(StyleWithProperties style, Properties props, boolean bInherit){
// *Absolute* values fit with css
String s;
- if (bInherit || style.getProperty(XMLString.FO_MARGIN_LEFT,false)!=null) {
+ if (bInherit || style.hasProperty(XMLString.FO_MARGIN_LEFT)) {
s = style.getAbsoluteProperty(XMLString.FO_MARGIN_LEFT);
- if (s!=null) { props.addValue("margin-left",scale(s)); }
- else { props.addValue("margin-left","0"); }
+ if (s!=null) { props.addProperty("margin-left",scale(s)); }
+ else { props.addProperty("margin-left","0"); }
}
- if (bInherit || style.getProperty(XMLString.FO_MARGIN_RIGHT,false)!=null) {
+ if (bInherit || style.hasProperty(XMLString.FO_MARGIN_RIGHT)) {
s = style.getAbsoluteProperty(XMLString.FO_MARGIN_RIGHT);
- if (s!=null) { props.addValue("margin-right",scale(s)); }
- else { props.addValue("margin-right","0"); }
+ if (s!=null) { props.addProperty("margin-right",scale(s)); }
+ else { props.addProperty("margin-right","0"); }
}
- if (bInherit || style.getProperty(XMLString.FO_MARGIN_TOP,false)!=null) {
+ if (bInherit || style.hasProperty(XMLString.FO_MARGIN_TOP)) {
s = style.getAbsoluteProperty(XMLString.FO_MARGIN_TOP);
- if (s!=null) { props.addValue("margin-top",scale(s)); }
- else { props.addValue("margin-top","0"); }
+ if (s!=null) { props.addProperty("margin-top",scale(s)); }
+ else { props.addProperty("margin-top","0"); }
}
- if (bInherit || style.getProperty(XMLString.FO_MARGIN_BOTTOM,false)!=null) {
+ if (bInherit || style.hasProperty(XMLString.FO_MARGIN_BOTTOM)) {
s = style.getAbsoluteProperty(XMLString.FO_MARGIN_BOTTOM);
- if (s!=null) { props.addValue("margin-bottom",scale(s)); }
- else { props.addValue("margin-bottom","0"); }
+ if (s!=null) { props.addProperty("margin-bottom",scale(s)); }
+ else { props.addProperty("margin-bottom","0"); }
}
}
- public void cssBorder(StyleWithProperties style, CSVList props, boolean bInherit){
+ public void cssBorder(StyleWithProperties style, Properties props, boolean bInherit){
// Same as in css
boolean bHasBorder = false;
String s=null;
@@ -184,38 +180,38 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
s = style.getProperty(XMLString.FO_BORDER);
}
if (s!=null) {
- props.addValue("border",borderScale(s)); bHasBorder = true;
+ props.addProperty("border",borderScale(s)); bHasBorder = true;
}
else { // apply individual borders
if (bInherit || style.getProperty(XMLString.FO_BORDER_TOP,false)!=null) {
s = style.getProperty(XMLString.FO_BORDER_TOP);
- if (s!=null) { props.addValue("border-top",borderScale(s)); bHasBorder=true; }
+ if (s!=null) { props.addProperty("border-top",borderScale(s)); bHasBorder=true; }
}
if (bInherit || style.getProperty(XMLString.FO_BORDER_BOTTOM,false)!=null) {
s = style.getProperty(XMLString.FO_BORDER_BOTTOM);
- if (s!=null) { props.addValue("border-bottom",borderScale(s)); bHasBorder=true; }
+ if (s!=null) { props.addProperty("border-bottom",borderScale(s)); bHasBorder=true; }
}
if (bInherit || style.getProperty(XMLString.FO_BORDER_LEFT,false)!=null) {
s = style.getProperty(XMLString.FO_BORDER_LEFT);
- if (s!=null) { props.addValue("border-left",borderScale(s)); bHasBorder=true; }
+ if (s!=null) { props.addProperty("border-left",borderScale(s)); bHasBorder=true; }
}
if (bInherit || style.getProperty(XMLString.FO_BORDER_RIGHT,false)!=null) {
s = style.getProperty(XMLString.FO_BORDER_RIGHT);
- if (s!=null) { props.addValue("border-right",borderScale(s)); bHasBorder=true; }
+ if (s!=null) { props.addProperty("border-right",borderScale(s)); bHasBorder=true; }
}
}
// Default to no border:
- if (bInherit && !bHasBorder) { props.addValue("border","none"); }
+ if (bInherit && !bHasBorder) { props.addProperty("border","none"); }
}
- public void cssPadding(StyleWithProperties style, CSVList props, boolean bInherit){
+ public void cssPadding(StyleWithProperties style, Properties props, boolean bInherit){
// *Absolute* values fit with css
String s=null;
if (bInherit || style.getProperty(XMLString.FO_PADDING,false)!=null) {
s = style.getAbsoluteProperty(XMLString.FO_PADDING);
}
if (s!=null) {
- props.addValue("padding",scale(s));
+ props.addProperty("padding",scale(s));
}
else { // apply individual paddings
boolean bTop = false;
@@ -224,58 +220,58 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
boolean bRight = false;
if (bInherit || style.getProperty(XMLString.FO_PADDING_TOP,false)!=null) {
s = style.getAbsoluteProperty(XMLString.FO_PADDING_TOP);
- if (s!=null) { props.addValue("padding-top",scale(s)); bTop=true; }
+ if (s!=null) { props.addProperty("padding-top",scale(s)); bTop=true; }
}
if (bInherit || style.getProperty(XMLString.FO_PADDING_BOTTOM,false)!=null) {
s = style.getAbsoluteProperty(XMLString.FO_PADDING_BOTTOM);
- if (s!=null) { props.addValue("padding-bottom",scale(s)); bBottom=true; }
+ if (s!=null) { props.addProperty("padding-bottom",scale(s)); bBottom=true; }
}
if (bInherit || style.getProperty(XMLString.FO_PADDING_LEFT,false)!=null) {
s = style.getAbsoluteProperty(XMLString.FO_PADDING_LEFT);
- if (s!=null) { props.addValue("padding-left",scale(s)); bLeft=true; }
+ if (s!=null) { props.addProperty("padding-left",scale(s)); bLeft=true; }
}
if (bInherit || style.getProperty(XMLString.FO_PADDING_RIGHT,false)!=null) {
s = style.getAbsoluteProperty(XMLString.FO_PADDING_RIGHT);
- if (s!=null) { props.addValue("padding-right",scale(s)); bRight=true; }
+ if (s!=null) { props.addProperty("padding-right",scale(s)); bRight=true; }
}
if (bInherit) { // must specify padding
if (!bTop && !bBottom && !bLeft && !bRight) {
- props.addValue("padding","0");
+ props.addProperty("padding","0");
}
else {
- if (!bTop) { props.addValue("padding-top","0"); }
- if (!bBottom) { props.addValue("padding-bottom","0"); }
- if (!bLeft) { props.addValue("padding-left","0"); }
- if (!bRight) { props.addValue("padding-right","0"); }
+ if (!bTop) { props.addProperty("padding-top","0"); }
+ if (!bBottom) { props.addProperty("padding-bottom","0"); }
+ if (!bLeft) { props.addProperty("padding-left","0"); }
+ if (!bRight) { props.addProperty("padding-right","0"); }
}
}
}
}
// parapgrah styles need this for special treatment of background color
- public void cssBackgroundCommon(StyleWithProperties style, CSVList props, boolean bInherit){
+ public void cssBackgroundCommon(StyleWithProperties style, Properties props, boolean bInherit){
// Background image:
String sUrl = style.getBackgroundImageProperty(XMLString.XLINK_HREF);
if (sUrl!=null) { // currently only support for linked image
- props.addValue("background-image","url("+escapeUrl(sUrl)+")");
+ props.addProperty("background-image","url("+escapeUrl(sUrl)+")");
String sRepeat = style.getBackgroundImageProperty(XMLString.STYLE_REPEAT);
if ("no-repeat".equals(sRepeat) || "stretch".equals(sRepeat)) {
- props.addValue("background-repeat","no-repeat");
+ props.addProperty("background-repeat","no-repeat");
}
else {
- props.addValue("background-repeat","repeat");
+ props.addProperty("background-repeat","repeat");
}
String sPosition = style.getBackgroundImageProperty(XMLString.STYLE_POSITION);
- if (sPosition!=null) { props.addValue("background-position",sPosition); }
+ if (sPosition!=null) { props.addProperty("background-position",sPosition); }
}
}
- public void cssBackground(StyleWithProperties style, CSVList props, boolean bInherit){
+ public void cssBackground(StyleWithProperties style, Properties props, boolean bInherit){
// Background color: Same as in css
String s = style.getProperty(XMLString.FO_BACKGROUND_COLOR,bInherit);
- if (s!=null) { props.addValue("background-color",s); }
+ if (s!=null) { props.addProperty("background-color",s); }
cssBackgroundCommon(style,props,bInherit);
}
diff --git a/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java b/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java
index 20c4d57..c6afc2d 100644
--- a/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java
@@ -37,6 +37,7 @@ import writer2latex.xhtml.Converter;
import writer2latex.xhtml.StyleInfo;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMapItem;
+import writer2latex.xhtml.style.properties.Properties;
public class HeadingStyleParser extends StyleParser {
@@ -83,9 +84,9 @@ public class HeadingStyleParser extends StyleParser {
}
private String composeBasicDeclarationBlock( int i) {
- CSVList props = new CSVList(";");
- getParSc().applyProperties(ofr.getHeadingStyle(i), props, true);
- props.addValue("clear", "left");
+ Properties props = new Properties(";");
+ getParSP().applyProperties(ofr.getHeadingStyle(i), props, true);
+ props.addProperty("clear", "left");
return props.toString();
}
@@ -96,9 +97,9 @@ public class HeadingStyleParser extends StyleParser {
public String composeDeclarationBlock(String displayName) {
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(displayName);
- CSVList props = new CSVList(";");
- getParSc().applyProperties(style, props, true);
- props.addValue("clear", "left");
+ Properties props = new Properties(";");
+ getParSP().applyProperties(style, props, true);
+ props.addProperty("clear", "left");
return props.toString();
}
@@ -124,7 +125,7 @@ public class HeadingStyleParser extends StyleParser {
// Apply parent style + hard formatting
applyStyle(nLevel, style.getParentName(), info);
if (bConvertHard) {
- getParSc().applyProperties(style, info.props, false);
+ getParSP().applyProperties(style, info.props, false);
}
} else {
String sDisplayName = style.getDisplayName();
diff --git a/src/main/java/writer2latex/xhtml/style/ListStyleParser.java b/src/main/java/writer2latex/xhtml/style/ListStyleParser.java
index 1a11ba9..9802e10 100644
--- a/src/main/java/writer2latex/xhtml/style/ListStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/ListStyleParser.java
@@ -39,6 +39,7 @@ import writer2latex.xhtml.Converter;
import writer2latex.xhtml.StyleInfo;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMapItem;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument list styles to
@@ -156,7 +157,7 @@ public class ListStyleParser extends StyleParser {
private String composeDeclarationBlock(String displayName, int level) {
ListStyle style = (ListStyle) getStyles().getStyleByDisplayName(displayName);
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
cssList(style, level, props);
return props.toString();
}
@@ -170,65 +171,65 @@ public class ListStyleParser extends StyleParser {
return ofr.getListStyles();
}
- private void cssList(ListStyle style, int nLevel, CSVList props){
+ private void cssList(ListStyle style, int nLevel, Properties props){
// translates "list" style properties for a particular level
// Mozilla does not seem to support the "marker" mechanism of CSS2
// so we will stick with the simpler CSS1-like list style properties
- props.addValue("margin-top","0");
- props.addValue("margin-bottom","0");
+ props.addProperty("margin-top","0");
+ props.addProperty("margin-bottom","0");
if (config.listFormatting()!=XhtmlConfig.HARD_LABELS) {
// 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"); }
+ if ("1".equals(sNumFormat)) { props.addProperty("list-style-type","decimal"); }
+ else if ("i".equals(sNumFormat)) { props.addProperty("list-style-type","lower-roman"); }
+ else if ("I".equals(sNumFormat)) { props.addProperty("list-style-type","upper-roman"); }
+ else if ("a".equals(sNumFormat)) { props.addProperty("list-style-type","lower-alpha"); }
+ else if ("A".equals(sNumFormat)) { props.addProperty("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","circle"); break;
- case 0: props.addValue("list-style-type","square"); break;
+ case 1: props.addProperty("list-style-type","disc"); break;
+ case 2: props.addProperty("list-style-type","circle"); break;
+ case 0: props.addProperty("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+"')"); }
+ if (sHref!=null) { props.addProperty("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");
+ props.addProperty("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");
+ props.addProperty("margin-left", "2em");
}
else {
- props.addValue("margin-left","0");
+ props.addProperty("margin-left","0");
}
// Also reset the padding (some browsers use a non-zero default value)
- props.addValue("padding-left", "0");
+ props.addProperty("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");
+ props.addProperty("clear","left");
String textStyleName = style.getLevelProperty(nLevel, XMLString.TEXT_STYLE_NAME);
if (textStyleName != null) {
StyleWithProperties charStyle = (StyleWithProperties) ofr.getTextStyles().getStyle(textStyleName);
- getTextSc().cssText(charStyle, props, true);
+ getTextSP().cssText(charStyle, props, true);
}
}
diff --git a/src/main/java/writer2latex/xhtml/style/PageStyleParser.java b/src/main/java/writer2latex/xhtml/style/PageStyleParser.java
index bcf20a6..6522018 100644
--- a/src/main/java/writer2latex/xhtml/style/PageStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/PageStyleParser.java
@@ -38,6 +38,7 @@ import writer2latex.util.Calc;
import writer2latex.xhtml.Converter;
import writer2latex.xhtml.StyleInfo;
import writer2latex.xhtml.XhtmlConfig;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument page styles to CSS2 styles.
@@ -229,49 +230,49 @@ public class PageStyleParser extends StyleParser {
}
// Background properties in draw: Color, gradient, hatching or bitmap
- private void cssDrawBackground(StyleWithProperties style, CSVList props, boolean bInherit){
+ private void cssDrawBackground(StyleWithProperties style, Properties props, boolean bInherit){
// Fill color: Same as in css
String s = style.getProperty(XMLString.DRAW_FILL_COLOR,bInherit);
- if (s!=null) { props.addValue("background-color",s); }
+ if (s!=null) { props.addProperty("background-color",s); }
}
- private void cssPageSize(PageLayout style, CSVList props) {
+ private void cssPageSize(PageLayout style, Properties props) {
String sWidth = style.getProperty(XMLString.FO_PAGE_WIDTH);
- if (sWidth!=null) { props.addValue("width",scale(sWidth)); }
+ if (sWidth!=null) { props.addProperty("width",scale(sWidth)); }
String sHeight = style.getProperty(XMLString.FO_PAGE_HEIGHT);
- if (sHeight!=null) { props.addValue("height",scale(sHeight)); }
+ if (sHeight!=null) { props.addProperty("height",scale(sHeight)); }
}
// Footnote rule
- private void cssFootnoteRule(PageLayout style, CSVList props) {
+ private void cssFootnoteRule(PageLayout style, Properties props) {
String sBefore = style.getFootnoteProperty(XMLString.STYLE_DISTANCE_BEFORE_SEP);
- if (sBefore!=null) { props.addValue("margin-top",scale(sBefore)); }
+ if (sBefore!=null) { props.addProperty("margin-top",scale(sBefore)); }
String sAfter = style.getFootnoteProperty(XMLString.STYLE_DISTANCE_AFTER_SEP);
- if (sAfter!=null) { props.addValue("margin-bottom", scale(sAfter)); }
+ if (sAfter!=null) { props.addProperty("margin-bottom", scale(sAfter)); }
String sHeight = style.getFootnoteProperty(XMLString.STYLE_WIDTH);
- if (sHeight!=null) { props.addValue("height", scale(sHeight)); }
+ if (sHeight!=null) { props.addProperty("height", scale(sHeight)); }
String sWidth = style.getFootnoteProperty(XMLString.STYLE_REL_WIDTH);
- if (sWidth!=null) { props.addValue("width", sWidth); }
+ if (sWidth!=null) { props.addProperty("width", sWidth); }
String sColor = style.getFootnoteProperty(XMLString.STYLE_COLOR);
if (sColor!=null) { // To get the expected result in all browsers we must set both
- props.addValue("color", sColor);
- props.addValue("background-color", sColor);
+ props.addProperty("color", sColor);
+ props.addProperty("background-color", sColor);
}
String sAdjustment = style.getFootnoteProperty(XMLString.STYLE_ADJUSTMENT);
if ("right".equals(sAdjustment)) {
- props.addValue("margin-left", "auto");
- props.addValue("margin-right", "0");
+ props.addProperty("margin-left", "auto");
+ props.addProperty("margin-right", "0");
}
else if ("center".equals(sAdjustment)) {
- props.addValue("margin-left", "auto");
- props.addValue("margin-right", "auto");
+ props.addProperty("margin-left", "auto");
+ props.addProperty("margin-right", "auto");
}
else { // default left
- props.addValue("margin-left", "0");
- props.addValue("margin-right", "auto");
+ props.addProperty("margin-left", "0");
+ props.addProperty("margin-right", "auto");
}
}
diff --git a/src/main/java/writer2latex/xhtml/style/ParStyleParser.java b/src/main/java/writer2latex/xhtml/style/ParStyleParser.java
index 3b47efd..092ff8c 100644
--- a/src/main/java/writer2latex/xhtml/style/ParStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/ParStyleParser.java
@@ -32,6 +32,7 @@ import writer2latex.office.XMLString;
import writer2latex.util.CSVList;
import writer2latex.xhtml.Converter;
import writer2latex.xhtml.XhtmlConfig;
+import writer2latex.xhtml.style.properties.Properties;
/*
TODO: drop caps (contained in a child of the style:properties element)
@@ -80,21 +81,21 @@ public class ParStyleParser extends StyleWithPropertiesParser {
* @param props the CSVList
object to add information to
* @param bInherit true if properties should be inherited from parent style(s)
*/
- public void applyProperties(StyleWithProperties style, CSVList props, boolean bInherit) {
- cssPageBreak(style,props,bInherit);
- getFrameSc().cssMargins(style,props,bInherit);
- getFrameSc().cssBorder(style,props,bInherit);
- getFrameSc().cssPadding(style,props,bInherit);
- getFrameSc().cssBackgroundCommon(style,props,bInherit);
- cssPar(style,props,bInherit);
- getTextSc().cssTextCommon(style,props,bInherit);
- }
+ public void applyProperties(StyleWithProperties style, Properties props, boolean bInherit) {
+ cssPageBreak(style, props, bInherit);
+ getFrameSc().cssMargins(style, props, bInherit);
+ getFrameSc().cssBorder(style, props, bInherit);
+ getFrameSc().cssPadding(style, props, bInherit);
+ getFrameSc().cssBackgroundCommon(style, props, bInherit);
+ cssPar(style, props, bInherit);
+ getTextSP().cssTextCommon(style, props, bInherit);
+ }
public String getTextBackground(String sStyleName) {
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
StyleWithProperties style = ofr.getParStyle(sStyleName);
if (style!=null) {
- getTextSc().cssTextBackground(style,props,true);
+ getTextSP().cssTextBackground(style,props,true);
}
return props.toString();
}
@@ -107,16 +108,16 @@ public class ParStyleParser extends StyleWithPropertiesParser {
return style.getParentName();
}
- public void cssPageBreak(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void cssPageBreak(StyleWithProperties style, Properties props, boolean bInherit) {
if ("page".equals(style.getProperty(XMLString.FO_BREAK_BEFORE, bInherit))) {
- props.addValue("page-break-before", "always");
+ props.addProperty("page-break-before", "always");
}
else if ("page".equals(style.getProperty(XMLString.FO_BREAK_AFTER, bInherit))) {
- props.addValue("page-break-after", "always");
+ props.addProperty("page-break-after", "always");
}
}
- public void cssPar(StyleWithProperties style, CSVList props, boolean bInherit){
+ public void cssPar(StyleWithProperties style, Properties props, boolean bInherit){
String s;
// translates paragraph style properties.
@@ -137,17 +138,17 @@ public class ParStyleParser extends StyleWithPropertiesParser {
// Background color fits with css (note: Paragraph property!)
s = style.getParProperty(XMLString.FO_BACKGROUND_COLOR,bInherit);
- if (s!=null) { props.addValue("background-color",s); }
+ if (s!=null) { props.addProperty("background-color",s); }
// Indentation: Absolute values of this property fit with css...
if (bInherit || style.getProperty(XMLString.FO_TEXT_INDENT,false)!=null) {
s = style.getAbsoluteProperty(XMLString.FO_TEXT_INDENT);
if (s!=null) {
- props.addValue("text-indent",scale(s));
+ props.addProperty("text-indent",scale(s));
}
else { // ... but css doesn't have this one
s = style.getProperty(XMLString.STYLE_AUTO_TEXT_INDENT);
- if ("true".equals(s)) { props.addValue("text-indent","2em"); }
+ if ("true".equals(s)) { props.addProperty("text-indent","2em"); }
}
}
@@ -156,14 +157,14 @@ public class ParStyleParser extends StyleWithPropertiesParser {
if (s!=null) { // rename two property values:
if (s.equals("start")) { s="left"; }
else if (s.equals("end")) { s="right"; }
- props.addValue("text-align",s);
+ props.addProperty("text-align",s);
}
// Wrap (only in table cells, only in spreadsheets):
if (ofr.isSpreadsheet()) {
s = style.getProperty(XMLString.FO_WRAP_OPTION,bInherit);
- if ("no-wrap".equals(s)) props.addValue("white-space","nowrap");
- else if ("wrap".equals(s)) props.addValue("white-space","normal");
+ if ("no-wrap".equals(s)) props.addProperty("white-space","nowrap");
+ else if ("wrap".equals(s)) props.addProperty("white-space","normal");
}
}
diff --git a/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java b/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java
index f818c25..1d32b21 100644
--- a/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/PresentationStyleParser.java
@@ -38,6 +38,7 @@ import writer2latex.xhtml.Converter;
import writer2latex.xhtml.StyleInfo;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMap;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument presentation styles to CSS2 styles.
@@ -120,10 +121,10 @@ public class PresentationStyleParser extends FrameStyleParser {
public String composeDeclarationBlock(String displayName) {
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(displayName);
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
getFrameSc().cssMargins(style, props, true);
- getParSc().cssPar(style, props, true);
- getTextSc().cssTextCommon(style, props, true);
+ getParSP().cssPar(style, props, true);
+ getTextSP().cssTextCommon(style, props, true);
return props.toString();
}
diff --git a/src/main/java/writer2latex/xhtml/style/RowStyleParser.java b/src/main/java/writer2latex/xhtml/style/RowStyleParser.java
index c9c1d1e..d401f67 100644
--- a/src/main/java/writer2latex/xhtml/style/RowStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/RowStyleParser.java
@@ -33,6 +33,7 @@ import writer2latex.util.CSVList;
import writer2latex.xhtml.Converter;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMap;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument row styles to CSS2 styles.
@@ -75,7 +76,7 @@ public class RowStyleParser extends StyleWithPropertiesParser {
* @param props the CSVList
object to add information to
* @param bInherit true if properties should be inherited from parent style(s)
*/
- public void applyProperties(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void applyProperties(StyleWithProperties style, Properties props, boolean bInherit) {
getFrameSc().cssBackground(style,props,bInherit);
}
diff --git a/src/main/java/writer2latex/xhtml/style/SectionStyleParser.java b/src/main/java/writer2latex/xhtml/style/SectionStyleParser.java
index 6a8bb25..b465f9c 100644
--- a/src/main/java/writer2latex/xhtml/style/SectionStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/SectionStyleParser.java
@@ -33,6 +33,7 @@ import writer2latex.util.CSVList;
import writer2latex.xhtml.Converter;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMap;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument section styles to CSS2 styles.
@@ -79,7 +80,7 @@ public class SectionStyleParser extends StyleWithPropertiesParser {
* @param props the CSVList
object to add information to
* @param bInherit true if properties should be inherited from parent style(s)
*/
- public void applyProperties(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void applyProperties(StyleWithProperties style, Properties props, boolean bInherit) {
getFrameSc().cssBox(style,props,bInherit);
}
diff --git a/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java b/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java
index a993816..05ae5a7 100644
--- a/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java
+++ b/src/main/java/writer2latex/xhtml/style/StyleWithPropertiesParser.java
@@ -36,6 +36,7 @@ import writer2latex.xhtml.Converter;
import writer2latex.xhtml.StyleInfo;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMapItem;
+import writer2latex.xhtml.style.properties.Properties;
/**
*
This is an abstract class to convert an OpenDocument style family
@@ -43,7 +44,8 @@ import writer2latex.xhtml.XhtmlStyleMapItem;
*/
public abstract class StyleWithPropertiesParser extends StyleParser {
- /** Create a new StyleWithPropertiesConverterHelper
+ boolean inlineCSS = false;
+ /** Create a new StyleWithPropertiesConverterHelper
* @param ofr an OfficeReader
to read style information from
* @param config the configuration to use
* @param converter the main Converter
class
@@ -52,6 +54,7 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
public StyleWithPropertiesParser(OfficeReader ofr, XhtmlConfig config,
Converter converter, int nType) {
super(ofr,config,converter,nType);
+ inlineCSS = config.inlineCSS();
}
/** Apply a style, either by converting the style or by applying the
@@ -59,38 +62,48 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
* @param sStyleName name of the OpenDocument style
* @param info the StyleInfo
object to add information to
*/
- public void readStyle(String sStyleName, StyleInfo info) {
- StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
- info.sTagName = getStyleTag();
- if (style!=null) {
- if (config.multilingual()) { applyLang(style,info); }
- applyDirection(style,info);
- if (style.isAutomatic()) {
- // Apply parent style + hard formatting
- readStyle(style.getParentName(),info);
- if (bConvertHard) { applyProperties(style,info.props,false); }
- }
- else {
- String sDisplayName = style.getDisplayName();
- if (styleMap.contains(sDisplayName)) {
- // Apply attributes as specified in style map from user
- XhtmlStyleMapItem map = styleMap.get(sDisplayName);
- if (map.sElement.length()>0) {
- info.sTagName = map.sElement;
- }
- if (!"(none)".equals(map.sCss)) {
- info.sClass = map.sCss;
- }
- }
- else {
- // Generate class name from display name
- styleNames.addName(sDisplayName);
- info.sClass = getClassNamePrefix()
- + styleNames.getName(sDisplayName);
- }
- }
- }
- }
+ public void readStyle(String sStyleName, StyleInfo info) {
+ StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
+ if (style == null) {
+ return;
+ }
+ info.sTagName = getStyleTag();
+ if (config.multilingual()) {
+ applyLang(style, info);
+ }
+ applyDirection(style, info);
+ if (style.isAutomatic()) {
+ // Apply parent style + hard formatting
+ readStyle(style.getParentName(), info);
+ if (bConvertHard) {
+ applyProperties(style, info.props, false);
+ }
+ } else {
+
+ String displayName = style.getDisplayName();
+ if (styleMap.contains(displayName)) {
+ // Apply attributes as specified in style map from user
+ XhtmlStyleMapItem map = styleMap.get(displayName);
+ if (map.sElement.length() > 0) {
+ info.sTagName = map.sElement;
+ }
+ if (!"(none)".equals(map.sCss)) {
+ info.sClass = map.sCss;
+ }
+ } else {
+ // Generate class name from display name
+ styleNames.addName(displayName);
+ info.sClass = getClassNamePrefix() + styleNames.getName(displayName);
+ }
+ }
+ if (info.sClass != null && !info.sClass.equals(sStyleName)) {
+ StyleWithProperties classStyle = (StyleWithProperties) getStyles().getStyle(info.sClass);
+ if (classStyle != null && inlineCSS) {
+ applyProperties(classStyle, info.props, true);
+ }
+ }
+
+ }
/** Convert style information for used styles
* @param sIndent a String of spaces to add before each line
@@ -99,6 +112,9 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
if (!bConvertStyles) {
return "";
}
+ if (inlineCSS) {
+ return "";
+ }
StringBuilder buf = new StringBuilder();
EnumerationCSVList
object to add information to
* @param bInherit true if properties should be inherited from parent style(s)
*/
- public abstract void applyProperties(StyleWithProperties style, CSVList props, boolean bInherit);
+ public abstract void applyProperties(StyleWithProperties style, Properties props, boolean bInherit);
}
diff --git a/src/main/java/writer2latex/xhtml/style/Styles.java b/src/main/java/writer2latex/xhtml/style/Styles.java
index 31d92ed..c6005a5 100644
--- a/src/main/java/writer2latex/xhtml/style/Styles.java
+++ b/src/main/java/writer2latex/xhtml/style/Styles.java
@@ -36,6 +36,7 @@ import writer2latex.xhtml.Converter;
import writer2latex.xhtml.Parser;
import writer2latex.xhtml.StyleInfo;
import writer2latex.xhtml.XhtmlConfig;
+import writer2latex.xhtml.style.properties.Properties;
/** This class converts OpenDocument styles to CSS2 styles.
* Note that some elements in OpenDocument has attributes that also maps to CSS2 properties.
@@ -89,9 +90,9 @@ public class Styles extends Parser {
// Accessor methods for helpers: We need to override the style helper accessors
- public TextStyleParser getTextSc() { return textStyleParser; }
+ public TextStyleParser getTextSP() { return textStyleParser; }
- public ParStyleParser getParSc() { return parStyleParser; }
+ public ParStyleParser getParSP() { return parStyleParser; }
public HeadingStyleParser getHeadingSc() { return headingStyleParser; }
@@ -184,15 +185,15 @@ public class Styles extends Parser {
if (config.xhtmlCustomStylesheet().length()==0 &&
(config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL ||
config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD)) {
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
// Default paragraph/cell/frame style is applied to the body element
StyleWithProperties defaultStyle = getDefaultStyle();
if (defaultStyle!=null) {
// text properties only!
- getTextSc().cssTextCommon(defaultStyle,props,true);
+ getTextSP().cssTextCommon(defaultStyle,props,true);
if (config.useDefaultFont() && config.defaultFontName().length()>0) {
- props.addValue("font-family", "'"+config.defaultFontName()+"'");
+ props.addProperty("font-family", "'"+config.defaultFontName()+"'");
}
}
@@ -200,9 +201,9 @@ public class Styles extends Parser {
if (ofr.isText() && !converter.isOPS()) {
String sMaxWidth = config.getMaxWidth().trim();
if (sMaxWidth.length()>0) {
- props.addValue("max-width", sMaxWidth);
- props.addValue("margin-left","auto");
- props.addValue("margin-right","auto");
+ props.addProperty("max-width", sMaxWidth);
+ props.addProperty("margin-left","auto");
+ props.addProperty("margin-right","auto");
}
}
diff --git a/src/main/java/writer2latex/xhtml/style/TableStyleParser.java b/src/main/java/writer2latex/xhtml/style/TableStyleParser.java
index af81260..c125fa6 100644
--- a/src/main/java/writer2latex/xhtml/style/TableStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/TableStyleParser.java
@@ -33,6 +33,7 @@ import writer2latex.util.CSVList;
import writer2latex.xhtml.Converter;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMap;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument table styles to CSS2 styles.
@@ -75,24 +76,24 @@ public class TableStyleParser extends StyleWithPropertiesParser {
* @param props the CSVList
object to add information to
* @param bInherit true if properties should be inherited from parent style(s)
*/
- public void applyProperties(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void applyProperties(StyleWithProperties style, Properties props, boolean bInherit) {
// Page break
- getParSc().cssPageBreak(style, props, bInherit);
+ getParSP().cssPageBreak(style, props, bInherit);
// Apply background
getFrameSc().cssBackground(style,props,bInherit);
// Table-specific properties
cssTable(style,props,bInherit);
}
- private void cssTable(StyleWithProperties style, CSVList props, boolean bInherit){
+ private void cssTable(StyleWithProperties style, Properties props, boolean bInherit){
// Top and bottom margins
String sMarginTop = style.getAbsoluteProperty(XMLString.FO_MARGIN_TOP);
- if (sMarginTop!=null) { props.addValue("margin-top",scale(sMarginTop)); }
- else { props.addValue("margin-top","0"); }
+ if (sMarginTop!=null) { props.addProperty("margin-top",scale(sMarginTop)); }
+ else { props.addProperty("margin-top","0"); }
String sMarginBottom = style.getAbsoluteProperty(XMLString.FO_MARGIN_BOTTOM);
- if (sMarginBottom!=null) { props.addValue("margin-bottom",scale(sMarginBottom)); }
- else { props.addValue("margin-bottom","0"); }
+ if (sMarginBottom!=null) { props.addProperty("margin-bottom",scale(sMarginBottom)); }
+ else { props.addProperty("margin-bottom","0"); }
// Left and right margins and horizontal alignment
String sAlign = style.getProperty(XMLString.TABLE_ALIGN);
@@ -111,8 +112,8 @@ public class TableStyleParser extends StyleWithPropertiesParser {
sMarginRight = "auto";
}
- if (sMarginLeft!=null) { props.addValue("margin-left",sMarginLeft); }
- if (sMarginRight!=null) { props.addValue("margin-right",sMarginRight); }
+ if (sMarginLeft!=null) { props.addProperty("margin-left",sMarginLeft); }
+ if (sMarginRight!=null) { props.addProperty("margin-right",sMarginRight); }
}
}
diff --git a/src/main/java/writer2latex/xhtml/style/TextStyleParser.java b/src/main/java/writer2latex/xhtml/style/TextStyleParser.java
index 8cce2f4..e316f6e 100644
--- a/src/main/java/writer2latex/xhtml/style/TextStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/TextStyleParser.java
@@ -40,6 +40,7 @@ import writer2latex.xhtml.Converter;
import writer2latex.xhtml.StyleInfo;
import writer2latex.xhtml.XhtmlConfig;
import writer2latex.xhtml.XhtmlStyleMapItem;
+import writer2latex.xhtml.style.properties.Properties;
/**
* This class converts OpenDocument text styles to CSS2 styles.
@@ -205,7 +206,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
private String composeVisitedAnchorDeclarationBlock(String visitedStyleName) {
StyleWithProperties style;
style = ofr.getTextStyle(visitedStyleName);
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
cssText(style, props, true);
cssHyperlink(style, props);
String visitedAnchorDeclarationBlock = props.toString();
@@ -219,7 +220,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
private String composeAnchorDeclarationBlock(String sStyleName) {
StyleWithProperties style = ofr.getTextStyle(sStyleName);
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
cssText(style, props, true);
cssHyperlink(style, props);
String anchorDeclaration = props.toString();
@@ -227,7 +228,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
}
private String composeVisitedLinkDeclarationBlock(StyleWithProperties defaultLinkStyle) {
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
cssText(defaultLinkStyle, props, true);
cssHyperlink(defaultLinkStyle, props);
String visitedLinkDeclaration = props.toString();
@@ -235,7 +236,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
}
private String composeLinkDeclarationBlock(StyleWithProperties defaultLinkStyle) {
- CSVList props = new CSVList(";");
+ Properties props = new Properties(";");
cssText(defaultLinkStyle, props, true);
cssHyperlink(defaultLinkStyle, props);
String linkDeclaration = props.toString();
@@ -262,7 +263,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
* @param props the CSVList
object to add information to
* @param bInherit true if properties should be inherited from parent style(s)
*/
- public void applyProperties(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void applyProperties(StyleWithProperties style, Properties props, boolean bInherit) {
cssText(style,props,bInherit);
}
@@ -295,36 +296,36 @@ public class TextStyleParser extends StyleWithPropertiesParser {
// - fo:hyphenation-*
//
- public void cssText(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void cssText(StyleWithProperties style, Properties props, boolean bInherit) {
cssTextCommon(style,props,bInherit);
cssTextBackground(style,props,bInherit);
}
- public void cssTextCommon(StyleWithProperties style, CSVList props, boolean bInherit) {
- String s=null,s2=null,s3=null,s4=null;
+ public void cssTextCommon(StyleWithProperties style, Properties props, boolean bInherit) {
+ String fontName=null,s2=null,s3=null,s4=null;
CSVList val;
-
+
// Font family
if (bConvertFont && (bInherit || style.getProperty(XMLString.STYLE_FONT_NAME,false)!=null)) {
val = new CSVList(","); // multivalue property!
// Get font family information from font declaration or from style
- s = style.getProperty(XMLString.STYLE_FONT_NAME);
- if (s!=null) {
- FontDeclaration fd = (FontDeclaration) ofr.getFontDeclarations().getStyle(s);
+ fontName = style.getProperty(XMLString.STYLE_FONT_NAME);
+ if (fontName!=null) {
+ FontDeclaration fd = (FontDeclaration) ofr.getFontDeclarations().getStyle(fontName);
if (fd!=null) {
- s = fd.getFontFamily();
+ fontName = fd.getFontFamily();
s2 = fd.getFontFamilyGeneric();
s3 = fd.getFontPitch();
}
}
else {
- s = style.getProperty(XMLString.FO_FONT_FAMILY);
+ fontName = style.getProperty(XMLString.FO_FONT_FAMILY);
s2 = style.getProperty(XMLString.STYLE_FONT_FAMILY_GENERIC);
s3 = style.getProperty(XMLString.STYLE_FONT_PITCH);
}
// Add the western font family (CJK and CTL is more complicated)
- if (s!=null) { val.addValue(s); }
+ if (fontName!=null) { val.addValue(fontName); }
// Add generic font family
if ("fixed".equals(s3)) { val.addValue("monospace"); }
else if ("roman".equals(s2)) { val.addValue("serif"); }
@@ -333,20 +334,20 @@ public class TextStyleParser extends StyleWithPropertiesParser {
else if ("decorative".equals(s2)) { val.addValue("fantasy"); }
else if ("script".equals(s2)) { val.addValue("cursive"); }
else if ("system".equals(s2)) { val.addValue("serif"); } // System default font
- if (!val.isEmpty()) { props.addValue("font-family",val.toString()); }
+ if (!val.isEmpty()) { props.addProperty("font-family",val.toString()); }
}
// Font style (italics): This property fit with css2
- s = style.getProperty(XMLString.FO_FONT_STYLE,bInherit);
- if (s!=null) { props.addValue("font-style",s); }
+ fontName = style.getProperty(XMLString.FO_FONT_STYLE,bInherit);
+ if (fontName!=null) { props.addProperty("font-style",fontName); }
// Font variant (small caps): This property fit with css2
- s = style.getProperty(XMLString.FO_FONT_VARIANT,bInherit);
- if (s!=null) { props.addValue("font-variant",s); }
+ fontName = style.getProperty(XMLString.FO_FONT_VARIANT,bInherit);
+ if (fontName!=null) { props.addProperty("font-variant",fontName); }
// Font weight (bold): This property fit with css2
- s = style.getProperty(XMLString.FO_FONT_WEIGHT,bInherit);
- if (s!=null) { props.addValue("font-weight",s); }
+ fontName = style.getProperty(XMLString.FO_FONT_WEIGHT,bInherit);
+ if (fontName!=null) { props.addProperty("font-weight",fontName); }
// Font size: Absolute values of this property fit with css2
// this is handled together with sub- and superscripts (style:text-position)
@@ -354,7 +355,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
// Second value (optional): percentage (relative size);
if (bInherit || style.getProperty(XMLString.FO_FONT_SIZE,false)!=null
|| style.getProperty(XMLString.STYLE_TEXT_POSITION,false)!=null) {
- s = style.getAbsoluteProperty(XMLString.FO_FONT_SIZE);
+ fontName = style.getAbsoluteProperty(XMLString.FO_FONT_SIZE);
s2 = style.getProperty(XMLString.STYLE_TEXT_POSITION);
if (s2!=null) {
s2 = s2.trim();
@@ -366,54 +367,54 @@ public class TextStyleParser extends StyleWithPropertiesParser {
else { // one value
s3 = s2; s4="100%";
}
- if (s!=null) {
+ if (fontName!=null) {
if (bRelativeFontSize) {
- String sFontSize = Calc.divide(Calc.multiply(sFontScaling, Calc.multiply(s4,s)), sBaseFontSize);
- if (!"100%".equals(sFontSize)) props.addValue("font-size", sFontSize);
+ String sFontSize = Calc.divide(Calc.multiply(sFontScaling, Calc.multiply(s4,fontName)), sBaseFontSize);
+ if (!"100%".equals(sFontSize)) props.addProperty("font-size", sFontSize);
}
else {
- props.addValue("font-size",Calc.multiply(s4,scale(s)));
+ props.addProperty("font-size",Calc.multiply(s4,scale(fontName)));
}
}
else {
- props.addValue("font-size",s4);
+ props.addProperty("font-size",s4);
}
if (!"0%".equals(s3)) {
- props.addValue("vertical-align",s3);
+ props.addProperty("vertical-align",s3);
}
}
- else if (s!=null) {
+ else if (fontName!=null) {
if (bRelativeFontSize) {
- String sFontSize = Calc.divide(Calc.multiply(sFontScaling, s),sBaseFontSize);
+ String sFontSize = Calc.divide(Calc.multiply(sFontScaling, fontName),sBaseFontSize);
if (!"100%".equals(sFontSize)) {
- props.addValue("font-size", sFontSize);
+ props.addProperty("font-size", sFontSize);
}
}
else {
- props.addValue("font-size",scale(s));
+ props.addProperty("font-size",scale(fontName));
}
}
}
// Color: This attribute fit with css2
- s = style.getProperty(XMLString.FO_COLOR,bInherit);
- if (s!=null) { props.addValue("color",s); }
+ fontName = style.getProperty(XMLString.FO_COLOR,bInherit);
+ if (fontName!=null) { props.addProperty("color",fontName); }
// Shadow: This attribute fit with css2
// (Currently OOo has only one shadow style, which is saved as 1pt 1pt)
- s = style.getProperty(XMLString.FO_TEXT_SHADOW,bInherit);
- if (s!=null) { props.addValue("text-shadow",s); }
+ fontName = style.getProperty(XMLString.FO_TEXT_SHADOW,bInherit);
+ if (fontName!=null) { props.addProperty("text-shadow",fontName); }
// Text decoration. Here OOo is more flexible that CSS2.
if (ofr.isOpenDocument()) {
- s = style.getProperty(XMLString.STYLE_TEXT_LINE_THROUGH_STYLE,bInherit);
+ fontName = style.getProperty(XMLString.STYLE_TEXT_LINE_THROUGH_STYLE,bInherit);
s2 = style.getProperty(XMLString.STYLE_TEXT_UNDERLINE_STYLE,bInherit);
}
else {
- s = style.getProperty(XMLString.STYLE_TEXT_CROSSING_OUT,bInherit);
+ fontName = style.getProperty(XMLString.STYLE_TEXT_CROSSING_OUT,bInherit);
s2 = style.getProperty(XMLString.STYLE_TEXT_UNDERLINE,bInherit);
}
s3 = style.getProperty(XMLString.STYLE_TEXT_BLINKING,bInherit);
@@ -421,46 +422,46 @@ public class TextStyleParser extends StyleWithPropertiesParser {
// text-decoration, there is no way to turn on one kind of decoration and
// turn another one off (without creating another inline element).
// If one decoration is turned of, we turn them all off:
- if ("none".equals(s) || "none".equals(s2) || "false".equals(s3)) {
- props.addValue("text-decoration","none");
+ if ("none".equals(fontName) || "none".equals(s2) || "false".equals(s3)) {
+ props.addProperty("text-decoration","none");
}
else { // set the required properties
val = new CSVList(" "); // multivalue property!
- if (s!=null && !"none".equals(s)) { val.addValue("line-through"); }
+ if (fontName!=null && !"none".equals(fontName)) { val.addValue("line-through"); }
if (s2!=null && !"none".equals(s2)) { val.addValue("underline"); }
if (s3!=null && "true".equals(s3)) { val.addValue("blink"); }
- if (!val.isEmpty()) { props.addValue("text-decoration",val.toString()); }
+ if (!val.isEmpty()) { props.addProperty("text-decoration",val.toString()); }
}
// Letter spacing: This property fit with css
- s = style.getProperty(XMLString.FO_LETTER_SPACING,bInherit);
- if ( s != null ) {
+ fontName = style.getProperty(XMLString.FO_LETTER_SPACING,bInherit);
+ if ( fontName != null ) {
if ( minLetterSpacing != null ) {
- String onlyNums = scale(s).replaceAll("[a-zA-Z]", "");
+ String onlyNums = scale(fontName).replaceAll("[a-zA-Z]", "");
Double curLS = Double.parseDouble(onlyNums);
if ( minLetterSpacing < curLS ) {
- props.addValue("letter-spacing",scale(s));
+ props.addProperty("letter-spacing",scale(fontName));
}
} else {
- props.addValue("letter-spacing",scale(s));
+ props.addProperty("letter-spacing",scale(fontName));
}
}
// Capitalization: This property fit with css
- s = style.getProperty(XMLString.FO_TEXT_TRANSFORM,bInherit);
- if (s!=null) { props.addValue("text-transform",s); }
+ fontName = style.getProperty(XMLString.FO_TEXT_TRANSFORM,bInherit);
+ if (fontName!=null) { props.addProperty("text-transform",fontName); }
}
- public void cssTextBackground(StyleWithProperties style, CSVList props, boolean bInherit) {
+ public void cssTextBackground(StyleWithProperties style, Properties props, boolean bInherit) {
// Background color: This attribute fit with css when applied to inline text
String s =ofr.isOpenDocument() ?
style.getTextProperty(XMLString.FO_BACKGROUND_COLOR,bInherit) :
style.getTextProperty(XMLString.STYLE_TEXT_BACKGROUND_COLOR,bInherit);
- if (s!=null) { props.addValue("background-color",s); }
+ if (s!=null) { props.addProperty("background-color",s); }
}
- private void cssHyperlink(StyleWithProperties style, CSVList props) {
+ private void cssHyperlink(StyleWithProperties style, Properties props) {
String s1,s2;
// For hyperlinks, export text-decoration:none even if nothing is defined in source
if (ofr.isOpenDocument()) {
@@ -473,7 +474,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
}
String s3 = style.getProperty(XMLString.STYLE_TEXT_BLINKING,true);
if (s1==null && s2==null && s3==null) {
- props.addValue("text-decoration","none");
+ props.addProperty("text-decoration","none");
}
}
diff --git a/src/main/java/writer2latex/xhtml/style/properties/Properties.java b/src/main/java/writer2latex/xhtml/style/properties/Properties.java
new file mode 100644
index 0000000..00eac42
--- /dev/null
+++ b/src/main/java/writer2latex/xhtml/style/properties/Properties.java
@@ -0,0 +1,52 @@
+package writer2latex.xhtml.style.properties;
+
+import java.util.HashMap;
+import java.util.Map;
+
+//Create a list of values separated by commas or another seperation character
+public class Properties{
+ private String separator;
+ private String internalSeparator;
+ private HashMap