Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormegumi.telles2015-02-12 20:38:46 +0000
committerAngel Avila2015-02-12 20:38:46 +0000
commit7d3439655bbc155cdaf18e1e3746d59ab584de6e (patch)
tree4b08da0644431ef0c1a170687b5c0f5042ca7df8 /plugins/org.eclipse.osee.define.report.api/src
parent39a07891ea7d3189535f8a015b0d7eb1ce461597 (diff)
downloadorg.eclipse.osee-7d3439655bbc155cdaf18e1e3746d59ab584de6e.tar.gz
org.eclipse.osee-7d3439655bbc155cdaf18e1e3746d59ab584de6e.tar.xz
org.eclipse.osee-7d3439655bbc155cdaf18e1e3746d59ab584de6e.zip
feature[ats_ATS160219]: Fix missing/wrong footers in word content
Diffstat (limited to 'plugins/org.eclipse.osee.define.report.api/src')
-rw-r--r--plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightAnchor.java28
-rw-r--r--plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightResult.java44
-rw-r--r--plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/ReportConstants.java59
3 files changed, 94 insertions, 37 deletions
diff --git a/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightAnchor.java b/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightAnchor.java
index 4b87e14000a..9cd4f3456a3 100644
--- a/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightAnchor.java
+++ b/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightAnchor.java
@@ -20,16 +20,8 @@ public class DataRightAnchor {
private String id;
private DataRightId dataRightId;
- private boolean needsPageBreak;
- private boolean isNextDifferent;
-
- public boolean isNextDifferent() {
- return isNextDifferent;
- }
-
- public void setNextDifferent(boolean isNextDifferent) {
- this.isNextDifferent = isNextDifferent;
- }
+ private boolean isSetDataRightFooter = false;
+ private boolean isContinuous = false;
public String getId() {
return id;
@@ -47,12 +39,20 @@ public class DataRightAnchor {
this.dataRightId = rightId;
}
- public boolean isNeedsPageBreak() {
- return needsPageBreak;
+ public boolean isSetDataRightFooter() {
+ return isSetDataRightFooter;
+ }
+
+ public void setSetDataRightFooter(boolean isSetDataRightFooter) {
+ this.isSetDataRightFooter = isSetDataRightFooter;
+ }
+
+ public boolean isContinuous() {
+ return isContinuous;
}
- public void setNeedsPageBreak(boolean needsPageBreak) {
- this.needsPageBreak = needsPageBreak;
+ public void setContinuous(boolean isContinuous) {
+ this.isContinuous = isContinuous;
}
}
diff --git a/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightResult.java b/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightResult.java
index 977969df39b..f1241cbd259 100644
--- a/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightResult.java
+++ b/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/DataRightResult.java
@@ -25,9 +25,6 @@ import org.eclipse.osee.framework.jdk.core.util.Strings;
*/
@XmlRootElement
public class DataRightResult {
- private static final String NEW_PAGE_TEMPLATE =
- "<w:p><w:pPr><w:spacing w:after=\"0\"/><w:sectPr>%s</w:sectPr></w:pPr></w:p>";
- private static final String SAME_PAGE_TEMPLATE = "<w:sectPr>%s</w:sectPr>";
@XmlTransient
private List<DataRightAnchor> dataRightAnchors;
@@ -66,32 +63,33 @@ public class DataRightResult {
public String getContent(String guid, PageOrientation orientation) {
checkInitialized();
- String toReturn = null;
+ String footer = null;
+
+ // account for orientation
+ String portrait = String.format(ReportConstants.PAGE_ADDS, ReportConstants.PORTRAIT_ORIENT);
+ String landscape = String.format(ReportConstants.PAGE_ADDS, ReportConstants.LANDSCAPE_ORIENT);
+ String page_adds = orientation.isLandscape() ? landscape : portrait;
DataRightAnchor anchor = guidToAnchor.get(guid);
if (anchor != null) {
- boolean needsPageBreak = anchor.isNeedsPageBreak();
- boolean isNextDifferent = anchor.isNextDifferent();
-
- String partialFooter = "";
- DataRightId key = anchor.getDataRightId();
- if (key != null) {
- DataRight dataRight = dataRightIdToDataRight.get(key);
- if (dataRight != null) {
- partialFooter = normalize(dataRight.getContent());
- }
- }
- if (orientation.isLandscape()) {
- toReturn = partialFooter;
- } else if (isNextDifferent || needsPageBreak) {
- if (needsPageBreak) {
- toReturn = String.format(NEW_PAGE_TEMPLATE, partialFooter);
- } else {
- toReturn = String.format(SAME_PAGE_TEMPLATE, partialFooter);
+ boolean isSetDataRightFooter = anchor.isSetDataRightFooter();
+ boolean isContinuous = anchor.isContinuous();
+ if (isSetDataRightFooter) {
+ // set footer section since next footer differs
+ DataRightId key = anchor.getDataRightId();
+ if (key != null) {
+ DataRight dataRight = dataRightIdToDataRight.get(key);
+ if (dataRight != null) {
+ footer = normalize(dataRight.getContent());
+ footer = String.format(ReportConstants.NEW_PAGE_TEMPLATE, footer + page_adds);
+ }
}
+ } else if (!isContinuous) {
+ // set page break since next footer differs;
+ footer = String.format(ReportConstants.NEW_PAGE_TEMPLATE, page_adds);
}
}
- return Strings.isValid(toReturn) ? toReturn : "";
+ return Strings.isValid(footer) ? footer : "";
}
private String normalize(String partialFooter) {
diff --git a/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/ReportConstants.java b/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/ReportConstants.java
new file mode 100644
index 00000000000..604ee7959c8
--- /dev/null
+++ b/plugins/org.eclipse.osee.define.report.api/src/org/eclipse/osee/define/report/api/ReportConstants.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.define.report.api;
+
+/**
+ * @author Megumi Telles
+ */
+public class ReportConstants {
+
+ public ReportConstants() {
+ //Utility class
+ }
+
+ //regex
+ public static final String FTR = "<w:ftr[\\s\\S]+?</w:ftr>";
+ public static final String PAGE_SZ = "<w:pgSz [^>]*/>";
+
+ //wordml
+ public static final String PG_SZ = "<w:pgSz w:w=\"12240\" w:h=\"15840\" w:code=\"1\"/>";
+ public static final String CONTINUOUS = "<w:type w:val=\"continuous\"/>";
+ public static final String SECTION_TEMPLATE = "<w:sectPr>%s</w:sectPr>";
+ public static final String LANDSCAPE_ORIENT = "<w:pgSz w:w=\"15840\" w:h=\"12240\" w:orient=\"landscape\"/>";
+ public static final String PORTRAIT_ORIENT = "<w:pgSz w:w=\"12240\" w:h=\"15840\"/>";
+ static final String NEW_PAGE_TEMPLATE =
+ "<w:p><w:pPr><w:spacing w:after=\"0\"/>" + SECTION_TEMPLATE + "</w:pPr></w:p>";
+ public static final String PAGE_ADDS =
+ "%s <w:pgMar w:top=\"1440\" w:right=\"1440\" w:bottom=\"1440\" w:left=\"1440\" w:header=\"720\" w:footer=\"720\" w:gutter=\"0\"/><w:cols w:space=\"720\"/>";
+ public static final String INS = "</w:ins>";
+ public static final String[] WXML_CHARS = new String[] {"&", "<", ">", "\""};
+ public static final String[] WXML_ESCAPES = new String[] {"&amp;", "&lt;", "&gt;", "&quot;"};
+ public static final String FONT = "<w:rFonts w:ascii=\"Helvetica\" w:hAnsi=\"Helvetica\" w:cs=\"Helvetica\"/>";
+ public static final String RUN_END = "</w:t></w:r>";
+ public static final String PARA_END = "</w:p>";
+ public static final String PARA_START = "<w:p>";
+ public static final String EMPTY_PARAGRAPH = "<w:p/>";
+ public static final String PARAGRAPH_END = RUN_END + PARA_END;
+ public static final String PARAGRAPH_START = PARA_START + "<w:r><w:t>";
+ public static final String HEADING_BOLDED = "<w:rPr><w:b/></w:rPr><w:t xml:space=\"preserve\">%s</w:t>";
+ public static final String SENTENCE = "<w:t xml:space=\"preserve\">%s</w:t>";
+ public static final String BULLETSYM = "<w:t></w:t>";
+ public static final String OLD_BULLET_STYLE = "bullettight1";
+ public static final String NEW_BULLET_STYLE = "bulletlvl2";
+ public static final String PARA_REGEX = "<w:p(.*?)>";
+ public static final String PARA_PROP_START = "<w:pPr>";
+ public static final String PARA_PROP_REGEX = PARA_PROP_START + "(.*?)</w:pPr>";
+ public static final String FONT_REGEX = "<w:rFonts(.*?)/>";
+ public static final String LISTNUM_FIELD_HEAD = "<w:pPr><w:rPr><w:vanish/></w:rPr></w:pPr>";
+ public static final String LISTNUM_FIELD_TAIL =
+ "<w:r><w:rPr><w:vanish/></w:rPr><w:fldChar w:fldCharType=\"begin\"/></w:r><w:r><w:rPr><w:vanish/></w:rPr><w:instrText>LISTNUM\"listreset\"\\l1\\s0</w:instrText></w:r><w:r><w:rPr><w:vanish/></w:rPr><w:fldChar w:fldCharType=\"end\"/><wx:t wx:val=\"1.\"/></w:r>";
+ public static final String LISTNUM_FIELD = LISTNUM_FIELD_HEAD + LISTNUM_FIELD_TAIL;
+} \ No newline at end of file

Back to the top