-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(master): add modifier for slide master background color #86
- Loading branch information
Showing
4 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Automizer from '../src/automizer'; | ||
import { ModifyTextHelper } from '../src'; | ||
import ModifyBackgroundHelper from '../src/helper/modify-background-helper'; | ||
|
||
test('Auto-import source slideLayout and -master and modify background color', async () => { | ||
const automizer = new Automizer({ | ||
templateDir: `${__dirname}/pptx-templates`, | ||
outputDir: `${__dirname}/pptx-output`, | ||
autoImportSlideMasters: true, | ||
}); | ||
|
||
const pres = await automizer | ||
.loadRoot(`EmptyTemplate.pptx`) | ||
.load('SlideMasterBackgrounds.pptx') | ||
.addMaster(`SlideMasterBackgrounds.pptx`, 1, async (master) => { | ||
master.modify( | ||
ModifyBackgroundHelper.setSolidFill({ | ||
type: 'srgbClr', | ||
value: 'aaccbb', | ||
}), | ||
); | ||
}) | ||
.addSlide(`SlideMasterBackgrounds.pptx`, 3) | ||
.write(`modify-master-background-color.test.pptx`); | ||
|
||
expect(pres.masters).toBe(2); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { XmlDocument } from '../types/xml-types'; | ||
import ModifyColorHelper from './modify-color-helper'; | ||
import { Color } from '../types/modify-types'; | ||
|
||
export default class ModifyBackgroundHelper { | ||
/** | ||
* Set solid fill of modified shape | ||
*/ | ||
static setSolidFill = | ||
(color: Color) => | ||
(slideMasterXml: XmlDocument): void => { | ||
const bgPr = slideMasterXml.getElementsByTagName('p:bgPr')?.item(0); | ||
if (bgPr) { | ||
ModifyColorHelper.solidFill(color)(bgPr); | ||
} else { | ||
throw 'No background properties for slideMaster'; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters