public int getRunType() {
getEscherTextboxWrapper();
if (_txtbox == null) return -1;
- TextHeaderAtom headerAtom = (TextHeaderAtom)_txtbox.findFirstOfType(TextHeaderAtom.typeID);
- assert(headerAtom != null);
- return headerAtom.getTextType();
+ List<HSLFTextParagraph> paras = HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet());
+ return (paras.isEmpty()) ? -1 : paras.get(0).getRunType();
}
/**
public void setRunType(int type) {
getEscherTextboxWrapper();
if (_txtbox == null) return;
- TextHeaderAtom headerAtom = (TextHeaderAtom)_txtbox.findFirstOfType(TextHeaderAtom.typeID);
- assert(headerAtom != null);
- headerAtom.setTextType(type);
+ List<HSLFTextParagraph> paras = HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet());
+ if (!paras.isEmpty()) {
+ paras.get(0).setRunType(type);
+ }
}
/**
*/
public String getText() {
String rawText = getRawText();
- TextHeaderAtom _headerAtom = (TextHeaderAtom)_txtbox.findFirstOfType(TextHeaderAtom.typeID);
- int runType = (_headerAtom == null) ? -1 : _headerAtom.getTextType();
-
- return HSLFTextParagraph.toExternalString(rawText, runType);
+ return HSLFTextParagraph.toExternalString(rawText, getRunType());
}
import java.awt.geom.AffineTransform;\r
import java.awt.geom.Rectangle2D;\r
\r
+import org.apache.poi.hslf.usermodel.HSLFShape;\r
import org.apache.poi.sl.usermodel.PlaceableShape;\r
import org.apache.poi.sl.usermodel.Shape;\r
\r
\r
PlaceableShape ps = (PlaceableShape)shape;\r
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);\r
- final Rectangle2D anchor = (tx != null)\r
- ? tx.createTransformedShape(ps.getAnchor()).getBounds2D()\r
- : ps.getAnchor();\r
+ if (tx == null) tx = new AffineTransform();\r
+ final Rectangle2D anchor = tx.createTransformedShape(ps.getAnchor()).getBounds2D();\r
\r
// rotation\r
double rotation = ps.getRotation();\r
// normalize rotation\r
rotation %= 360.;\r
if (rotation < 0) rotation += 360.;\r
+\r
int quadrant = (((int)rotation+45)/90)%4;\r
double scaleX = 1.0, scaleY = 1.0;\r
-\r
+ \r
// scale to bounding box (bug #53176)\r
if (quadrant == 1 || quadrant == 3) {\r
// In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation \r
// be already (differently) scaled, so you can paint the shape in its default orientation\r
// and later on, turn it around again to compare it with its original size ...\r
\r
- // graphics coordinate space\r
- AffineTransform txg = new AffineTransform();\r
- txg.translate(centerX, centerY);\r
- txg.rotate(Math.toRadians(90));\r
- txg.translate(-centerX, -centerY);\r
-\r
- boolean oldVariant = true;\r
- Rectangle2D anchor2;\r
- \r
- if (oldVariant) {\r
- // shape coordinate space\r
- AffineTransform txs = new AffineTransform(tx);\r
+ AffineTransform txs;\r
+ if (ps instanceof HSLFShape) {\r
+ txs = new AffineTransform(tx);\r
+ } else {\r
+ // this handling is only based on try and error ... not sure why xslf is handled differently.\r
+ txs = new AffineTransform();\r
txs.translate(centerX, centerY);\r
- txs.rotate(Math.toRadians(90));\r
+ txs.rotate(Math.PI/2.); // actually doesn't matter if +/- 90 degrees\r
txs.translate(-centerX, -centerY);\r
- txg.concatenate(txs);\r
- anchor2 = txg.createTransformedShape(ps.getAnchor()).getBounds2D();\r
- } else {\r
- anchor2 = txg.createTransformedShape(anchor).getBounds2D();\r
+ txs.concatenate(tx);\r
}\r
-\r
+ \r
+ txs.translate(centerX, centerY);\r
+ txs.rotate(Math.PI/2.);\r
+ txs.translate(-centerX, -centerY);\r
+ \r
+ Rectangle2D anchor2 = txs.createTransformedShape(ps.getAnchor()).getBounds2D();\r
+ \r
scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() / anchor2.getWidth();\r
scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() / anchor2.getHeight();\r
- \r
- graphics.translate(centerX, centerY);\r
- graphics.rotate(Math.toRadians(rotation-quadrant*90.));\r
- graphics.scale(scaleX, scaleY);\r
- graphics.rotate(Math.toRadians(quadrant*90));\r
- graphics.translate(-centerX, -centerY);\r
} else {\r
- graphics.translate(centerX, centerY);\r
- graphics.rotate(Math.toRadians(rotation));\r
- graphics.scale(scaleX, scaleY);\r
- graphics.translate(-centerX, -centerY);\r
+ quadrant = 0;\r
}\r
+ \r
// transformation is applied reversed ...\r
+ graphics.translate(centerX, centerY);\r
+ graphics.rotate(Math.toRadians(rotation-quadrant*90.));\r
+ graphics.scale(scaleX, scaleY);\r
+ graphics.rotate(Math.toRadians(quadrant*90));\r
+ graphics.translate(-centerX, -centerY);\r
}\r
\r
//flip horizontal\r
package org.apache.poi.sl.draw;\r
\r
+import java.awt.Dimension;\r
+import java.awt.Color;\r
import java.awt.Graphics2D;\r
+\r
import java.awt.geom.AffineTransform;\r
\r
import org.apache.poi.sl.usermodel.*;\r
}\r
\r
public void draw(Graphics2D graphics) {\r
+ Dimension dim = sheet.getSlideShow().getPageSize();\r
+ Color whiteTrans = new Color(1f,1f,1f,0f);\r
+ graphics.setColor(whiteTrans);\r
+ graphics.fillRect(0, 0, (int)dim.getWidth(), (int)dim.getHeight());\r
+ \r
DrawFactory drawFact = DrawFactory.getInstance(graphics);\r
MasterSheet<? extends Shape, ? extends SlideShow> master = sheet.getMasterSheet();\r
\r