OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
690 stars 95 forks source link

Svg imae getting changed after inserting into slide using setSelectedDataAsync method in PowerPoint #4967

Open nikhilatsap opened 1 month ago

nikhilatsap commented 1 month ago

Inserted image (coercion Type xmlSvg) into a powerpoint slide using the setSelectedData method gets distorted

Your Environment

Expected behavior

The image should get inserted without getting changed, the original positions of the elements inside the svg should stay same and not change during the insertion.

Current behavior

When I add an image (coercion Type xmlSvg) into a powerpoint slide using the setSelectedData method it gets distorted and the content gets shifted in vertical direction either upwards or downwards due to how powerpoint is processing the svg and extracting the wrong transform translate values from the original svg string that we pass to the api. The svg string that we pass to the setSelectedDataAsync method and the svg string that gets pasted are quite different

Steps to reproduce

  1. store the example svg in a variable, ( use this svg ) "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\" class=\"viz-renderer-sandbox-div\" width=\"281\" height=\"184\"><rect width=\"100%\" height=\"100%\" fill=\"rgba(237, 237, 237, 0.95)\"/><g class=\"sapFpaBiRichTextEditorTextEditor headerSection-container\" width=\"281\" height=\"56\"><text class=\"headerSection-titleRow\" dominant-baseline=\"text-before-edge\" fill=\"rgb(35, 31, 32)\" width=\"275\" height=\"20\" x=\"2\" y=\"20\"><tspan style=\"color: #231f20 ; font-family: "72-web" , "arial" , "helvetica" , sans-serif ; font-size: 16px ; font-weight: bold\" width=\"82.19792175292969\" height=\"18\" x=\"2\" y=\"20.666664123535156\" dominant-baseline=\"text-before-edge\" fill=\"rgb(35, 31, 32)\">Headcount<text class=\"headerSection-subtitleRow\" dominant-baseline=\"text-before-edge\" fill=\"rgb(166, 168, 171)\" width=\"48.65625\" height=\"20\" x=\"2\" y=\"43\"><tspan style=\"color: #a6a8ab ; font-family: "72-web" , "arial" , "helvetica" , sans-serif ; font-size: 11px ; white-space: pre\" width=\"48.65625\" height=\"12\" x=\"2\" y=\"47\" dominant-baseline=\"text-before-edge\" fill=\"rgb(166, 168, 171)\">Model M1<svg class=\"vizParentContainer bodyTheming sap-custom-default-viz sap-user-defined-widget-api-custom-theme viz-export\" style=\"\"><svg class=\"cellContainer\" style=\"\"><svg class=\"VizContainer\" x=\"0\" y=\"56\" style=\"height: 128px; width: 281px; overflow: hidden;\"><svg class=\"primary-container\" y=\"0\" style=\"width: 264px;\"><text class=\"primary-entry\" y=\"12\" style=\"\" xml:space=\"preserve\"><tspan class=\"primary-number\" dominant-baseline=\"text-before-edge\" style=\"text-align: left;width: auto; color: rgb(88, 89, 91); cursor: pointer; font-size: 69.6842px; font-style: normal; font-family: "72-web", arial, helvetica, sans-serif; font-weight: bold;\" dx=\"0\" dy=\"0\" x=\"0\" fill=\"rgb(88, 89, 91)\">1,021<tspan class=\"primary-label\" dominant-baseline=\"text-before-edge\" style=\"text-align: left; letter-spacing: 1px;width: auto; margin-left: 0px; color: rgb(166, 168, 171); font-size: 17.4211px; font-style: normal; font-family: "72-web", arial, helvetica, sans-serif; font-weight: normal;\" dx=\"0\" dy=\"80\" x=\"0\" fill=\"rgb(166, 168, 171)\">Institutions"

  2. Pass this to the setSelectedDataAsync method with coercion type xmlSvg and see how parts of image get shifted along y-axis

  3. render the same svg string in an online svg renderer or save the svg in a file and open that file in a browser and see that the svg renders properly

Context

This is affecting the release of one of our very important features which will allow the users to paste svgs instead of pngs into their slides for better image quality

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

qinliuMSFT commented 1 month ago

Thank you for reporting this issue. It has been put on our backlog #9444215 , the team will investigate and we will reply to you as soon as there is any progress. Thank you for your patience.