Skip to main content
Inspiring
October 28, 2021
Answered

InDesign Library - Block Addition of Frames

  • October 28, 2021
  • 1 reply
  • 198 views

Hi,

 

I want to block addition of frames to InDesign Library. (*.indl).

 

I am observing kSnippetBasedCatalogBoss and catpure the command kLibraryAddItemCmdBoss with message kBeforeDoMessageBoss.

 

From kLibraryAddItemCmdBoss, I am able to identify which frames are being added by the user and I can decide whether to block the addition of frames or not.

 

From Observer, I set ErrorUtils::PMSetGlobalErrorCode(kCancel) when kLibraryAddItemCmdBoss &&  kBeforeDoMessageBoss command is executed.

 

The above method works and it doesn't allow frame to be added in Library.

 

But then it display the following message as shown in the screenshot -

 

 

I don't want any message to be displayed.

 

I also tried the following -

 

1. With kLibraryAddItemCmdBoss, we have ICopyCmdData interface, from where I get IDataExchangeHandler and call IDataExchangeHandler->Clear().

 

InDesign still displays the error message.

 

2. I added my own error ErrorStringService and passed my own error in ErrorUtils::PMSetGlobalErrorCode(kMyErrorCode) but then InDesign Crashes.

 

Am I observing correct boss class kSnippetBasedCatalogBoss and obsering right command kLibraryAddItemCmdBoss ?

 

Can anyone help me on this ?

 

Regards,

Rahul Rastogi

 

This topic has been closed for replies.
Correct answer Rahul_Rastogi

Found the solution -

 

 if(::GetClass(iCommand) == kLibraryAddItemCmdBoss && theChange == kBeforeDoMessageBoss)
{

InterfacePtr<ILibraryCmdData> iLibraryCmdData(iCommand, IID_ILIBRARYCMDDATA);
if(!iLibraryCmdData)
break;

iDestLibrary = iLibraryCmdData->GetDestLibrary();
}
else if(::GetClass(iCommand) == kLibraryAddItemCmdBoss && theChange == kAfterDoMessageBoss)
{

InterfacePtr<ILibraryCmdData> iLibraryCmdData(iCommand, IID_ILIBRARYCMDDATA);
if(!iLibraryCmdData)
break;

AssetIDList assetIDList = iLibraryCmdData->GetAssetList();

Utils<ILibraryCmdUtils>()->ProcessLibraryDeleteItemsCmd(assetIDList, iDestLibrary);


// set the global error to kSuccess otherwise InDesign displays message "disk is full".
ErrorUtils::PMSetGlobalErrorCode(kSuccess);

}

1 reply

Rahul_RastogiAuthorCorrect answer
Inspiring
October 29, 2021

Found the solution -

 

 if(::GetClass(iCommand) == kLibraryAddItemCmdBoss && theChange == kBeforeDoMessageBoss)
{

InterfacePtr<ILibraryCmdData> iLibraryCmdData(iCommand, IID_ILIBRARYCMDDATA);
if(!iLibraryCmdData)
break;

iDestLibrary = iLibraryCmdData->GetDestLibrary();
}
else if(::GetClass(iCommand) == kLibraryAddItemCmdBoss && theChange == kAfterDoMessageBoss)
{

InterfacePtr<ILibraryCmdData> iLibraryCmdData(iCommand, IID_ILIBRARYCMDDATA);
if(!iLibraryCmdData)
break;

AssetIDList assetIDList = iLibraryCmdData->GetAssetList();

Utils<ILibraryCmdUtils>()->ProcessLibraryDeleteItemsCmd(assetIDList, iDestLibrary);


// set the global error to kSuccess otherwise InDesign displays message "disk is full".
ErrorUtils::PMSetGlobalErrorCode(kSuccess);

}