|
|
@@ -1982,119 +1982,121 @@ export default () => {
|
|
|
// ---------- 形状 ----------
|
|
|
else if (el.type === 'shape') {
|
|
|
if (el.shapType === 'line' || /Connector/.test(el.shapType)) {
|
|
|
- // 线条元素(单独处理)
|
|
|
- const lineElement = parseLineElement(el, ratio)
|
|
|
- slide.elements.push(lineElement)
|
|
|
+ //el.isFlipH = el.isFlipV = false;
|
|
|
+ //el.rotate = 0;
|
|
|
+ // // 线条元素(单独处理)
|
|
|
+ // const lineElement = parseLineElement(el, ratio)
|
|
|
+ // slide.elements.push(lineElement)
|
|
|
}
|
|
|
- else {
|
|
|
- const shape = shapeList.find(item => item.pptxShapeType === el.shapType)
|
|
|
+ // else {
|
|
|
+ const shape = shapeList.find(item => item.pptxShapeType === el.shapType)
|
|
|
|
|
|
- const vAlignMap: { [key: string]: ShapeTextAlign } = {
|
|
|
- mid: 'middle',
|
|
|
- down: 'bottom',
|
|
|
- up: 'top',
|
|
|
+ const vAlignMap: { [key: string]: ShapeTextAlign } = {
|
|
|
+ mid: 'middle',
|
|
|
+ down: 'bottom',
|
|
|
+ up: 'top',
|
|
|
+ }
|
|
|
+
|
|
|
+ const gradient: Gradient | undefined = el.fill?.type === 'gradient'
|
|
|
+ ? {
|
|
|
+ type: el.fill.value.path === 'line' ? 'linear' : 'radial',
|
|
|
+ colors: el.fill.value.colors.map(item => ({
|
|
|
+ ...item,
|
|
|
+ pos: parseInt(item.pos),
|
|
|
+ })),
|
|
|
+ rotate: el.fill.value.rot,
|
|
|
}
|
|
|
+ : undefined
|
|
|
|
|
|
- const gradient: Gradient | undefined = el.fill?.type === 'gradient'
|
|
|
- ? {
|
|
|
- type: el.fill.value.path === 'line' ? 'linear' : 'radial',
|
|
|
- colors: el.fill.value.colors.map(item => ({
|
|
|
- ...item,
|
|
|
- pos: parseInt(item.pos),
|
|
|
- })),
|
|
|
- rotate: el.fill.value.rot,
|
|
|
- }
|
|
|
- : undefined
|
|
|
+ const pattern: string | undefined = el.fill?.type === 'image' ? el.fill.value.picBase64 : undefined
|
|
|
+ const fill = el.fill?.type === 'color' ? el.fill.value : 'none'
|
|
|
+ const style = getStyle(convertFontSizePtToPx(el.content, ratio, el.autoFit)) + (el.pathBBox?.pWidth ? ';width:' + (el.pathBBox?.pWidth * ratio) + 'px;height:' + (el.pathBBox?.pHeight * ratio) + 'px;' : '') // 设置字体的样式等,这里由于不支持的样式在里面会过滤
|
|
|
+ const element: PPTShapeElement = {
|
|
|
+ type: 'shape',
|
|
|
+ id: nanoid(10),
|
|
|
+ width: el.width,
|
|
|
+ height: el.height,
|
|
|
+ left: el.left,
|
|
|
+ top: el.top,
|
|
|
+ viewBox: [200, 200],
|
|
|
+ path: 'M 0 0 L 200 0 L 200 200 L 0 200 Z',
|
|
|
+ fill,
|
|
|
+ gradient,
|
|
|
+ pattern,
|
|
|
+ fixedRatio: false,
|
|
|
+ rotate: el.rotate,
|
|
|
+ pathBBox: el.pathBBox,
|
|
|
+ outline: {
|
|
|
+ color: el.borderColor,
|
|
|
+ width: +(el.borderWidth * ratio).toFixed(2),
|
|
|
+ style: el.borderType,
|
|
|
+ },
|
|
|
+ text: {
|
|
|
+ content: convertFontSizePtToPx(el.content, ratio, el.autoFit),
|
|
|
+ style: style,
|
|
|
+ defaultFontName: theme.value.fontName,
|
|
|
+ defaultColor: theme.value.fontColor,
|
|
|
+ align: vAlignMap[el.vAlign] || 'middle',
|
|
|
+ },
|
|
|
+ flipH: el.isFlipH,
|
|
|
+ flipV: el.isFlipV,
|
|
|
+ }
|
|
|
|
|
|
- const pattern: string | undefined = el.fill?.type === 'image' ? el.fill.value.picBase64 : undefined
|
|
|
- const fill = el.fill?.type === 'color' ? el.fill.value : 'none'
|
|
|
- const style = getStyle(convertFontSizePtToPx(el.content, ratio, el.autoFit)) + (el.pathBBox?.pWidth ? ';width:' + (el.pathBBox?.pWidth * ratio) + 'px;height:' + (el.pathBBox?.pHeight * ratio) + 'px;' : '') // 设置字体的样式等,这里由于不支持的样式在里面会过滤
|
|
|
- const element: PPTShapeElement = {
|
|
|
- type: 'shape',
|
|
|
- id: nanoid(10),
|
|
|
- width: el.width,
|
|
|
- height: el.height,
|
|
|
- left: el.left,
|
|
|
- top: el.top,
|
|
|
- viewBox: [200, 200],
|
|
|
- path: 'M 0 0 L 200 0 L 200 200 L 0 200 Z',
|
|
|
- fill,
|
|
|
- gradient,
|
|
|
- pattern,
|
|
|
- fixedRatio: false,
|
|
|
- rotate: el.rotate,
|
|
|
- pathBBox: el.pathBBox,
|
|
|
- outline: {
|
|
|
- color: el.borderColor,
|
|
|
- width: +(el.borderWidth * ratio).toFixed(2),
|
|
|
- style: el.borderType,
|
|
|
- },
|
|
|
- text: {
|
|
|
- content: convertFontSizePtToPx(el.content, ratio, el.autoFit),
|
|
|
- style: style,
|
|
|
- defaultFontName: theme.value.fontName,
|
|
|
- defaultColor: theme.value.fontColor,
|
|
|
- align: vAlignMap[el.vAlign] || 'middle',
|
|
|
- },
|
|
|
- flipH: el.isFlipH,
|
|
|
- flipV: el.isFlipV,
|
|
|
+ if (el.shadow) {
|
|
|
+ element.shadow = {
|
|
|
+ h: el.shadow.h * ratio,
|
|
|
+ v: el.shadow.v * ratio,
|
|
|
+ blur: el.shadow.blur * ratio,
|
|
|
+ color: el.shadow.color,
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (el.shadow) {
|
|
|
- element.shadow = {
|
|
|
- h: el.shadow.h * ratio,
|
|
|
- v: el.shadow.v * ratio,
|
|
|
- blur: el.shadow.blur * ratio,
|
|
|
- color: el.shadow.color,
|
|
|
+ if (shape) {
|
|
|
+ const { maxX, maxY } = getSvgPathRange(el.path)
|
|
|
+ element.path = el.path
|
|
|
+ element.viewBox = poriginWidth ? [maxX, maxY] : [originWidth, originHeight]
|
|
|
+ /*
|
|
|
+ if (shape.pathFormula) {
|
|
|
+ element.pathFormula = shape.pathFormula
|
|
|
+ element.viewBox = [el.width, el.height]
|
|
|
+ // element.viewBox = [poriginWidth || originWidth || maxX, poriginHeight || originHeight || maxY];
|
|
|
+ const pathFormula = SHAPE_PATH_FORMULAS[shape.pathFormula]
|
|
|
+ if ('editable' in pathFormula && pathFormula.editable) {
|
|
|
+ element.path = pathFormula.formula(el.width, el.height, pathFormula.defaultValue)
|
|
|
+ element.keypoints = pathFormula.defaultValue
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if (shape) {
|
|
|
- const { maxX, maxY } = getSvgPathRange(el.path)
|
|
|
- element.path = el.path
|
|
|
- element.viewBox = poriginWidth ? [maxX, maxY] : [originWidth, originHeight]
|
|
|
- /*
|
|
|
- if (shape.pathFormula) {
|
|
|
- element.pathFormula = shape.pathFormula
|
|
|
- element.viewBox = [el.width, el.height]
|
|
|
- // element.viewBox = [poriginWidth || originWidth || maxX, poriginHeight || originHeight || maxY];
|
|
|
- const pathFormula = SHAPE_PATH_FORMULAS[shape.pathFormula]
|
|
|
- if ('editable' in pathFormula && pathFormula.editable) {
|
|
|
- element.path = pathFormula.formula(el.width, el.height, pathFormula.defaultValue)
|
|
|
- element.keypoints = pathFormula.defaultValue
|
|
|
- }
|
|
|
- else {
|
|
|
- element.path = pathFormula.formula(el.width, el.height)
|
|
|
- }
|
|
|
+ else {
|
|
|
+ element.path = pathFormula.formula(el.width, el.height)
|
|
|
}
|
|
|
- */
|
|
|
- }
|
|
|
- else if (el.path && el.path.indexOf('NaN') === -1) {
|
|
|
- const { maxX, maxY } = getSvgPathRange(el.path)
|
|
|
- element.path = el.path
|
|
|
- element.viewBox = poriginWidth ? [maxX, maxY] : [originWidth, originHeight]
|
|
|
- // element.viewBox = [originWidth || maxX, originHeight || maxY];
|
|
|
- // element.viewBox = originWidth? [(originWidth/(poriginWidth||1)), (originHeight/(poriginHeight||1))] : [maxX, maxY];
|
|
|
- // element.viewBox = [poriginWidth || maxX, poriginHeight || maxY];
|
|
|
}
|
|
|
+ */
|
|
|
+ }
|
|
|
+ else if (el.path && el.path.indexOf('NaN') === -1) {
|
|
|
+ const { maxX, maxY } = getSvgPathRange(el.path)
|
|
|
+ element.path = el.path
|
|
|
+ element.viewBox = poriginWidth ? [maxX, maxY] : [originWidth, originHeight]
|
|
|
+ // element.viewBox = [originWidth || maxX, originHeight || maxY];
|
|
|
+ // element.viewBox = originWidth? [(originWidth/(poriginWidth||1)), (originHeight/(poriginHeight||1))] : [maxX, maxY];
|
|
|
+ // element.viewBox = [poriginWidth || maxX, poriginHeight || maxY];
|
|
|
+ }
|
|
|
|
|
|
- if (el.shapType === 'custom') {
|
|
|
- if (el.path!.indexOf('NaN') !== -1) {
|
|
|
- if (element.width === 0) element.width = 0.1
|
|
|
- if (element.height === 0) element.height = 0.1
|
|
|
- element.path = el.path!.replace(/NaN/g, '0')
|
|
|
- }
|
|
|
- const { maxX, maxY } = getSvgPathRange(element.path)
|
|
|
- element.viewBox = poriginWidth ? [maxX, maxY] : [originWidth, originHeight]
|
|
|
- // element.viewBox = [originWidth || maxX, originHeight || maxY];
|
|
|
- // element.viewBox = [poriginWidth || originWidth || maxX, poriginHeight || originHeight || maxY];
|
|
|
- // element.viewBox = [poriginWidth || originWidth || maxX, poriginHeight || originHeight || maxY];
|
|
|
- // element.viewBox = [Math.max(maxX, originWidth), Math.max(maxY, originHeight)];
|
|
|
- // element.viewBox = [originWidth, originHeight];
|
|
|
+ if (el.shapType === 'custom') {
|
|
|
+ if (el.path!.indexOf('NaN') !== -1) {
|
|
|
+ if (element.width === 0) element.width = 0.1
|
|
|
+ if (element.height === 0) element.height = 0.1
|
|
|
+ element.path = el.path!.replace(/NaN/g, '0')
|
|
|
}
|
|
|
-
|
|
|
- if (element.path) slide.elements.push(element)
|
|
|
+ const { maxX, maxY } = getSvgPathRange(element.path)
|
|
|
+ element.viewBox = poriginWidth ? [maxX, maxY] : [originWidth, originHeight]
|
|
|
+ // element.viewBox = [originWidth || maxX, originHeight || maxY];
|
|
|
+ // element.viewBox = [poriginWidth || originWidth || maxX, poriginHeight || originHeight || maxY];
|
|
|
+ // element.viewBox = [poriginWidth || originWidth || maxX, poriginHeight || originHeight || maxY];
|
|
|
+ // element.viewBox = [Math.max(maxX, originWidth), Math.max(maxY, originHeight)];
|
|
|
+ // element.viewBox = [originWidth, originHeight];
|
|
|
}
|
|
|
+
|
|
|
+ if (element.path) slide.elements.push(element)
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
// ---------- 表格 ----------
|