bool AP_App::openCmdLinePlugins(const AP_Args * Args, bool &bSuccess) { if(Args->m_sPluginArgs) { // // Start a plugin rather than the main abiword application. // const char * szName = NULL; XAP_Module * pModule = NULL; const char * szRequest = NULL; bool bFound = false; if(Args->m_sPluginArgs[0]) { szRequest = Args->m_sPluginArgs[0]; const UT_GenericVector<XAP_Module*> * pVec = XAP_ModuleManager::instance().enumModules (); UT_DEBUGMSG((" %d plugins loaded \n",pVec->getItemCount())); for (UT_sint32 i = 0; (i < pVec->size()) && !bFound; i++) { pModule = pVec->getNthItem (i); szName = pModule->getModuleInfo()->name; UT_DEBUGMSG(("%s\n", szName)); if(strcmp(szName,szRequest) == 0) { bFound = true; } } } if(!bFound) { fprintf(stderr, "Plugin %s not found or loaded \n",szRequest); bSuccess = false; return false; } // // You must put the name of the ev_EditMethod in the usage field // of the plugin registered information. // const char * evExecute = pModule->getModuleInfo()->usage; EV_EditMethodContainer* pEMC = Args->getApp()->getEditMethodContainer(); const EV_EditMethod * pInvoke = pEMC->findEditMethodByName(evExecute); if(!pInvoke) { fprintf(stderr, "Plugin %s invoke method %s not found \n", Args->m_sPluginArgs[0],evExecute); bSuccess = false; return false; } // // Execute the plugin, then quit // UT_String *sCommandLine = Args->getPluginOptions(); ev_EditMethod_invoke(pInvoke, *sCommandLine); delete sCommandLine; return false; } return true; }
/*! * A callback for AP_Args's doWindowlessArgs call which handles * platform-specific windowless args. * return false if we should exit normally but Window should not be displayed */ bool AP_Win32App::doWindowlessArgs(const AP_Args *Args, bool & bSuccess) { bSuccess = true; AP_Win32App * pMyWin32App = static_cast<AP_Win32App*>(Args->getApp()); if (Args->m_sGeometry) { // [--geometry <X geometry string>] #if 0 gint x = 0; gint y = 0; guint width = 0; guint height = 0; XParseGeometry(Args->m_sGeometry, &x, &y, &width, &height); // set the xap-level geometry for future frame use Args->getApp()->setGeometry(x, y, width, height, f); #endif parseAndSetGeometry(Args->m_sGeometry); } else if (Args->m_sPrintTo) { if (Args->m_sFiles[0]) { UT_DEBUGMSG(("DOM: Printing file %s\n", Args->m_sFiles[0])); AP_Convert conv ; if (Args->m_sMerge) conv.setMergeSource (Args->m_sMerge); if (Args->m_impProps) conv.setImpProps (Args->m_impProps); if (Args->m_expProps) conv.setExpProps (Args->m_expProps); UT_String s = "AbiWord: "; s+= Args->m_sFiles[0]; UT_Win32LocaleString prn, doc; prn.fromASCII (Args->m_sPrintTo); doc.fromASCII (s.c_str()); GR_Graphics * pG = GR_Win32Graphics::getPrinterGraphics(prn.c_str(), doc.c_str()); if(!pG) { // do not assert here, if the graphics creation failed, the static // constructor has asserted already somewhere more relevant return false; } conv.setVerbose(Args->m_iVerbose); conv.print (Args->m_sFiles[0], pG, Args->m_sFileExtension); delete pG; } else { // couldn't load document UT_DEBUGMSG(("Error: no file to print!\n")); bSuccess = false; } return false; } if(Args->m_sPluginArgs) { // // Start a plugin rather than the main abiword application. // const char * szName = NULL; XAP_Module * pModule = NULL; bool bFound = false; if(Args->m_sPluginArgs[0]) { const char * szRequest = Args->m_sPluginArgs[0]; const UT_GenericVector<XAP_Module*> * pVec = XAP_ModuleManager::instance().enumModules (); UT_DEBUGMSG((" %d plugins loaded \n",pVec->getItemCount())); for (UT_sint32 i = 0; (i < pVec->size()) && !bFound; i++) { pModule = pVec->getNthItem (i); szName = pModule->getModuleInfo()->name; UT_DEBUGMSG(("%s\n", szName)); if(strcmp(szName,szRequest) == 0) { bFound = true; } } } if(!bFound) { UT_DEBUGMSG(("Plugin %s not found or loaded \n",Args->m_sPluginArgs[0])); bSuccess = false; return false; } // // You must put the name of the ev_EditMethod in the usage field // of the plugin registered information. // const char * evExecute = pModule->getModuleInfo()->usage; EV_EditMethodContainer* pEMC = pMyWin32App->getEditMethodContainer(); const EV_EditMethod * pInvoke = pEMC->findEditMethodByName(evExecute); if(!pInvoke) { UT_DEBUGMSG(("Plugin %s invoke method %s not found \n", Args->m_sPluginArgs[0],evExecute)); bSuccess = false; return false; } // // Execute the plugin, then quit // ev_EditMethod_invoke(pInvoke, UT_String("Called From App")); return false; } return true; }
bool ev_EditMethod_invoke (const UT_String& methodName, const UT_UCS4String & data) { return ev_EditMethod_invoke ( methodName.c_str(), data ) ; }
bool ev_EditMethod_invoke (const char * methodName, const UT_UCSChar * data) { UT_return_val_if_fail(data, false); return ev_EditMethod_invoke ( methodName, UT_UCS4String(data) ) ; }
bool ev_EditMethod_invoke (const char * methodName, const UT_UCS4String & data) { return ev_EditMethod_invoke ( ev_EditMethod_lookup ( methodName ), data ) ; }
bool ev_EditMethod_invoke (const EV_EditMethod * pEM, const UT_UCS4String & data) { EV_EditMethodCallData callData ( data.ucs4_str(), static_cast<UT_uint32>(data.size()) ) ; return ev_EditMethod_invoke ( pEM, &callData ) ; }