mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
fix: 导入PPTX组合元素旋转后位置计算、超小形状显示异常
This commit is contained in:
parent
88ab684ffc
commit
dbdab187e5
@ -102,6 +102,32 @@ export default () => {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const calculateRotatedPosition = (
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
w: number,
|
||||||
|
h: number,
|
||||||
|
ox: number,
|
||||||
|
oy: number,
|
||||||
|
k: number,
|
||||||
|
) => {
|
||||||
|
const radians = k * (Math.PI / 180)
|
||||||
|
|
||||||
|
const containerCenterX = x + w / 2
|
||||||
|
const containerCenterY = y + h / 2
|
||||||
|
|
||||||
|
const relativeX = ox - w / 2
|
||||||
|
const relativeY = oy - h / 2
|
||||||
|
|
||||||
|
const rotatedX = relativeX * Math.cos(radians) + relativeY * Math.sin(radians)
|
||||||
|
const rotatedY = -relativeX * Math.sin(radians) + relativeY * Math.cos(radians)
|
||||||
|
|
||||||
|
const graphicX = containerCenterX + rotatedX
|
||||||
|
const graphicY = containerCenterY + rotatedY
|
||||||
|
|
||||||
|
return { x: graphicX, y: graphicY }
|
||||||
|
}
|
||||||
|
|
||||||
// 导入PPTX文件
|
// 导入PPTX文件
|
||||||
const importPPTXFile = (files: FileList) => {
|
const importPPTXFile = (files: FileList) => {
|
||||||
const file = files[0]
|
const file = files[0]
|
||||||
@ -467,7 +493,26 @@ export default () => {
|
|||||||
options,
|
options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else if (el.type === 'group' || el.type === 'diagram') {
|
else if (el.type === 'group') {
|
||||||
|
const elements = el.elements.map(_el => {
|
||||||
|
let left = _el.left + originLeft
|
||||||
|
let top = _el.top + originTop
|
||||||
|
|
||||||
|
if (el.rotate) {
|
||||||
|
const { x, y } = calculateRotatedPosition(originLeft, originTop, originWidth, originHeight, _el.left, _el.top, el.rotate)
|
||||||
|
left = x
|
||||||
|
top = y
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
..._el,
|
||||||
|
left,
|
||||||
|
top,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
parseElements(elements)
|
||||||
|
}
|
||||||
|
else if (el.type === 'diagram') {
|
||||||
const elements = el.elements.map(_el => ({
|
const elements = el.elements.map(_el => ({
|
||||||
..._el,
|
..._el,
|
||||||
left: _el.left + originLeft,
|
left: _el.left + originLeft,
|
||||||
|
@ -111,6 +111,7 @@ const text = computed<ShapeText>(() => {
|
|||||||
svg {
|
svg {
|
||||||
transform-origin: 0 0;
|
transform-origin: 0 0;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.shape-text {
|
.shape-text {
|
||||||
|
@ -208,6 +208,7 @@ const startEdit = () => {
|
|||||||
svg {
|
svg {
|
||||||
transform-origin: 0 0;
|
transform-origin: 0 0;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shape-path {
|
.shape-path {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user