diff options
author | mpotterc0k | 2013-05-09 21:46:58 +0000 |
---|---|---|
committer | Ryan T. Baldwin | 2013-05-09 21:46:58 +0000 |
commit | 5cc73fe224f37087e74a6443b1b69c59e14f7f32 (patch) | |
tree | d64469141d300db3c5b261455e27eb2172da9d27 | |
parent | 23c137aebf40f994a0370d175fcdf82a518f3d77 (diff) | |
download | org.eclipse.osee-5cc73fe224f37087e74a6443b1b69c59e14f7f32.tar.gz org.eclipse.osee-5cc73fe224f37087e74a6443b1b69c59e14f7f32.tar.xz org.eclipse.osee-5cc73fe224f37087e74a6443b1b69c59e14f7f32.zip |
feature[ats_A0KLY]: Add Normalize HTML utility class
Change-Id: I320acbef928cc71dab5460e8281330a99e4e39a8
8 files changed, 892 insertions, 2 deletions
diff --git a/features/org.eclipse.osee.framework.feature/feature.xml b/features/org.eclipse.osee.framework.feature/feature.xml index e4b6982e4b4..534eb4b2013 100644 --- a/features/org.eclipse.osee.framework.feature/feature.xml +++ b/features/org.eclipse.osee.framework.feature/feature.xml @@ -39,7 +39,8 @@ <import plugin="org.apache.commons.dbcp" version="1.4.0" match="compatible"/> <import plugin="org.apache.commons.pool" version="1.6.0" match="compatible"/> <import plugin="com.google.guava" version="10.0.1.v201203051515" match="perfect"/> - <import plugin="com.google.guava" version="12.0.0" match="greaterOrEqual"/> + <import plugin="com.google.guava" version="12.0.0" match="greaterOrEqual"/> + <import plugin="org.jsoup"/> </requires> <plugin diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java index 8705625a02e..8f869ab3bf3 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/AllSkynetCoreJunitTestSuite.java @@ -17,6 +17,7 @@ import org.eclipse.osee.framework.skynet.core.internal.event.InternalEventTestSu import org.eclipse.osee.framework.skynet.core.linking.LinkingTestSuite; import org.eclipse.osee.framework.skynet.core.relation.RelationTestSuite; import org.eclipse.osee.framework.skynet.core.transaction.TransactionTestSuite; +import org.eclipse.osee.framework.skynet.core.utility.UtilityTestSuite; import org.eclipse.osee.framework.skynet.core.word.WordTestSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -30,6 +31,7 @@ import org.junit.runners.Suite; LinkingTestSuite.class, RelationTestSuite.class, TransactionTestSuite.class, + UtilityTestSuite.class, WordTestSuite.class}) public class AllSkynetCoreJunitTestSuite { // diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/NormalizeHtmlTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/NormalizeHtmlTest.java new file mode 100644 index 00000000000..4308fb854dd --- /dev/null +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/NormalizeHtmlTest.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2013 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.framework.skynet.core.utility; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import junit.framework.Assert; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.junit.Test; + +/** + * @author Marc A. Potter + */ +public class NormalizeHtmlTest { + + private static final String SUPPORT_PATH = "support"; + private static final String CONVERTED_HTML = "NormalizeHtml_converted.htm"; + private static final String TEST_DOC = "NormalizeHtml_test_doc.htm"; + + @Test + public void test() throws Exception { + String input = getResource(TEST_DOC); + String expected = getResource(CONVERTED_HTML); + + input = NormalizeHtml.convertToNormalizedHTML(input); + + input = bodyOnly(input); + expected = bodyOnly(expected); + input = input.replaceAll("\r", ""); + expected = expected.replaceAll("\r", ""); + Assert.assertEquals("Converted HTML does not equal expected", expected, input); + } + + private String getResource(String resource) throws IOException { + String resourcePath = String.format("%s/%s", SUPPORT_PATH, resource); + + URL input = getClass().getResource(resourcePath); + + String output = null; + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(input.openStream()); + output = Lib.inputStreamToString(inputStream); + } finally { + Lib.close(inputStream); + } + return output; + } + + private static String bodyOnly(String input) { + int iBodyStart = input.indexOf("<body"); + int iBodyEnd = input.indexOf("</body"); + if ((iBodyStart == -1) || (iBodyEnd == -1)) { + return input; + } + iBodyStart = iBodyStart + 1 + input.substring(iBodyStart).indexOf('>'); + return input.substring(iBodyStart, iBodyEnd - 1); + } + +} diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/UtilityTestSuite.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/UtilityTestSuite.java new file mode 100644 index 00000000000..77ceddf5b2f --- /dev/null +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/UtilityTestSuite.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2013 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.framework.skynet.core.utility; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({NormalizeHtmlTest.class}) +/** + * @author Marc A. Potter + */ +public class UtilityTestSuite { + // Test Suite +} diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/support/NormalizeHtml_converted.htm b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/support/NormalizeHtml_converted.htm new file mode 100644 index 00000000000..092f5e515e8 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/support/NormalizeHtml_converted.htm @@ -0,0 +1,427 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <meta http-equiv="CONTENT-TYPE" content="text/html; charset=windows-1252" /> + <title></title> + <meta name="GENERATOR" content="OpenOffice.org 3.2 (Win32)" /> + <meta name="AUTHOR" content="Marc Potter" /> + <meta name="CREATED" content="20130307;17140000" /> + <meta name="CHANGEDBY" content="Marc Potter" /> + <meta name="CHANGED" content="20130307;17140000" /> + <meta name="Category" content="" /> + <meta name="Company" content="The Boeing Company" /> + <meta name="HyperlinkBase" content="" /> + <meta name="Manager" content="" /> + <meta name="Version" content="12" /> + <style type="text/css"> + <!-- + P { margin-bottom: 0.08in } + --> + + </style> + </head> + <body lang="en" dir="LTR"> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: xx-small;">6 pt font</span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: xx-small;"> + <strong>7 pt font bold </strong> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: xx-small;"> + <span style="text-decoration: underline;"> + <strong>8 pt font bold underline </strong> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style=" font-size: small;"> + <em> + <span style="text-decoration: underline;"> + <strong>9 pt font bold, unerline italic </strong> + </span> + </em> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #ff0000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: small;"> + <em> + <span style="text-decoration: underline;"> + <strong>10 pt font bold, underline, italic, red </strong> + </span> + </em> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: small;">10.5 pt font normal</span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style=" color: #000000"> + <span style="background: #ffff00">11 pt font highlighted </span> + </span> + </span> + </span> + </p> + <p align="RIGHT" style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style="background: #ffffff">12 pt font normal right justified</span> + </span> + </span> + </span> + </p> + <p align="CENTER" style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style=" color: #000000"> + <span style=" font-size: medium;"> + <span style="background: #ffffff">13 pt font centered</span> + </span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style="background: #ffffff">14 pt font justified (doesn't seem to work in HTML or OO)</span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: large;"> + <span style="background: #ffffff">15 pt font normal outline</span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: large;"> + <span style="background: #ffffff">16 pt font shadow</span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style="text-decoration: line-through;"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: x-large;"> + <span style="background: #ffffff">18 point font strikeout</span> + </span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style=" color: #000000"> + <span style=" font-size: x-large;"> + <span style="background: #ffffff">20 pt font </span> + </span> + </span> + <span style=" color: #000000"> + <sup> + <span style=" font-size: x-large;"> + <span style="background: #ffffff">super script</span> + </span> + </sup> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style=" color: #000000"> + <span style=" font-size: xx-large;"> + <span style="background: #ffffff">22 pt font </span> + </span> + </span> + <span style=" color: #000000"> + <sub> + <span style=" font-size: xx-large;"> + <span style="background: #ffffff">sub script</span> + </span> + </sub> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: xx-large;"> + <span style="background: #ffffff">24 pt font normal </span> + </span> + </span> + </span> + </p> + <table width="4369" border="1" bordercolor="#000000" cellpadding="0" cellspacing="3"> + <colgroup> + <col width="2180" /> + <col width="2178" /> + </colgroup> + <tbody> + <tr valign="TOP"> + <td width="2180"> + <p style="margin-top: 0.07in"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: xx-large;">26 pt in table with border</span> + </span> + </p> + </td> + <td width="2178"> + <p style="margin-top: 0.07in"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: xx-large;">26 pt in table with border</span> + </span> + </p> + </td> + </tr> + <tr valign="TOP"> + <td width="2180"> + <p style="margin-top: 0.07in"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: xx-large;">28 pt in table with border</span> + </span> + </p> + </td> + <td width="2178"> + <p style="margin-top: 0.07in"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: xx-large;">28 pt in table with border</span> + </span> + </p> + </td> + </tr> + </tbody> + </table> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">32 pt font</span> + </span> + </span> + </span> + </p> + <table width="4369" border="1" bordercolor="#000000" cellpadding="0" cellspacing="0"> + <colgroup> + <col width="2183" /> + <col width="2184" /> + </colgroup> + <tbody> + <tr valign="TOP"> + <td width="2183"> + <p style="margin-top: 0.07in"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;">36 pt in table without border</span> + </span> + </p> + </td> + <td width="2184"> + <p style="margin-top: 0.07in"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;">36 pt in table without border</span> + </span> + </p> + </td> + </tr> + <tr valign="TOP"> + <td width="2183"> + <p style="margin-top: 0.07in"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;">40 pt in table w/o border</span> + </span> + </p> + </td> + <td width="2184"> + <p style="margin-top: 0.07in"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;">40 pt in table w/o border</span> + </span> + </p> + </td> + </tr> + </tbody> + </table> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">48 pt</span> + </span> + </span> + </span> + </p> + <ol> + <li> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">54 pt numbered list</span> + </span> + </span> + </span> + </p> + </li> + <li> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">60 pt</span> + </span> + </span> + </span> + </p> + </li> + </ol> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <ul> + <li> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">66 pt bulleted</span> + </span> + </span> + </span> + </p> + </li> + <li> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">72 pt</span> + </span> + </span> + </span> + </p> + </li> + </ul> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-left: 0.49in; margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">80 pt indent right </span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">88 pt</span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" color: #000000"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: 300%;"> + <span style="background: #ffffff">96 pt</span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style=" color: #000000"> + <span style=" font-family: Algerian, fantasy"> + <span style=" font-size: small;"> + <span style="background: #ffffff">New font 10 pt with special chars !@#$%^&*()_+}{[]<>,.:";'/?~`</span> + </span> + </span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <span style=" font-family: Times New Roman, serif"> + <span style=" font-size: medium;"> + <span style=" color: #000000"> + <span style=" font-family: Algerian, fantasy"> + <span style=" font-size: small;"> + <span style="background: #ffffff">This is a test: " this is a test " ' this isn't not a test'</span> + </span> + </span> + </span> + </span> + </span> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <br /> + </p> + <p style="margin-bottom: 0.14in; line-height: 115%"> + <br /> + <br /> + </p> + </body> +</html>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/support/NormalizeHtml_test_doc.htm b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/support/NormalizeHtml_test_doc.htm new file mode 100644 index 00000000000..ef338dbdb40 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/utility/support/NormalizeHtml_test_doc.htm @@ -0,0 +1,170 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252"> + <TITLE></TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2 (Win32)"> + <META NAME="AUTHOR" CONTENT="Marc Potter"> + <META NAME="CREATED" CONTENT="20130307;17140000"> + <META NAME="CHANGEDBY" CONTENT="Marc Potter"> + <META NAME="CHANGED" CONTENT="20130307;17140000"> + <META NAME="Category" CONTENT=""> + <META NAME="Company" CONTENT="The Boeing Company"> + <META NAME="HyperlinkBase" CONTENT=""> + <META NAME="Manager" CONTENT=""> + <META NAME="Version" CONTENT="12"> + <STYLE TYPE="text/css"> + <!-- + P { margin-bottom: 0.08in } + --> + </STYLE> +</HEAD> +<BODY LANG="en" DIR="LTR"> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=1 STYLE="font-size: 6pt">6 +pt font</FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=1 STYLE="font-size: 7pt"><B>7 +pt font bold </B></FONT></FONT> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=1 STYLE="font-size: 8pt"><U><B>8 +pt font bold underline </B></U></FONT></FONT> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2 STYLE="font-size: 9pt"><I><U><B>9 +pt font bold, unerline italic </B></U></I></FONT></FONT></FONT> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#ff0000"><FONT FACE="Times New Roman, serif"><FONT SIZE=2><I><U><B>10 +pt font bold, underline, italic, red </B></U></I></FONT></FONT></FONT> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=2>10.5 +pt font normal</FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT COLOR="#000000"><SPAN STYLE="background: #ffff00">11 +pt font highlighted </SPAN></FONT></FONT></FONT> +</P> +<P ALIGN=RIGHT STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> +<FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><SPAN STYLE="background: #ffffff">12 +pt font normal right justified</SPAN></FONT></FONT></FONT></P> +<P ALIGN=CENTER STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> +<FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT COLOR="#000000"><FONT SIZE=3 STYLE="font-size: 13pt"><SPAN STYLE="background: #ffffff">13 +pt font centered</SPAN></FONT></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 13pt"><SPAN STYLE="background: #ffffff">14 +pt font justified (doesn't seem to work in HTML or OO)</SPAN></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 15pt"><SPAN STYLE="background: #ffffff">15 +pt font normal outline</SPAN></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=4 STYLE="font-size: 16pt"><SPAN STYLE="background: #ffffff">16 +pt font shadow</SPAN></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><STRIKE><FONT FACE="Times New Roman, serif"><FONT SIZE=5><SPAN STYLE="background: #ffffff">18 +point font strikeout</SPAN></FONT></FONT></STRIKE></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT COLOR="#000000"><FONT SIZE=5 STYLE="font-size: 20pt"><SPAN STYLE="background: #ffffff">20 +pt font </SPAN></FONT></FONT><FONT COLOR="#000000"><SUP><FONT SIZE=5 STYLE="font-size: 20pt"><SPAN STYLE="background: #ffffff">super +script</SPAN></FONT></SUP></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT COLOR="#000000"><FONT SIZE=6 STYLE="font-size: 22pt"><SPAN STYLE="background: #ffffff">22 +pt font </SPAN></FONT></FONT><FONT COLOR="#000000"><SUB><FONT SIZE=6 STYLE="font-size: 22pt"><SPAN STYLE="background: #ffffff">sub +script</SPAN></FONT></SUB></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=6><SPAN STYLE="background: #ffffff">24 +pt font normal </SPAN></FONT></FONT></FONT> +</P> +<TABLE WIDTH=4369 BORDER=1 BORDERCOLOR="#000000" CELLPADDING=0 CELLSPACING=3> + <COL WIDTH=2180> + <COL WIDTH=2178> + <TR VALIGN=TOP> + <TD WIDTH=2180> + <P STYLE="margin-top: 0.07in"><FONT FACE="Times New Roman, serif"><FONT SIZE=6 STYLE="font-size: 26pt">26 + pt in table with border</FONT></FONT></P> + </TD> + <TD WIDTH=2178> + <P STYLE="margin-top: 0.07in"><FONT FACE="Times New Roman, serif"><FONT SIZE=6 STYLE="font-size: 26pt">26 + pt in table with border</FONT></FONT></P> + </TD> + </TR> + <TR VALIGN=TOP> + <TD WIDTH=2180> + <P STYLE="margin-top: 0.07in"><FONT FACE="Times New Roman, serif"><FONT SIZE=6 STYLE="font-size: 28pt">28 + pt in table with border</FONT></FONT></P> + </TD> + <TD WIDTH=2178> + <P STYLE="margin-top: 0.07in"><FONT FACE="Times New Roman, serif"><FONT SIZE=6 STYLE="font-size: 28pt">28 + pt in table with border</FONT></FONT></P> + </TD> + </TR> +</TABLE> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 32pt"><SPAN STYLE="background: #ffffff">32 +pt font</SPAN></FONT></FONT></FONT></P> +<TABLE WIDTH=4369 BORDER=1 BORDERCOLOR="#000000" CELLPADDING=0 CELLSPACING=0> + <COL WIDTH=2183> + <COL WIDTH=2184> + <TR VALIGN=TOP> + <TD WIDTH=2183> + <P STYLE="margin-top: 0.07in"><FONT FACE="Times New Roman, serif"><FONT SIZE=7>36 + pt in table without border</FONT></FONT></P> + </TD> + <TD WIDTH=2184> + <P STYLE="margin-top: 0.07in"><FONT FACE="Times New Roman, serif"><FONT SIZE=7>36 + pt in table without border</FONT></FONT></P> + </TD> + </TR> + <TR VALIGN=TOP> + <TD WIDTH=2183> + <P STYLE="margin-top: 0.07in"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 40pt">40 + pt in table w/o border</FONT></FONT></P> + </TD> + <TD WIDTH=2184> + <P STYLE="margin-top: 0.07in"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 40pt">40 + pt in table w/o border</FONT></FONT></P> + </TD> + </TR> +</TABLE> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 48pt"><SPAN STYLE="background: #ffffff">48 +pt</SPAN></FONT></FONT></FONT></P> +<OL> + <LI><P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 54pt"><SPAN STYLE="background: #ffffff">54 + pt numbered list</SPAN></FONT></FONT></FONT></P> + <LI><P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 60pt"><SPAN STYLE="background: #ffffff">60 + pt</SPAN></FONT></FONT></FONT></P> +</OL> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<UL> + <LI><P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 66pt"><SPAN STYLE="background: #ffffff">66 + pt bulleted</SPAN></FONT></FONT></FONT></P> + <LI><P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> + <FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 72pt"><SPAN STYLE="background: #ffffff">72 + pt</SPAN></FONT></FONT></FONT></P> +</UL> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-left: 0.49in; margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"> +<FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 80pt"><SPAN STYLE="background: #ffffff">80 +pt indent right </SPAN></FONT></FONT></FONT> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 88pt"><SPAN STYLE="background: #ffffff">88 +pt</SPAN></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT COLOR="#000000"><FONT FACE="Times New Roman, serif"><FONT SIZE=7 STYLE="font-size: 96pt"><SPAN STYLE="background: #ffffff">96 +pt</SPAN></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT COLOR="#000000"><FONT FACE="Algerian, fantasy"><FONT SIZE=2><SPAN STYLE="background: #ffffff">New +font 10 pt with special chars !@#$%^&*()_+}{[]<>,.:”;'/?~`</SPAN></FONT></FONT></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT COLOR="#000000"><FONT FACE="Algerian, fantasy"><FONT SIZE=2><SPAN STYLE="background: #ffffff">This +is a test: “ this is a test ” ‘ this isn't not a test’</SPAN></FONT></FONT></FONT></FONT></FONT></P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-top: 0.07in; margin-bottom: 0in; line-height: 100%"><BR> +</P> +<P STYLE="margin-bottom: 0.14in; line-height: 115%"><BR><BR> +</P> +</BODY> +</HTML>
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF index 27deb6faf7e..9bc3c8ca5ad 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.skynet.core/META-INF/MANIFEST.MF @@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.osee.framework.database, org.eclipse.osee.framework.messaging.event.res, org.eclipse.osee.framework.messaging, - org.eclipse.osee.framework.lifecycle + org.eclipse.osee.framework.lifecycle, + org.jsoup;bundle-version="1.7.2" Export-Package: org.eclipse.osee.framework.skynet.core, org.eclipse.osee.framework.skynet.core.artifact, org.eclipse.osee.framework.skynet.core.artifact.factory, diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/NormalizeHtml.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/NormalizeHtml.java new file mode 100644 index 00000000000..6a88e13707b --- /dev/null +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/NormalizeHtml.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (c) 2013 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.framework.skynet.core.utility; + +import java.util.TreeMap; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Attribute; +import org.jsoup.nodes.Attributes; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Document.OutputSettings; +import org.jsoup.nodes.Document.QuirksMode; +import org.jsoup.nodes.Element; +import org.jsoup.nodes.Entities.EscapeMode; +import org.jsoup.select.Elements; + +/** + * This class will convert an HTML string to a normalized format. This allows the same output from HTML regardless of + * the input editor. The least versatile editor will be used. Currently that is TinyMCE. The reason to do this is that + * options can be removed, but not added to the HTML + * + * <pre> + * Assumptions: + * The input is valid HTML + * Items that change + * HTML tags may be upper case, tinyMCE are lower + * <FONT> is converted to <span> + * tinyMCE does NOT use font point only small, medium, ... + * 6-8 point == xx-small + * 9-11 point == small + * 12-13 point == medium + * 14-16 point == large + * 18-20 point == x-large + * 22-28 point == xx-large + * >28 point == 300% + * replace &ldquot; &rdquot; &lsquot; &rsquot; to " and ' + * replace <b> with <strong> + * replace <i> with + * <em> + * replace <u> with <span style="text-decoration: underline;"> + * remove bordercolor from table tag + * <pre/> + * + * @author Marc A. Potter + */ +public final class NormalizeHtml { + + private static final TreeMap<Integer, String> FONT_MAP = initializeFontMap(); + private static final String[] FONT_VALUES = FONT_MAP.values().toArray(new String[0]); + private static final String MEDIUM_FONT = "medium;"; + private static final String CHARSET = "UTF-8"; + private static final int INDENT_AMOUNT = 4; + private static final String ldquo = String.valueOf('\u201C'); + private static final String rdquo = String.valueOf('\u201D'); + private static final String lsquo = String.valueOf('\u2018'); + private static final String rsquo = String.valueOf('\u2019'); + + private NormalizeHtml() { + // Utility Class + } + + private static TreeMap<Integer, String> initializeFontMap() { + TreeMap<Integer, String> map = new TreeMap<Integer, String>(); + map.put(new Integer(8), "xx-small;"); + map.put(new Integer(11), "small;"); + map.put(new Integer(13), "medium;"); + map.put(new Integer(16), "large;"); + map.put(new Integer(20), "x-large;"); + map.put(new Integer(28), "xx-large;"); + map.put(new Integer(Integer.MAX_VALUE), "300%;"); + return map; + } + + public static String convertToNormalizedHTML(String inputHTML) { + Document doc = Jsoup.parse(inputHTML); + doc.quirksMode(QuirksMode.noQuirks); + OutputSettings outputSettings = doc.outputSettings(); + outputSettings.charset(CHARSET); + outputSettings.escapeMode(EscapeMode.xhtml); + outputSettings.prettyPrint(true); + outputSettings.outline(true); + outputSettings.indentAmount(INDENT_AMOUNT); + doc.outputSettings(outputSettings); + Elements bold = doc.select("b"); + for (Element e : bold) { + e.tagName("strong"); + } + Elements italic = doc.select("i"); + for (Element e : italic) { + e.tagName("em"); + } + Elements underline = doc.select("u"); + for (Element e : underline) { + e.tagName("span"); + e.attr("style", "text-decoration: underline;"); + } + Elements strike = doc.select("strike"); + for (Element e : strike) { + e.tagName("span"); + e.attr("style", "text-decoration: line-through;"); + } + processFontTags(doc); + return processText(doc); + } + + private static String processText(Document doc) { + /** + * Nothing is ever as easy as it should be, since text nodes are not elements the select does not work. Therefore, + * process the output HTML + */ + String theText = doc.outerHtml(); + + /** + * convert “ and ” to " convert ‘ and ’ to ' The parser itself changes the symbols to + * the appropriate HTML variable at read/write time. Therefore, just change the actual symbols. Use the unicode + * definitions of the special characters since they are multibyte Jsoup sets ' to &apos on input, reset this to ' + */ + theText = theText.replaceAll(ldquo, "\""); + theText = theText.replaceAll(rdquo, "\""); + theText = theText.replaceAll(lsquo, "'"); + theText = theText.replaceAll(rsquo, "'"); + theText = theText.replaceAll("'", "'"); + return theText; + } + + private static void processFontTags(Document doc) { + Elements font = doc.select("font"); + for (Element e : font) { + Attributes attrs = e.attributes().clone(); + StringBuilder styleString = new StringBuilder(); + String theSizeString = ""; + for (Attribute attribute : attrs) { + String attributeName = attribute.getKey(); + String attributeValue = attribute.getValue(); + if (attributeName.equalsIgnoreCase("face")) { + styleString.append(" font-family: "); + styleString.append(attributeValue); + } else if (attributeName.equalsIgnoreCase("size")) { + int theSize = Integer.valueOf(attributeValue.trim()); + if (theSize <= FONT_VALUES.length) { + theSizeString = FONT_VALUES[theSize - 1]; + } + } else if (attributeName.equalsIgnoreCase("color")) { + styleString.append(" color: "); + styleString.append(attributeValue); + } else if (attributeName.equalsIgnoreCase("style")) { + // possible that font size specified here (font-size: xxpt) + int size = attributeValue.indexOf("font-size:"); + if (size != -1) { + size += "font-size:".length(); + theSizeString = getFontSize(attributeValue.substring(size)); + } + } + e.removeAttr(attributeName); + } + if (theSizeString.length() > 0) { + styleString.append(" font-size: "); + styleString.append(theSizeString); + } + e.tagName("span"); + e.attr("style", styleString.toString()); + } + } + + /** + * Expected format of the input is font-size: NNpt Note that there may be other information after the pt font-size: + * NNpt font-family: .... If the string is not formatted correctly, return a medium font as default + */ + private static String getFontSize(String inputStyle) { + int theSize = 1; + String theReturn; + int thePointStart = inputStyle.indexOf(' '), thePointEnd = inputStyle.lastIndexOf("pt"); + if (thePointStart == -1) { + thePointStart = 0; + } + while ((inputStyle.charAt(thePointStart) == ' ') && (thePointStart < inputStyle.length())) { + thePointStart++; + } + if (thePointStart >= thePointEnd) { + theReturn = MEDIUM_FONT; // average middle font + } else { + theSize = Integer.valueOf(inputStyle.substring(thePointStart, thePointEnd)); + theReturn = FONT_MAP.ceilingEntry(theSize).getValue(); + } + return theReturn; + } + +} |