Improved PDF export (every article is a chapter, outline, FileDialog)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / actions / mediawiki / post / PostJob.java
index 7726ecc..e32b44a 100644 (file)
@@ -15,6 +15,7 @@ import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.UnexpectedAn
 import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
 import net.sourceforge.phpeclipse.wiki.internal.Configuration;
 import net.sourceforge.phpeclipse.wiki.preferences.Util;
+import net.sourceforge.phpeclipse.wiki.renderer.StringUtil;
 import net.sourceforge.phpeclipse.wiki.velocity.EditorText;
 import net.sourceforge.phpeclipse.wiki.xml.Page;
 import net.sourceforge.phpeclipse.wiki.xml.XStreamManager;
@@ -133,7 +134,7 @@ public class PostJob extends WorkspaceJob {
             wikiURLTitle = Util.getURLWikiName(file);
             String body = StoreWikipediaAction.getInputStreamAsString(is, wikipedia.getCharSet());
             char ch;
-            boolean noContent = checkNoContent(body);
+            boolean noContent = StringUtil.checkNoContent(body);
             String srcBasePath = Util.getWikiTextsPath(file);
             String binBasePath = Util.getProjectsWikiOutputPath(file.getProject(), WikiEditorPlugin.HTML_OUTPUT_PATH);
 
@@ -235,43 +236,6 @@ public class PostJob extends WorkspaceJob {
     return Status.CANCEL_STATUS;
   }
 
-  /**
-   * @param body
-   * @param j
-   * @return
-   */
-  private boolean checkNoContent(String body) {
-    char ch;
-    boolean noContent = true;
-    int j = 0;
-    try {
-      while (true) {
-        ch = body.charAt(j++);
-        if (!Character.isWhitespace(ch)) {
-          if (ch == '<' && body.charAt(j) == '!' && body.charAt(j + 1) == '-' && body.charAt(j + 2) == '-') {
-            //<!-- ... -->
-            j += 3;
-            while (true) {
-              ch = body.charAt(j++);
-              if (ch == '-' && body.charAt(j) == '-' && body.charAt(j + 1) == '>') {
-                j += 2;
-                break;
-              }
-            }
-          } else if (ch == '<' && body.charAt(j) == 'b' && body.charAt(j + 1) == 'r' && body.charAt(j + 2) == '>') {
-            // <br>
-          } else {
-            noContent = false;
-            break;
-          }
-        }
-      }
-    } catch (IndexOutOfBoundsException e) {
-
-    }
-    return noContent;
-  }
-
   public boolean isModal(Job job) {
     Boolean isModal = (Boolean) job.getProperty(IProgressConstants.PROPERTY_IN_DIALOG);
     if (isModal == null) {