internal void AddRole(PdfName structType)
{
if (structType == null) {
return;
}
foreach (PdfName name in standardTypes) {
if (name.Equals(structType))
return;
}
PdfObject obj;
if (sourceRoleMap == null) {
obj = GetDirectObject(structTreeRoot.Get(PdfName.ROLEMAP));
if (obj == null || !obj.IsDictionary()) {
return;
}
sourceRoleMap = (PdfDictionary)obj;
}
obj = sourceRoleMap.Get(structType);
if (obj == null || !obj.IsName()) {
return;
}
PdfObject currentRole;
if (roleMap == null) {
roleMap = new PdfDictionary();
structureTreeRoot.Put(PdfName.ROLEMAP, roleMap);
roleMap.Put(structType,obj);
} else if ((currentRole = roleMap.Get(structType)) != null) {
if (!currentRole.Equals(obj)) {
throw new BadPdfFormatException(MessageLocalization.GetComposedMessage("conflict.input.rolemap",obj));
}
} else {
roleMap.Put(structType,obj);
}
}