/* File: ListMenuNames.cpp Contains: Tool to list all of the menu names used by Acrobat and its plug-ins Written by: Mark Gavin Appligent, Inc. 22 East Baltimore Avenue Lansdowne, PA 19018-4129 ( 610 ) 284-4006 Copyright: ©1997-2007 by Appligent, Inc. Change History (most recent first): */ #include "CorCalls.h" #include "AVCalls.h" #include "PDCalls.h" #include "CosCalls.h" #include "ASCalls.h" #if MAC_PLATFORM #include "SafeResources.h" #endif #if WIN_ENV #include "resource.h" extern HINSTANCE gHINSTANCE ; #endif #include "TASUtils.h" #include "TAVUtils.h" #include "APReport.h" // -------------------------- ASAtom gProductASAtom ; // -------------------------- // Display the About box for the Print Page plug-in static ACCB1 void ACCB2 DoAboutListMenuNames( void * data ) { //TAVUtils::SimpleAlert( kAboutDlg ) ; return ; } // end DoAboutListMenuNames // -------------------------- static ACCB1 void ACCB2 ListMenu( AVMenubar inAVMenubar, const char * inMenuName, APReport* inReport ) { char theString[256] ; AVMenu theAVMenu = ( AVMenu )NULL ; AVMenuItem theAVMenuItem ; ASAtom theMenuItemName ; ASInt32 theMenuItemCount ; if ( ! inAVMenubar ) return ; theAVMenu = AVMenubarAcquireMenuByName ( inAVMenubar, inMenuName ) ; if ( ! theAVMenu ) return ; theMenuItemCount = AVMenuGetNumMenuItems ( theAVMenu ) ; for ( long index = 0; index < theMenuItemCount; index++ ) { theAVMenuItem = AVMenuAcquireMenuItemByIndex( theAVMenu, index ) ; theMenuItemName = AVMenuItemGetName ( theAVMenuItem ) ; const char * theStringPtr = ASAtomGetString ( theMenuItemName ) ; strcpy( theString, theStringPtr ) ; strcat( theString, "\r\n" ); inReport->Write( theString, strlen( theString ) ) ; ListMenu( inAVMenubar, theStringPtr, inReport ) ; } // end for } // end ListMenu // -------------------------- static ACCB1 void ACCB2 ListAllMenus( APReport* inReport ) { char theString[256] ; AVMenubar theAVMenubar = ( AVMenubar )NULL ; AVMenu theAVMenu = ( AVMenu )NULL ; AVMenuItem theAVMenuItem ; ASAtom theMenuName ; ASInt32 theMenuCount ; theAVMenubar = AVAppGetMenubar() ; // get the main menu if ( ! theAVMenubar ) return ; theMenuCount = AVMenubarGetNumMenus ( theAVMenubar ) ; for ( long index = 0; index < theMenuCount; index++ ) { theAVMenu = AVMenubarAcquireMenuByIndex ( theAVMenubar, index ) ; if ( ! theAVMenu ) return ; theMenuName = AVMenuGetName ( theAVMenu ) ; const char * theStringPtr = ASAtomGetString ( theMenuName ) ; strcpy( theString, "--" ) ; strcat( theString, theStringPtr ) ; strcat( theString, "\r\n" ); inReport->Write( theString, strlen( theString ) ) ; ListMenu( theAVMenubar, theStringPtr, inReport ) ; strcpy( theString, "\r\n" ); inReport->Write( theString, strlen( theString ) ) ; // add blank line AVMenuRelease ( theAVMenu ) ; } // end for } // end ListAllMenus // -------------------------- // Display the About box for the Print Page plug-in static ACCB1 void ACCB2 DoListMenuNames( void * data ) { char theString[256] ; char theTimeString[256] ; ASTimeRec theASTimeRec ; ASInt32 theError ; APReport * theLog = new APReport( "ListMenuNamesReport.txt" ) ; if ( theLog == NULL ) return ; strcpy( theString, "File generated by the ListMenuNames plug-in for Adobe Acrobat\r\n" ) ; theLog->Write( theString, strlen( theString ) ) ; strcpy( theString, "Written by Mark Gavin, mgavin@appligent.com\r\n" ) ; theLog->Write( theString, strlen( theString ) ) ; strcpy( theString, "Copyrighted 1997-2006 Appligent, Inc., http://www.appligent.com\r\n" ) ; theLog->Write( theString, strlen( theString ) ) ; strcpy( theString, "\r\n" ); theLog->Write( theString, strlen( theString ) ) ; // add blank line theError = TASUtils::GetLocalTime( &theASTimeRec ) ; memset( theString, 0, sizeof( theString ) ) ; memset( theTimeString, 0, sizeof( theTimeString ) ) ; theError = TASUtils::ASTimeRecToString( &theASTimeRec, theString, theTimeString ) ; strcat( theString, "\r\n" ); theLog->Write( theString, strlen( theString ) ) ; strcat( theTimeString, "\r\n" ); theLog->Write( theTimeString, strlen( theTimeString ) ) ; strcpy( theString, "\r\n" ); theLog->Write( theString, strlen( theString ) ) ; // add blank line ListAllMenus( theLog ) ; delete( theLog ) ; return ; } // end DoListMenuNames // ------------------------- #pragma mark -- init // ------------------------- static ACCB1 boolean ACCB2 InitPlugInMenus( void ) { AVMenubar theAVMenubar ; AVMenu theAVMenu ; ASInt16 theFlags = 0 ; DURING theAVMenubar = AVAppGetMenubar() ; if ( ! theAVMenubar ) E_RETURN( false ) ; TAVUtils::AppendToAboutMenu( "List Menu Names...", "DGAP:AboutListMenuNames", &DoAboutListMenuNames ) ; theAVMenu = AVMenubarAcquireMenuByName( theAVMenubar, "Extensions" ) ; if ( ! theAVMenu ) E_RETURN( false ) ; TAVUtils::AppendMenuItem( theAVMenu, "List Menu Names...", "DGAP:ListMenuNames", NULL, &DoListMenuNames ) ; HANDLER TASUtils::DisplayErrorAlert( ERRORCODE ) ; END_HANDLER return true ; } // end InitPlugInMenus // ------------------------- static ACCB1 boolean ACCB2 InitPlugIn( void ) { boolean theResult = true ; theResult = InitPlugInMenus() ; if ( theResult == false ) return theResult ; return theResult ; } // end InitPlugIn // ------------------------- static ACCB1 boolean ACCB2 UnloadPlugIn( void ) { return true ; } // end UnloadPlugIn // ------------------------- ACCB1 ASBool ACCB2 PIHandshake( Uns32 handshakeVersion, void *handshakeData ) { if ( handshakeVersion == HANDSHAKE_V0200 ) { PIHandshakeData_V0200 *hsData = ( PIHandshakeData_V0200 * )handshakeData ; hsData->extensionName = ASAtomFromString( "DGAP:ListMenuNames" ) ; hsData->exportHFTsCallback = NULL ; hsData->importReplaceAndRegisterCallback = NULL ; hsData->initCallback = ASCallbackCreateProto( PIInitProcType, ( void * )InitPlugIn ) ; hsData->unloadCallback = ASCallbackCreateProto( PIUnloadProcType, ( void * )UnloadPlugIn ) ; return true ; } return false ; } // end PIHandshake // -------------------------