~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to lib/cppunit-1.10.0/src/msvc6/DSPlugIn/DSAddIn.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// AddInMod.cpp : implementation file
 
2
//
 
3
 
 
4
#include "stdafx.h"
 
5
 
 
6
#include "DSPlugIn.h"
 
7
#include "COMHelper.h"
 
8
#include "DSAddIn.h"
 
9
 
 
10
#ifdef _DEBUG
 
11
#define new DEBUG_NEW
 
12
#undef THIS_FILE
 
13
static char THIS_FILE[] = __FILE__;
 
14
#endif
 
15
 
 
16
 
 
17
COMUtility::COMExceptionThrower CDSAddIn::cex_;
 
18
 
 
19
CDSAddIn::~CDSAddIn( void)
 
20
{
 
21
}
 
22
 
 
23
// This is called when the user first loads the add-in, and on start-up
 
24
//  of each subsequent Developer Studio session
 
25
STDMETHODIMP CDSAddIn::OnConnection(IApplication* pApp, VARIANT_BOOL bFirstTime,
 
26
                long dwCookie, VARIANT_BOOL* OnConnection)
 
27
{
 
28
  HRESULT result = S_OK;
 
29
 
 
30
  try
 
31
  {
 
32
    CComPtr< IUnknown> pIUnk;
 
33
 
 
34
          AFX_MANAGE_STATE(AfxGetStaticModuleState());
 
35
 
 
36
    cex_ = _Module.GetClassObject( GetObjectCLSID(), IID_IUnknown, reinterpret_cast<void**>(&pIUnk));
 
37
 
 
38
    cex_ = CoRegisterClassObject( 
 
39
      GetObjectCLSID(),
 
40
      pIUnk,
 
41
      CLSCTX_LOCAL_SERVER,
 
42
      REGCLS_MULTIPLEUSE,
 
43
      &classRegistrationId_
 
44
      );
 
45
 
 
46
    pIApp_ = pApp;
 
47
 
 
48
    m_dwCookie = dwCookie;
 
49
    *OnConnection = VARIANT_TRUE;
 
50
  }
 
51
  catch( const std::bad_cast&)
 
52
  {
 
53
    *OnConnection = VARIANT_FALSE;
 
54
  }
 
55
  catch( const _com_error&)
 
56
  {
 
57
    *OnConnection = VARIANT_FALSE;
 
58
  }
 
59
 
 
60
  return result;
 
61
}
 
62
 
 
63
// This is called on shut-down, and also when the user unloads the add-in
 
64
STDMETHODIMP CDSAddIn::OnDisconnection(VARIANT_BOOL bLastTime)
 
65
{
 
66
  pIApp_.Release();
 
67
  CoRevokeClassObject( classRegistrationId_);
 
68
 
 
69
        return S_OK;
 
70
}
 
71
 
 
72
 
 
73
// ITestRunnerDSPlugin
 
74
STDMETHODIMP CDSAddIn::goToLineInSourceCode( BSTR fileName, int lineNumber)
 
75
{
 
76
  HRESULT result = S_OK;
 
77
 
 
78
        AFX_MANAGE_STATE(AfxGetStaticModuleState());
 
79
 
 
80
  try
 
81
  {
 
82
    CComPtr< IDispatch> tmp;
 
83
    CComPtr< IDocuments> pIDocuments;
 
84
    CComPtr< ITextDocument> pITextDocu;
 
85
    CComPtr< ITextSelection> pITextSel;
 
86
 
 
87
    cex_ = pIApp_->get_Documents( &tmp);
 
88
    pIDocuments.Attach( COMUtility::interface_cast<IDocuments>( tmp.p));
 
89
    tmp.Release();
 
90
    cex_ = pIDocuments->Open( fileName,
 
91
                             CComVariant(),
 
92
                             CComVariant(),
 
93
                             &tmp);
 
94
    pITextDocu.Attach( COMUtility::interface_cast< ITextDocument>( tmp.p));
 
95
    tmp.Release();
 
96
    cex_ = pITextDocu->get_Selection( &tmp);
 
97
    pITextSel.Attach( COMUtility::interface_cast< ITextSelection>( tmp.p));
 
98
    cex_ = pITextSel->GoToLine( lineNumber, CComVariant( 1));
 
99
  }
 
100
  catch( const std::bad_cast&)
 
101
  {
 
102
    result = E_FAIL;
 
103
  }
 
104
  catch( const _com_error&)
 
105
  {
 
106
    result = E_FAIL;
 
107
  }
 
108
  
 
109
  return result;
 
110
}