diff --git a/src/main/java/writer2latex/xhtml/content/TextParser.java b/src/main/java/writer2latex/xhtml/content/TextParser.java
index 7db71e8..dcd9da2 100644
--- a/src/main/java/writer2latex/xhtml/content/TextParser.java
+++ b/src/main/java/writer2latex/xhtml/content/TextParser.java
@@ -671,8 +671,9 @@ public class TextParser extends Parser {
// Apply style
StyleInfo info = new StyleInfo();
info.sTagName = "h" + nLevel;
+ getHeadingSc().readParentStyle(nLevel, sStyleName, info);
getHeadingSc().applyStyle(nLevel, sStyleName, info);
-
+
// add root element
Element heading = converter.createElement(info.sTagName);
hnode.appendChild(heading);
diff --git a/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java b/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java
index c6afc2d..e5972df 100644
--- a/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java
+++ b/src/main/java/writer2latex/xhtml/style/HeadingStyleParser.java
@@ -43,7 +43,7 @@ public class HeadingStyleParser extends StyleParser {
// Sets of additional styles (other than the main heading style for the level)
private List> otherLevelStyles;
-
+ private boolean inlineCSS;
public HeadingStyleParser(OfficeReader ofr, XhtmlConfig config,
Converter converter, int nType) {
super(ofr, config, converter, nType);
@@ -51,6 +51,7 @@ public class HeadingStyleParser extends StyleParser {
this.bConvertStyles = config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_HARD;
this.bConvertHard = config.xhtmlFormatting()==XhtmlConfig.CONVERT_ALL || config.xhtmlFormatting()==XhtmlConfig.IGNORE_STYLES;
this.otherLevelStyles = new ArrayList>();
+ this.inlineCSS = config.inlineCSS();
for (int i=0; i<=6; i++) {
otherLevelStyles.add(new HashSet());
}
@@ -58,7 +59,7 @@ public class HeadingStyleParser extends StyleParser {
@Override
public String composeStyleDeclarations() {
- if (!bConvertStyles) {
+ if (!bConvertStyles || inlineCSS) {
return "";
}
StringBuilder result = new StringBuilder();
@@ -116,38 +117,52 @@ public class HeadingStyleParser extends StyleParser {
*/
public void applyStyle(int nLevel, String sStyleName, StyleInfo info) {
StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
- if (style != null) {
- if (config.multilingual()) {
- applyLang(style, info);
+ if (style == null) {
+ return;
+ }
+ if (config.multilingual()) {
+ applyLang(style, info);
+ }
+ applyDirection(style, info);
+ if (style.isAutomatic()) {
+ // Apply parent style + hard formatting
+ applyStyle(nLevel, style.getParentName(), info);
+ if (bConvertHard) {
+ getParSP().applyProperties(style, info.props, false);
}
- applyDirection(style, info);
- if (style.isAutomatic()) {
- // Apply parent style + hard formatting
- applyStyle(nLevel, style.getParentName(), info);
- if (bConvertHard) {
- getParSP().applyProperties(style, info.props, false);
+ } else {
+ String sDisplayName = style.getDisplayName();
+ if (styleMap.contains(sDisplayName)) {
+ // Apply attributes as specified in style map from user
+ XhtmlStyleMapItem map = styleMap.get(sDisplayName);
+ info.sTagName = map.sBlockElement;
+ if (!"(none)".equals(map.sBlockCss)) {
+ info.sClass = map.sBlockCss;
}
- } else {
- String sDisplayName = style.getDisplayName();
- if (styleMap.contains(sDisplayName)) {
- // Apply attributes as specified in style map from user
- XhtmlStyleMapItem map = styleMap.get(sDisplayName);
- info.sTagName = map.sBlockElement;
- if (!"(none)".equals(map.sBlockCss)) {
- info.sClass = map.sBlockCss;
- }
- } else if (style != ofr.getHeadingStyle(nLevel)) {
- // This is not the main style for this level, add class and remember
- styleNames.addName(sDisplayName);
- info.sClass = styleNames.getName(sDisplayName);
- if (1 <= nLevel && nLevel <= 6) {
- otherLevelStyles.get(nLevel).add(sDisplayName);
- }
+ } else if (style != ofr.getHeadingStyle(nLevel)) {
+ // This is not the main style for this level, add class and remember
+ styleNames.addName(sDisplayName);
+ info.sClass = styleNames.getName(sDisplayName);
+ if (1 <= nLevel && nLevel <= 6) {
+ otherLevelStyles.get(nLevel).add(sDisplayName);
}
}
}
- }
+ }
+
+ public void readParentStyle(int level,String styleName, StyleInfo info) {
+ if (!inlineCSS || styleName == null) {
+ return;
+ }
+ if (info.sClass != null && info.sClass.equals("qwertyc")) {
+ System.out.println(info.toString());
+ }
+ StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(styleName);
+ getParSP().applyProperties(style, info.props, true);
+ info.props.addProperty("clear", "left");
+ getParSP().applyProperties(ofr.getHeadingStyle(level), info.props, true);
+ }
/** Apply an inner style on a heading. The inner style surrounds the text content, excluding the numbering label.
* Inner styles are not an OpenDocument feature, but is provided as an additional style hook for own style sheets.
* An inner style is only applied if there is an explicit style map for the style.