vscustompackage.zip
VsCustomPackage
Debug
Bined.dll
Docs
ExtendingProjects.doc
VSIPPackageCreationHandout.doc
SampleStuff
VsCustomPackage.def
VsCustomPackage.sln.2003
VsCustomPackage.suo.2003
VsCustomPackage.vcproj.2003
vscustompackage_spy.zip
VsCustomPackage-b3-final spy
VsCustomPackage.def
VsCustomPackage.sln.2003
VsCustomPackage.vcproj.2003
|
/**********************************************************************
- File Name: VsEditorFactory.cpp
- Date: 12/5/2003 4:58:09 PM
- Author: Michael Sheinin
- Description :
- Notes:
**********************************************************************/
#include "StdAfx.h"
#include "vseditorfactory.h"
#include "ServiceProvider.h"
#include "DocData.h"
#include "DocView.h"
#include "Mediator.h"
CVsEditorFactory::CVsEditorFactory()
{
//CDbg::Trace( " CVsEditorFactory::CVsEditorFactory()\n" );
m_pRealObject = NULL;
m_pServiceProvider = NULL;
}
CVsEditorFactory::~CVsEditorFactory()
{
CDbg::Trace( " CVsEditorFactory::~CVsEditorFactory()\n" );
m_pRealObject = NULL;
}
STDMETHODIMP CVsEditorFactory::QueryInterface(REFIID rid, void** ppObj )
{
CDbg::Trace( " CVsEditorFactory::QueryInterface\n" );
if ( m_pRealObject )
{
return m_pRealObject->QueryInterface(rid,ppObj);
}
*ppObj = NULL;
return E_INVALIDARG;
}
STDMETHODIMP_(ULONG) CVsEditorFactory::AddRef()
{
CDbg::Trace( " CVsEditorFactory::AddRef\n" );
if ( m_pRealObject )
{
return m_pRealObject->AddRef();
}
return 0;
}
STDMETHODIMP_(ULONG) CVsEditorFactory::Release()
{
CDbg::Trace( " CVsEditorFactory::Release\n" );
if ( m_pRealObject )
{
ULONG uRes = m_pRealObject->Release();
if ( uRes == 0 )
{
delete this;
}
return uRes;
}
return 0;
}
STDMETHODIMP CVsEditorFactory::CreateEditorInstance(DWORD dwFlg, LPCOLESTR pszDoc, LPOLESTR pszView,
void* pvHier, DWORD dwID, IUnknown* pDocDataExisting,
IUnknown** ppDocView, IUnknown** ppDocData, BSTR* pbsCapt,
GUID* pguidCmdUI, void** pCDW )
{
CDbg::Trace( " CVsEditorFactory::CreateEditorInstance\n" );
if ( wcsstr(pszDoc,L".bine") != NULL )//lame but good enough for 99% cases
{
static GUID guidCmd = {0x00380033,0x0043,0x0034,0x35,0x00,0x7D,0x00,0x00,0x00,0x1C,0x77};
CDocumentData* pDocData = new CDocumentData();
CDocumentView* pDocView = new CDocumentView();
CMediator* pMdtr = new CMediator();
if ( pDocData && pDocView && pMdtr )
{
pDocData->Attach( pMdtr );
pDocView->Attach( pMdtr );
*pbsCapt = NULL;
pDocData->QueryInterface(IID_IUnknown, (void**)ppDocData );//obtain correct pointer
pDocView->QueryInterface(IID_IUnknown, (void**)ppDocView );//obtain correct pointer
*pCDW = NULL;
*pguidCmdUI = guidCmd;
return S_OK;
}
}
else if ( m_pRealObject )
{
return m_pRealObject->CreateEditorInstance(dwFlg,pszDoc,pszView,pvHier,dwID,pDocDataExisting,
ppDocView,ppDocData, pbsCapt, pguidCmdUI, pCDW );
}
return E_FAIL;
}
STDMETHODIMP CVsEditorFactory::Stub4( IServiceProvider* pSP )
{
CDbg::Trace( " CVsEditorFactory::Stub4\n" );
if ( pSP )
{
m_pServiceProvider = pSP;
m_pServiceProvider->AddRef();
}
if ( m_pRealObject )
{
return m_pRealObject->Stub4( pSP );
}
return E_INVALIDARG;
}
STDMETHODIMP CVsEditorFactory::Stub5( )
{
CDbg::Trace( " CVsEditorFactory::Stub5\n" );
if ( m_pServiceProvider )
{
m_pServiceProvider->Release();
m_pServiceProvider = NULL;
}
if ( m_pRealObject )
{
return m_pRealObject->Stub5();
}
return E_INVALIDARG;
}
STDMETHODIMP CVsEditorFactory::Stub6( void* p1, void* p2)
{
CDbg::Trace( " CVsEditorFactory::Stub6() = S_OK\n" );
return S_OK; //xor eax,eax
}
BOOL CVsEditorFactory::Attach(void* pEditFact)
{
if ( m_pRealObject == NULL )
{
m_pRealObject = (IVsEditorFactory*)pEditFact;
return TRUE;
}
return FALSE;
}
|
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
For the last 7 years I have developed software in real-time/embedded and MS-Windows environments for military and civil markets. I hold B.Sc. degree in computer engineering. Living in Ontario, Canada, I like hiking and traveling in general. Currently, I'm looking for employment opportunity inside the GTA.