Adobe(R) InDesign(TM) allows you to protect any custom data written by your plug-in when the document is opened in an environment without your plug-in. You can provide warnings and/or a FixUpData function to handle repairs.
Issue
My plug-in writes custom data to InDesign documents. How do I prevent problems if an end-user opens the document in an environment without the plug-in?
Solution
Your plug-in stores data as ClassIDs and ImplementationIDs and can specify the importance of each ID. There are 3 levels of importance:
- Default
Tells the end-user that the document contains data from a missing plug-in. The default warning message asks if they want to continue the open, and opens the original document if they decide to continue.
- Critical
Tells the end-user that the document contains data from a missing plug-in, and strongly advises them not to open the document. They can choose to continue, in which case the application opens a copy of the original as an untitled document to try to preserve the information.
This is done by adding a CriticalTags resource in your ODFRC Resource file. (See objectmodeltypes.fh for details.). This is how you would specify this in InDesign 2.x and CS.
resource CritcalTags(1)
{
kImplementationIDSpace,
{
kMyAdditionalPersistentDataImpl,
}
};
- Ignore
Doesn't put up a warning message and proceeds with the open as if the plug-in isn't missing. This is done by adding an IgnoreTags resource in your ODFRC resource file. (See objectmodeltypes.fh for details.). This is how you would specify this in InDesign 2.x and CS.
resource IgnoreTags(1)
{
kImplementationIDSpace,
{
kMyAdditionalPersistentDataImpl,
}
};
You can supply a custom
IPlugIn::FixUpData() method in your plug-in if there are checks your plug-in can do on opening a document that has been edited without your plug-in, to bring its data back in sync.
WARNING:
The IgnoreTags are generally safe to use for preferences, which are typically used only by the plug-in that adds it. However, if you are adding persistent data to other types of boss classes, like the
FrameLabel sample plug-in is doing, you should use some extra precautions to make sure that the additional persistent data from your plug-in isn't referred to by other subsystems in InDesign. Please note that the
FrameLabel sample plug-in also calls the
AddPageItemAdornmentCmd command, which adds the adornment boss class (by UID) into the list of adornments for a page item. This is also persisted into the document. If you do not have the plug-in that knows how to handle the adornment, the behavior may be unpredictable.