diff --git a/src/main/java/writer2latex/office/MasterPage.java b/src/main/java/writer2latex/office/MasterPage.java
index 16cf997..81aeaee 100644
--- a/src/main/java/writer2latex/office/MasterPage.java
+++ b/src/main/java/writer2latex/office/MasterPage.java
@@ -27,6 +27,7 @@ package writer2latex.office;
import org.w3c.dom.Node;
import writer2latex.util.Misc;
+import writer2latex.xhtml.Debug;
/**
Class representing a master page in OOo Writer
*/
public class MasterPage extends OfficeStyle {
@@ -35,7 +36,7 @@ public class MasterPage extends OfficeStyle {
private Node headerLeft = null;
private Node footer = null;
private Node footerLeft = null;
-
+ private int columns = 1;
public String getProperty(String sPropName) {
return properties.getProperty(sPropName);
}
diff --git a/src/main/java/writer2latex/xhtml/DocumentSeparator.java b/src/main/java/writer2latex/xhtml/DocumentSeparator.java
index d84f51a..a5a2b57 100644
--- a/src/main/java/writer2latex/xhtml/DocumentSeparator.java
+++ b/src/main/java/writer2latex/xhtml/DocumentSeparator.java
@@ -1,8 +1,9 @@
package writer2latex.xhtml;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.LinkedList;
-
-
+import java.util.List;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -34,7 +35,7 @@ public class DocumentSeparator {
private static Converter converter = null;
private XhtmlConfig config = null;
private Node prevPageNode = null;
- private String pageContainerStyle = null;
+ private List pageContanerStyles = new ArrayList(Arrays.asList(""));
public DocumentSeparator(XhtmlConfig config,Converter converter) {
this.config = config;
@@ -46,10 +47,7 @@ public class DocumentSeparator {
breakStyle = config.getPageBreakStyle();
}
- public void setPageContainerStyle(String style) {
- this.pageContainerStyle = style;
- }
- protected Node processOutlineLevel(Node currentNode, Node hnode, int pageNum) {
+ protected Node processOutlineLevel(Node currentNode, Node hnode, int pageNum) {
//Get outline level
String sLevel = getAttribute(currentNode, XMLString.TEXT_OUTLINE_LEVEL);
@@ -353,9 +351,8 @@ public class DocumentSeparator {
}
Element container = converter.createElement("div");
container.setAttribute("class", "pageContainer");
- if (pageContainerStyle != null) {
- //System.out.println(pageContainerStyle);
- container.setAttribute("style", pageContainerStyle);
+ if (!getLastPageContainerStyle().isEmpty()) {
+ container.setAttribute("style", getLastPageContainerStyle());
}
hnode.appendChild(container);
return container;
@@ -378,8 +375,22 @@ public class DocumentSeparator {
return comment;
}
- public String getPageContainerStyle() {
- return this.pageContainerStyle;
+ public void setPageContainerStyle(String style){
+ pageContanerStyles.set(0, style);
+ }
+ public void addPageContainerStyle(String style){
+ pageContanerStyles.add(style);
+ }
+ public void rmPageContainerStyle() {
+ int size = pageContanerStyles.size();
+ if (size < 2) {
+ System.out.println("Tried to remove last container (page) style!");
+ System.exit(1);
+ }
+ pageContanerStyles.remove(size-1);
+ }
+ private String getLastPageContainerStyle() {
+ return pageContanerStyles.get(pageContanerStyles.size()-1);
}
}
diff --git a/src/main/java/writer2latex/xhtml/TextConverter.java b/src/main/java/writer2latex/xhtml/TextConverter.java
index 6217239..a0f8c68 100644
--- a/src/main/java/writer2latex/xhtml/TextConverter.java
+++ b/src/main/java/writer2latex/xhtml/TextConverter.java
@@ -538,11 +538,9 @@ public class TextConverter extends ConverterHelper {
boolean isLast = false;
if (last != null && last.equals("true")) { isLast = true;}
- String savedStyle = docSep.getPageContainerStyle();
-
if (!bDisplayHiddenText && "none".equals(Misc.getAttribute(onode,TEXT_DISPLAY))) { return hnode; }
hnode = docSep.closePage(hnode);
- setSectionStyle(onode);
+ boolean removeStyleAtExit = setSectionStyle(onode);
hnode = docSep.openPage(hnode, pageNum);
hnode = traverseBlockText(onode, hnode);
@@ -552,12 +550,15 @@ public class TextConverter extends ConverterHelper {
endnotesContext = lastEndnotesContext;
footnotesContext = lastFootnotesContext;
- docSep.setPageContainerStyle(savedStyle);
+ if (removeStyleAtExit) {
+ docSep.rmPageContainerStyle();
+ }
return hnode;
}
- private void setSectionStyle(Node onode) {
+ private boolean setSectionStyle(Node onode) {
+ boolean result = false;
StyleWithProperties sectionStyle;
String styleName = Misc.getAttribute(onode,TEXT_STYLE_NAME);
String sectionName = Misc.getAttribute(onode,TEXT_NAME);
@@ -568,7 +569,8 @@ public class TextConverter extends ConverterHelper {
int colCount = sectionStyle.getColCount();
if (colCount > 1 ) {
String styleValue = "column-count: " + colCount + ";";
- docSep.setPageContainerStyle(styleValue);
+ docSep.addPageContainerStyle(styleValue);
+ result = true;
}
String collectEndnotes = sectionStyle.getSectionProperty("endnote", false);
if (collectEndnotes != null && collectEndnotes.equals("true")) {
@@ -579,7 +581,7 @@ public class TextConverter extends ConverterHelper {
footnotesContext = sectionName;
}
}
-
+ return result;
}
private void handleHeading(Element onode, Element hnode, boolean bAfterSplit) {
@@ -1842,22 +1844,23 @@ public class TextConverter extends ConverterHelper {
return false;
}
+
private void updateMasterPage(StyleWithProperties style) {
-
- if (style != null && hasMasterPage(style)) {
- String sMasterPage = style.getMasterPageName();
- if (sMasterPage != null && sMasterPage.length() > 0) {
- currentMasterPage = sMasterPage;
- // Set next master page
- MasterPage masterPage = ofr.getFullMasterPage(currentMasterPage);
- nextMasterPage = masterPage.getProperty(STYLE_NEXT_STYLE_NAME);
- }
- } else if (nextMasterPage != null){
- currentMasterPage = nextMasterPage;
- MasterPage masterPage = ofr.getFullMasterPage(currentMasterPage);
- nextMasterPage = masterPage.getProperty(STYLE_NEXT_STYLE_NAME);
- }
-
+
+ if (!hasMasterPage(style) && nextMasterPage == null) {
+ return;
+ }
+ if (hasMasterPage(style)) {
+ String sMasterPage = style.getMasterPageName();
+ currentMasterPage = sMasterPage;
+ } else {
+ currentMasterPage = nextMasterPage;
+ }
+ MasterPage masterPage = ofr.getFullMasterPage(currentMasterPage);
+ nextMasterPage = masterPage.getProperty(STYLE_NEXT_STYLE_NAME);
+ //TODO:PROCESS MASTERPAGE COLUMNS
+ //docSep.setPageContainerStyle("column-count: 2;");
+
}
private boolean hasBreakBefore(StyleWithProperties style) {