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(
XComponent.class, xCList);
XEventListener listen = new EventListener();
dicList.addEventListener(listen);
dicList.dispose();
assure("dispose didn't work", disposed);
dicList.removeEventListener(listen);
DesktopTools.closeDoc(xDoc);
return res;
}