Skip to content

Commit

Permalink
Merge pull request #90 from airslate-oss/ASP-29780-remove-run-get-sid…
Browse files Browse the repository at this point in the history
…e-efect

[ASP-29780] removed run get...() side efects
  • Loading branch information
alekseytatarynov authored Mar 27, 2023
2 parents aae72f7 + c8f6da5 commit 047b9b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ subprojects {
apply plugin: 'de.thetaphi.forbiddenapis'
apply plugin: 'com.github.spotbugs'

version = '5.2.3-AIRSLATE-26.5'
version = '5.2.3-AIRSLATE-26.8'
ext {
bouncyCastleVersion = '1.70'
commonsCodecVersion = '1.15'
Expand Down
27 changes: 19 additions & 8 deletions poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,16 @@ public void setUnderline(UnderlinePatterns value) {
* @return The underline, or null create is false and there is no underline.
*/
private CTUnderline getCTUnderline(boolean create) {
CTRPr pr = getRunProperties(true);
return pr.sizeOfUArray() > 0 ? pr.getUArray(0) : (create ? pr.addNewU() : null);
CTRPr pr = getRunProperties(create);
if (pr != null) {
if (pr.sizeOfUArray() > 0) {
return pr.getUArray(0);
}
if (create) {
return pr.addNewU();
}
}
return null;
}

/**
Expand Down Expand Up @@ -580,9 +588,11 @@ public STThemeColor.Enum getUnderlineThemeColor() {
* @since 4.0.0
*/
public String getUnderlineColor() {
CTUnderline underline = getCTUnderline(true);
assert(underline != null);
CTUnderline underline = getCTUnderline(false);
String colorName = "auto";
if (underline == null) {
return colorName;
}
Object rawValue = underline.getColor();
if (rawValue != null) {
if (rawValue instanceof String) {
Expand Down Expand Up @@ -1671,11 +1681,12 @@ public STEm.Enum getEmphasisMark() {
if (pr == null) {
return STEm.NONE;
}
CTEm emphasis = pr.sizeOfEmArray() > 0 ? pr.getEmArray(0) : pr.addNewEm();

STEm.Enum val = emphasis.getVal();
if (pr.sizeOfEmArray() == 0) {
return STEm.NONE;
}
STEm.Enum val = pr.getEmArray(0).getVal();
if (val == null) {
val = STEm.NONE;
return STEm.NONE;
}
return val;
}
Expand Down

0 comments on commit 047b9b2

Please sign in to comment.