vstoundo-redopowerpoint-2013

PowerPoint 2013 VSTO Undo-Redo CustomerData or CustomXMLPart manipulation


I'm building a PowerPoint VSTO addin where I store a lot of metadata on the presentation.

I'm currently storing it as XML as either manipulating AddIn.Application.ActivePresentation.CustomXMLParts for global data and Slide.CustomerData for slide specific information.

The problem is that neither of them is represented on the Undo/Redo stack. I can make a quintrillion changes to the presentation and modify my Custom XML at the middle somewhere, undo everything and still read back the XML I have last set.

Since I want my modifications to be Undo/Redoable, the best I could think of is storing the XML on a Shape and delete+recreate it on every modification. The problem with this is that the user can obliviously delete the shape or the slide the shape is stored on.

I need something less visible (to prevent accidental removal) and - preferably global - object on the presentation that I can store my XML on that is deletable/recreatable and modifies that Undo/Redo stack.

Is there something like this?

Or is there a better way to do this?


Solution

  • To answer my own question:

    There is Tags!

    When you add something to it with Tags.Add("Name", "Value") it is properly undoable, unlike CustomerData or CustomXMLParts.

    Tags is present on the presentation and on the slides so both of my scenarios are covered.