Refactoring styles conversion. Added Properties class.
This commit is contained in:
parent
20c6326b5e
commit
ca3c2123f4
23 changed files with 383 additions and 298 deletions
|
@ -221,6 +221,13 @@ public class StyleWithProperties extends OfficeStyle {
|
||||||
}
|
}
|
||||||
return null; // no value
|
return null; // no value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasProperty(String propertyName) {
|
||||||
|
if (getProperty(propertyName) == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Remove this method
|
// TODO: Remove this method
|
||||||
public String getProperty(String sProperty){
|
public String getProperty(String sProperty){
|
||||||
|
|
|
@ -887,8 +887,8 @@ public class Converter extends BasicConverter {
|
||||||
String sStyleName = onode.getAttribute(XMLString.TEXT_STYLE_NAME);
|
String sStyleName = onode.getAttribute(XMLString.TEXT_STYLE_NAME);
|
||||||
String sVisitedStyleName = onode.getAttribute(XMLString.TEXT_VISITED_STYLE_NAME);
|
String sVisitedStyleName = onode.getAttribute(XMLString.TEXT_VISITED_STYLE_NAME);
|
||||||
StyleInfo anchorInfo = new StyleInfo();
|
StyleInfo anchorInfo = new StyleInfo();
|
||||||
styles.getTextSc().applyAnchorStyle(sStyleName,sVisitedStyleName,anchorInfo);
|
styles.getTextSP().applyAnchorStyle(sStyleName,sVisitedStyleName,anchorInfo);
|
||||||
styles.getTextSc().writeStyle(anchorInfo,anchor);
|
styles.getTextSP().writeStyle(anchorInfo,anchor);
|
||||||
|
|
||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,9 @@ public class Parser {
|
||||||
|
|
||||||
protected Styles getStyleCv() { return converter.getStylesParser(); }
|
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(); }
|
protected HeadingStyleParser getHeadingSc() { return converter.getStylesParser().getHeadingSc(); }
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
|
|
||||||
package writer2latex.xhtml;
|
package writer2latex.xhtml;
|
||||||
|
|
||||||
import writer2latex.util.CSVList;
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
public class StyleInfo {
|
public class StyleInfo {
|
||||||
public String sTagName = null;
|
public String sTagName = null;
|
||||||
public String sClass = null;
|
public String sClass = null;
|
||||||
public CSVList props = new CSVList(";");
|
public Properties props = new Properties(";");
|
||||||
public String sLang = null;
|
public String sLang = null;
|
||||||
public String sDir = null;
|
public String sDir = null;
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ import writer2latex.xhtml.Parser;
|
||||||
import writer2latex.xhtml.StyleInfo;
|
import writer2latex.xhtml.StyleInfo;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlDocument;
|
import writer2latex.xhtml.XhtmlDocument;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
import writer2latex.base.BinaryGraphicsDocument;
|
import writer2latex.base.BinaryGraphicsDocument;
|
||||||
import writer2latex.office.EmbeddedObject;
|
import writer2latex.office.EmbeddedObject;
|
||||||
import writer2latex.office.EmbeddedXMLObject;
|
import writer2latex.office.EmbeddedXMLObject;
|
||||||
|
@ -167,9 +168,9 @@ public class DrawParser extends Parser {
|
||||||
// Style it (TODO: Apply hard drawing-page (background) style)
|
// Style it (TODO: Apply hard drawing-page (background) style)
|
||||||
StyleInfo info = new StyleInfo();
|
StyleInfo info = new StyleInfo();
|
||||||
getPageSc().applyStyle(onode.getAttribute(XMLString.DRAW_MASTER_PAGE_NAME),info);
|
getPageSc().applyStyle(onode.getAttribute(XMLString.DRAW_MASTER_PAGE_NAME),info);
|
||||||
info.props.addValue("top","40px"); // Somewhat arbitrary
|
info.props.addProperty("top","40px"); // Somewhat arbitrary
|
||||||
info.props.addValue("left","0");
|
info.props.addProperty("left","0");
|
||||||
info.props.addValue("position","absolute");
|
info.props.addProperty("position","absolute");
|
||||||
writeStyle(info,div);
|
writeStyle(info,div);
|
||||||
|
|
||||||
// Traverse the draw:page
|
// Traverse the draw:page
|
||||||
|
@ -463,7 +464,7 @@ public class DrawParser extends Parser {
|
||||||
Element elementWithFont = (Element) convertedMath;
|
Element elementWithFont = (Element) convertedMath;
|
||||||
String styleAttr = elementWithFont.getAttribute("style");
|
String styleAttr = elementWithFont.getAttribute("style");
|
||||||
if (styleAttr == null) { styleAttr = "";}
|
if (styleAttr == null) { styleAttr = "";}
|
||||||
String fontValue = getStyleCv().getTextSc().scale(fontSize+"pt");
|
String fontValue = getStyleCv().getTextSP().scale(fontSize+"pt");
|
||||||
elementWithFont.setAttribute("style", "font-size:"+ fontValue);
|
elementWithFont.setAttribute("style", "font-size:"+ fontValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -678,15 +679,15 @@ public class DrawParser extends Parser {
|
||||||
break;
|
break;
|
||||||
case ABSOLUTE:
|
case ABSOLUTE:
|
||||||
sContentWidth = applyImageSize(frame,info.props,nMode,false);
|
sContentWidth = applyImageSize(frame,info.props,nMode,false);
|
||||||
info.props.addValue("margin-left","auto");
|
info.props.addProperty("margin-left","auto");
|
||||||
info.props.addValue("margin-right","auto");
|
info.props.addProperty("margin-right","auto");
|
||||||
applyPosition(frame,info.props);
|
applyPosition(frame,info.props);
|
||||||
break;
|
break;
|
||||||
case CENTERED:
|
case CENTERED:
|
||||||
info.props.addValue("margin-top","2px");
|
info.props.addProperty("margin-top","2px");
|
||||||
info.props.addValue("margin-bottom","2px");
|
info.props.addProperty("margin-bottom","2px");
|
||||||
info.props.addValue("margin-left","auto");
|
info.props.addProperty("margin-left","auto");
|
||||||
info.props.addValue("margin-right","auto");
|
info.props.addProperty("margin-right","auto");
|
||||||
sContentWidth = applyImageSize(frame,info.props,nMode,true);
|
sContentWidth = applyImageSize(frame,info.props,nMode,true);
|
||||||
break;
|
break;
|
||||||
case FLOATING:
|
case FLOATING:
|
||||||
|
@ -697,33 +698,33 @@ public class DrawParser extends Parser {
|
||||||
String sWrap = style.getProperty(XMLString.STYLE_WRAP);
|
String sWrap = style.getProperty(XMLString.STYLE_WRAP);
|
||||||
if (isLeft(sPos)) {
|
if (isLeft(sPos)) {
|
||||||
if (mayWrapRight(sWrap)) {
|
if (mayWrapRight(sWrap)) {
|
||||||
info.props.addValue("float","left");
|
info.props.addProperty("float","left");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: Remove the margin-right attribute from the existing properties
|
// TODO: Remove the margin-right attribute from the existing properties
|
||||||
// and likewise for the other two cases below (requires new CSVList)
|
// 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)) {
|
else if (isRight(sPos)) {
|
||||||
if (mayWrapLeft(sWrap)) {
|
if (mayWrapLeft(sWrap)) {
|
||||||
info.props.addValue("float","right");
|
info.props.addProperty("float","right");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
info.props.addValue("margin-left", "auto");
|
info.props.addProperty("margin-left", "auto");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isCenter(sPos)) {
|
else if (isCenter(sPos)) {
|
||||||
info.props.addValue("margin-left", "auto");
|
info.props.addProperty("margin-left", "auto");
|
||||||
info.props.addValue("margin-right", "auto");
|
info.props.addProperty("margin-right", "auto");
|
||||||
}
|
}
|
||||||
else if (isFromLeft(sPos)) {
|
else if (isFromLeft(sPos)) {
|
||||||
if (mayWrapRight(sWrap)) {
|
if (mayWrapRight(sWrap)) {
|
||||||
info.props.addValue("float","left");
|
info.props.addProperty("float","left");
|
||||||
}
|
}
|
||||||
String sX = frame.getAttribute(XMLString.SVG_X);
|
String sX = frame.getAttribute(XMLString.SVG_X);
|
||||||
if (sX!=null && sX.length()>0) {
|
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
|
// 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));
|
StyleWithProperties style = ofr.getFrameStyle(node.getAttribute(XMLString.DRAW_STYLE_NAME));
|
||||||
|
|
||||||
String sWidth = getFrameWidth(node, style);
|
String sWidth = getFrameWidth(node, style);
|
||||||
if (sWidth!=null) {
|
if (sWidth!=null) {
|
||||||
props.addValue("width",scale(sWidth));
|
props.addProperty("width",scale(sWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bOnlyWidth) {
|
if (!bOnlyWidth) {
|
||||||
String sHeight = getFrameHeight(node,style);
|
String sHeight = getFrameHeight(node,style);
|
||||||
if (sHeight!=null) {
|
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: 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)
|
// 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) {
|
switch (nImageSize) {
|
||||||
case XhtmlConfig.ABSOLUTE:
|
case XhtmlConfig.ABSOLUTE:
|
||||||
return applySize(node, props, bOnlyWidth);
|
return applySize(node, props, bOnlyWidth);
|
||||||
case XhtmlConfig.RELATIVE:
|
case XhtmlConfig.RELATIVE:
|
||||||
if (nMode==FULL_SCREEN) {
|
if (nMode==FULL_SCREEN) {
|
||||||
props.addValue("max-width","100%");
|
props.addProperty("max-width","100%");
|
||||||
props.addValue("height","100%");
|
props.addProperty("height","100%");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String sWidth = getFrameWidth(node, ofr.getFrameStyle(node.getAttribute(XMLString.DRAW_STYLE_NAME)));
|
String sWidth = getFrameWidth(node, ofr.getFrameStyle(node.getAttribute(XMLString.DRAW_STYLE_NAME)));
|
||||||
if (sWidth!=null) {
|
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;
|
return sWidth;
|
||||||
}
|
}
|
||||||
|
@ -1105,7 +1106,7 @@ public class DrawParser extends Parser {
|
||||||
return null;
|
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
|
// 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
|
// We thus have to subtract the margins to get correct placement
|
||||||
String sX = node.getAttribute(XMLString.SVG_X);
|
String sX = node.getAttribute(XMLString.SVG_X);
|
||||||
|
@ -1120,9 +1121,9 @@ public class DrawParser extends Parser {
|
||||||
if (s!=null) sY=Calc.sub(sY,s);
|
if (s!=null) sY=Calc.sub(sY,s);
|
||||||
}
|
}
|
||||||
|
|
||||||
props.addValue("position","absolute");
|
props.addProperty("position","absolute");
|
||||||
if (sX!=null && sX.length()>0) { props.addValue("left",scale(sX)); }
|
if (sX!=null && sX.length()>0) { props.addProperty("left",scale(sX)); }
|
||||||
if (sY!=null && sY.length()>0) { props.addValue("top",scale(sY)); }
|
if (sY!=null && sY.length()>0) { props.addProperty("top",scale(sY)); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1182,8 +1183,8 @@ public class DrawParser extends Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bWrap) {
|
if (bWrap) {
|
||||||
info.props.addValue("float",sAlign);
|
info.props.addProperty("float",sAlign);
|
||||||
if (sX!=null && sX.length()>0) { info.props.addValue("margin-left",sX); }
|
if (sX!=null && sX.length()>0) { info.props.addProperty("margin-left",sX); }
|
||||||
if (hnodeInline!=null) {
|
if (hnodeInline!=null) {
|
||||||
hnodeInline.appendChild(object);
|
hnodeInline.appendChild(object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ class NoteParser extends Parser {
|
||||||
// Style it
|
// Style it
|
||||||
String sCitStyle = noteConfig.getProperty(XMLString.TEXT_CITATION_STYLE_NAME);
|
String sCitStyle = noteConfig.getProperty(XMLString.TEXT_CITATION_STYLE_NAME);
|
||||||
StyleInfo linkInfo = new StyleInfo();
|
StyleInfo linkInfo = new StyleInfo();
|
||||||
getTextSc().readStyle(sCitStyle,linkInfo);
|
getTextSP().readStyle(sCitStyle,linkInfo);
|
||||||
writeStyle(linkInfo,link);
|
writeStyle(linkInfo,link);
|
||||||
|
|
||||||
// Add prefix
|
// Add prefix
|
||||||
|
|
|
@ -138,7 +138,7 @@ class TOCParser extends IndexParser {
|
||||||
|
|
||||||
void handleParagraph(Element onode, Element par, String sCurrentListLabel) {
|
void handleParagraph(Element onode, Element par, String sCurrentListLabel) {
|
||||||
String sStyleName = Misc.getAttribute(onode,XMLString.TEXT_STYLE_NAME);
|
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));
|
converter.addTarget(par,TOC_LINK_PREFIX+(++nTocIndex));
|
||||||
TocEntry entry = new TocEntry();
|
TocEntry entry = new TocEntry();
|
||||||
entry.onode = (Element) onode;
|
entry.onode = (Element) onode;
|
||||||
|
@ -251,7 +251,7 @@ class TOCParser extends IndexParser {
|
||||||
getTextCv().traverseInlineText(entry.onode,a);
|
getTextCv().traverseInlineText(entry.onode,a);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
nLevel = tocReader.getIndexSourceStyleLevel(sStyleName);
|
||||||
if (tocReader.useIndexSourceStyles() && 1<=nLevel && nLevel<=tocReader.getOutlineLevel()) {
|
if (tocReader.useIndexSourceStyles() && 1<=nLevel && nLevel<=tocReader.getOutlineLevel()) {
|
||||||
Element p = getTextCv().createParagraph(li,sEntryStyleName[nLevel]);
|
Element p = getTextCv().createParagraph(li,sEntryStyleName[nLevel]);
|
||||||
|
@ -265,7 +265,7 @@ class TOCParser extends IndexParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (XMLString.TEXT_P.equals(sNodeName)) {
|
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);
|
int nLevel = tocReader.getIndexSourceStyleLevel(sStyleName);
|
||||||
if (tocReader.useIndexSourceStyles() && 1<=nLevel && nLevel<=tocReader.getOutlineLevel()) {
|
if (tocReader.useIndexSourceStyles() && 1<=nLevel && nLevel<=tocReader.getOutlineLevel()) {
|
||||||
Element p = getTextCv().createParagraph(li,sEntryStyleName[nLevel]);
|
Element p = getTextCv().createParagraph(li,sEntryStyleName[nLevel]);
|
||||||
|
|
|
@ -349,7 +349,7 @@ public class TableParser extends Parser {
|
||||||
// Set table width
|
// Set table width
|
||||||
String sWidth = style.getProperty(XMLString.STYLE_REL_WIDTH);
|
String sWidth = style.getProperty(XMLString.STYLE_REL_WIDTH);
|
||||||
if (sWidth!=null) {
|
if (sWidth!=null) {
|
||||||
info.props.addValue("width",sWidth);
|
info.props.addProperty("width",sWidth);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sWidth = style.getProperty(XMLString.STYLE_WIDTH);
|
sWidth = style.getProperty(XMLString.STYLE_WIDTH);
|
||||||
|
@ -357,10 +357,10 @@ public class TableParser extends Parser {
|
||||||
if (config.tableSize()==XhtmlConfig.RELATIVE){
|
if (config.tableSize()==XhtmlConfig.RELATIVE){
|
||||||
// Force relative width
|
// Force relative width
|
||||||
sWidth=Calc.divide(sWidth, converter.getContentWidth(), true);
|
sWidth=Calc.divide(sWidth, converter.getContentWidth(), true);
|
||||||
info.props.addValue("width",sWidth);
|
info.props.addProperty("width",sWidth);
|
||||||
}
|
}
|
||||||
else {
|
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:
|
// Writer uses a separating border model, Calc a collapsing:
|
||||||
// props.addValue("border-collapse", bCalc ? "collapse" : "separate");
|
// props.addValue("border-collapse", bCalc ? "collapse" : "separate");
|
||||||
// For now always use separating model:
|
// For now always use separating model:
|
||||||
info.props.addValue("border-collapse", "separate");
|
info.props.addProperty("border-collapse", "separate");
|
||||||
info.props.addValue("border-spacing", "0");
|
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...
|
//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) {
|
if (bIsSubTable) {
|
||||||
// Should try to fill the cell; hence:
|
// Should try to fill the cell; hence:
|
||||||
info.props.addValue("width","100%");
|
info.props.addProperty("width","100%");
|
||||||
info.props.addValue("margin","0");
|
info.props.addProperty("margin","0");
|
||||||
}
|
}
|
||||||
writeStyle(info,table);
|
writeStyle(info,table);
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ public class TableParser extends Parser {
|
||||||
String s = style.getAbsoluteProperty(XMLString.STYLE_ROW_HEIGHT);
|
String s = style.getAbsoluteProperty(XMLString.STYLE_ROW_HEIGHT);
|
||||||
// Do not export minimal row height; causes trouble with ie
|
// Do not export minimal row height; causes trouble with ie
|
||||||
//if (s==null) { s = style.getAbsoluteProperty(XMLString.STYLE_MIN_ROW_HEIGHT); }
|
//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) {
|
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))) {
|
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
|
// Strings go left, other types (float, time, date, percentage, currency, boolean) go right
|
||||||
// The default is string
|
// 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) {
|
if (bIsSubTable) {
|
||||||
// Cannot set height of a subtable, if the subtable does not fill
|
// Cannot set height of a subtable, if the subtable does not fill
|
||||||
// the entire cell it is placed at the top
|
// 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!
|
// 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);
|
writeStyle(info,cell);
|
||||||
|
|
|
@ -712,7 +712,7 @@ public class TextParser extends Parser {
|
||||||
traverseInlineText(onode, content);
|
traverseInlineText(onode, content);
|
||||||
|
|
||||||
// Add before/after text if required
|
// 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
|
// Keep track of current headings for split output
|
||||||
currentHeading[nLevel] = heading;
|
currentHeading[nLevel] = heading;
|
||||||
|
@ -782,7 +782,7 @@ public class TextParser extends Parser {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Otherwise, add before/after text if required
|
// 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();
|
StyleInfo info = new StyleInfo();
|
||||||
if (style!=null) {
|
if (style!=null) {
|
||||||
String sTextStyleName = style.getLevelProperty(nLevel,TEXT_STYLE_NAME);
|
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.sTagName==null) { info.sTagName = "span"; }
|
||||||
if (info.sClass==null) { info.sClass = sDefaultStyle; }
|
if (info.sClass==null) { info.sClass = sDefaultStyle; }
|
||||||
|
|
||||||
Element content = converter.createElement(info.sTagName);
|
Element content = converter.createElement(info.sTagName);
|
||||||
getTextSc().writeStyle(info, content);
|
getTextSP().writeStyle(info, content);
|
||||||
hnode.appendChild(content);
|
hnode.appendChild(content);
|
||||||
content.appendChild( converter.createTextNode(sLabel) );
|
content.appendChild( converter.createTextNode(sLabel) );
|
||||||
}
|
}
|
||||||
|
@ -1642,10 +1642,11 @@ public class TextParser extends Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a styled paragraph node */
|
/* Create a styled paragraph node */
|
||||||
protected Element createParagraph(Element node, String sStyleName) {
|
protected Element createParagraph(Element node, String styleName) {
|
||||||
StyleInfo info = new StyleInfo();
|
StyleInfo info = new StyleInfo();
|
||||||
StyleWithProperties style = ofr.getParStyle(sStyleName);
|
StyleWithProperties style = ofr.getParStyle(styleName);
|
||||||
getParSc().readStyle(sStyleName,info);
|
getParSP().readStyle(styleName,info);
|
||||||
|
|
||||||
Element para = converter.createElement(info.sTagName);
|
Element para = converter.createElement(info.sTagName);
|
||||||
node.appendChild(para);
|
node.appendChild(para);
|
||||||
|
|
||||||
|
@ -1663,7 +1664,7 @@ public class TextParser extends Parser {
|
||||||
if (config.xhtmlFormatting()==XhtmlConfig.IGNORE_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD) {
|
if (config.xhtmlFormatting()==XhtmlConfig.IGNORE_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
String sBack = getParSc().getTextBackground(sStyleName);
|
String sBack = getParSP().getTextBackground(sStyleName);
|
||||||
if (sBack.length()>0) {
|
if (sBack.length()>0) {
|
||||||
Element span = converter.createElement("span");
|
Element span = converter.createElement("span");
|
||||||
span.setAttribute("style",sBack);
|
span.setAttribute("style",sBack);
|
||||||
|
@ -1678,7 +1679,8 @@ public class TextParser extends Parser {
|
||||||
/* Create a styled inline node */
|
/* Create a styled inline node */
|
||||||
protected Element createInline(Element node, String sStyleName) {
|
protected Element createInline(Element node, String sStyleName) {
|
||||||
StyleInfo info = new StyleInfo();
|
StyleInfo info = new StyleInfo();
|
||||||
getTextSc().readStyle(sStyleName,info);
|
getTextSP().readStyle(sStyleName,info);
|
||||||
|
|
||||||
Element newNode = node;
|
Element newNode = node;
|
||||||
if (info.hasAttributes() || !"span".equals(info.sTagName)) {
|
if (info.hasAttributes() || !"span".equals(info.sTagName)) {
|
||||||
// We (probably) need to create a new element
|
// We (probably) need to create a new element
|
||||||
|
|
|
@ -33,6 +33,7 @@ import writer2latex.util.CSVList;
|
||||||
import writer2latex.xhtml.Converter;
|
import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMap;
|
import writer2latex.xhtml.XhtmlStyleMap;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument cell styles to CSS2 styles.
|
* This class converts OpenDocument cell styles to CSS2 styles.
|
||||||
|
@ -75,31 +76,31 @@ public class CellStyleParser extends StyleWithPropertiesParser {
|
||||||
* @param props the <code>CSVList</code> object to add information to
|
* @param props the <code>CSVList</code> object to add information to
|
||||||
* @param bInherit true if properties should be inherited from parent style(s)
|
* @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)
|
// Apply "inner" box properties (no margins)
|
||||||
getFrameSc().cssBorder(style,props,bInherit);
|
getFrameSc().cssBorder(style,props,bInherit);
|
||||||
getFrameSc().cssPadding(style,props,bInherit);
|
getFrameSc().cssPadding(style,props,bInherit);
|
||||||
getFrameSc().cssBackground(style,props,bInherit);
|
getFrameSc().cssBackground(style,props,bInherit);
|
||||||
// only relevant for spreadsheets
|
// only relevant for spreadsheets
|
||||||
getParSc().cssPar(style,props,bInherit);
|
getParSP().cssPar(style,props,bInherit);
|
||||||
getTextSc().cssTextCommon(style,props,bInherit);
|
getTextSP().cssTextCommon(style,props,bInherit);
|
||||||
// Cell-specific properties (vertical alignment)
|
// Cell-specific properties (vertical alignment)
|
||||||
cssCell(style,props,bInherit);
|
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
|
// Vertical align: Some values fit with css
|
||||||
String s = ofr.isOpenDocument() ?
|
String s = ofr.isOpenDocument() ?
|
||||||
style.getProperty(XMLString.STYLE_VERTICAL_ALIGN,bInherit) :
|
style.getProperty(XMLString.STYLE_VERTICAL_ALIGN,bInherit) :
|
||||||
style.getProperty(XMLString.FO_VERTICAL_ALIGN,bInherit);
|
style.getProperty(XMLString.FO_VERTICAL_ALIGN,bInherit);
|
||||||
if ("middle".equals(s)) { props.addValue("vertical-align","middle"); }
|
if ("middle".equals(s)) { props.addProperty("vertical-align","middle"); }
|
||||||
else if ("bottom".equals(s)) { props.addValue("vertical-align","bottom"); }
|
else if ("bottom".equals(s)) { props.addProperty("vertical-align","bottom"); }
|
||||||
else if ("top".equals(s)) { props.addValue("vertical-align","top"); }
|
else if ("top".equals(s)) { props.addProperty("vertical-align","top"); }
|
||||||
else {
|
else {
|
||||||
// No value or "automatic" means, according to the spec,
|
// No value or "automatic" means, according to the spec,
|
||||||
//"The application decide how to align the text."
|
//"The application decide how to align the text."
|
||||||
// We treat this case like OOo does:
|
// We treat this case like OOo does:
|
||||||
props.addValue("vertical-align", ofr.isSpreadsheet() ? "bottom" : "top");
|
props.addProperty("vertical-align", ofr.isSpreadsheet() ? "bottom" : "top");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import writer2latex.util.Calc;
|
||||||
import writer2latex.util.SimpleInputBuffer;
|
import writer2latex.util.SimpleInputBuffer;
|
||||||
import writer2latex.xhtml.Converter;
|
import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument graphic (frame) styles to CSS2 styles.
|
* This class converts OpenDocument graphic (frame) styles to CSS2 styles.
|
||||||
|
@ -94,10 +95,10 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
|
||||||
|
|
||||||
public String composeDeclarationBlock( String sDisplayName) {
|
public String composeDeclarationBlock( String sDisplayName) {
|
||||||
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName);
|
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(sDisplayName);
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
getFrameSc().cssMargins(style, props, true);
|
getFrameSc().cssMargins(style, props, true);
|
||||||
getParSc().cssPar(style, props, true);
|
getParSP().cssPar(style, props, true);
|
||||||
getTextSc().cssTextCommon(style, props, true);
|
getTextSP().cssTextCommon(style, props, true);
|
||||||
return props.toString();
|
return props.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,57 +127,52 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
|
||||||
* @param props the <code>CSVList</code> object to add information to
|
* @param props the <code>CSVList</code> object to add information to
|
||||||
* @param bInherit true if properties should be inherited from parent style(s)
|
* @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);
|
cssBox(style,props,bInherit);
|
||||||
getTextSc().cssTextCommon(style,props,bInherit); // only in presentations
|
getTextSP().cssTextCommon(style,props,bInherit); // only in presentations
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// OpenDocument frame properties
|
// 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.
|
// translates "box" style properties.
|
||||||
// these can be applied to paragraph styles, frame styles and page styles.
|
// these can be applied to paragraph styles, frame styles and page styles.
|
||||||
// The following properties are not supported by CSS2:
|
// The following properties are not supported by CSS2:
|
||||||
// style:border-line-width and style:border-line-width-*
|
// style:border-line-width and style:border-line-width-*
|
||||||
// TODO: What about shadow?
|
// TODO: What about shadow?
|
||||||
cssMargins(style,props,bInherit);
|
cssMargins(style,props,bInherit);
|
||||||
cssBorder(style,props,bInherit);
|
cssBorder(style,props,bInherit);
|
||||||
cssPadding(style,props,bInherit);
|
cssPadding(style,props,bInherit);
|
||||||
cssBackground(style,props,bInherit);
|
cssBackground(style,props,bInherit);
|
||||||
cssColumns(style,props,bInherit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cssColumns(StyleWithProperties style, CSVList props, boolean bInherit) {
|
public void cssMargins(StyleWithProperties style, Properties props, boolean bInherit){
|
||||||
String columnCount = style.getAbsoluteProperty(XMLString.FO_COLUMN_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cssMargins(StyleWithProperties style, CSVList props, boolean bInherit){
|
|
||||||
// *Absolute* values fit with css
|
// *Absolute* values fit with css
|
||||||
String s;
|
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);
|
s = style.getAbsoluteProperty(XMLString.FO_MARGIN_LEFT);
|
||||||
if (s!=null) { props.addValue("margin-left",scale(s)); }
|
if (s!=null) { props.addProperty("margin-left",scale(s)); }
|
||||||
else { props.addValue("margin-left","0"); }
|
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);
|
s = style.getAbsoluteProperty(XMLString.FO_MARGIN_RIGHT);
|
||||||
if (s!=null) { props.addValue("margin-right",scale(s)); }
|
if (s!=null) { props.addProperty("margin-right",scale(s)); }
|
||||||
else { props.addValue("margin-right","0"); }
|
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);
|
s = style.getAbsoluteProperty(XMLString.FO_MARGIN_TOP);
|
||||||
if (s!=null) { props.addValue("margin-top",scale(s)); }
|
if (s!=null) { props.addProperty("margin-top",scale(s)); }
|
||||||
else { props.addValue("margin-top","0"); }
|
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);
|
s = style.getAbsoluteProperty(XMLString.FO_MARGIN_BOTTOM);
|
||||||
if (s!=null) { props.addValue("margin-bottom",scale(s)); }
|
if (s!=null) { props.addProperty("margin-bottom",scale(s)); }
|
||||||
else { props.addValue("margin-bottom","0"); }
|
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
|
// Same as in css
|
||||||
boolean bHasBorder = false;
|
boolean bHasBorder = false;
|
||||||
String s=null;
|
String s=null;
|
||||||
|
@ -184,38 +180,38 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
|
||||||
s = style.getProperty(XMLString.FO_BORDER);
|
s = style.getProperty(XMLString.FO_BORDER);
|
||||||
}
|
}
|
||||||
if (s!=null) {
|
if (s!=null) {
|
||||||
props.addValue("border",borderScale(s)); bHasBorder = true;
|
props.addProperty("border",borderScale(s)); bHasBorder = true;
|
||||||
}
|
}
|
||||||
else { // apply individual borders
|
else { // apply individual borders
|
||||||
if (bInherit || style.getProperty(XMLString.FO_BORDER_TOP,false)!=null) {
|
if (bInherit || style.getProperty(XMLString.FO_BORDER_TOP,false)!=null) {
|
||||||
s = style.getProperty(XMLString.FO_BORDER_TOP);
|
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) {
|
if (bInherit || style.getProperty(XMLString.FO_BORDER_BOTTOM,false)!=null) {
|
||||||
s = style.getProperty(XMLString.FO_BORDER_BOTTOM);
|
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) {
|
if (bInherit || style.getProperty(XMLString.FO_BORDER_LEFT,false)!=null) {
|
||||||
s = style.getProperty(XMLString.FO_BORDER_LEFT);
|
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) {
|
if (bInherit || style.getProperty(XMLString.FO_BORDER_RIGHT,false)!=null) {
|
||||||
s = style.getProperty(XMLString.FO_BORDER_RIGHT);
|
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:
|
// 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
|
// *Absolute* values fit with css
|
||||||
String s=null;
|
String s=null;
|
||||||
if (bInherit || style.getProperty(XMLString.FO_PADDING,false)!=null) {
|
if (bInherit || style.getProperty(XMLString.FO_PADDING,false)!=null) {
|
||||||
s = style.getAbsoluteProperty(XMLString.FO_PADDING);
|
s = style.getAbsoluteProperty(XMLString.FO_PADDING);
|
||||||
}
|
}
|
||||||
if (s!=null) {
|
if (s!=null) {
|
||||||
props.addValue("padding",scale(s));
|
props.addProperty("padding",scale(s));
|
||||||
}
|
}
|
||||||
else { // apply individual paddings
|
else { // apply individual paddings
|
||||||
boolean bTop = false;
|
boolean bTop = false;
|
||||||
|
@ -224,58 +220,58 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
|
||||||
boolean bRight = false;
|
boolean bRight = false;
|
||||||
if (bInherit || style.getProperty(XMLString.FO_PADDING_TOP,false)!=null) {
|
if (bInherit || style.getProperty(XMLString.FO_PADDING_TOP,false)!=null) {
|
||||||
s = style.getAbsoluteProperty(XMLString.FO_PADDING_TOP);
|
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) {
|
if (bInherit || style.getProperty(XMLString.FO_PADDING_BOTTOM,false)!=null) {
|
||||||
s = style.getAbsoluteProperty(XMLString.FO_PADDING_BOTTOM);
|
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) {
|
if (bInherit || style.getProperty(XMLString.FO_PADDING_LEFT,false)!=null) {
|
||||||
s = style.getAbsoluteProperty(XMLString.FO_PADDING_LEFT);
|
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) {
|
if (bInherit || style.getProperty(XMLString.FO_PADDING_RIGHT,false)!=null) {
|
||||||
s = style.getAbsoluteProperty(XMLString.FO_PADDING_RIGHT);
|
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 (bInherit) { // must specify padding
|
||||||
if (!bTop && !bBottom && !bLeft && !bRight) {
|
if (!bTop && !bBottom && !bLeft && !bRight) {
|
||||||
props.addValue("padding","0");
|
props.addProperty("padding","0");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!bTop) { props.addValue("padding-top","0"); }
|
if (!bTop) { props.addProperty("padding-top","0"); }
|
||||||
if (!bBottom) { props.addValue("padding-bottom","0"); }
|
if (!bBottom) { props.addProperty("padding-bottom","0"); }
|
||||||
if (!bLeft) { props.addValue("padding-left","0"); }
|
if (!bLeft) { props.addProperty("padding-left","0"); }
|
||||||
if (!bRight) { props.addValue("padding-right","0"); }
|
if (!bRight) { props.addProperty("padding-right","0"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parapgrah styles need this for special treatment of background color
|
// 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:
|
// Background image:
|
||||||
String sUrl = style.getBackgroundImageProperty(XMLString.XLINK_HREF);
|
String sUrl = style.getBackgroundImageProperty(XMLString.XLINK_HREF);
|
||||||
if (sUrl!=null) { // currently only support for linked image
|
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);
|
String sRepeat = style.getBackgroundImageProperty(XMLString.STYLE_REPEAT);
|
||||||
if ("no-repeat".equals(sRepeat) || "stretch".equals(sRepeat)) {
|
if ("no-repeat".equals(sRepeat) || "stretch".equals(sRepeat)) {
|
||||||
props.addValue("background-repeat","no-repeat");
|
props.addProperty("background-repeat","no-repeat");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
props.addValue("background-repeat","repeat");
|
props.addProperty("background-repeat","repeat");
|
||||||
}
|
}
|
||||||
|
|
||||||
String sPosition = style.getBackgroundImageProperty(XMLString.STYLE_POSITION);
|
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
|
// Background color: Same as in css
|
||||||
String s = style.getProperty(XMLString.FO_BACKGROUND_COLOR,bInherit);
|
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);
|
cssBackgroundCommon(style,props,bInherit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.StyleInfo;
|
import writer2latex.xhtml.StyleInfo;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMapItem;
|
import writer2latex.xhtml.XhtmlStyleMapItem;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
public class HeadingStyleParser extends StyleParser {
|
public class HeadingStyleParser extends StyleParser {
|
||||||
|
|
||||||
|
@ -83,9 +84,9 @@ public class HeadingStyleParser extends StyleParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String composeBasicDeclarationBlock( int i) {
|
private String composeBasicDeclarationBlock( int i) {
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
getParSc().applyProperties(ofr.getHeadingStyle(i), props, true);
|
getParSP().applyProperties(ofr.getHeadingStyle(i), props, true);
|
||||||
props.addValue("clear", "left");
|
props.addProperty("clear", "left");
|
||||||
return props.toString();
|
return props.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,9 +97,9 @@ public class HeadingStyleParser extends StyleParser {
|
||||||
|
|
||||||
public String composeDeclarationBlock(String displayName) {
|
public String composeDeclarationBlock(String displayName) {
|
||||||
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(displayName);
|
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(displayName);
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
getParSc().applyProperties(style, props, true);
|
getParSP().applyProperties(style, props, true);
|
||||||
props.addValue("clear", "left");
|
props.addProperty("clear", "left");
|
||||||
return props.toString();
|
return props.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ public class HeadingStyleParser extends StyleParser {
|
||||||
// Apply parent style + hard formatting
|
// Apply parent style + hard formatting
|
||||||
applyStyle(nLevel, style.getParentName(), info);
|
applyStyle(nLevel, style.getParentName(), info);
|
||||||
if (bConvertHard) {
|
if (bConvertHard) {
|
||||||
getParSc().applyProperties(style, info.props, false);
|
getParSP().applyProperties(style, info.props, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String sDisplayName = style.getDisplayName();
|
String sDisplayName = style.getDisplayName();
|
||||||
|
|
|
@ -39,6 +39,7 @@ import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.StyleInfo;
|
import writer2latex.xhtml.StyleInfo;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMapItem;
|
import writer2latex.xhtml.XhtmlStyleMapItem;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument list styles to
|
* This class converts OpenDocument list styles to
|
||||||
|
@ -156,7 +157,7 @@ public class ListStyleParser extends StyleParser {
|
||||||
|
|
||||||
private String composeDeclarationBlock(String displayName, int level) {
|
private String composeDeclarationBlock(String displayName, int level) {
|
||||||
ListStyle style = (ListStyle) getStyles().getStyleByDisplayName(displayName);
|
ListStyle style = (ListStyle) getStyles().getStyleByDisplayName(displayName);
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
cssList(style, level, props);
|
cssList(style, level, props);
|
||||||
return props.toString();
|
return props.toString();
|
||||||
}
|
}
|
||||||
|
@ -170,65 +171,65 @@ public class ListStyleParser extends StyleParser {
|
||||||
return ofr.getListStyles();
|
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
|
// translates "list" style properties for a particular level
|
||||||
// Mozilla does not seem to support the "marker" mechanism of CSS2
|
// Mozilla does not seem to support the "marker" mechanism of CSS2
|
||||||
// so we will stick with the simpler CSS1-like list style properties
|
// so we will stick with the simpler CSS1-like list style properties
|
||||||
props.addValue("margin-top","0");
|
props.addProperty("margin-top","0");
|
||||||
props.addValue("margin-bottom","0");
|
props.addProperty("margin-bottom","0");
|
||||||
if (config.listFormatting()!=XhtmlConfig.HARD_LABELS) {
|
if (config.listFormatting()!=XhtmlConfig.HARD_LABELS) {
|
||||||
// Export the numbering to CSS1
|
// Export the numbering to CSS1
|
||||||
String sLevelType = style.getLevelType(nLevel);
|
String sLevelType = style.getLevelType(nLevel);
|
||||||
if (XMLString.TEXT_LIST_LEVEL_STYLE_NUMBER.equals(sLevelType)) {
|
if (XMLString.TEXT_LIST_LEVEL_STYLE_NUMBER.equals(sLevelType)) {
|
||||||
// Numbering style, get number format
|
// Numbering style, get number format
|
||||||
String sNumFormat = style.getLevelProperty(nLevel,XMLString.STYLE_NUM_FORMAT);
|
String sNumFormat = style.getLevelProperty(nLevel,XMLString.STYLE_NUM_FORMAT);
|
||||||
if ("1".equals(sNumFormat)) { props.addValue("list-style-type","decimal"); }
|
if ("1".equals(sNumFormat)) { props.addProperty("list-style-type","decimal"); }
|
||||||
else if ("i".equals(sNumFormat)) { props.addValue("list-style-type","lower-roman"); }
|
else if ("i".equals(sNumFormat)) { props.addProperty("list-style-type","lower-roman"); }
|
||||||
else if ("I".equals(sNumFormat)) { props.addValue("list-style-type","upper-roman"); }
|
else if ("I".equals(sNumFormat)) { props.addProperty("list-style-type","upper-roman"); }
|
||||||
else if ("a".equals(sNumFormat)) { props.addValue("list-style-type","lower-alpha"); }
|
else if ("a".equals(sNumFormat)) { props.addProperty("list-style-type","lower-alpha"); }
|
||||||
else if ("A".equals(sNumFormat)) { props.addValue("list-style-type","upper-alpha"); }
|
else if ("A".equals(sNumFormat)) { props.addProperty("list-style-type","upper-alpha"); }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (XMLString.TEXT_LIST_LEVEL_STYLE_BULLET.equals(sLevelType)) {
|
else if (XMLString.TEXT_LIST_LEVEL_STYLE_BULLET.equals(sLevelType)) {
|
||||||
// Bullet. We can only choose from disc, bullet and square
|
// Bullet. We can only choose from disc, bullet and square
|
||||||
switch (nLevel % 3) {
|
switch (nLevel % 3) {
|
||||||
case 1: props.addValue("list-style-type","disc"); break;
|
case 1: props.addProperty("list-style-type","disc"); break;
|
||||||
case 2: props.addValue("list-style-type","circle"); break;
|
case 2: props.addProperty("list-style-type","circle"); break;
|
||||||
case 0: props.addValue("list-style-type","square"); break;
|
case 0: props.addProperty("list-style-type","square"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (XMLString.TEXT_LIST_LEVEL_STYLE_IMAGE.equals(sLevelType)) {
|
else if (XMLString.TEXT_LIST_LEVEL_STYLE_IMAGE.equals(sLevelType)) {
|
||||||
// Image. TODO: Handle embedded images
|
// Image. TODO: Handle embedded images
|
||||||
String sHref = style.getLevelProperty(nLevel,XMLString.XLINK_HREF);
|
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 {
|
else {
|
||||||
// No numbering generated by the list; we add hard numbering to the paragraph
|
// 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
|
// In this case we also set the left margin for the list
|
||||||
// For real styles the margins are applied to the paragraphs
|
// 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
|
// This is more tricky for hard styles, so we use a default left margin on the list
|
||||||
if (style.isAutomatic() && nLevel>1) {
|
if (style.isAutomatic() && nLevel>1) {
|
||||||
props.addValue("margin-left", "2em");
|
props.addProperty("margin-left", "2em");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
props.addValue("margin-left","0");
|
props.addProperty("margin-left","0");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also reset the padding (some browsers use a non-zero default value)
|
// 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
|
// We don't want floats to pass a list to the left (Mozilla and IE both
|
||||||
//handles this terribly!)
|
//handles this terribly!)
|
||||||
props.addValue("clear:left");
|
props.addProperty("clear","left");
|
||||||
String textStyleName = style.getLevelProperty(nLevel, XMLString.TEXT_STYLE_NAME);
|
String textStyleName = style.getLevelProperty(nLevel, XMLString.TEXT_STYLE_NAME);
|
||||||
if (textStyleName != null) {
|
if (textStyleName != null) {
|
||||||
StyleWithProperties charStyle = (StyleWithProperties) ofr.getTextStyles().getStyle(textStyleName);
|
StyleWithProperties charStyle = (StyleWithProperties) ofr.getTextStyles().getStyle(textStyleName);
|
||||||
getTextSc().cssText(charStyle, props, true);
|
getTextSP().cssText(charStyle, props, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import writer2latex.util.Calc;
|
||||||
import writer2latex.xhtml.Converter;
|
import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.StyleInfo;
|
import writer2latex.xhtml.StyleInfo;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument page styles to CSS2 styles.
|
* 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
|
// 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
|
// Fill color: Same as in css
|
||||||
String s = style.getProperty(XMLString.DRAW_FILL_COLOR,bInherit);
|
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);
|
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);
|
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
|
// 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);
|
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);
|
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);
|
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);
|
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);
|
String sColor = style.getFootnoteProperty(XMLString.STYLE_COLOR);
|
||||||
if (sColor!=null) { // To get the expected result in all browsers we must set both
|
if (sColor!=null) { // To get the expected result in all browsers we must set both
|
||||||
props.addValue("color", sColor);
|
props.addProperty("color", sColor);
|
||||||
props.addValue("background-color", sColor);
|
props.addProperty("background-color", sColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
String sAdjustment = style.getFootnoteProperty(XMLString.STYLE_ADJUSTMENT);
|
String sAdjustment = style.getFootnoteProperty(XMLString.STYLE_ADJUSTMENT);
|
||||||
if ("right".equals(sAdjustment)) {
|
if ("right".equals(sAdjustment)) {
|
||||||
props.addValue("margin-left", "auto");
|
props.addProperty("margin-left", "auto");
|
||||||
props.addValue("margin-right", "0");
|
props.addProperty("margin-right", "0");
|
||||||
}
|
}
|
||||||
else if ("center".equals(sAdjustment)) {
|
else if ("center".equals(sAdjustment)) {
|
||||||
props.addValue("margin-left", "auto");
|
props.addProperty("margin-left", "auto");
|
||||||
props.addValue("margin-right", "auto");
|
props.addProperty("margin-right", "auto");
|
||||||
}
|
}
|
||||||
else { // default left
|
else { // default left
|
||||||
props.addValue("margin-left", "0");
|
props.addProperty("margin-left", "0");
|
||||||
props.addValue("margin-right", "auto");
|
props.addProperty("margin-right", "auto");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import writer2latex.office.XMLString;
|
||||||
import writer2latex.util.CSVList;
|
import writer2latex.util.CSVList;
|
||||||
import writer2latex.xhtml.Converter;
|
import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: drop caps (contained in a child of the style:properties element)
|
TODO: drop caps (contained in a child of the style:properties element)
|
||||||
|
@ -80,21 +81,21 @@ public class ParStyleParser extends StyleWithPropertiesParser {
|
||||||
* @param props the <code>CSVList</code> object to add information to
|
* @param props the <code>CSVList</code> object to add information to
|
||||||
* @param bInherit true if properties should be inherited from parent style(s)
|
* @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) {
|
||||||
cssPageBreak(style,props,bInherit);
|
cssPageBreak(style, props, bInherit);
|
||||||
getFrameSc().cssMargins(style,props,bInherit);
|
getFrameSc().cssMargins(style, props, bInherit);
|
||||||
getFrameSc().cssBorder(style,props,bInherit);
|
getFrameSc().cssBorder(style, props, bInherit);
|
||||||
getFrameSc().cssPadding(style,props,bInherit);
|
getFrameSc().cssPadding(style, props, bInherit);
|
||||||
getFrameSc().cssBackgroundCommon(style,props,bInherit);
|
getFrameSc().cssBackgroundCommon(style, props, bInherit);
|
||||||
cssPar(style,props,bInherit);
|
cssPar(style, props, bInherit);
|
||||||
getTextSc().cssTextCommon(style,props,bInherit);
|
getTextSP().cssTextCommon(style, props, bInherit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTextBackground(String sStyleName) {
|
public String getTextBackground(String sStyleName) {
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
StyleWithProperties style = ofr.getParStyle(sStyleName);
|
StyleWithProperties style = ofr.getParStyle(sStyleName);
|
||||||
if (style!=null) {
|
if (style!=null) {
|
||||||
getTextSc().cssTextBackground(style,props,true);
|
getTextSP().cssTextBackground(style,props,true);
|
||||||
}
|
}
|
||||||
return props.toString();
|
return props.toString();
|
||||||
}
|
}
|
||||||
|
@ -107,16 +108,16 @@ public class ParStyleParser extends StyleWithPropertiesParser {
|
||||||
return style.getParentName();
|
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))) {
|
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))) {
|
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;
|
String s;
|
||||||
|
|
||||||
// translates paragraph style properties.
|
// translates paragraph style properties.
|
||||||
|
@ -137,17 +138,17 @@ public class ParStyleParser extends StyleWithPropertiesParser {
|
||||||
|
|
||||||
// Background color fits with css (note: Paragraph property!)
|
// Background color fits with css (note: Paragraph property!)
|
||||||
s = style.getParProperty(XMLString.FO_BACKGROUND_COLOR,bInherit);
|
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...
|
// Indentation: Absolute values of this property fit with css...
|
||||||
if (bInherit || style.getProperty(XMLString.FO_TEXT_INDENT,false)!=null) {
|
if (bInherit || style.getProperty(XMLString.FO_TEXT_INDENT,false)!=null) {
|
||||||
s = style.getAbsoluteProperty(XMLString.FO_TEXT_INDENT);
|
s = style.getAbsoluteProperty(XMLString.FO_TEXT_INDENT);
|
||||||
if (s!=null) {
|
if (s!=null) {
|
||||||
props.addValue("text-indent",scale(s));
|
props.addProperty("text-indent",scale(s));
|
||||||
}
|
}
|
||||||
else { // ... but css doesn't have this one
|
else { // ... but css doesn't have this one
|
||||||
s = style.getProperty(XMLString.STYLE_AUTO_TEXT_INDENT);
|
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!=null) { // rename two property values:
|
||||||
if (s.equals("start")) { s="left"; }
|
if (s.equals("start")) { s="left"; }
|
||||||
else if (s.equals("end")) { s="right"; }
|
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):
|
// Wrap (only in table cells, only in spreadsheets):
|
||||||
if (ofr.isSpreadsheet()) {
|
if (ofr.isSpreadsheet()) {
|
||||||
s = style.getProperty(XMLString.FO_WRAP_OPTION,bInherit);
|
s = style.getProperty(XMLString.FO_WRAP_OPTION,bInherit);
|
||||||
if ("no-wrap".equals(s)) props.addValue("white-space","nowrap");
|
if ("no-wrap".equals(s)) props.addProperty("white-space","nowrap");
|
||||||
else if ("wrap".equals(s)) props.addValue("white-space","normal");
|
else if ("wrap".equals(s)) props.addProperty("white-space","normal");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.StyleInfo;
|
import writer2latex.xhtml.StyleInfo;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMap;
|
import writer2latex.xhtml.XhtmlStyleMap;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument presentation styles to CSS2 styles.
|
* This class converts OpenDocument presentation styles to CSS2 styles.
|
||||||
|
@ -120,10 +121,10 @@ public class PresentationStyleParser extends FrameStyleParser {
|
||||||
|
|
||||||
public String composeDeclarationBlock(String displayName) {
|
public String composeDeclarationBlock(String displayName) {
|
||||||
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(displayName);
|
StyleWithProperties style = (StyleWithProperties) getStyles().getStyleByDisplayName(displayName);
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
getFrameSc().cssMargins(style, props, true);
|
getFrameSc().cssMargins(style, props, true);
|
||||||
getParSc().cssPar(style, props, true);
|
getParSP().cssPar(style, props, true);
|
||||||
getTextSc().cssTextCommon(style, props, true);
|
getTextSP().cssTextCommon(style, props, true);
|
||||||
return props.toString();
|
return props.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import writer2latex.util.CSVList;
|
||||||
import writer2latex.xhtml.Converter;
|
import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMap;
|
import writer2latex.xhtml.XhtmlStyleMap;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument row styles to CSS2 styles.
|
* This class converts OpenDocument row styles to CSS2 styles.
|
||||||
|
@ -75,7 +76,7 @@ public class RowStyleParser extends StyleWithPropertiesParser {
|
||||||
* @param props the <code>CSVList</code> object to add information to
|
* @param props the <code>CSVList</code> object to add information to
|
||||||
* @param bInherit true if properties should be inherited from parent style(s)
|
* @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);
|
getFrameSc().cssBackground(style,props,bInherit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import writer2latex.util.CSVList;
|
||||||
import writer2latex.xhtml.Converter;
|
import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMap;
|
import writer2latex.xhtml.XhtmlStyleMap;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument section styles to CSS2 styles.
|
* This class converts OpenDocument section styles to CSS2 styles.
|
||||||
|
@ -79,7 +80,7 @@ public class SectionStyleParser extends StyleWithPropertiesParser {
|
||||||
* @param props the <code>CSVList</code> object to add information to
|
* @param props the <code>CSVList</code> object to add information to
|
||||||
* @param bInherit true if properties should be inherited from parent style(s)
|
* @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);
|
getFrameSc().cssBox(style,props,bInherit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.StyleInfo;
|
import writer2latex.xhtml.StyleInfo;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMapItem;
|
import writer2latex.xhtml.XhtmlStyleMapItem;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>This is an abstract class to convert an OpenDocument style family
|
* <p>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 {
|
public abstract class StyleWithPropertiesParser extends StyleParser {
|
||||||
|
|
||||||
/** Create a new <code>StyleWithPropertiesConverterHelper</code>
|
boolean inlineCSS = false;
|
||||||
|
/** Create a new <code>StyleWithPropertiesConverterHelper</code>
|
||||||
* @param ofr an <code>OfficeReader</code> to read style information from
|
* @param ofr an <code>OfficeReader</code> to read style information from
|
||||||
* @param config the configuration to use
|
* @param config the configuration to use
|
||||||
* @param converter the main <code>Converter</code> class
|
* @param converter the main <code>Converter</code> class
|
||||||
|
@ -52,6 +54,7 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
|
||||||
public StyleWithPropertiesParser(OfficeReader ofr, XhtmlConfig config,
|
public StyleWithPropertiesParser(OfficeReader ofr, XhtmlConfig config,
|
||||||
Converter converter, int nType) {
|
Converter converter, int nType) {
|
||||||
super(ofr,config,converter,nType);
|
super(ofr,config,converter,nType);
|
||||||
|
inlineCSS = config.inlineCSS();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Apply a style, either by converting the style or by applying the
|
/** 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 sStyleName name of the OpenDocument style
|
||||||
* @param info the <code>StyleInfo</code> object to add information to
|
* @param info the <code>StyleInfo</code> object to add information to
|
||||||
*/
|
*/
|
||||||
public void readStyle(String sStyleName, StyleInfo info) {
|
public void readStyle(String sStyleName, StyleInfo info) {
|
||||||
StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
|
StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
|
||||||
info.sTagName = getStyleTag();
|
if (style == null) {
|
||||||
if (style!=null) {
|
return;
|
||||||
if (config.multilingual()) { applyLang(style,info); }
|
}
|
||||||
applyDirection(style,info);
|
info.sTagName = getStyleTag();
|
||||||
if (style.isAutomatic()) {
|
if (config.multilingual()) {
|
||||||
// Apply parent style + hard formatting
|
applyLang(style, info);
|
||||||
readStyle(style.getParentName(),info);
|
}
|
||||||
if (bConvertHard) { applyProperties(style,info.props,false); }
|
applyDirection(style, info);
|
||||||
}
|
if (style.isAutomatic()) {
|
||||||
else {
|
// Apply parent style + hard formatting
|
||||||
String sDisplayName = style.getDisplayName();
|
readStyle(style.getParentName(), info);
|
||||||
if (styleMap.contains(sDisplayName)) {
|
if (bConvertHard) {
|
||||||
// Apply attributes as specified in style map from user
|
applyProperties(style, info.props, false);
|
||||||
XhtmlStyleMapItem map = styleMap.get(sDisplayName);
|
}
|
||||||
if (map.sElement.length()>0) {
|
} else {
|
||||||
info.sTagName = map.sElement;
|
|
||||||
}
|
String displayName = style.getDisplayName();
|
||||||
if (!"(none)".equals(map.sCss)) {
|
if (styleMap.contains(displayName)) {
|
||||||
info.sClass = map.sCss;
|
// Apply attributes as specified in style map from user
|
||||||
}
|
XhtmlStyleMapItem map = styleMap.get(displayName);
|
||||||
}
|
if (map.sElement.length() > 0) {
|
||||||
else {
|
info.sTagName = map.sElement;
|
||||||
// Generate class name from display name
|
}
|
||||||
styleNames.addName(sDisplayName);
|
if (!"(none)".equals(map.sCss)) {
|
||||||
info.sClass = getClassNamePrefix()
|
info.sClass = map.sCss;
|
||||||
+ styleNames.getName(sDisplayName);
|
}
|
||||||
}
|
} 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
|
/** Convert style information for used styles
|
||||||
* @param sIndent a String of spaces to add before each line
|
* @param sIndent a String of spaces to add before each line
|
||||||
|
@ -99,6 +112,9 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
|
||||||
if (!bConvertStyles) {
|
if (!bConvertStyles) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
if (inlineCSS) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
Enumeration<String> names = styleNames.keys();
|
Enumeration<String> names = styleNames.keys();
|
||||||
while (names.hasMoreElements()) {
|
while (names.hasMoreElements()) {
|
||||||
|
@ -126,7 +142,7 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
|
||||||
if (style == null) {
|
if (style == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
|
|
||||||
applyProperties(style, props, true);
|
applyProperties(style, props, true);
|
||||||
return props.toString();
|
return props.toString();
|
||||||
|
@ -155,7 +171,7 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
|
||||||
* @param props the <code>CSVList</code> object to add information to
|
* @param props the <code>CSVList</code> object to add information to
|
||||||
* @param bInherit true if properties should be inherited from parent style(s)
|
* @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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.Parser;
|
import writer2latex.xhtml.Parser;
|
||||||
import writer2latex.xhtml.StyleInfo;
|
import writer2latex.xhtml.StyleInfo;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/** This class converts OpenDocument styles to CSS2 styles.
|
/** This class converts OpenDocument styles to CSS2 styles.
|
||||||
* Note that some elements in OpenDocument has attributes that also maps to CSS2 properties.
|
* 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
|
// 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; }
|
public HeadingStyleParser getHeadingSc() { return headingStyleParser; }
|
||||||
|
|
||||||
|
@ -184,15 +185,15 @@ public class Styles extends Parser {
|
||||||
if (config.xhtmlCustomStylesheet().length()==0 &&
|
if (config.xhtmlCustomStylesheet().length()==0 &&
|
||||||
(config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL ||
|
(config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL ||
|
||||||
config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD)) {
|
config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD)) {
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
|
|
||||||
// Default paragraph/cell/frame style is applied to the body element
|
// Default paragraph/cell/frame style is applied to the body element
|
||||||
StyleWithProperties defaultStyle = getDefaultStyle();
|
StyleWithProperties defaultStyle = getDefaultStyle();
|
||||||
if (defaultStyle!=null) {
|
if (defaultStyle!=null) {
|
||||||
// text properties only!
|
// text properties only!
|
||||||
getTextSc().cssTextCommon(defaultStyle,props,true);
|
getTextSP().cssTextCommon(defaultStyle,props,true);
|
||||||
if (config.useDefaultFont() && config.defaultFontName().length()>0) {
|
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()) {
|
if (ofr.isText() && !converter.isOPS()) {
|
||||||
String sMaxWidth = config.getMaxWidth().trim();
|
String sMaxWidth = config.getMaxWidth().trim();
|
||||||
if (sMaxWidth.length()>0) {
|
if (sMaxWidth.length()>0) {
|
||||||
props.addValue("max-width", sMaxWidth);
|
props.addProperty("max-width", sMaxWidth);
|
||||||
props.addValue("margin-left","auto");
|
props.addProperty("margin-left","auto");
|
||||||
props.addValue("margin-right","auto");
|
props.addProperty("margin-right","auto");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import writer2latex.util.CSVList;
|
||||||
import writer2latex.xhtml.Converter;
|
import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMap;
|
import writer2latex.xhtml.XhtmlStyleMap;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument table styles to CSS2 styles.
|
* This class converts OpenDocument table styles to CSS2 styles.
|
||||||
|
@ -75,24 +76,24 @@ public class TableStyleParser extends StyleWithPropertiesParser {
|
||||||
* @param props the <code>CSVList</code> object to add information to
|
* @param props the <code>CSVList</code> object to add information to
|
||||||
* @param bInherit true if properties should be inherited from parent style(s)
|
* @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
|
// Page break
|
||||||
getParSc().cssPageBreak(style, props, bInherit);
|
getParSP().cssPageBreak(style, props, bInherit);
|
||||||
// Apply background
|
// Apply background
|
||||||
getFrameSc().cssBackground(style,props,bInherit);
|
getFrameSc().cssBackground(style,props,bInherit);
|
||||||
// Table-specific properties
|
// Table-specific properties
|
||||||
cssTable(style,props,bInherit);
|
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
|
// Top and bottom margins
|
||||||
String sMarginTop = style.getAbsoluteProperty(XMLString.FO_MARGIN_TOP);
|
String sMarginTop = style.getAbsoluteProperty(XMLString.FO_MARGIN_TOP);
|
||||||
if (sMarginTop!=null) { props.addValue("margin-top",scale(sMarginTop)); }
|
if (sMarginTop!=null) { props.addProperty("margin-top",scale(sMarginTop)); }
|
||||||
else { props.addValue("margin-top","0"); }
|
else { props.addProperty("margin-top","0"); }
|
||||||
|
|
||||||
String sMarginBottom = style.getAbsoluteProperty(XMLString.FO_MARGIN_BOTTOM);
|
String sMarginBottom = style.getAbsoluteProperty(XMLString.FO_MARGIN_BOTTOM);
|
||||||
if (sMarginBottom!=null) { props.addValue("margin-bottom",scale(sMarginBottom)); }
|
if (sMarginBottom!=null) { props.addProperty("margin-bottom",scale(sMarginBottom)); }
|
||||||
else { props.addValue("margin-bottom","0"); }
|
else { props.addProperty("margin-bottom","0"); }
|
||||||
|
|
||||||
// Left and right margins and horizontal alignment
|
// Left and right margins and horizontal alignment
|
||||||
String sAlign = style.getProperty(XMLString.TABLE_ALIGN);
|
String sAlign = style.getProperty(XMLString.TABLE_ALIGN);
|
||||||
|
@ -111,8 +112,8 @@ public class TableStyleParser extends StyleWithPropertiesParser {
|
||||||
sMarginRight = "auto";
|
sMarginRight = "auto";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sMarginLeft!=null) { props.addValue("margin-left",sMarginLeft); }
|
if (sMarginLeft!=null) { props.addProperty("margin-left",sMarginLeft); }
|
||||||
if (sMarginRight!=null) { props.addValue("margin-right",sMarginRight); }
|
if (sMarginRight!=null) { props.addProperty("margin-right",sMarginRight); }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import writer2latex.xhtml.Converter;
|
||||||
import writer2latex.xhtml.StyleInfo;
|
import writer2latex.xhtml.StyleInfo;
|
||||||
import writer2latex.xhtml.XhtmlConfig;
|
import writer2latex.xhtml.XhtmlConfig;
|
||||||
import writer2latex.xhtml.XhtmlStyleMapItem;
|
import writer2latex.xhtml.XhtmlStyleMapItem;
|
||||||
|
import writer2latex.xhtml.style.properties.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class converts OpenDocument text styles to CSS2 styles.
|
* This class converts OpenDocument text styles to CSS2 styles.
|
||||||
|
@ -205,7 +206,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
||||||
private String composeVisitedAnchorDeclarationBlock(String visitedStyleName) {
|
private String composeVisitedAnchorDeclarationBlock(String visitedStyleName) {
|
||||||
StyleWithProperties style;
|
StyleWithProperties style;
|
||||||
style = ofr.getTextStyle(visitedStyleName);
|
style = ofr.getTextStyle(visitedStyleName);
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
cssText(style, props, true);
|
cssText(style, props, true);
|
||||||
cssHyperlink(style, props);
|
cssHyperlink(style, props);
|
||||||
String visitedAnchorDeclarationBlock = props.toString();
|
String visitedAnchorDeclarationBlock = props.toString();
|
||||||
|
@ -219,7 +220,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
||||||
|
|
||||||
private String composeAnchorDeclarationBlock(String sStyleName) {
|
private String composeAnchorDeclarationBlock(String sStyleName) {
|
||||||
StyleWithProperties style = ofr.getTextStyle(sStyleName);
|
StyleWithProperties style = ofr.getTextStyle(sStyleName);
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
cssText(style, props, true);
|
cssText(style, props, true);
|
||||||
cssHyperlink(style, props);
|
cssHyperlink(style, props);
|
||||||
String anchorDeclaration = props.toString();
|
String anchorDeclaration = props.toString();
|
||||||
|
@ -227,7 +228,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String composeVisitedLinkDeclarationBlock(StyleWithProperties defaultLinkStyle) {
|
private String composeVisitedLinkDeclarationBlock(StyleWithProperties defaultLinkStyle) {
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
cssText(defaultLinkStyle, props, true);
|
cssText(defaultLinkStyle, props, true);
|
||||||
cssHyperlink(defaultLinkStyle, props);
|
cssHyperlink(defaultLinkStyle, props);
|
||||||
String visitedLinkDeclaration = props.toString();
|
String visitedLinkDeclaration = props.toString();
|
||||||
|
@ -235,7 +236,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String composeLinkDeclarationBlock(StyleWithProperties defaultLinkStyle) {
|
private String composeLinkDeclarationBlock(StyleWithProperties defaultLinkStyle) {
|
||||||
CSVList props = new CSVList(";");
|
Properties props = new Properties(";");
|
||||||
cssText(defaultLinkStyle, props, true);
|
cssText(defaultLinkStyle, props, true);
|
||||||
cssHyperlink(defaultLinkStyle, props);
|
cssHyperlink(defaultLinkStyle, props);
|
||||||
String linkDeclaration = props.toString();
|
String linkDeclaration = props.toString();
|
||||||
|
@ -262,7 +263,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
||||||
* @param props the <code>CSVList</code> object to add information to
|
* @param props the <code>CSVList</code> object to add information to
|
||||||
* @param bInherit true if properties should be inherited from parent style(s)
|
* @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);
|
cssText(style,props,bInherit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,36 +296,36 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
||||||
// - fo:hyphenation-*
|
// - fo:hyphenation-*
|
||||||
//
|
//
|
||||||
|
|
||||||
public void cssText(StyleWithProperties style, CSVList props, boolean bInherit) {
|
public void cssText(StyleWithProperties style, Properties props, boolean bInherit) {
|
||||||
cssTextCommon(style,props,bInherit);
|
cssTextCommon(style,props,bInherit);
|
||||||
cssTextBackground(style,props,bInherit);
|
cssTextBackground(style,props,bInherit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cssTextCommon(StyleWithProperties style, CSVList props, boolean bInherit) {
|
public void cssTextCommon(StyleWithProperties style, Properties props, boolean bInherit) {
|
||||||
String s=null,s2=null,s3=null,s4=null;
|
String fontName=null,s2=null,s3=null,s4=null;
|
||||||
CSVList val;
|
CSVList val;
|
||||||
|
|
||||||
// Font family
|
// Font family
|
||||||
if (bConvertFont && (bInherit || style.getProperty(XMLString.STYLE_FONT_NAME,false)!=null)) {
|
if (bConvertFont && (bInherit || style.getProperty(XMLString.STYLE_FONT_NAME,false)!=null)) {
|
||||||
val = new CSVList(","); // multivalue property!
|
val = new CSVList(","); // multivalue property!
|
||||||
// Get font family information from font declaration or from style
|
// Get font family information from font declaration or from style
|
||||||
s = style.getProperty(XMLString.STYLE_FONT_NAME);
|
fontName = style.getProperty(XMLString.STYLE_FONT_NAME);
|
||||||
if (s!=null) {
|
if (fontName!=null) {
|
||||||
FontDeclaration fd = (FontDeclaration) ofr.getFontDeclarations().getStyle(s);
|
FontDeclaration fd = (FontDeclaration) ofr.getFontDeclarations().getStyle(fontName);
|
||||||
if (fd!=null) {
|
if (fd!=null) {
|
||||||
s = fd.getFontFamily();
|
fontName = fd.getFontFamily();
|
||||||
s2 = fd.getFontFamilyGeneric();
|
s2 = fd.getFontFamilyGeneric();
|
||||||
s3 = fd.getFontPitch();
|
s3 = fd.getFontPitch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s = style.getProperty(XMLString.FO_FONT_FAMILY);
|
fontName = style.getProperty(XMLString.FO_FONT_FAMILY);
|
||||||
s2 = style.getProperty(XMLString.STYLE_FONT_FAMILY_GENERIC);
|
s2 = style.getProperty(XMLString.STYLE_FONT_FAMILY_GENERIC);
|
||||||
s3 = style.getProperty(XMLString.STYLE_FONT_PITCH);
|
s3 = style.getProperty(XMLString.STYLE_FONT_PITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the western font family (CJK and CTL is more complicated)
|
// 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
|
// Add generic font family
|
||||||
if ("fixed".equals(s3)) { val.addValue("monospace"); }
|
if ("fixed".equals(s3)) { val.addValue("monospace"); }
|
||||||
else if ("roman".equals(s2)) { val.addValue("serif"); }
|
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 ("decorative".equals(s2)) { val.addValue("fantasy"); }
|
||||||
else if ("script".equals(s2)) { val.addValue("cursive"); }
|
else if ("script".equals(s2)) { val.addValue("cursive"); }
|
||||||
else if ("system".equals(s2)) { val.addValue("serif"); } // System default font
|
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
|
// Font style (italics): This property fit with css2
|
||||||
s = style.getProperty(XMLString.FO_FONT_STYLE,bInherit);
|
fontName = style.getProperty(XMLString.FO_FONT_STYLE,bInherit);
|
||||||
if (s!=null) { props.addValue("font-style",s); }
|
if (fontName!=null) { props.addProperty("font-style",fontName); }
|
||||||
|
|
||||||
// Font variant (small caps): This property fit with css2
|
// Font variant (small caps): This property fit with css2
|
||||||
s = style.getProperty(XMLString.FO_FONT_VARIANT,bInherit);
|
fontName = style.getProperty(XMLString.FO_FONT_VARIANT,bInherit);
|
||||||
if (s!=null) { props.addValue("font-variant",s); }
|
if (fontName!=null) { props.addProperty("font-variant",fontName); }
|
||||||
|
|
||||||
// Font weight (bold): This property fit with css2
|
// Font weight (bold): This property fit with css2
|
||||||
s = style.getProperty(XMLString.FO_FONT_WEIGHT,bInherit);
|
fontName = style.getProperty(XMLString.FO_FONT_WEIGHT,bInherit);
|
||||||
if (s!=null) { props.addValue("font-weight",s); }
|
if (fontName!=null) { props.addProperty("font-weight",fontName); }
|
||||||
|
|
||||||
// Font size: Absolute values of this property fit with css2
|
// Font size: Absolute values of this property fit with css2
|
||||||
// this is handled together with sub- and superscripts (style:text-position)
|
// 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);
|
// Second value (optional): percentage (relative size);
|
||||||
if (bInherit || style.getProperty(XMLString.FO_FONT_SIZE,false)!=null
|
if (bInherit || style.getProperty(XMLString.FO_FONT_SIZE,false)!=null
|
||||||
|| style.getProperty(XMLString.STYLE_TEXT_POSITION,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);
|
s2 = style.getProperty(XMLString.STYLE_TEXT_POSITION);
|
||||||
if (s2!=null) {
|
if (s2!=null) {
|
||||||
s2 = s2.trim();
|
s2 = s2.trim();
|
||||||
|
@ -366,54 +367,54 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
||||||
else { // one value
|
else { // one value
|
||||||
s3 = s2; s4="100%";
|
s3 = s2; s4="100%";
|
||||||
}
|
}
|
||||||
if (s!=null) {
|
if (fontName!=null) {
|
||||||
if (bRelativeFontSize) {
|
if (bRelativeFontSize) {
|
||||||
|
|
||||||
String sFontSize = Calc.divide(Calc.multiply(sFontScaling, Calc.multiply(s4,s)), sBaseFontSize);
|
String sFontSize = Calc.divide(Calc.multiply(sFontScaling, Calc.multiply(s4,fontName)), sBaseFontSize);
|
||||||
if (!"100%".equals(sFontSize)) props.addValue("font-size", sFontSize);
|
if (!"100%".equals(sFontSize)) props.addProperty("font-size", sFontSize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
props.addValue("font-size",Calc.multiply(s4,scale(s)));
|
props.addProperty("font-size",Calc.multiply(s4,scale(fontName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
props.addValue("font-size",s4);
|
props.addProperty("font-size",s4);
|
||||||
}
|
}
|
||||||
if (!"0%".equals(s3)) {
|
if (!"0%".equals(s3)) {
|
||||||
props.addValue("vertical-align",s3);
|
props.addProperty("vertical-align",s3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (s!=null) {
|
else if (fontName!=null) {
|
||||||
|
|
||||||
if (bRelativeFontSize) {
|
if (bRelativeFontSize) {
|
||||||
String sFontSize = Calc.divide(Calc.multiply(sFontScaling, s),sBaseFontSize);
|
String sFontSize = Calc.divide(Calc.multiply(sFontScaling, fontName),sBaseFontSize);
|
||||||
if (!"100%".equals(sFontSize)) {
|
if (!"100%".equals(sFontSize)) {
|
||||||
props.addValue("font-size", sFontSize);
|
props.addProperty("font-size", sFontSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
props.addValue("font-size",scale(s));
|
props.addProperty("font-size",scale(fontName));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color: This attribute fit with css2
|
// Color: This attribute fit with css2
|
||||||
s = style.getProperty(XMLString.FO_COLOR,bInherit);
|
fontName = style.getProperty(XMLString.FO_COLOR,bInherit);
|
||||||
if (s!=null) { props.addValue("color",s); }
|
if (fontName!=null) { props.addProperty("color",fontName); }
|
||||||
|
|
||||||
// Shadow: This attribute fit with css2
|
// Shadow: This attribute fit with css2
|
||||||
// (Currently OOo has only one shadow style, which is saved as 1pt 1pt)
|
// (Currently OOo has only one shadow style, which is saved as 1pt 1pt)
|
||||||
s = style.getProperty(XMLString.FO_TEXT_SHADOW,bInherit);
|
fontName = style.getProperty(XMLString.FO_TEXT_SHADOW,bInherit);
|
||||||
if (s!=null) { props.addValue("text-shadow",s); }
|
if (fontName!=null) { props.addProperty("text-shadow",fontName); }
|
||||||
|
|
||||||
// Text decoration. Here OOo is more flexible that CSS2.
|
// Text decoration. Here OOo is more flexible that CSS2.
|
||||||
if (ofr.isOpenDocument()) {
|
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);
|
s2 = style.getProperty(XMLString.STYLE_TEXT_UNDERLINE_STYLE,bInherit);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
s2 = style.getProperty(XMLString.STYLE_TEXT_UNDERLINE,bInherit);
|
||||||
}
|
}
|
||||||
s3 = style.getProperty(XMLString.STYLE_TEXT_BLINKING,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
|
// text-decoration, there is no way to turn on one kind of decoration and
|
||||||
// turn another one off (without creating another inline element).
|
// turn another one off (without creating another inline element).
|
||||||
// If one decoration is turned of, we turn them all off:
|
// If one decoration is turned of, we turn them all off:
|
||||||
if ("none".equals(s) || "none".equals(s2) || "false".equals(s3)) {
|
if ("none".equals(fontName) || "none".equals(s2) || "false".equals(s3)) {
|
||||||
props.addValue("text-decoration","none");
|
props.addProperty("text-decoration","none");
|
||||||
}
|
}
|
||||||
else { // set the required properties
|
else { // set the required properties
|
||||||
val = new CSVList(" "); // multivalue property!
|
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 (s2!=null && !"none".equals(s2)) { val.addValue("underline"); }
|
||||||
if (s3!=null && "true".equals(s3)) { val.addValue("blink"); }
|
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
|
// Letter spacing: This property fit with css
|
||||||
s = style.getProperty(XMLString.FO_LETTER_SPACING,bInherit);
|
fontName = style.getProperty(XMLString.FO_LETTER_SPACING,bInherit);
|
||||||
if ( s != null ) {
|
if ( fontName != null ) {
|
||||||
if ( minLetterSpacing != 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);
|
Double curLS = Double.parseDouble(onlyNums);
|
||||||
if ( minLetterSpacing < curLS ) {
|
if ( minLetterSpacing < curLS ) {
|
||||||
props.addValue("letter-spacing",scale(s));
|
props.addProperty("letter-spacing",scale(fontName));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
props.addValue("letter-spacing",scale(s));
|
props.addProperty("letter-spacing",scale(fontName));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capitalization: This property fit with css
|
// Capitalization: This property fit with css
|
||||||
s = style.getProperty(XMLString.FO_TEXT_TRANSFORM,bInherit);
|
fontName = style.getProperty(XMLString.FO_TEXT_TRANSFORM,bInherit);
|
||||||
if (s!=null) { props.addValue("text-transform",s); }
|
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
|
// Background color: This attribute fit with css when applied to inline text
|
||||||
String s =ofr.isOpenDocument() ?
|
String s =ofr.isOpenDocument() ?
|
||||||
style.getTextProperty(XMLString.FO_BACKGROUND_COLOR,bInherit) :
|
style.getTextProperty(XMLString.FO_BACKGROUND_COLOR,bInherit) :
|
||||||
style.getTextProperty(XMLString.STYLE_TEXT_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;
|
String s1,s2;
|
||||||
// For hyperlinks, export text-decoration:none even if nothing is defined in source
|
// For hyperlinks, export text-decoration:none even if nothing is defined in source
|
||||||
if (ofr.isOpenDocument()) {
|
if (ofr.isOpenDocument()) {
|
||||||
|
@ -473,7 +474,7 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
||||||
}
|
}
|
||||||
String s3 = style.getProperty(XMLString.STYLE_TEXT_BLINKING,true);
|
String s3 = style.getProperty(XMLString.STYLE_TEXT_BLINKING,true);
|
||||||
if (s1==null && s2==null && s3==null) {
|
if (s1==null && s2==null && s3==null) {
|
||||||
props.addValue("text-decoration","none");
|
props.addProperty("text-decoration","none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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<String, String> list;
|
||||||
|
private final static String DEFAULT_INTERNAL_SEPARATOR = ":";
|
||||||
|
public Properties(String separator, String internalSeapartor) {
|
||||||
|
this.separator = separator;
|
||||||
|
this.internalSeparator = internalSeapartor;
|
||||||
|
this.list = new HashMap<String, String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties(String separator) {
|
||||||
|
this(separator, DEFAULT_INTERNAL_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties(char charSeparator) {
|
||||||
|
this(Character.toString(charSeparator), DEFAULT_INTERNAL_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProperty(String name, String value) {
|
||||||
|
if (name == null || value == null || this.hasProperty(name)) { return; }
|
||||||
|
list.put(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void replaceProperty(String name, String value) {
|
||||||
|
if (name == null || value == null ) { return; }
|
||||||
|
list.put(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasProperty(String name) {
|
||||||
|
return list.containsKey(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> entry: list.entrySet()) {
|
||||||
|
buffer.append(entry.getKey() + internalSeparator + entry.getValue() + separator);
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return list.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue