You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/06/14 01:26:47 UTC
svn commit: r1685344 - in /poi/branches/common_sl/src:
ooxml/java/org/apache/poi/xslf/usermodel/
scratchpad/src/org/apache/poi/hslf/usermodel/
scratchpad/src/org/apache/poi/sl/draw/
scratchpad/src/org/apache/poi/sl/usermodel/
Author: kiwiwings
Date: Sat Jun 13 23:26:46 2015
New Revision: 1685344
URL: http://svn.apache.org/r1685344
Log:
Rendering of rotated group shapes fixed, other smaller fixes, defaulting to white transparent slide background
Modified:
poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawBackground.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PlaceableShape.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeType.java
poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Sat Jun 13 23:26:46 2015
@@ -248,4 +248,10 @@ public final class XSLFSlide extends XSL
// TODO Auto-generated method stub
}
+
+ @Override
+ public int getSlideNumber() {
+ int idx = getSlideShow().getSlides().indexOf(this);
+ return (idx == -1) ? idx : idx+1;
+ }
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java Sat Jun 13 23:26:46 2015
@@ -116,8 +116,8 @@ public final class HSLFShapeFactory {
break;
}
case LINE:
- shape = new Line(spContainer, parent);
- break;
+// shape = new Line(spContainer, parent);
+// break;
case NOT_PRIMITIVE: {
EscherOptRecord opt = HSLFShape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
EscherProperty prop = HSLFShape.getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java Sat Jun 13 23:26:46 2015
@@ -219,6 +219,7 @@ public final class HSLFSlide extends HSL
/**
* Returns the (public facing) page number of this slide
*/
+ @Override
public int getSlideNumber() { return _slideNo; }
/**
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java Sat Jun 13 23:26:46 2015
@@ -174,6 +174,11 @@ public final class HSLFTextParagraph imp
return (_headerAtom != null) ? _headerAtom.getTextType() : -1;
}
+ public void setRunType(int runType) {
+ if (_headerAtom != null) _headerAtom.setTextType(runType);
+ }
+
+
/**
* Is this Text Run one from a {@link PPDrawing}, or is it
* one from the {@link SlideListWithText}?
@@ -1151,6 +1156,7 @@ public final class HSLFTextParagraph imp
HSLFTextRun nextRun = new HSLFTextRun(para);
nextRun.setText("");
runs.add(nextRun);
+ ccRun++;
} else {
// need to add +1 to the last run of the last paragraph
len++;
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java Sat Jun 13 23:26:46 2015
@@ -214,9 +214,8 @@ public abstract class HSLFTextShape exte
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();
}
/**
@@ -228,9 +227,10 @@ public abstract class HSLFTextShape exte
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);
+ }
}
/**
@@ -711,10 +711,7 @@ public abstract class HSLFTextShape exte
*/
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());
}
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawBackground.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawBackground.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawBackground.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawBackground.java Sat Jun 13 23:26:46 2015
@@ -4,6 +4,7 @@ import java.awt.*;
import java.awt.geom.Rectangle2D;
import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.Shape;
public class DrawBackground<T extends Background> extends DrawShape<T> {
@@ -16,6 +17,7 @@ public class DrawBackground<T extends Ba
final Rectangle2D anchor = new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight());
PlaceableShape ps = new PlaceableShape(){
+ public ShapeContainer<? extends Shape> getParent() { return null; }
public Rectangle2D getAnchor() { return anchor; }
public void setAnchor(Rectangle2D anchor) {}
public double getRotation() { return 0; }
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawShape.java Sat Jun 13 23:26:46 2015
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
+import org.apache.poi.hslf.usermodel.HSLFShape;
import org.apache.poi.sl.usermodel.PlaceableShape;
import org.apache.poi.sl.usermodel.Shape;
@@ -26,9 +27,8 @@ public class DrawShape<T extends Shape>
PlaceableShape ps = (PlaceableShape)shape;
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
- final Rectangle2D anchor = (tx != null)
- ? tx.createTransformedShape(ps.getAnchor()).getBounds2D()
- : ps.getAnchor();
+ if (tx == null) tx = new AffineTransform();
+ final Rectangle2D anchor = tx.createTransformedShape(ps.getAnchor()).getBounds2D();
// rotation
double rotation = ps.getRotation();
@@ -40,9 +40,10 @@ public class DrawShape<T extends Shape>
// normalize rotation
rotation %= 360.;
if (rotation < 0) rotation += 360.;
+
int quadrant = (((int)rotation+45)/90)%4;
double scaleX = 1.0, scaleY = 1.0;
-
+
// scale to bounding box (bug #53176)
if (quadrant == 1 || quadrant == 3) {
// In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation
@@ -54,42 +55,36 @@ public class DrawShape<T extends Shape>
// be already (differently) scaled, so you can paint the shape in its default orientation
// and later on, turn it around again to compare it with its original size ...
- // graphics coordinate space
- AffineTransform txg = new AffineTransform();
- txg.translate(centerX, centerY);
- txg.rotate(Math.toRadians(90));
- txg.translate(-centerX, -centerY);
-
- boolean oldVariant = true;
- Rectangle2D anchor2;
-
- if (oldVariant) {
- // shape coordinate space
- AffineTransform txs = new AffineTransform(tx);
+ AffineTransform txs;
+ if (ps instanceof HSLFShape) {
+ txs = new AffineTransform(tx);
+ } else {
+ // this handling is only based on try and error ... not sure why xslf is handled differently.
+ txs = new AffineTransform();
txs.translate(centerX, centerY);
- txs.rotate(Math.toRadians(90));
+ txs.rotate(Math.PI/2.); // actually doesn't matter if +/- 90 degrees
txs.translate(-centerX, -centerY);
- txg.concatenate(txs);
- anchor2 = txg.createTransformedShape(ps.getAnchor()).getBounds2D();
- } else {
- anchor2 = txg.createTransformedShape(anchor).getBounds2D();
+ txs.concatenate(tx);
}
-
+
+ txs.translate(centerX, centerY);
+ txs.rotate(Math.PI/2.);
+ txs.translate(-centerX, -centerY);
+
+ Rectangle2D anchor2 = txs.createTransformedShape(ps.getAnchor()).getBounds2D();
+
scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() / anchor2.getWidth();
scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() / anchor2.getHeight();
-
- graphics.translate(centerX, centerY);
- graphics.rotate(Math.toRadians(rotation-quadrant*90.));
- graphics.scale(scaleX, scaleY);
- graphics.rotate(Math.toRadians(quadrant*90));
- graphics.translate(-centerX, -centerY);
} else {
- graphics.translate(centerX, centerY);
- graphics.rotate(Math.toRadians(rotation));
- graphics.scale(scaleX, scaleY);
- graphics.translate(-centerX, -centerY);
+ quadrant = 0;
}
+
// transformation is applied reversed ...
+ graphics.translate(centerX, centerY);
+ graphics.rotate(Math.toRadians(rotation-quadrant*90.));
+ graphics.scale(scaleX, scaleY);
+ graphics.rotate(Math.toRadians(quadrant*90));
+ graphics.translate(-centerX, -centerY);
}
//flip horizontal
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSheet.java Sat Jun 13 23:26:46 2015
@@ -1,6 +1,9 @@
package org.apache.poi.sl.draw;
+import java.awt.Dimension;
+import java.awt.Color;
import java.awt.Graphics2D;
+
import java.awt.geom.AffineTransform;
import org.apache.poi.sl.usermodel.*;
@@ -15,6 +18,11 @@ public class DrawSheet<T extends Sheet<?
}
public void draw(Graphics2D graphics) {
+ Dimension dim = sheet.getSlideShow().getPageSize();
+ Color whiteTrans = new Color(1f,1f,1f,0f);
+ graphics.setColor(whiteTrans);
+ graphics.fillRect(0, 0, (int)dim.getWidth(), (int)dim.getHeight());
+
DrawFactory drawFact = DrawFactory.getInstance(graphics);
MasterSheet<? extends Shape, ? extends SlideShow> master = sheet.getMasterSheet();
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PlaceableShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PlaceableShape.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PlaceableShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/PlaceableShape.java Sat Jun 13 23:26:46 2015
@@ -20,6 +20,8 @@ package org.apache.poi.sl.usermodel;
import java.awt.geom.Rectangle2D;
public interface PlaceableShape {
+ ShapeContainer<? extends Shape> getParent();
+
/**
* @return the position of this shape within the drawing canvas.
* The coordinates are expressed in points
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeType.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeType.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeType.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/ShapeType.java Sat Jun 13 23:26:46 2015
@@ -288,7 +288,9 @@ public enum ShapeType {
/** name of the presetShapeDefinit(i)on entry */
public String getOoxmlName() {
if (this == SEAL) return STAR_16.getOoxmlName();
- if (ooxmlId == -1) return null;
+ if (ooxmlId == -1) {
+ return (name().startsWith("TEXT")) ? RECT.getOoxmlName() : null;
+ }
StringBuilder sb = new StringBuilder();
boolean toLower = true;
Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java?rev=1685344&r1=1685343&r2=1685344&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/Slide.java Sat Jun 13 23:26:46 2015
@@ -29,4 +29,9 @@ public interface Slide<T extends Shape,
boolean getFollowMasterObjects();
void setFollowMasterObjects(boolean follow);
+
+ /**
+ * @return the 1-based slide no.
+ */
+ int getSlideNumber();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org