summaryrefslogtreecommitdiff
path: root/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-08-23 15:19:40 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-08-23 15:19:40 +0200
commit566a5bcb2039dbe6db6b9696449c6f5fe142c763 (patch)
tree2012c7ad41c5058904ba05848e17d1e248f7559d /odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
parentcbb79e541cd2aa1f56cf7fbefcf8d0ce9c8db664 (diff)
recreated tag libreoffice-3.3.0.4 which had these commits:
commit f4a669793477ff9765085fff8ced14cbe8d7f159 (tag: refs/tags/libreoffice-3.3.0.4, refs/remotes/origin/libreoffice-3-3-0) Author: Petr Mladek <pmladek@suse.cz> Date: Tue Jan 18 19:01:21 2011 +0100 Version 3.3.0.4, tag libreoffice-3.3.0.4 (3.3-rc4) commit c6241c81b61717941cf0a3e4a4188468ceddef07 Author: Petr Mladek <pmladek@suse.cz> Date: Tue Jan 11 22:59:38 2011 +0100 Branch libreoffice-3-3-0 This is 'libreoffice-3-3-0' - the stable branch for the 3.3.0 release. Only very safe changes, reviewed by three people are allowed. If you want to commit more complicated fix for the next 3.3.x release, please use the 'libreoffice-3-3' branch. If you want to build something cool, unstable, and risky, use master.
Notes
Notes: split repo tag: sdk_libreoffice-3.3.0.4
Diffstat (limited to 'odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java')
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java102
1 files changed, 51 insertions, 51 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
index 9e2cd5a81853..f63bc81af147 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
@@ -2,7 +2,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
// uno
@@ -43,10 +43,10 @@ import com.sun.star.lang.XSingleServiceFactory;
// supported Interfaces
import com.sun.star.linguistic2.XSpellChecker;
import com.sun.star.linguistic2.XLinguServiceEventBroadcaster;
-import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XInitialization;
import com.sun.star.lang.XComponent;
-import com.sun.star.lang.XServiceInfo;
-import com.sun.star.lang.XServiceDisplayName;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XServiceDisplayName;
// Exceptions
import com.sun.star.uno.Exception;
@@ -101,10 +101,10 @@ public class SampleSpellChecker extends ComponentBase implements
{
return aLoc1.Language.equals( aLoc2.Language ) &&
aLoc1.Country .equals( aLoc2.Country ) &&
- aLoc1.Variant .equals( aLoc2.Variant );
+ aLoc1.Variant .equals( aLoc2.Variant );
}
- private boolean GetValueToUse(
+ private boolean GetValueToUse(
String aPropName,
boolean bDefaultVal,
PropertyValue[] aProps )
@@ -139,13 +139,13 @@ public class SampleSpellChecker extends ComponentBase implements
catch (Exception e) {
bRes = bDefaultVal;
}
-
+
return bRes;
}
private boolean IsUpper( String aWord, Locale aLocale )
{
- java.util.Locale aLang = new java.util.Locale(
+ java.util.Locale aLang = new java.util.Locale(
aLocale.Language, aLocale.Country, aLocale.Variant );
return aWord.equals( aWord.toUpperCase( aLang ) );
}
@@ -161,14 +161,14 @@ public class SampleSpellChecker extends ComponentBase implements
return false;
}
- private short GetSpellFailure(
- String aWord,
+ private short GetSpellFailure(
+ String aWord,
Locale aLocale,
- PropertyValue[] aProperties )
+ PropertyValue[] aProperties )
{
short nRes = -1;
- //!! This code needs to be replaced by code calling the actual
+ //!! This code needs to be replaced by code calling the actual
//!! implementation of your spellchecker
boolean bIsGermanPreReform = GetValueToUse( "IsGermanPreReform", false, aProperties );
if (IsEqual( aLocale, new Locale( "de", "DE", "" ) ))
@@ -188,23 +188,23 @@ public class SampleSpellChecker extends ComponentBase implements
{
// default value (no other SpellFailure type is applicable)
nRes = SpellFailure.SPELLING_ERROR;
-
+
if (aWord.equals( "arizona" ))
nRes = SpellFailure.CAPTION_ERROR;
else if (aWord.equals( "house" ))
nRes = SpellFailure.SPELLING_ERROR;
else if (aWord.equals( "course" ))
nRes = SpellFailure.IS_NEGATIVE_WORD;
- }
+ }
}
-
+
return nRes;
}
- private XSpellAlternatives GetProposals(
- String aWord,
- Locale aLocale,
- PropertyValue[] aProperties )
+ private XSpellAlternatives GetProposals(
+ String aWord,
+ Locale aLocale,
+ PropertyValue[] aProperties )
{
short nType = SpellFailure.SPELLING_ERROR;
String[] aProposals = null;
@@ -218,7 +218,7 @@ public class SampleSpellChecker extends ComponentBase implements
boolean bIsSpellUpperCase = GetValueToUse( "IsSpellUpperCase", false, aProperties );
boolean bIsSpellCapitalization = GetValueToUse( "IsSpellCapitalization", true, aProperties );
- //!! This code needs to be replaced by code calling the actual
+ //!! This code needs to be replaced by code calling the actual
//!! implementation of your spellchecker
if (IsEqual( aLocale, new Locale( "de", "DE", "" ) ))
{
@@ -257,17 +257,17 @@ public class SampleSpellChecker extends ComponentBase implements
return new XSpellAlternatives_impl( aWord, aLocale,
nType, aProposals );
}
-
+
// __________ interface methods __________
-
-
+
+
//*****************
//XSupportedLocales
//*****************
public Locale[] getLocales()
throws com.sun.star.uno.RuntimeException
{
- Locale aLocales[] =
+ Locale aLocales[] =
{
new Locale( "de", "DE", "" ),
new Locale( "en", "US", "" )
@@ -275,30 +275,30 @@ public class SampleSpellChecker extends ComponentBase implements
return aLocales;
}
-
- public boolean hasLocale( Locale aLocale )
+
+ public boolean hasLocale( Locale aLocale )
throws com.sun.star.uno.RuntimeException
{
boolean bRes = false;
if ( IsEqual( aLocale, new Locale( "de", "DE", "" ) ) ||
IsEqual( aLocale, new Locale( "en", "US", "" ) ))
bRes = true;
- return bRes;
+ return bRes;
}
-
+
//*************
//XSpellChecker
//*************
public boolean isValid(
String aWord, Locale aLocale,
- PropertyValue[] aProperties )
+ PropertyValue[] aProperties )
throws com.sun.star.uno.RuntimeException,
IllegalArgumentException
{
if (IsEqual( aLocale, new Locale() ) || aWord.length() == 0)
return true;
-
+
// linguistic is currently not allowed to throw exceptions
// thus we return null which means 'word cannot be spelled'
if (!hasLocale( aLocale ))
@@ -312,7 +312,7 @@ public class SampleSpellChecker extends ComponentBase implements
boolean bIsSpellWithDigits = GetValueToUse( "IsSpellWithDigits", false, aProperties );
boolean bIsSpellUpperCase = GetValueToUse( "IsSpellUpperCase", false, aProperties );
boolean bIsSpellCapitalization = GetValueToUse( "IsSpellCapitalization", true, aProperties );
-
+
short nFailure = GetSpellFailure( aWord, aLocale, aProperties );
if (nFailure != -1)
{
@@ -327,22 +327,22 @@ public class SampleSpellChecker extends ComponentBase implements
return nFailure == -1;
}
-
-
+
+
public XSpellAlternatives spell(
String aWord, Locale aLocale,
- PropertyValue[] aProperties )
+ PropertyValue[] aProperties )
throws com.sun.star.uno.RuntimeException,
IllegalArgumentException
{
if (IsEqual( aLocale, new Locale() ) || aWord.length() == 0)
return null;
-
+
// linguistic is currently not allowed to throw exceptions
// thus we return null fwhich means 'word cannot be spelled'
if (!hasLocale( aLocale ))
return null;
-
+
XSpellAlternatives xRes = null;
if (!isValid( aWord, aLocale, aProperties ))
{
@@ -350,8 +350,8 @@ public class SampleSpellChecker extends ComponentBase implements
}
return xRes;
}
-
-
+
+
//*****************************
//XLinguServiceEventBroadcaster
//*****************************
@@ -359,35 +359,35 @@ public class SampleSpellChecker extends ComponentBase implements
XLinguServiceEventListener xLstnr )
throws com.sun.star.uno.RuntimeException
{
- boolean bRes = false;
+ boolean bRes = false;
if (!bDisposing && xLstnr != null)
bRes = aPropChgHelper.addLinguServiceEventListener( xLstnr );
return bRes;
}
-
+
public boolean removeLinguServiceEventListener(
- XLinguServiceEventListener xLstnr )
+ XLinguServiceEventListener xLstnr )
throws com.sun.star.uno.RuntimeException
{
- boolean bRes = false;
+ boolean bRes = false;
if (!bDisposing && xLstnr != null)
bRes = aPropChgHelper.removeLinguServiceEventListener( xLstnr );
return bRes;
- }
+ }
//********************
// XServiceDisplayName
//********************
- public String getServiceDisplayName( Locale aLocale )
+ public String getServiceDisplayName( Locale aLocale )
throws com.sun.star.uno.RuntimeException
{
- return "Java Samples";
+ return "Java Samples";
}
//****************
// XInitialization
//****************
- public void initialize( Object[] aArguments )
+ public void initialize( Object[] aArguments )
throws com.sun.star.uno.Exception,
com.sun.star.uno.RuntimeException
{
@@ -422,17 +422,17 @@ public class SampleSpellChecker extends ComponentBase implements
{
return _aSvcImplName;
}
-
+
public String[] getSupportedServiceNames()
throws com.sun.star.uno.RuntimeException
{
return getSupportedServiceNames_Static();
}
-
+
// __________ static things __________
public static String _aSvcImplName = "com.sun.star.linguistic2.JavaSamples.SampleSpellChecker";
-
+
public static String[] getSupportedServiceNames_Static()
{
String[] aResult = { "com.sun.star.linguistic2.SpellChecker" };
@@ -474,7 +474,7 @@ public class SampleSpellChecker extends ComponentBase implements
* @param xRegKey the registryKey
* @see com.sun.star.comp.loader.JavaLoader
*/
- public static boolean __writeRegistryServiceInfo(
+ public static boolean __writeRegistryServiceInfo(
com.sun.star.registry.XRegistryKey xRegKey )
{
boolean bResult = true;