Revision: 7366
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7366&view=rev
Author:   dnaber
Date:     2012-06-16 14:30:27 +0000 (Sat, 16 Jun 2012)
Log Message:
-----------
small code cleanup

Modified Paths:
--------------
    trunk/JLanguageTool/src/java/org/languagetool/openoffice/Main.java

Modified: trunk/JLanguageTool/src/java/org/languagetool/openoffice/Main.java
===================================================================
--- trunk/JLanguageTool/src/java/org/languagetool/openoffice/Main.java  
2012-06-16 11:15:05 UTC (rev 7365)
+++ trunk/JLanguageTool/src/java/org/languagetool/openoffice/Main.java  
2012-06-16 14:30:27 UTC (rev 7366)
@@ -268,11 +268,9 @@
       final String paraText, final Locale locale, final ProofreadingResult 
paRes) {
 
     if (!StringTools.isEmpty(paraText) && hasLocale(locale)) {
-        // caching the instance of LT
         Language langForShortName;
         try {
-               langForShortName = 
Language.getLanguageForShortName(locale.Language 
-                               + "-" + locale.Variant);
+               langForShortName = 
Language.getLanguageForShortName(locale.Language + "-" + locale.Variant);
         } catch (Exception e) {
                langForShortName = 
Language.getLanguageForShortName(locale.Language);
         }
@@ -281,17 +279,7 @@
           if (docLanguage == null) {
             return paRes;
           }
-          try {
-               prepareConfig(docLanguage);                               
-            langTool = new JLanguageTool(docLanguage, 
config.getMotherTongue());
-            langTool.activateDefaultPatternRules();
-            langTool.activateDefaultFalseFriendRules();
-            langTool.disableRule(HunspellRule.RULE_ID);
-            langTool.disableRule(MorfologikSpellerRule.RULE_ID);
-            recheck = false;
-          } catch (final Throwable t) {
-            showError(t);
-          }
+          initLanguageTool();
         }
 
         if (config.getDisabledRuleIds() != null) {
@@ -364,6 +352,20 @@
     return paRes;
   }
 
+  private void initLanguageTool() {
+    try {
+      prepareConfig(docLanguage);
+      langTool = new JLanguageTool(docLanguage, config.getMotherTongue());
+      langTool.activateDefaultPatternRules();
+      langTool.activateDefaultFalseFriendRules();
+      langTool.disableRule(HunspellRule.RULE_ID);
+      langTool.disableRule(MorfologikSpellerRule.RULE_ID);
+      recheck = false;
+    } catch (final Throwable t) {
+      showError(t);
+    }
+  }
+
   private synchronized String getSentence(final String paraText,
       final int startPos) {
     if (paraText.equals(currentPara) && tokenizedSentences != null) {
@@ -791,28 +793,25 @@
   @Override
   public int compare(final SingleProofreadingError match1,
       final SingleProofreadingError match2) {
-    if (match1.aSuggestions.length == 0 
-        && match2.aSuggestions.length > 0) {
+    if (match1.aSuggestions.length == 0 && match2.aSuggestions.length > 0) {
       return 1;
     }
-    if (match2.aSuggestions.length == 0 
-        && match1.aSuggestions.length > 0) {
+    if (match2.aSuggestions.length == 0 && match1.aSuggestions.length > 0) {
       return -1;
     }    
     final int error1pos = match1.nErrorStart;
     final int error2pos = match2.nErrorStart;
-    if (error1pos > error2pos)
+    if (error1pos > error2pos) {
       return 1;
-    else if (error1pos < error2pos)
+    } else if (error1pos < error2pos) {
       return -1;
-    else
+    } else {
       if (match1.aSuggestions.length != 0
           && match2.aSuggestions.length != 0
-          && match1.aSuggestions.length 
-          != match2.aSuggestions.length) {
-      return ((Integer) (match1.aSuggestions.length))
-          .compareTo(match2.aSuggestions.length);
+          && match1.aSuggestions.length != match2.aSuggestions.length) {
+        return ((Integer) 
(match1.aSuggestions.length)).compareTo(match2.aSuggestions.length);
       }
+    }
     return match1.aRuleIdentifier.compareTo(match2.aRuleIdentifier);
   }
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to