From 2b7d1142c0e4656b7ba20c06c13b724ac72e981f Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Sun, 16 Feb 2020 14:22:48 +0100 Subject: [PATCH] Apply footer/header margins from page layout --- .../java/writer2latex/xhtml/content/TextParser.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/writer2latex/xhtml/content/TextParser.java b/src/main/java/writer2latex/xhtml/content/TextParser.java index 06f702d..14316ef 100644 --- a/src/main/java/writer2latex/xhtml/content/TextParser.java +++ b/src/main/java/writer2latex/xhtml/content/TextParser.java @@ -1776,6 +1776,9 @@ public class TextParser extends Parser { inHeader = true; MasterPage masterPage = ofr.getFullMasterPage(currentMasterPage); if (currentMasterPage != null) { + String pageLayoutName = masterPage.getPageLayoutName(); + PageLayout pageLayout = ofr.getPageLayout(pageLayoutName); + String marginBottom = pageLayout.getFooterProperty(FO_MARGIN_BOTTOM); if (pageNum % 2 == 0) { headerNode = masterPage.getHeaderLeft(); } @@ -1785,6 +1788,9 @@ public class TextParser extends Parser { if (headerNode != null) { //Create header element Element headerElement = converter.createElement("header"); + if (marginBottom != null) { + headerElement.setAttribute("style", "margin-bottom:"+getPageSc().scale(marginBottom)+";"); + } Node pageNode = node.getParentNode(); pageNode.insertBefore(headerElement, node); traverseBlockText(headerNode, headerElement); @@ -1801,6 +1807,9 @@ public class TextParser extends Parser { inFooter = true; MasterPage masterPage = ofr.getFullMasterPage(currentMasterPage); if (currentMasterPage != null) { + String pageLayoutName = masterPage.getPageLayoutName(); + PageLayout pageLayout = ofr.getPageLayout(pageLayoutName); + String marginTop = pageLayout.getFooterProperty(FO_MARGIN_TOP); if (pageNum % 2 == 0) { footerNode = masterPage.getFooterLeft(); } @@ -1810,6 +1819,9 @@ public class TextParser extends Parser { if (footerNode != null) { //Create footer element Element footerElement = converter.createElement("footer"); + if (marginTop != null) { + footerElement.setAttribute("style", "margin-top:"+getPageSc().scale(marginTop)+";"); + } Node pageNode = node.getParentNode(); pageNode.appendChild(footerElement); traverseBlockText(footerNode, footerElement);