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
820383f831
commit
fc13e82853
@ -31,7 +31,8 @@ export default () => {
|
|||||||
const slidesStore = useSlidesStore()
|
const slidesStore = useSlidesStore()
|
||||||
const { theme } = storeToRefs(useSlidesStore())
|
const { theme } = storeToRefs(useSlidesStore())
|
||||||
|
|
||||||
const { viewportSize } = storeToRefs(useMainStore())
|
const mainStore = useMainStore()
|
||||||
|
const { viewportSize } = storeToRefs(mainStore)
|
||||||
|
|
||||||
const { addSlidesFromData } = useAddSlidesOrElements()
|
const { addSlidesFromData } = useAddSlidesOrElements()
|
||||||
const { isEmptySlide } = useSlideHandler()
|
const { isEmptySlide } = useSlideHandler()
|
||||||
@ -107,9 +108,10 @@ export default () => {
|
|||||||
reader.onload = async e => {
|
reader.onload = async e => {
|
||||||
const json = await parse(e.target!.result as ArrayBuffer)
|
const json = await parse(e.target!.result as ArrayBuffer)
|
||||||
|
|
||||||
const ratioForPt2Px = 96 / 72
|
const ratio = 96 / 72
|
||||||
const width = json.size.width
|
const width = json.size.width
|
||||||
const ratio = viewportSize.value / width
|
|
||||||
|
mainStore.setViewportSize(width * ratio)
|
||||||
|
|
||||||
const slides: Slide[] = []
|
const slides: Slide[] = []
|
||||||
for (const item of json.slides) {
|
for (const item of json.slides) {
|
||||||
@ -173,7 +175,7 @@ export default () => {
|
|||||||
rotate: el.rotate,
|
rotate: el.rotate,
|
||||||
defaultFontName: theme.value.fontName,
|
defaultFontName: theme.value.fontName,
|
||||||
defaultColor: theme.value.fontColor,
|
defaultColor: theme.value.fontColor,
|
||||||
content: convertFontSizePtToPx(el.content, ratioForPt2Px),
|
content: convertFontSizePtToPx(el.content, ratio),
|
||||||
lineHeight: 1,
|
lineHeight: 1,
|
||||||
outline: {
|
outline: {
|
||||||
color: el.borderColor,
|
color: el.borderColor,
|
||||||
@ -185,9 +187,9 @@ export default () => {
|
|||||||
}
|
}
|
||||||
if (el.shadow) {
|
if (el.shadow) {
|
||||||
textEl.shadow = {
|
textEl.shadow = {
|
||||||
h: el.shadow.h * ratioForPt2Px,
|
h: el.shadow.h * ratio,
|
||||||
v: el.shadow.v * ratioForPt2Px,
|
v: el.shadow.v * ratio,
|
||||||
blur: el.shadow.blur * ratioForPt2Px,
|
blur: el.shadow.blur * ratio,
|
||||||
color: el.shadow.color,
|
color: el.shadow.color,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,7 +271,7 @@ export default () => {
|
|||||||
style: el.borderType === 'solid' ? 'solid' : 'dashed',
|
style: el.borderType === 'solid' ? 'solid' : 'dashed',
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
content: convertFontSizePtToPx(el.content, ratioForPt2Px),
|
content: convertFontSizePtToPx(el.content, ratio),
|
||||||
defaultFontName: theme.value.fontName,
|
defaultFontName: theme.value.fontName,
|
||||||
defaultColor: theme.value.fontColor,
|
defaultColor: theme.value.fontColor,
|
||||||
align: vAlignMap[el.vAlign] || 'middle',
|
align: vAlignMap[el.vAlign] || 'middle',
|
||||||
@ -279,9 +281,9 @@ export default () => {
|
|||||||
}
|
}
|
||||||
if (el.shadow) {
|
if (el.shadow) {
|
||||||
element.shadow = {
|
element.shadow = {
|
||||||
h: el.shadow.h * ratioForPt2Px,
|
h: el.shadow.h * ratio,
|
||||||
v: el.shadow.v * ratioForPt2Px,
|
v: el.shadow.v * ratio,
|
||||||
blur: el.shadow.blur * ratioForPt2Px,
|
blur: el.shadow.blur * ratio,
|
||||||
color: el.shadow.color,
|
color: el.shadow.color,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,7 +333,7 @@ export default () => {
|
|||||||
const align = p?.style.textAlign || 'left'
|
const align = p?.style.textAlign || 'left'
|
||||||
|
|
||||||
const span = textDiv.querySelector('span')
|
const span = textDiv.querySelector('span')
|
||||||
const fontsize = span?.style.fontSize ? (parseInt(span?.style.fontSize) * ratioForPt2Px).toFixed(1) + 'px' : ''
|
const fontsize = span?.style.fontSize ? (parseInt(span?.style.fontSize) * ratio).toFixed(1) + 'px' : ''
|
||||||
const fontname = span?.style.fontFamily || ''
|
const fontname = span?.style.fontFamily || ''
|
||||||
const color = span?.style.color || cellData.fontColor
|
const color = span?.style.color || cellData.fontColor
|
||||||
|
|
||||||
@ -455,8 +457,7 @@ export default () => {
|
|||||||
parseElements(item.elements)
|
parseElements(item.elements)
|
||||||
slides.push(slide)
|
slides.push(slide)
|
||||||
}
|
}
|
||||||
if (isEmptySlide.value) slidesStore.setSlides(slides)
|
slidesStore.setSlides(slides)
|
||||||
else addSlidesFromData(slides)
|
|
||||||
exporting.value = false
|
exporting.value = false
|
||||||
}
|
}
|
||||||
reader.readAsArrayBuffer(file)
|
reader.readAsArrayBuffer(file)
|
||||||
|
@ -117,6 +117,10 @@ export const useMainStore = defineStore('main', {
|
|||||||
this.canvasPercentage = percentage
|
this.canvasPercentage = percentage
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setViewportSize(size: number) {
|
||||||
|
this.viewportSize = size
|
||||||
|
},
|
||||||
|
|
||||||
setCanvasScale(scale: number) {
|
setCanvasScale(scale: number) {
|
||||||
this.canvasScale = scale
|
this.canvasScale = scale
|
||||||
},
|
},
|
||||||
|
@ -63,6 +63,7 @@ export default (canvasRef: Ref<HTMLElement | undefined>) => {
|
|||||||
// 可视区域缩放或比例变化时,重置/更新可视区域的位置
|
// 可视区域缩放或比例变化时,重置/更新可视区域的位置
|
||||||
watch(canvasPercentage, setViewportPosition)
|
watch(canvasPercentage, setViewportPosition)
|
||||||
watch(viewportRatio, initViewportPosition)
|
watch(viewportRatio, initViewportPosition)
|
||||||
|
watch(viewportSize, initViewportPosition)
|
||||||
|
|
||||||
// 画布拖拽状态改变(复原)时,重置可视区域的位置
|
// 画布拖拽状态改变(复原)时,重置可视区域的位置
|
||||||
watch(canvasDragged, () => {
|
watch(canvasDragged, () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user