i'm donig the following:
- Code: Select all
private void setLockLevel(SdtElement sdtElement, STLock lockLevel) {
Boolean lockFound = Boolean.FALSE;
for (Object o: sdtElement.getSdtPr().getRPrOrAliasOrLock()) {
o = XmlUtils.unwrap(o);
if (o instanceof CTLock) {
lockFound = Boolean.TRUE;
((CTLock) o).setVal(lockLevel);
break;
}
}
if (!lockFound.booleanValue()) {
CTLock newLock = new CTLock();
newLock.setVal(lockLevel);
sdtElement.getSdtPr().getRPrOrAliasOrLock().add(newLock);
}
}
When I'm trying to save (WordprocessingMLPackage.save(File)) the docx file with the SdtElement and the new lock level (added cause no CTLock was found) ...