Skip to main content
Participant
June 15, 2011
Question

How to interrupt/cancel save process

  • June 15, 2011
  • 2 replies
  • 7214 views

Hello,

Here is the situation : A user is working on an InDesign document with the plugin I develop. He clicks on the save button. At this moment, I would like to "catch" the save action to display a OK/Cancel dialog box. A click on OK will effectively save, while a Cancel click cancels the save action.

I have seen the signal system, but it only allows to be informed when a save is being to be processed. I did not see anything about canceling the save process. Is it possible ?

Thanks a lot.

This topic has been closed for replies.

2 replies

Legend
June 15, 2011

Search the SDK for IDocFileHandler.

To install, your document signal handler stores a classID of your implementation within kDocBoss[IID_ICLASSIDDATA], and from within you chain-call the boss/implementation that was previously stored there.

Dirk

Participating Frequently
June 15, 2011

First you should ask yourself if there is really any need to do this. It could be considered very annoying by the user and there is a reason this is not the default behavior.

If you still decide to go forward, you would typically use a CommandInterceptor to intercept the save command. This is done by creating an implementation of ICommandInterceptor that checks the Command ID in the InterceptProcessCommand method and then returns kCmdNotHandled to complete the save command or kCmdHandled to cancel the save command. You would also need to use a startup service to install the CommandInterceptor on the CommandProcessor.

Keep in mind that messing with CommandInterceptor can be very dangerous, especially when you choose to cancel the command via kCmdHandled. It's easy to make mistakes that mess up the document state or crashes InDesign if you are not prepared for a cancellation of a command.

Inspiring
June 16, 2011

[Note : I changed my account, I am the same user as xldperigee1. Sorry for inconvenience]

Dirk Becker wrote:

Search the SDK for IDocFileHandler.

To install, your document signal handler stores a classID of your implementation within kDocBoss[IID_ICLASSIDDATA], and from within you chain-call the boss/implementation that was previously stored there.

Dirk

I can't use signals because I really need to be able to interrupt the save process. Thank you for trying helping me

MTornros wrote:

First you should ask yourself if there is really any need to do this. It could be considered very annoying by the user and there is a reason this is not the default behavior.

I do not have really the choice. I am not a decision-maker. The plugin I develop interacts with another software that must be protected when an InDesign document is saved by checking some prerequisites.

Inspiring
June 17, 2011

I'm meeting a last problem : In my interceptor, how could I "filter" the commands ? Currently, I intercept every commands. I didn't see any link between a command and an actionID. I tried to use an ActionFilter, but didn't manage to make it work. Did I code with my feet, or was it not the right way to do it ?


Suggestions would be appreciated.

Regards.