View | Details | Raw Unified | Return to bug 51622
Collapse All | Expand All

(-)src/java/org/apache/poi/ss/util/SheetUtil.java (-2 / +7 lines)
Lines 21-26 Link Here
21
import java.awt.font.TextAttribute;
21
import java.awt.font.TextAttribute;
22
import java.awt.font.TextLayout;
22
import java.awt.font.TextLayout;
23
import java.awt.geom.AffineTransform;
23
import java.awt.geom.AffineTransform;
24
import java.awt.geom.Rectangle2D;
24
import java.text.AttributedString;
25
import java.text.AttributedString;
25
import java.util.Locale;
26
import java.util.Locale;
26
import java.util.Map;
27
import java.util.Map;
Lines 165-170 Link Here
165
    private static double getCellWidth(int defaultCharWidth, int colspan,
166
    private static double getCellWidth(int defaultCharWidth, int colspan,
166
            CellStyle style, double width, AttributedString str) {
167
            CellStyle style, double width, AttributedString str) {
167
        TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
168
        TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
169
        final Rectangle2D bounds;
168
        if(style.getRotation() != 0){
170
        if(style.getRotation() != 0){
169
            /*
171
            /*
170
             * Transform the text using a scale so that it's height is increased by a multiple of the leading,
172
             * Transform the text using a scale so that it's height is increased by a multiple of the leading,
Lines 177-186 Link Here
177
            trans.concatenate(
179
            trans.concatenate(
178
            AffineTransform.getScaleInstance(1, fontHeightMultiple)
180
            AffineTransform.getScaleInstance(1, fontHeightMultiple)
179
            );
181
            );
180
            width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + style.getIndention());
182
            bounds = layout.getOutline(trans).getBounds();
181
        } else {
183
        } else {
182
            width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + style.getIndention());
184
            bounds = layout.getBounds();
183
        }
185
        }
186
        // entireWidth accounts for leading spaces which is excluded from bounds.getWidth()
187
        final double frameWidth = bounds.getX() + bounds.getWidth();
188
        width = Math.max(width, ((frameWidth / colspan) / defaultCharWidth) + style.getIndention());
184
        return width;
189
        return width;
185
    }
190
    }
186
191

Return to bug 51622