[richfaces-svn-commits] JBoss Rich Faces SVN: r14533 - in branches/community/3.3.X/ui/editor/src: test/java/org/richfaces/seamparser and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Jun 5 07:56:27 EDT 2009


Author: Alex.Kolonitsky
Date: 2009-06-05 07:56:27 -0400 (Fri, 05 Jun 2009)
New Revision: 14533

Modified:
   branches/community/3.3.X/ui/editor/src/main/java/org/richfaces/convert/seamtext/tags/LineTag.java
   branches/community/3.3.X/ui/editor/src/main/java/org/richfaces/convert/seamtext/tags/ParagraphTag.java
   branches/community/3.3.X/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java
Log:
RF Problem with editor and Seam Text
https://jira.jboss.org/jira/browse/RF-7291

Modified: branches/community/3.3.X/ui/editor/src/main/java/org/richfaces/convert/seamtext/tags/LineTag.java
===================================================================
--- branches/community/3.3.X/ui/editor/src/main/java/org/richfaces/convert/seamtext/tags/LineTag.java	2009-06-05 10:26:10 UTC (rev 14532)
+++ branches/community/3.3.X/ui/editor/src/main/java/org/richfaces/convert/seamtext/tags/LineTag.java	2009-06-05 11:56:27 UTC (rev 14533)
@@ -47,26 +47,41 @@
         return super.printPlain();
     }
     
-    private boolean isFirstChars = true;
+//    private boolean isFirstChars = true;
     
     @Override
     public void appendBody(String str) {
-        if (isFirstChars) {
-            char text[] = str.toCharArray();
-            int i = 0;
-            while (i < text.length && (text[i] == '\r' || text[i] == '\n')) {
-                i++;
+//        if (isFirstChars) {
+//            char text[] = str.toCharArray();
+//            int firstNotNewLineChar = 0;
+//            while (firstNotNewLineChar < text.length && (text[firstNotNewLineChar] == '\r' || text[firstNotNewLineChar] == '\n')) {
+//                firstNotNewLineChar++;
+//            }
+//              
+//            if (firstNotNewLineChar < text.length) {
+//                super.appendBody(str.substring(firstNotNewLineChar));
+//                isFirstChars = false;
+//            } else {
+//                return;
+//            }
+//        } else {
+            super.appendBody(removeNewLineChars(str));
+//        }
+    }
+    
+    private String removeNewLineChars(String str) {
+        char text[] = str.toCharArray();
+        char result[] = new char[text.length];
+        int resultSize = 0;
+        
+        for (int textIndex = 0; textIndex < text.length; textIndex++) {
+            if (text[textIndex] != '\r' && text[textIndex] != '\n') {
+                result[resultSize] = text[textIndex];
+                resultSize++;
             }
-              
-            if (i < text.length) {
-                super.appendBody(str.substring(i));
-                isFirstChars = false;
-            } else {
-                return;
-            }
-        } else {
-            super.appendBody(str);
         }
+            
+        return new String(result, 0, resultSize);
     }
 
     @Override

Modified: branches/community/3.3.X/ui/editor/src/main/java/org/richfaces/convert/seamtext/tags/ParagraphTag.java
===================================================================
--- branches/community/3.3.X/ui/editor/src/main/java/org/richfaces/convert/seamtext/tags/ParagraphTag.java	2009-06-05 10:26:10 UTC (rev 14532)
+++ branches/community/3.3.X/ui/editor/src/main/java/org/richfaces/convert/seamtext/tags/ParagraphTag.java	2009-06-05 11:56:27 UTC (rev 14533)
@@ -34,7 +34,34 @@
         super(P);
     }
     
+    private boolean isFirstChars = true;
+    
     @Override
+    public void appendBody(String str) {
+        if (isFirstChars) {
+            String substr = cutLeadBreaklines(str);  
+            if (substr != null) {
+                body.add(substr);
+                isFirstChars = false;
+            } else {
+                return;
+            }
+        } else {
+            body.add(str);
+        }
+    }
+    
+    private String cutLeadBreaklines(String str) {
+        char text[] = str.toCharArray();
+        int firstNotNewLineChar = 0;
+        while (firstNotNewLineChar < text.length && (text[firstNotNewLineChar] == '\r' || text[firstNotNewLineChar] == '\n')) {
+            firstNotNewLineChar++;
+        }
+        
+        return firstNotNewLineChar < text.length ? str.substring(firstNotNewLineChar) : null;
+    }
+    
+    @Override
     public String printStart() {
         return "";
     }

Modified: branches/community/3.3.X/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java
===================================================================
--- branches/community/3.3.X/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java	2009-06-05 10:26:10 UTC (rev 14532)
+++ branches/community/3.3.X/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java	2009-06-05 11:56:27 UTC (rev 14533)
@@ -335,6 +335,21 @@
         assertTrue(result.contains(content));
     }
     
+    public void testRF7291() throws Exception {
+        final String content = 
+            "<ul>" +
+            "<li>an item :\n" +
+            "  <ul>\n" +
+            "    <li>first</li>\n" +
+            "    <li>second</li>\n" +
+            "  </ul>\n" +
+            "</li>" +
+            "<li>another item</li>" +
+            "</ul>" ;
+        
+        assertHtml2SeamConverting(content);
+    }
+    
     public void testUglyTextFromWord() throws Exception {
         final String str = "<p><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\"/><meta content=\"Word.Document\" name=\"ProgId\"/><meta content=\"Microsoft Word 12\" name=\"Generator\"/><meta content=\"Microsoft Word 12\" name=\"Originator\"/><link href=\"file:///E:\\TEMP~1\\msohtmlclip1\\01\\clip_filelist.xml\" rel=\"File-List\"/><link href=\"file:///E:\\TEMP~1\\msohtmlclip1\\01\\clip_themedata.thmx\" rel=\"themeData\"/><link href=\"file:///E:\\TEMP~1\\msohtmlclip1\\01\\clip_colorschememapping.xml\" rel=\"colorSchemeMapping\"/>"
                 + "<!--[if gte mso 9]><xml>\n"




More information about the richfaces-svn-commits mailing list