try to avoid class cast issues

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925500 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2025-05-11 13:26:06 +00:00
parent 39935860ed
commit 85212023d6
2 changed files with 19 additions and 4 deletions

View File

@ -578,9 +578,16 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
if(lnSpc > 0) {
// check if the percentage value is scaled
CTTextNormalAutofit normAutofit = _shape.getTxBody().getBodyPr().getNormAutofit();
if(normAutofit != null) {
double scale = 1 - (double)normAutofit.getLnSpcReduction() / 100000;
lnSpc *= scale;
if(normAutofit != null && normAutofit.isSetLnSpcReduction()) {
final Object lnSpcReduction = normAutofit.getLnSpcReduction();
final int divisor = 100000;
if (lnSpcReduction instanceof Number) {
double scale = 1 - ((Number) lnSpcReduction).doubleValue() / divisor;
lnSpc *= scale;
} else if (lnSpcReduction instanceof String) {
double scale = 1 - Double.parseDouble((String) lnSpcReduction) / divisor;
lnSpc *= scale;
}
}
}

View File

@ -130,7 +130,15 @@ public class XSSFTextRun {
double scale = 1;
double size = XSSFFont.DEFAULT_FONT_SIZE; // default font size
CTTextNormalAutofit afit = getParentParagraph().getParentShape().getTxBody().getBodyPr().getNormAutofit();
if(afit != null) scale = (double)afit.getFontScale() / 100000;
if (afit != null && afit.isSetFontScale()) {
final Object fs = afit.getFontScale();
final int divisor = 100000;
if (fs instanceof Number) {
scale = ((Number) fs).doubleValue() / divisor;
} else if (fs instanceof String) {
scale = Double.parseDouble((String) fs) / divisor;
}
}
CTTextCharacterProperties rPr = getRPrOrNull();
if(rPr != null && rPr.isSetSz()){