sergey-tihon / Clippit

Fresh PowerTools for OpenXml
https://sergey-tihon.github.io/Clippit/
MIT License
50 stars 19 forks source link

Feature: Support for custom content controls in DocumentAssembler #66

Open IvanDrag0 opened 1 year ago

IvanDrag0 commented 1 year ago

Currently, Clippit is capable of performing a number of actions using DocumentAssembler based on the text found in the content controls (Repeat, Table, Image, etc.). While those actions are very encompassing, would it be possible to add a way to either generate custom/additional actions (based on code) or a way to designate a specific word as a "miscellaneous" control that Clippit can read.

For example, instead of using the control to add pre-generated images, I want to be able to add images/diagrams on the fly using something like PlantUML:

Word:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est.

<Custom PlantUML="./Root/Diagram">

Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem.

XML:

<?xml version="1.0"?>
<Root>
    <Diagram>
        @startuml
        Bob -> Alice : hello
        @enduml
    </Diagram>
</Root>

Result:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est.

image

Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem.

That would probably also mean that the DocumentAssembler class would need a way to pass those custom functions and/or definitions (such as DocumentAssembler.AddCustom(funcName(), var value)) or a way to specify the code in the document/xml file.

sergey-tihon commented 1 year ago

would it be possible to add a way to either generate custom/additional actions (based on code) or a way to designate a specific word as a "miscellaneous" control that Clippit can read.

yes, if you are ready to work on it: propose a design, implementation, tests, and samples/docs.

I did a Markdown to PowerPoint slide generator in the past. When if insert the link, image or object (more complicated than text with formatting) you have to add new parts inside the package, add/update relationships between parts and generate unique rIds.

In general case, these custom/additional actions should has write access to the package and know how to update it correctly. At first sight, such an extensibility model looks complicated and fragile (at least for me)