Altova Authentic 2024 Desktop

El código de este apartado muestra una sencilla implementación de un complemento de Authentic Desktop para entornos IDE. Añade un comando de menú y un separador (disponible con Authentic Desktop) al menú Herramientas. Dentro del método OnUpdateCommand() el comando nuevo solamente se habilita cuando el documento activo se abre en la vista Cuadrícula. El comando busca el elemento XML que está resaltado y abre cualquier dirección URL empezando con "http://" a partir del valor textual del elemento.

 

/////////////////////////////////////////////////////////////////////////////

// CXMLSpyIDEPlugIn

 

#import "XMLSpy.tlb"

using namespace XMLSpyLib;

 

HRESULT CXMLSpyIDEPlugIn::OnCommand(long nID, IDispatch* pXMLSpy)

{

 USES_CONVERSION;

 

 if(nID == 1)        {

         IApplicationPtr        ipSpyApp;

         

         if(pXMLSpy)        {

                 if(SUCCEEDED(pXMLSpy->QueryInterface(__uuidof(IApplication),(void **)&ipSpyApp))) {

                         IDocumentPtr        ipDocPtr = ipSpyApp->ActiveDocument;

 

                         // imaginamos que la vista Cuadrícula está activa

                         if(ipDocPtr)        {

                                 IGridViewPtr        ipGridPtr = ipDocPtr->GridView;

 

                                 if(ipGridPtr)        {

                                         IXMLDataPtr                ipXMLData = ipGridPtr->CurrentFocus;

 

                                         CString        strValue = W2T(ipXMLData->TextValue);

 

                                         if(!strValue.IsEmpty() && (strValue.Left(7) == _T("http://")))

                                                 ::ShellExecute(NULL,_T("open"),W2T(ipXMLData->TextValue),NULL,NULL,SW_SHOWNORMAL);

                                 }

                         }

                 }

         }

 }

 

 return S_OK;

}

 

 

HRESULT CXMLSpyIDEPlugIn::OnUpdateCommand(long nID, IDispatch* pXMLSpy, SPYUpdateAction* pAction)

{

 *pAction = spyDisable;

 

 if(nID == 1)        {

         IApplicationPtr        ipSpyApp;

         

         if(pXMLSpy)        {

                 if(SUCCEEDED(pXMLSpy->QueryInterface(__uuidof(IApplication),(void **)&ipSpyApp)))        {

                         IDocumentPtr        ipDocPtr = ipSpyApp->ActiveDocument;

 

                         // habilitar solamente si la vista Cuadrícula está activa

                         if((ipDocPtr != NULL) && (ipDocPtr->CurrentViewMode == spyViewGrid))

                                 *pAction = spyEnable;

                 }

         }

 }

 

 return S_OK;

}

 

 

HRESULT CXMLSpyIDEPlugIn::OnEvent(long nEventID, SAFEARRAY **arrayParameters, IDispatch* pXMLSpy, VARIANT* pReturnValue)

{

 return S_OK;

}

 

HRESULT CXMLSpyIDEPlugIn::GetUIModifications(BSTR* pModificationsXML)

{

 CComBSTR        bstrMods = _T(" \

                         <ConfigurationData>        \

                                 <Modifications>        ");

 // agregar "Abrir URL..." al menú Herramientas

 bstrMods.Append (_T(" \

                                         <Modification> \

                                                 <Action>Add</Action> \

                                                 <UIElement type=\"MenuItem\"> \

                                                         <ID>1</ID> \

                                                         <Name>Abrir URL...</Name> \

                                                         <Place>0</Place> \

                                                         <MenuID>129</MenuID> \

                                                         <Parent>:Herramientas</Parent> \

                                                 </UIElement> \

                                         </Modification>        "));

 // agregar separador al menú Herramientas

 bstrMods.Append (_T(" \

                                         <Modification> \

                                                 <Action>Add</Action> \

                                                 <UIElement type=\"MenuItem\"> \

                                                         <ID>0</ID> \

                                                         <Place>1</Place> \

                                                         <MenuID>129</MenuID> \

                                                         <Parent>:Herramientas</Parent> \

                                                 </UIElement> \

                                         </Modification>        "));

 // finalizar descripción de la modificación

 bstrMods.Append (_T(" \

                                 </Modifications> \

                         </ConfigurationData>"));

 

 return bstrMods.CopyTo(pModificationsXML);

}

 

 

HRESULT CXMLSpyIDEPlugIn::GetDescription(BSTR* pDescription)

{

 CComBSTR        bstrDescr = _T("ATL C++ XMLSpy IDE PlugIn;Este complemento demuestra la implementación de un DLL ATL sencillo como complemento de XMLSpy para entornos IDE.");

 return bstrDescr.CopyTo(pDescription);

}

 

© 2017-2023 Altova GmbH