diff options
author | megumi.telles | 2013-12-12 18:12:07 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-12-16 18:08:45 +0000 |
commit | 9e3186c65ead7f54240a0c5e069a8dcc104a3c8a (patch) | |
tree | 83a1edc04b13948d584cfa19dd07f0842eefb7aa /plugins/org.eclipse.osee.framework.ui.skynet | |
parent | 625ee40bb2b897f5be429279fe51c1425e34bd87 (diff) | |
download | org.eclipse.osee-9e3186c65ead7f54240a0c5e069a8dcc104a3c8a.tar.gz org.eclipse.osee-9e3186c65ead7f54240a0c5e069a8dcc104a3c8a.tar.xz org.eclipse.osee-9e3186c65ead7f54240a0c5e069a8dcc104a3c8a.zip |
feature[ats_ZVZ63]: Create abstract Dsl wordMl creator
Change-Id: Iaf5fd56cf614871de7acf763db38e975bca9a605
Diffstat (limited to 'plugins/org.eclipse.osee.framework.ui.skynet')
-rw-r--r-- | plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/dsl/AbstractDslWordMlCreator.java | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/dsl/AbstractDslWordMlCreator.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/dsl/AbstractDslWordMlCreator.java new file mode 100644 index 00000000000..7ed4298406d --- /dev/null +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/dsl/AbstractDslWordMlCreator.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 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 + *******************************************************************************/ +//@formatter:off +package org.eclipse.osee.framework.ui.skynet.render.dsl; + +import org.eclipse.osee.framework.skynet.core.artifact.Attribute; +import org.eclipse.osee.framework.ui.skynet.render.PresentationType; + + +/** + * @author Theron Virgin + * @author Megumi Telles + */ +public abstract class AbstractDslWordMlCreator { + + private static final String[] XML_CHARS = new String[] {"[&]", "[<]", "[>]", "[\"]"}; + private static final String[] XML_ESCAPES = new String[] {"&", "<", ">", """}; + private static String emptyParagraph = "<w:p/>"; + private static String paragraphEnd = "</w:t></w:r></w:p>"; + private static String start = + "<w:p><w:pPr><w:pStyle w:val=\"reqlang1\"/><w:spacing w:before=\"0\" w:after=\"0\"/></w:pPr><w:r><w:t>"; + private static final String[] TAB_ARRAY = + new String[] {"\r\t\t\t\t\t\t\t\t", "\r\t\t\t\t\t\t\t", "\r\t\t\t\t\t\t", "\r\t\t\t\t\t", "\r\t\t\t\t", + "\r\t\t\t", "\r\t\t", "\r\t"}; + private static final String[] TAB_STYLE_ARRAY = + new String[] {"w:val=\"reqlang9\"", "w:val=\"reqlang8\"", "w:val=\"reqlang7\"", "w:val=\"reqlang6\"", + "w:val=\"reqlang5\"", "w:val=\"reqlang4\"", "w:val=\"reqlang3\"", "w:val=\"reqlang2\""}; + + public String getWordMlFromAttribute(String attribute, PresentationType presentationType) { + String toReturn = ""; + toReturn = emptyParagraph + getIfWordMl(attribute, true); + return toReturn; + } + + public String getIfWordMl(String attribute, boolean addEndParagraph) { + String wordml = attribute; + wordml = escape(wordml).toString(); + wordml = wordml.replace("\r\n", "\r"); + wordml = wordml.replace("\n\r", "\r"); + wordml = wordml.replace("\n", "\r"); + wordml = replaceTabs(wordml); + wordml = wordml.replace("\r", paragraphEnd + start); + wordml = start + wordml; + wordml = wordml + paragraphEnd; + + if (addEndParagraph) { + wordml = wordml.concat("<w:p></w:p>"); + } + return wordml; + } + + public String replaceTabs(String wordml) { + for (int x = 0; x < TAB_ARRAY.length; x++) { + wordml = + wordml.replace(TAB_ARRAY[x], (paragraphEnd + start).replace("w:val=\"reqlang1\"", TAB_STYLE_ARRAY[x])); + } + return wordml; + } + + public CharSequence escape(CharSequence text) { + String textString = text.toString(); + for (int x = 0; x < XML_CHARS.length; x++) { + textString = textString.replaceAll(XML_CHARS[x], XML_ESCAPES[x]); + } + + return textString; + } + + public abstract boolean isArtifactAttribute(Attribute<?> attribute); + +} |