You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2025/01/04 07:51:46 UTC
[Bug 69522] New: XmlComplexContentImpl cannot be cast to CTPath2DQuadBezierTo
https://bz.apache.org/bugzilla/show_bug.cgi?id=69522
Bug ID: 69522
Summary: XmlComplexContentImpl cannot be cast to
CTPath2DQuadBezierTo
Product: POI
Version: 5.3.0-FINAL
Hardware: PC
Status: NEW
Severity: blocker
Priority: P2
Component: XSLF
Assignee: dev@poi.apache.org
Reporter: yudalang@ucas.edu.cn
Target Milestone: ---
Created attachment 39963
--> https://bz.apache.org/bugzilla/attachment.cgi?id=39963&action=edit
The reproduce class
This is a blocker problem for user can NOT use the export functionality.
Call me if need any other staffs.
# The error output:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException:
org.apache.xmlbeans.impl.values.XmlComplexContentImpl cannot be cast to
org.openxmlformats.schemas.drawingml.x2006.main.CTPath2DQuadBezierTo
at
org.openxmlformats.schemas.drawingml.x2006.main.impl.CTPath2DImpl.addNewQuadBezTo(CTPath2DImpl.java:555)
at
org.apache.poi.xslf.usermodel.XSLFFreeformShape.addQuadBezierTo(XSLFFreeformShape.java:204)
at
org.apache.poi.xslf.usermodel.XSLFFreeformShape.setPath(XSLFFreeformShape.java:90)
at org.apache.poi.sl.draw.SLGraphics.fill(SLGraphics.java:330)
at
poi.test.general.path.TriangleDrawingExample$TrianglePanel.drawShape(TriangleDrawingExample.java:94)
at
poi.test.general.path.TriangleDrawingExample$TrianglePanel.paintComponent(TriangleDrawingExample.java:49)
at javax.swing.JComponent.paint(JComponent.java:1050)
at
poi.test.general.path.TriangleDrawingExample.lambda$0(TriangleDrawingExample.java:125)
# how to reproduce the problem
So see the attachment.
package poi.test.general.path;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Arc2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.QuadCurve2D;
import java.awt.geom.Rectangle2D;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import org.apache.poi.sl.draw.SLGraphics;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFGroupShape;
import org.apache.poi.xslf.usermodel.XSLFSlide;
public class TriangleDrawingExample extends JFrame {
TrianglePanel comp = new TrianglePanel();
public TriangleDrawingExample() {
// 设置 JFrame 的标题
setTitle("Triangle Drawing Example");
// 设置 JFrame 的大小
setSize(400, 400);
// 设置 JFrame 的关闭操作
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 将自定义面板添加到 JFrame
add(comp);
// 设置 JFrame 可见
setVisible(true);
}
// 自定义 JPanel 用于绘制三角形
class TrianglePanel extends JPanel {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.BLUE);
drawShape(g2d);
}
private void drawShape(Graphics2D g2d) {
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
int innerRadius = 50;
int sourceStartAngle = 0;
int targetStartAngle = 100;
int targetEndAngle = 145;
int sourceEndAngle = 40;
Point2D.Double sourceEndPoint = new Point2D.Double(0,
0);
Point2D.Double sourceStartPoint = new Point2D.Double(0,
0);
Point2D.Double targetStartPoint = new
Point2D.Double(getWidth(), getHeight());
Point2D.Double targetEndPoint = new
Point2D.Double(getWidth(), getHeight());
GeneralPath path = new GeneralPath();
{
Arc2D arc2 = new Arc2D.Double(centerX -
innerRadius, centerY - innerRadius, 2 * innerRadius,
2 * innerRadius,
sourceStartAngle, sourceEndAngle - sourceStartAngle, Arc2D.OPEN);
path.append(arc2, true);
QuadCurve2D chord = new
QuadCurve2D.Double(sourceEndPoint.getX(), sourceEndPoint.getY(), centerX,
centerY,
targetStartPoint.getX(), targetStartPoint.getY());
path.append(chord, true);
}
{
Arc2D arc2 = new Arc2D.Double(centerX -
innerRadius, centerY - innerRadius, 2 * innerRadius,
2 * innerRadius,
targetStartAngle, targetEndAngle - targetStartAngle, Arc2D.OPEN);
path.append(arc2, true);
QuadCurve2D chord = new
QuadCurve2D.Double(targetEndPoint.getX(), targetEndPoint.getY(), centerX,
centerY,
sourceStartPoint.getX(), sourceStartPoint.getY());
path.append(chord, true);
}
path.closePath();
g2d.setColor(Color.BLACK);
g2d.fill(path);
}
}
public static void main(String[] args) {
// 创建并运行 JFrame 实例
Runnable doRun = () -> {
TriangleDrawingExample triangleDrawingExample = new
TriangleDrawingExample();
TrianglePanel comp2 = triangleDrawingExample.comp;
try (XMLSlideShow ppt = new XMLSlideShow();
FileOutputStream out = new
FileOutputStream("C:\\Users\\yudal\\Desktop\\a.pptx")) {
Dimension size = comp2.getSize();
// Set the size of the slide to match JPanel
size
ppt.setPageSize(size);
// bar chart data. The first value is the bar
color, the second is the width
XSLFSlide slide = ppt.createSlide();
XSLFGroupShape group = slide.createGroup();
// define position of the drawing in the slide
Rectangle2D bounds = new Rectangle2D.Double(0,
0, size.getWidth(), size.getHeight());
group.setAnchor(bounds);
group.setInteriorAnchor(bounds);
Graphics2D graphics = new SLGraphics(group);
comp2.paint(graphics);
//这是用来辅助定位的一个Anchor 矩形,先不绘制了
//graphics.draw(group.getInteriorAnchor());
graphics.dispose();
ppt.write(out);
} catch (IOException e) {
e.printStackTrace();
}
};
SwingUtilities.invokeLater(doRun);
}
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69522] XmlComplexContentImpl cannot be cast to CTPath2DQuadBezierTo
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69522
--- Comment #3 from Dalang <yu...@ucas.edu.cn> ---
(In reply to Dalang from comment #2)
> I do not understand, this is a "can not use" block.
> Why cange to normal?
> The users can not use this poi XSLF functionalitiy?
>
> It should be blocked.
Sorry, I am new to this system, I understand.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69522] XmlComplexContentImpl cannot be cast to CTPath2DQuadBezierTo
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69522
--- Comment #2 from Dalang <yu...@ucas.edu.cn> ---
I do not understand, this is a "can not use" block.
Why cange to normal?
The users can not use this poi XSLF functionalitiy?
It should be blocked.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69522] XmlComplexContentImpl cannot be cast to CTPath2DQuadBezierTo
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69522
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from PJ Fanning <fa...@yahoo.com> ---
https://github.com/apache/poi/pull/1335 fixes this
But instead of waiting for a 6.0.0 release, you could add poi-ooxml-full jar to
the classpath instead of poi-ooxml-lite jar. We don't include all the OOXML
classes in poi-ooxml-lite and CTPath2DQuadBezierTo was one class that we left
out.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69522] XmlComplexContentImpl cannot be cast to CTPath2DQuadBezierTo
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69522
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|blocker |normal
--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
"Blocker" is used when anybody using the library is blocked from using it,
i.e. completely broken, which I don't think applies here, as only one certain
aspect is not processed properly.
Furthermore (HX)SLF format gets very little attention from the few active
committers right now, you best chance for getting a fix will be to investigate
and provide a PR if possible.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 69522] XmlComplexContentImpl cannot be cast to CTPath2DQuadBezierTo
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69522
Dalang <yu...@ucas.edu.cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
CC| |yudalang@ucas.edu.cn
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org