I've never used this but it sounds like that's what you need here.
That's kinda what I thought too. But it only works if the master item has not been deleted from the page or overridden. I've searched through the PageItems entry in the object model viewer several times, but can't find anything else. I don't want to override the item: I want to reinstate it to the page.
Hmmm... you could check the 'overridden' property for existing items (it'll only be true if the object was on a master page and also overridden), but that does not work for deleted items. The same goes for 'overriddenMasterPageItem'.
What you need is a list of 'overridden items', which may or may not still be on the page ...
What if you compare the page items on the applied master page against the actual page's masterPageItems?
"masterPageItems [..] The items on a specified document page that originated on the applied master page and have not been overridden or detached" (my emphasis)
The difference should be something that has been overridden or removed ... I think ...
Thanks for your posts, Jongware.
I don't think that page.masterPageItems will help, because it's a list of overridden and detached items, not deleted ones. It won't help to 'undelete' the master item, or to re-apply that specific master item to the document's page, without re-applying the whole master.
I think I might have to give up and just duplicate the master item onto the document pages where it's been deleted, and just live with its not being a part of the master page any more -- just means that any future changes to those objects would have to be done manually.
I guess it makes sense that you can't re-instate just one item from a master onto a page, because you can't do it manually using InDesign's UI. It's all or nothing!
If a page item is detached from the master, there's nothing connecting to to the master, so short of comparing the bounds or some other property, there's no way of knowing what master item it originated from.
If you are not dealing with detached items (only overridden or deleted items, then you can iterate through all the page items and if none are based on your master item (or if none of the page.masterPageItems are your item), it was deleted.
FWIW, If you want something to take care of reapplied master pages, you might want to check out AutoFlow Pro.
Thanks Harbs. Sounds like there is no way of restoring a master page item that's been deleted from a page, by script. I'll just duplicate the master object onto the page.