-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Static analysis (yes, I'm actually working on that ticket too) showed that the method JsonOperationConsumer.getDefaultOutlineLevelFromStyleHierarchy() does either not work or is overly complex. Look at the comments I added in the following snippet:
private static int getDefaultOutlineLevelFromStyleHierarchy(
TextParagraphElementBase paragraphBaseElement) {
OdfStyle style = paragraphBaseElement.getDocumentStyle();
int outlineLevel = getStyleOutlineLevel(style);
if (style != null) {
// if no outline Level was set, but there is a parentComponentElement
if (outlineLevel == NO_OUTLINE_LEVEL) { // <-- the if is only entered when outlineLevel == NO_OUTLINE_LEVEL
OdfStyleBase parentStyle = null;
style.getParentStyle();
while (outlineLevel == NO_OUTLINE_LEVEL) { // <-- this condition is always true because outlineLevel is never updated
outlineLevel = getStyleOutlineLevel(parentStyle); // <-- this will return the old value because parentStyle is null
if (outlineLevel != NO_OUTLINE_LEVEL) {
break;
}
if (parentStyle instanceof OdfStyle) { // <-- here, parentStyle is still null, so instanceOf will return false and parentStyle is not updated
parentStyle = ((OdfStyle) parentStyle).getParentStyle();
} else {
break; // <-- this break will always be reached in the first iteration
}
if (parentStyle == null) {
break;
}
}
}
}
return outlineLevel;
}Metadata
Metadata
Assignees
Labels
No labels