Package com.sun.star.lang

Examples of com.sun.star.lang.Locale


        // enter in a cellrange numbers and change the numberformat to DM
        XCell xCell = null;
        XCellRange xCellRange = null;
       
        try {
            Locale xLanguage = new Locale();
            xLanguage.Country = "de";    // Germany -> DM
            xLanguage.Language = "de";   // German
           
            // Numberformat string from DM
            String sSimple = "0 [$DM]";
View Full Code Here


public class MainTest extends TestCase {
 
  public void testDoProofreading() {
    final Main prog = new Main(null);
    final String testString = "To jest trudne zdanie. A to nastÄ™pne.  A to przedostatnie jest.\u0002 Test ostatniego.";
    final Locale plLoc = new Locale("pl", "PL", "");
    final PropertyValue[] prop = new PropertyValue[0];
    for (int i = 0; i<=testString.length(); i++) {
      final ProofreadingResult paRes = prog.doProofreading("1", testString, plLoc, i, testString.length(), prop);
      assertEquals("1", paRes.aDocumentIdentifier);
      assertTrue(paRes.nStartOfNextSentencePosition >= i);
View Full Code Here

        // Thus we may stay with an empty list in order to use the ones
        // form the property set.
        PropertyValue[] aEmptyProps = new PropertyValue[0];

        // use american english as language
        Locale aLocale = new Locale("en","US","");
   
       
       
        // another list of property values to used in function calls below.
        // Only properties with values different from the (default) values
        // in the LinguProperties property set need to be supllied.
        PropertyValue[] aProps = new PropertyValue[1];
        aProps[0] = new PropertyValue();
        aProps[0].Name  = "IsGermanPreReform";
        aProps[0].Value = new Boolean( true );
   
   
        GetSpell();   
        if (mxSpell !=  null)
        {
            // test with correct word
            String aWord = "horseback";
            boolean bIsCorrect = mxSpell.isValid( aWord, aLocale, aEmptyProps );
            System.out.println( aWord + ": " +  bIsCorrect );

            // test with incorrect word
            aWord = "course";
            bIsCorrect = mxSpell.isValid( aWord, aLocale , aEmptyProps );
            System.out.println( aWord + ": " +  bIsCorrect );   


            aWord = "house";
            XSpellAlternatives xAlt = mxSpell.spell( aWord, aLocale, aEmptyProps );
            if (xAlt == null)
                System.out.println( aWord + " is correct." );
            else
            {
                System.out.println( aWord + " is not correct. A list of proposals follows." );
                String[] aAlternatives = xAlt.getAlternatives();
                if (aAlternatives.length == 0)
                    System.out.println( "no proposal found." );
                else
                {
                    for (int i = 0; i < aAlternatives.length; ++i)
                        System.out.println( aAlternatives[i] );
                }
            }
        }


        GetHyph();   
        if (mxHyph != null)
        {
            // maximum number of characters to remain before the hyphen
            // character in the resulting word of the hyphenation
            short nMaxLeading = 6;

            XHyphenatedWord xHyphWord = mxHyph.hyphenate( "waterfall",
                                                          aLocale, nMaxLeading ,
                                                          aEmptyProps );
            if (xHyphWord == null)
                System.out.println( "no valid hyphenation position found" );
            else
            {
                System.out.println( "valid hyphenation pos found at "
                                    + xHyphWord.getHyphenationPos()
                        + " in " + xHyphWord.getWord() );
                System.out.println( "hyphenation char will be after char "
                                    + xHyphWord.getHyphenPos()
                        + " in " + xHyphWord.getHyphenatedWord() );
            }


            //! Note: 'aProps' needs to have set 'IsGermanPreReform' to true!
            xHyphWord = mxHyph.queryAlternativeSpelling( "Schiffahrt",
                                new Locale("de","DE",""), (short)4, aProps );
            if (xHyphWord == null)
                System.out.println( "no alternative spelling found at specified position." );
            else
            {
                if (xHyphWord.isAlternativeSpelling())
View Full Code Here

        //!! none of these cases should ever occur!
        //!! values provided only for safety
        if (this.aWord == null)
            this.aWord = new String();
        if (this.aLanguage == null)
            this.aLanguage = new Locale();
       
        // having no alternatives is OK though.
        // still for safety an empty existing array has to be provided.
        if (this.aAlt == null)
            this.aAlt = new String[]{};
View Full Code Here

    //XSupportedLocales
    //*****************
    public Locale[] getLocales()
        throws com.sun.star.uno.RuntimeException
    {
        Locale aLocales[] =
        {
            new Locale( "en", "US", "" )
        };

        return aLocales;
    }
View Full Code Here

   
    public boolean hasLocale( Locale aLocale )
        throws com.sun.star.uno.RuntimeException
    {
        boolean bRes = false;
        if (IsEqual( aLocale, new Locale( "en", "US", "" ) ))
            bRes = true;
        return bRes;       
    }
View Full Code Here

            String aTerm, Locale aLocale,
            PropertyValue[] aProperties )
        throws com.sun.star.lang.IllegalArgumentException,
               com.sun.star.uno.RuntimeException
    {
        if (IsEqual( aLocale, new Locale() ) || aTerm.length() == 0)
            return null;
       
        // linguistic is currently not allowed to throw exceptions
        // thus we return null fwhich means 'word cannot be looked up'
        if (!hasLocale( aLocale ))
            return null;

        // get values of relevant properties that may be used.
        //! The values for 'IsIgnoreControlCharacters' and 'IsUseDictionaryList'
        //! are handled by the dispatcher! Thus there is no need to access
        //! them here.
        boolean bIsGermanPreReform      = GetValueToUse( "IsGermanPreReform", false, aProperties );

        XMeaning[] aRes = null;

        //!! This code needs to be replaced by code calling the actual
        //!! implementation of your thesaurus
        if (aTerm.equals( "house" ) &&
            IsEqual( aLocale, new Locale( "en", "US", "" ) ) )
        {
            aRes = new XMeaning[]
                {
                    new XMeaning_impl( "a building where one lives",
                            new String[]{ "home", "place", "dwelling" } ),
View Full Code Here

        short nRes = -1;

        //!! 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", "" ) ))
        {
            if (bIsGermanPreReform && aWord.equals( "Schifffahrt" ))
                nRes = SpellFailure.SPELLING_ERROR;
            else if (!bIsGermanPreReform && aWord.equals( "Schiffahrt" ))
                nRes = SpellFailure.SPELLING_ERROR;
        }
        else if (IsEqual( aLocale, new Locale( "en", "US", "" ) ))
        {
            // words with 'u', 'U' and 'arizona' are defined to be incorrect
            boolean bIsValid = !(aWord.indexOf( "u" ) != -1 || aWord.indexOf( "U" ) != -1)
                                 && !aWord.equals( "arizona" );
View Full Code Here

        boolean bIsSpellUpperCase       = GetValueToUse( "IsSpellUpperCase", false, aProperties );
        boolean bIsSpellCapitalization  = GetValueToUse( "IsSpellCapitalization", true, aProperties );

        //!! This code needs to be replaced by code calling the actual
        //!! implementation of your spellchecker
        if (IsEqual( aLocale, new Locale( "de", "DE", "" ) ))
        {
            if (bIsGermanPreReform && aWord.equals( "Schifffahrt" ))
            {
                nType = SpellFailure.SPELLING_ERROR;
                aProposals = new String[]{ "Schiffahrt" };
            }
            else if (!bIsGermanPreReform && aWord.equals( "Schiffahrt" ))
            {
                nType = SpellFailure.SPELLING_ERROR;
                aProposals = new String[]{ "Schifffahrt" };
            }
        }
        else if (IsEqual( aLocale, new Locale( "en", "US", "" ) ))
        {
            if (aWord.equals( "arizona" ))
            {
                nType = SpellFailure.CAPTION_ERROR;
                aProposals = new String[]{ "Arizona" };
View Full Code Here

    //XSupportedLocales
    //*****************
    public Locale[] getLocales()
        throws com.sun.star.uno.RuntimeException
    {
        Locale aLocales[] =
        {
            new Locale( "de", "DE", "" ),
            new Locale( "en", "US", "" )
        };

        return aLocales;
    }
View Full Code Here

TOP

Related Classes of com.sun.star.lang.Locale

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.