MCPcopy
hub / github.com/THU-MAIC/OpenMAIC / getSlideBackgroundFill

Function getSlideBackgroundFill

packages/@openmaic/importer/src1/fill.js:272–603  ·  view source on GitHub ↗
(warpObj)

Source from the content-addressed store, hash-verified

270}
271
272export async function getSlideBackgroundFill(warpObj) {
273 const slideContent = warpObj['slideContent']
274 const slideLayoutContent = warpObj['slideLayoutContent']
275 const slideMasterContent = warpObj['slideMasterContent']
276
277 let bgPr = getTextByPathList(slideContent, ['p:sld', 'p:cSld', 'p:bg', 'p:bgPr'])
278 let bgRef = getTextByPathList(slideContent, ['p:sld', 'p:cSld', 'p:bg', 'p:bgRef'])
279
280 let background = '#fff'
281 let backgroundType = 'color'
282
283 if (bgPr) {
284 const bgFillTyp = getFillType(bgPr)
285
286 if (bgFillTyp === 'SOLID_FILL') {
287 const sldFill = bgPr['a:solidFill']
288 let clrMapOvr
289 const sldClrMapOvr = getTextByPathList(slideContent, ['p:sld', 'p:clrMapOvr', 'a:overrideClrMapping', 'attrs'])
290 if (sldClrMapOvr) clrMapOvr = sldClrMapOvr
291 else {
292 const sldClrMapOvr = getTextByPathList(slideLayoutContent, ['p:sldLayout', 'p:clrMapOvr', 'a:overrideClrMapping', 'attrs'])
293 if (sldClrMapOvr) clrMapOvr = sldClrMapOvr
294 else clrMapOvr = getTextByPathList(slideMasterContent, ['p:sldMaster', 'p:clrMap', 'attrs'])
295 }
296 const sldBgClr = getSolidFill(sldFill, clrMapOvr, undefined, warpObj)
297 background = sldBgClr
298 }
299 else if (bgFillTyp === 'GRADIENT_FILL') {
300 const gradientFill = getBgGradientFill(bgPr, undefined, slideMasterContent, warpObj)
301 if (typeof gradientFill === 'string') {
302 background = gradientFill
303 }
304 else if (gradientFill) {
305 background = gradientFill
306 backgroundType = 'gradient'
307 }
308 }
309 else if (bgFillTyp === 'PIC_FILL') {
310 background = await getBgPicFill(bgPr, 'slideBg', warpObj)
311 backgroundType = 'image'
312 }
313 else if (bgFillTyp === 'PATTERN_FILL') {
314 const patternFill = getPatternFill(bgPr, warpObj)
315 if (patternFill) {
316 background = patternFill
317 backgroundType = 'pattern'
318 }
319 }
320 }
321 else if (bgRef) {
322 let clrMapOvr
323 const sldClrMapOvr = getTextByPathList(slideContent, ['p:sld', 'p:clrMapOvr', 'a:overrideClrMapping', 'attrs'])
324 if (sldClrMapOvr) clrMapOvr = sldClrMapOvr
325 else {
326 const sldClrMapOvr = getTextByPathList(slideLayoutContent, ['p:sldLayout', 'p:clrMapOvr', 'a:overrideClrMapping', 'attrs'])
327 if (sldClrMapOvr) clrMapOvr = sldClrMapOvr
328 else clrMapOvr = getTextByPathList(slideMasterContent, ['p:sldMaster', 'p:clrMap', 'attrs'])
329 }

Callers 1

processSingleSlideFunction · 0.90

Calls 7

getTextByPathListFunction · 0.90
getFillTypeFunction · 0.85
getSolidFillFunction · 0.85
getBgGradientFillFunction · 0.85
getBgPicFillFunction · 0.85
getPatternFillFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected