]> source.dussan.org Git - poi.git/commitdiff
only calculate getTextHeight if it will be used
authorJaven O'Neal <onealj@apache.org>
Sun, 17 Jul 2016 20:33:32 +0000 (20:33 +0000)
committerJaven O'Neal <onealj@apache.org>
Sun, 17 Jul 2016 20:33:32 +0000 (20:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753115 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/sl/draw/DrawTextShape.java

index f6e3891e5f9cbb63c4a7774b7fa4fb3f615997c5..3a1d8faeeaa0d4e2883f4eaa90f09693dba50ba3 100644 (file)
@@ -85,9 +85,9 @@ public class DrawTextShape extends DrawSimpleShape {
             graphics.rotate(Math.toRadians(textRot));\r
             graphics.translate(-cx, -cy);\r
         }\r
-\r
+        \r
         // first dry-run to calculate the total height of the text\r
-        double textHeight = getTextHeight(graphics);\r
+        double textHeight;\r
 \r
         switch (s.getVerticalAlignment()){\r
             default:\r
@@ -95,9 +95,11 @@ public class DrawTextShape extends DrawSimpleShape {
                 y += insets.top;\r
                 break;\r
             case BOTTOM:\r
+                textHeight = getTextHeight(graphics);\r
                 y += anchor.getHeight() - textHeight - insets.bottom;\r
                 break;\r
             case MIDDLE:\r
+                textHeight = getTextHeight(graphics);\r
                 double delta = anchor.getHeight() - textHeight - insets.top - insets.bottom;\r
                 y += insets.top + delta/2;\r
                 break;\r