@@ -1,6 +1,9 @@
package pc.exam.pp.module.judgement.utils.wps_pptx.pptx4j ;
import org.docx4j.dml.* ;
import org.docx4j.openpackaging.packages.PresentationMLPackage ;
import org.docx4j.openpackaging.parts.PresentationML.SlidePart ;
import org.pptx4j.pml.CTSlideTiming ;
import java.math.BigInteger ;
import java.text.DecimalFormat ;
@@ -8,7 +11,7 @@ import java.text.DecimalFormat;
public class Shape {
/ / 大小 - 高度
public static String getShapeSizeHeight ( org . pptx4j . pml . Shape sp ) {
public static String getShapeSizeHeight ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTTransform2D xfrm = sp . getSpPr ( ) . getXfrm ( ) ;
/ / 获取位置和尺寸 ( 单位 EMU , 1英寸 = 914400 EMU , 1cm ≈ 360000 EMU )
CTPositiveSize2D ext = xfrm . getExt ( ) ; / / 尺寸
@@ -16,7 +19,7 @@ public class Shape {
return String . valueOf ( heightPt ) ;
}
/ / 大小 - 宽度
public static String getShapeSizeWidthPt ( org . pptx4j . pml . Shape sp ) {
public static String getShapeSizeWidthPt ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTTransform2D xfrm = sp . getSpPr ( ) . getXfrm ( ) ;
/ / 获取位置和尺寸 ( 单位 EMU , 1英寸 = 914400 EMU , 1cm ≈ 360000 EMU )
CTPositiveSize2D ext = xfrm . getExt ( ) ; / / 尺寸
@@ -24,7 +27,7 @@ public class Shape {
return String . valueOf ( widthPt ) ;
}
/ / 大小 - 锁定纵横比
public static String getShapeSizeLockAspectRatio ( org . pptx4j . pml . Shape sp ) {
public static String getShapeSizeLockAspectRatio ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTTransform2D xfrm = sp . getSpPr ( ) . getXfrm ( ) ;
/ / 获取位置和尺寸 ( 单位 EMU , 1英寸 = 914400 EMU , 1cm ≈ 360000 EMU )
CTPositiveSize2D ext = xfrm . getExt ( ) ; / / 尺寸
@@ -50,7 +53,7 @@ public class Shape {
}
/ / 位置 水平位置
public static String getShapePositionLeft ( org . pptx4j . pml . Shape sp ) {
public static String getShapePositionLeft ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTTransform2D xfrm = sp . getSpPr ( ) . getXfrm ( ) ;
if ( xfrm ! = null ) {
long x = xfrm . getOff ( ) . getX ( ) ; / / 水平位置 ( EMU )
@@ -59,7 +62,7 @@ public class Shape {
return " " ;
}
/ / 位置 垂直位置
public static String getShapePositionTop ( org . pptx4j . pml . Shape sp ) {
public static String getShapePositionTop ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTTransform2D xfrm = sp . getSpPr ( ) . getXfrm ( ) ;
if ( xfrm ! = null ) {
long y = xfrm . getOff ( ) . getY ( ) ; / / 垂直位置 ( EMU )
@@ -69,13 +72,13 @@ public class Shape {
}
/ / 形状填充 填充方式
public static String getShapeFillType ( org . pptx4j . pml . Shape sp ) {
public static String getShapeFillType ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
return SlideUtils . getFillType ( spPr ) ;
}
/ / 形状填充 纯色填充 - 颜色
public static String getShapeFillSolidColor ( org . pptx4j . pml . Shape sp ) {
public static String getShapeFillSolidColor ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
if ( spPr ! = null & & spPr . getSolidFill ( ) ! = null ) {
return SlideUtils . getSolidFillColor ( spPr . getSolidFill ( ) ) ;
@@ -84,7 +87,7 @@ public class Shape {
}
/ / 形状填充 渐变填充 - 效果
public static String getShapeFillGradientType ( org . pptx4j . pml . Shape sp ) {
public static String getShapeFillGradientType ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
if ( spPr ! = null & & spPr . getGradFill ( ) ! = null ) {
@@ -95,7 +98,7 @@ public class Shape {
}
/ / 形状填充 图片填充 - 效果
public static String getShapeFillPictureType ( org . pptx4j . pml . Shape sp ) {
public static String getShapeFillPictureType ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ){
CTShapeProperties spPr = sp . getSpPr ( ) ;
if ( spPr ! = null & & spPr . getBlipFill ( ) ! = null ) {
@@ -106,7 +109,7 @@ public class Shape {
}
/ / 形状填充 纹理填充 - 效果
public static String getShapeFillTextureType ( org . pptx4j . pml . Shape sp ) {
public static String getShapeFillTextureType ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
if ( spPr ! = null & & spPr . getPattFill ( ) ! = null ) {
return SlideUtils . printPatternFill ( spPr . getPattFill ( ) ) ;
@@ -115,7 +118,7 @@ public class Shape {
}
/ / 形状填充 图案填充 - 效果
public static String getShapeFillPatternType ( org . pptx4j . pml . Shape sp ) {
public static String getShapeFillPatternType ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
if ( spPr ! = null & & spPr . getPattFill ( ) ! = null ) {
return spPr . getPattFill ( ) . getPrst ( ) . value ( ) ;
@@ -124,17 +127,17 @@ public class Shape {
}
/ / 形状填充 幻灯片背景填充 - 效果
public static String getShapeFillSlideBackgroundType ( org . pptx4j . pml . Shape sp ) {
public static String getShapeFillSlideBackgroundType ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
return " " ;
}
/ / 形状填充 填充透明度
public static String getShapeFillOpacity ( org . pptx4j . pml . Shape sp ) {
public static String getShapeFillOpacity ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
return " " ;
}
/ / 形状线条 绘制
public static String getShapeLineDraw ( org . pptx4j . pml . Shape sp ) {
public static String getShapeLineDraw ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
if ( spPr ! = null & & spPr . getLn ( ) ! = null ) {
@@ -166,7 +169,7 @@ public class Shape {
}
/ / 形状线条 线条颜色
public static String getShapeLineColor ( org . pptx4j . pml . Shape sp ) {
public static String getShapeLineColor ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
if ( spPr ! = null & & spPr . getLn ( ) ! = null ) {
@@ -181,7 +184,7 @@ public class Shape {
}
/ / 形状线条 线条宽度
public static String getShapeLineWidth ( org . pptx4j . pml . Shape sp ) {
public static String getShapeLineWidth ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
if ( spPr ! = null & & spPr . getLn ( ) ! = null ) {
@@ -194,13 +197,13 @@ public class Shape {
}
/ / 形状线条 透明度
public static String getShapeLineOpacity ( org . pptx4j . pml . Shape sp ) {
public static String getShapeLineOpacity ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
return " " ;
}
/ / 形状线条 复合类型
public static String getStrokeCompound ( org . pptx4j . pml . Shape sp ) {
public static String getStrokeCompound ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
if ( sp = = null | | sp . getSpPr ( ) = = null ) return " 未定义 " ;
CTShapeProperties spPr = sp . getSpPr ( ) ;
CTLineProperties ln = spPr . getLn ( ) ;
@@ -219,7 +222,7 @@ public class Shape {
}
/ / 形状线条 短划线类型
public static String getStrokeDash ( org . pptx4j . pml . Shape sp ) {
public static String getStrokeDash ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
if ( sp = = null | | sp . getSpPr ( ) = = null ) return " solid " ;
CTShapeProperties spPr = sp . getSpPr ( ) ;
CTLineProperties ln = spPr . getLn ( ) ;
@@ -248,7 +251,7 @@ public class Shape {
/ / 形状效果 阴影 - 绘制
public static String getShapeShadowDraw ( org . pptx4j . pml . Shape sp ) {
public static String getShapeShadowDraw ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
CTEffectList effList = spPr . getEffectLst ( ) ;
if ( effList = = null ) {
@@ -261,7 +264,7 @@ public class Shape {
}
/ / 形状效果 阴影 - 效果
public static String getShapeShadowEffect ( org . pptx4j . pml . Shape sp ) {
public static String getShapeShadowEffect ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
if ( sp = = null | | sp . getSpPr ( ) = = null ) {
return " 无阴影 " ;
}
@@ -282,7 +285,7 @@ public class Shape {
}
/ / 形状效果 倒影 - 绘制
public static String getShapeReflectionDraw ( org . pptx4j . pml . Shape sp ) {
public static String getShapeReflectionDraw ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTShapeProperties spPr = sp . getSpPr ( ) ;
CTEffectList effList = spPr . getEffectLst ( ) ;
if ( effList = = null ) {
@@ -298,7 +301,7 @@ public class Shape {
}
/ / 形状效果 倒影 - 效果
public static String getShapeReflectionEffect ( org . pptx4j . pml . Shape sp ) {
public static String getShapeReflectionEffect ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTReflectionEffect r = SlideUtils . getReflection ( sp ) ;
if ( r = = null ) return " 无倒影 " ;
@@ -324,12 +327,42 @@ public class Shape {
}
/ / 形状效果 发光
public static String getShapeGlow ( org . pptx4j . pml . Shape sp ) {
public static String getShapeGlow ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
if ( sp = = null | | sp . getSpPr ( ) = = null ) return null ;
CTShapeProperties spPr = sp . getSpPr ( ) ;
CTEffectList eff = spPr . getEffectLst ( ) ;
return ( eff ! = null ) ? eff . getGlow ( ) . toString ( ) : null ;
}
/ / 形状效果 发光 - 效果
public static String getShapeGlowEffect ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
return " 待开发 " ;
}
/ / 形状效果 柔化边缘 - 绘制
public static String getShapeSoftEdgesDraw ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
CTSoftEdgesEffect se = getSoftEdge ( sp ) ;
return ( se ! = null ) ? " 是 " : " 否 " ;
}
/* —— 内部: spPr/effectLst/softEdge —— */
private static CTSoftEdgesEffect getSoftEdge ( org . pptx4j . pml . Shape shape ) {
if ( shape = = null | | shape . getSpPr ( ) = = null ) return null ;
CTShapeProperties spPr = shape . getSpPr ( ) ;
CTEffectList eff = spPr . getEffectLst ( ) ;
return ( eff ! = null ) ? eff . getSoftEdge ( ) : null ;
/ / 说明 : 极少数文件把效果写在 effectDag ; 若拿不到再补 effectDag 解析 。
}
/ / 动画 效果
public static String getAnimation ( org . pptx4j . pml . Shape sp , CTSlideTiming timing ) {
/ / 获取形状中的ID
if ( sp = = null ) return " 无动画 " ;
long spId = sp . getNvSpPr ( ) . getCNvPr ( ) . getId ( ) ;
/ / 获取动画效果
return " " ;
}
}