*
* @param keyList set the specified list of keywords.
* @see org.odftoolkit.odfdom.dom.element.meta.MetaKeywordElement.
*/
public void setKeywords(List<String> keyList) {
MetaKeywordElement keywordEle = OdfElement.findFirstChildNode(
MetaKeywordElement.class, mOfficeMetaElement);
List<MetaKeywordElement> toBeDeleted = new ArrayList<MetaKeywordElement>();
if (keywordEle != null) {
MetaKeywordElement keywordTmp;
toBeDeleted.add(keywordEle);
while ((keywordTmp = OdfElement.findNextChildNode(
MetaKeywordElement.class, keywordEle)) != null) {
keywordEle = keywordTmp;
toBeDeleted.add(keywordTmp);
}
}
// remove the original
for (MetaKeywordElement keyele : toBeDeleted) {
mOfficeMetaElement.removeChild(keyele);
}
// add new
for (int i = 0; i < keyList.size(); i++) {
MetaKeywordElement keywordElement = mOfficeMetaElement.newMetaKeywordElement();
keywordElement.setTextContent(keyList.get(i));
}
}