Package com.sun.star.linguistic2

Examples of com.sun.star.linguistic2.XHyphenator


        boolean res = true;

        try {
            res &= xNC.hasByName("addNewDictionary");

            XConversionDictionary myCD = new ConversionDictionary();
            xNC.insertByName("insertByName", myCD);
            res &= xNC.hasByName("insertByName");
            xNC.removeByName("insertByName");
            res &= !(xNC.hasByName("insertByName"));
        } catch (com.sun.star.lang.IllegalArgumentException e) {
View Full Code Here


    }

    private boolean checkXConversionDictionaryList(Object list) {
        boolean res = true;
        XConversionDictionaryList xCList = UnoRuntime.queryInterface(XConversionDictionaryList.class, list);
        XConversionDictionary xDict = null;

        try {
            xDict = xCList.addNewDictionary("addNewDictionary", aLocale,
                                            dictType);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            fail("Couldn't add Dictionary");
        } catch (com.sun.star.container.ElementExistException e) {
            res = false;
            fail("Couldn't add Dictionary");
        }

        try {
            xCList.addNewDictionary("addNewDictionary", aLocale, dictType);
            res = false;
            fail("wrong exception while adding Dictionary again");
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            fail("wrong exception while adding Dictionary again");
        } catch (com.sun.star.container.ElementExistException e) {
        }

        boolean localRes = checkNameContainer(xCList.getDictionaryContainer());
        res &= localRes;
        assertTrue("getDictionaryContainer didn't work as expected", localRes);

        String FileToLoad = TestDocument.getUrl("hangulhanja.sxc");
        // String FileToLoad = util.utils.getFullTestURL();

XComponent xDoc = DesktopTools.loadDoc(xMSF, FileToLoad,
                                               new PropertyValue[] {  });
        XSpreadsheet xSheet = getSheet(xDoc);
        boolean done = false;
        int counter = 0;
        int numberOfWords = 0;
        String wordToCheck = "";
        String expectedConversion = "";

        while (!done) {
            String[] HangulHanja = getLeftAndRight(counter, xSheet);
            done = (HangulHanja[0].equals(""));
            counter++;

            if (!done) {
                numberOfWords++;

                try {
                    xDict.addEntry(HangulHanja[0], HangulHanja[1]);
                    wordToCheck += HangulHanja[0];
                    expectedConversion += HangulHanja[1];
                } catch (com.sun.star.lang.IllegalArgumentException e) {
                    e.printStackTrace();
                    res = false;
                    fail("Exception while checking adding entry");
                } catch (com.sun.star.container.ElementExistException e) {
                    //ignored
                }
            }
        }

        try {
            xDict.addEntry(wordToCheck, expectedConversion);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace();
            res = false;
            fail("Exception while checking adding entry");
        } catch (com.sun.star.container.ElementExistException e) {
View Full Code Here

        boolean res = true;

        try {
            res &= xNC.hasByName("addNewDictionary");

            XConversionDictionary myCD = new ConversionDictionary();
            xNC.insertByName("insertByName", myCD);
            res &= xNC.hasByName("insertByName");
            xNC.removeByName("insertByName");
            res &= !(xNC.hasByName("insertByName"));
        } catch (com.sun.star.lang.IllegalArgumentException e) {
View Full Code Here

    private boolean checkXConversionDictionaryList(Object list) {
        boolean res = true;
        XConversionDictionaryList xCList = (XConversionDictionaryList) UnoRuntime.queryInterface(
                                                   XConversionDictionaryList.class,
                                                   list);
        XConversionDictionary xDict = null;

        try {
            xDict = xCList.addNewDictionary("addNewDictionary", aLocale,
                                            dictType);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            assure("Couldn't add Dictionary", false);
        } catch (com.sun.star.container.ElementExistException e) {
            res = false;
            assure("Couldn't add Dictionary", false);
        }

        try {
            xCList.addNewDictionary("addNewDictionary", aLocale, dictType);
            res = false;
            assure("wrong exception while adding Dictionary again", false);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            assure("wrong exception while adding Dictionary again", false);
        } catch (com.sun.star.container.ElementExistException e) {
        }

        boolean localRes = checkNameContainer(xCList.getDictionaryContainer());
        res &= localRes;
        assure("getDictionaryContainer didn't work as expected", localRes);

        String FileToLoad = util.utils.getFullTestURL("hangulhanja.sxc");
        XComponent xDoc = DesktopTools.loadDoc(xMSF, FileToLoad,
                                               new PropertyValue[] {  });
        XSpreadsheet xSheet = getSheet(xDoc);
        boolean done = false;
        int counter = 0;
        int numberOfWords = 0;
        String wordToCheck = "";
        String expectedConversion = "";

        while (!done) {
            String[] HangulHanja = getLeftAndRight(counter, xSheet);
            done = (HangulHanja[0].equals(""));
            counter++;

            if (!done) {
                numberOfWords++;

                try {
                    xDict.addEntry(HangulHanja[0], HangulHanja[1]);
                    wordToCheck += HangulHanja[0];
                    expectedConversion += HangulHanja[1];
                } catch (com.sun.star.lang.IllegalArgumentException e) {
                    e.printStackTrace();
                    res = false;
                    assure("Exception while checking adding entry", false);
                } catch (com.sun.star.container.ElementExistException e) {
                    //ignored
                }
            }
        }

        try {
            xDict.addEntry(wordToCheck, expectedConversion);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace();
            res = false;
            assure("Exception while checking adding entry", false);
        } catch (com.sun.star.container.ElementExistException e) {
View Full Code Here

        boolean res = true;

        try {
            res &= xNC.hasByName("addNewDictionary");

            XConversionDictionary myCD = new ConversionDictionary();
            xNC.insertByName("insertByName", myCD);
            res &= xNC.hasByName("insertByName");
            xNC.removeByName("insertByName");
            res &= !(xNC.hasByName("insertByName"));
        } catch (com.sun.star.lang.IllegalArgumentException e) {
View Full Code Here

        assure("XConversionDictionaryList doesnt work as expected", bList);
    }

    private boolean checkXConversionDictionaryList(Object list) {
        boolean res = true;
        XConversionDictionaryList xCList = (XConversionDictionaryList) UnoRuntime.queryInterface(
                                                   XConversionDictionaryList.class,
                                                   list);
        XConversionDictionary xDict = null;

        try {
            xDict = xCList.addNewDictionary("addNewDictionary", aLocale,
                                            dictType);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            assure("Couldn't add Dictionary", false);
        } catch (com.sun.star.container.ElementExistException e) {
            res = false;
            assure("Couldn't add Dictionary", false);
        }

        try {
            xCList.addNewDictionary("addNewDictionary", aLocale, dictType);
            res = false;
            assure("wrong exception while adding Dictionary again", false);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            assure("wrong exception while adding Dictionary again", false);
        } catch (com.sun.star.container.ElementExistException e) {
        }

        boolean localRes = checkNameContainer(xCList.getDictionaryContainer());
        res &= localRes;
        assure("getDictionaryContainer didn't work as expected", localRes);

        String FileToLoad = util.utils.getFullTestURL("hangulhanja.sxc");
        XComponent xDoc = DesktopTools.loadDoc(xMSF, FileToLoad,
                                               new PropertyValue[] {  });
        XSpreadsheet xSheet = getSheet(xDoc);
        boolean done = false;
        int counter = 0;
        int numberOfWords = 0;
        String wordToCheck = "";
        String expectedConversion = "";

        while (!done) {
            String[] HangulHanja = getLeftAndRight(counter, xSheet);
            done = (HangulHanja[0].equals(""));
            counter++;

            if (!done) {
                numberOfWords++;

                try {
                    xDict.addEntry(HangulHanja[0], HangulHanja[1]);
                    wordToCheck += HangulHanja[0];
                    expectedConversion += HangulHanja[1];
                } catch (com.sun.star.lang.IllegalArgumentException e) {
                    e.printStackTrace();
                    res = false;
                    assure("Exception while checking adding entry", false);
                } catch (com.sun.star.container.ElementExistException e) {
                    //ignored
                }
            }
        }

        try {
            xDict.addEntry(wordToCheck, expectedConversion);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace();
            res = false;
            assure("Exception while checking adding entry", false);
        } catch (com.sun.star.container.ElementExistException e) {
            //ignored
        }

        localRes = xCList.queryMaxCharCount(aLocale, dictType,
                                            ConversionDirection.FROM_LEFT) == 42;
        res &= localRes;
        assure("queryMaxCharCount returned the wrong value", localRes);

        String[] conversion = null;

        try {
            conversion = xCList.queryConversions(wordToCheck, 0,
                                                 wordToCheck.length(), aLocale,
                                                 dictType,
                                                 ConversionDirection.FROM_LEFT,
                                                 TextConversionOption.NONE);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            res = false;
            assure("Exception while calling queryConversions", false);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            assure("Exception while calling queryConversions", false);
        }

        localRes = conversion[0].equals(expectedConversion);
        res &= localRes;
        assure("queryConversions didn't work as expected", localRes);

        try {
            xCList.getDictionaryContainer().removeByName("addNewDictionary");
        } catch (com.sun.star.container.NoSuchElementException e) {
            res = false;
            assure("exception while removing Dictionary again", false);
        } catch (com.sun.star.lang.WrappedTargetException e) {
            res = false;
            assure("exception while removing Dictionary again", false);
        }

        localRes = !xCList.getDictionaryContainer()
                          .hasByName("addNewDictionary");
        res &= localRes;
        assure("Dictionary hasn't been removed properly", localRes);

        XComponent dicList = (XComponent) UnoRuntime.queryInterface(
View Full Code Here

        assertTrue("XConversionDictionaryList doesnt work as expected", bList);
    }

    private boolean checkXConversionDictionaryList(Object list) {
        boolean res = true;
        XConversionDictionaryList xCList = UnoRuntime.queryInterface(XConversionDictionaryList.class, list);
        XConversionDictionary xDict = null;

        try {
            xDict = xCList.addNewDictionary("addNewDictionary", aLocale,
                                            dictType);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            fail("Couldn't add Dictionary");
        } catch (com.sun.star.container.ElementExistException e) {
            res = false;
            fail("Couldn't add Dictionary");
        }

        try {
            xCList.addNewDictionary("addNewDictionary", aLocale, dictType);
            res = false;
            fail("wrong exception while adding Dictionary again");
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            fail("wrong exception while adding Dictionary again");
        } catch (com.sun.star.container.ElementExistException e) {
        }

        boolean localRes = checkNameContainer(xCList.getDictionaryContainer());
        res &= localRes;
        assertTrue("getDictionaryContainer didn't work as expected", localRes);

        String FileToLoad = TestDocument.getUrl("hangulhanja.sxc");
        // String FileToLoad = util.utils.getFullTestURL();

XComponent xDoc = DesktopTools.loadDoc(xMSF, FileToLoad,
                                               new PropertyValue[] {  });
        XSpreadsheet xSheet = getSheet(xDoc);
        boolean done = false;
        int counter = 0;
        int numberOfWords = 0;
        String wordToCheck = "";
        String expectedConversion = "";

        while (!done) {
            String[] HangulHanja = getLeftAndRight(counter, xSheet);
            done = (HangulHanja[0].equals(""));
            counter++;

            if (!done) {
                numberOfWords++;

                try {
                    xDict.addEntry(HangulHanja[0], HangulHanja[1]);
                    wordToCheck += HangulHanja[0];
                    expectedConversion += HangulHanja[1];
                } catch (com.sun.star.lang.IllegalArgumentException e) {
                    e.printStackTrace();
                    res = false;
                    fail("Exception while checking adding entry");
                } catch (com.sun.star.container.ElementExistException e) {
                    //ignored
                }
            }
        }

        try {
            xDict.addEntry(wordToCheck, expectedConversion);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace();
            res = false;
            fail("Exception while checking adding entry");
        } catch (com.sun.star.container.ElementExistException e) {
            //ignored
        }

        localRes = xCList.queryMaxCharCount(aLocale, dictType,
                                            ConversionDirection.FROM_LEFT) == 42;
        res &= localRes;
        assertTrue("queryMaxCharCount returned the wrong value", localRes);

        String[] conversion = null;

        try {
            conversion = xCList.queryConversions(wordToCheck, 0,
                                                 wordToCheck.length(), aLocale,
                                                 dictType,
                                                 ConversionDirection.FROM_LEFT,
                                                 TextConversionOption.NONE);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            res = false;
            fail("Exception while calling queryConversions");
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            fail("Exception while calling queryConversions");
        }

        localRes = conversion[0].equals(expectedConversion);
        res &= localRes;
        assertTrue("queryConversions didn't work as expected", localRes);

        try {
            xCList.getDictionaryContainer().removeByName("addNewDictionary");
        } catch (com.sun.star.container.NoSuchElementException e) {
            res = false;
            fail("exception while removing Dictionary again");
        } catch (com.sun.star.lang.WrappedTargetException e) {
            res = false;
            fail("exception while removing Dictionary again");
        }

        localRes = !xCList.getDictionaryContainer()
                          .hasByName("addNewDictionary");
        res &= localRes;
        assertTrue("Dictionary hasn't been removed properly", localRes);

        XComponent dicList = UnoRuntime.queryInterface(XComponent.class, xCList);
View Full Code Here

        assure("XConversionDictionaryList doesnt work as expected", bList);
    }

    private boolean checkXConversionDictionaryList(Object list) {
        boolean res = true;
        XConversionDictionaryList xCList = (XConversionDictionaryList) UnoRuntime.queryInterface(
                                                   XConversionDictionaryList.class,
                                                   list);
        XConversionDictionary xDict = null;

        try {
            xDict = xCList.addNewDictionary("addNewDictionary", aLocale,
                                            dictType);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            assure("Couldn't add Dictionary", false);
        } catch (com.sun.star.container.ElementExistException e) {
            res = false;
            assure("Couldn't add Dictionary", false);
        }

        try {
            xCList.addNewDictionary("addNewDictionary", aLocale, dictType);
            res = false;
            assure("wrong exception while adding Dictionary again", false);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            assure("wrong exception while adding Dictionary again", false);
        } catch (com.sun.star.container.ElementExistException e) {
        }

        boolean localRes = checkNameContainer(xCList.getDictionaryContainer());
        res &= localRes;
        assure("getDictionaryContainer didn't work as expected", localRes);

        String FileToLoad = util.utils.getFullTestURL("hangulhanja.sxc");
        XComponent xDoc = DesktopTools.loadDoc(xMSF, FileToLoad,
                                               new PropertyValue[] {  });
        XSpreadsheet xSheet = getSheet(xDoc);
        boolean done = false;
        int counter = 0;
        int numberOfWords = 0;
        String wordToCheck = "";
        String expectedConversion = "";

        while (!done) {
            String[] HangulHanja = getLeftAndRight(counter, xSheet);
            done = (HangulHanja[0].equals(""));
            counter++;

            if (!done) {
                numberOfWords++;

                try {
                    xDict.addEntry(HangulHanja[0], HangulHanja[1]);
                    wordToCheck += HangulHanja[0];
                    expectedConversion += HangulHanja[1];
                } catch (com.sun.star.lang.IllegalArgumentException e) {
                    e.printStackTrace();
                    res = false;
                    assure("Exception while checking adding entry", false);
                } catch (com.sun.star.container.ElementExistException e) {
                    //ignored
                }
            }
        }

        try {
            xDict.addEntry(wordToCheck, expectedConversion);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace();
            res = false;
            assure("Exception while checking adding entry", false);
        } catch (com.sun.star.container.ElementExistException e) {
            //ignored
        }

        localRes = xCList.queryMaxCharCount(aLocale, dictType,
                                            ConversionDirection.FROM_LEFT) == 42;
        res &= localRes;
        assure("queryMaxCharCount returned the wrong value", localRes);

        String[] conversion = null;

        try {
            conversion = xCList.queryConversions(wordToCheck, 0,
                                                 wordToCheck.length(), aLocale,
                                                 dictType,
                                                 ConversionDirection.FROM_LEFT,
                                                 TextConversionOption.NONE);
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            res = false;
            assure("Exception while calling queryConversions", false);
        } catch (com.sun.star.lang.NoSupportException e) {
            res = false;
            assure("Exception while calling queryConversions", false);
        }

        localRes = conversion[0].equals(expectedConversion);
        res &= localRes;
        assure("queryConversions didn't work as expected", localRes);

        try {
            xCList.getDictionaryContainer().removeByName("addNewDictionary");
        } catch (com.sun.star.container.NoSuchElementException e) {
            res = false;
            assure("exception while removing Dictionary again", false);
        } catch (com.sun.star.lang.WrappedTargetException e) {
            res = false;
            assure("exception while removing Dictionary again", false);
        }

        localRes = !xCList.getDictionaryContainer()
                          .hasByName("addNewDictionary");
        res &= localRes;
        assure("Dictionary hasn't been removed properly", localRes);

        XComponent dicList = (XComponent) UnoRuntime.queryInterface(
View Full Code Here

    * <code>listenerCallled</code> is true. <p>
    */
    public void _addDictionaryListEventListener() {
        listenerCalled = false;

        XDictionary xDic = oObj.createDictionary("ListenDic",
            new Locale("en","US","WIN"),
            com.sun.star.linguistic2.DictionaryType.POSITIVE,"");

        boolean res = oObj.addDictionaryListEventListener(listener, false);

        oObj.flushEvents();
        oObj.addDictionary(xDic);
        xDic.add("Positiv", false, "");
        xDic.setActive(true);
        oObj.flushEvents();
        oObj.removeDictionary(xDic);

        oObj.removeDictionaryListEventListener(listener);

View Full Code Here

    * <code>listenerCallled</code> is false. <p>
    */
    public void _removeDictionaryListEventListener() {
        listenerCalled = false;

        XDictionary xDic = oObj.createDictionary("ListenDic",
            new Locale("en","US","WIN"),
            com.sun.star.linguistic2.DictionaryType.POSITIVE,"");

        oObj.addDictionaryListEventListener(listener,false);

        oObj.flushEvents();
        oObj.addDictionary(xDic);
        xDic.add("Positiv", false,"");
        xDic.setActive(true);

        listenerCalled = false;
        boolean res = oObj.removeDictionaryListEventListener(listener);

        oObj.flushEvents();
View Full Code Here

TOP

Related Classes of com.sun.star.linguistic2.XHyphenator

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.