-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVGAppPlugin.cpp
More file actions
165 lines (143 loc) · 4.94 KB
/
Copy pathVGAppPlugin.cpp
File metadata and controls
165 lines (143 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "stdafx.h"
namespace local {
VGAppPlugin::VGAppPlugin() {
}
VGAppPlugin::~VGAppPlugin() {
}
COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE VGAppPlugin::GetTypeInfoCount(UINT* pctinfo) {
LOGINFO("{}", __FUNCTION__);
return E_NOTIMPL;
}
COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE VGAppPlugin::GetTypeInfo(
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) {
LOGINFO("{}", __FUNCTION__);
return E_NOTIMPL;
}
COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE VGAppPlugin::GetIDsOfNames(
REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) {
LOGINFO("{}(DISPID({}),LPOLESTR({}))", __FUNCTION__, rgDispId ? *rgDispId : 0, rgszNames ? shared::IConv::WStringToMBytes(*rgszNames) : "");
return E_NOTIMPL;
}
COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE VGAppPlugin::Invoke(
DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) {
HRESULT result = S_OK;
switch (dispIdMember) {
case 0x0008: {//!@ OnSave???
}break;
case 0x0011: {//!@ DISPID_APP_SELCHANGE
}break;
case 0x0012: {//!@ DISPID_APP_START
LOGINFO("{}({})", __FUNCTION__, "DISPID_APP_START");
}break;
case 0x0014: {//!@ DISPID_APP_ONPLUGINCMD
}break;
case 0x0015: {//!@ DISPID_APP_ONPLUGINCMDSTATE
}break;
default:
break;
}
LOGINFO("{}(dispIdMember=={})", __FUNCTION__, dispIdMember);
return result;
}
COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE VGAppPlugin::raw_OnLoad(VGCore::IVGApplication* Application) {
LOGINFO("{}", __FUNCTION__);
HRESULT result = S_OK;
do {
m_pVGApplication = Application;
if (m_pVGApplication)
m_pVGApplication->AddRef();
} while (0);
return result;
}
COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE VGAppPlugin::raw_StartSession(void) {
HRESULT result = S_OK;
do {
//VARIANT_BOOL success = VARIANT_TRUE;
//VGCore::ICUICommandBarPtr pMainMenu = nullptr;
//m_pVGApplication->get_MainMenu(&pMainMenu);
//auto sss = pMainMenu->GetControls();
//sss->AddCustomButton(_bstr_t("ClearFill"), _bstr_t("Clear Fill"), 0,success);
//m_pVGApplication->raw_AddPluginCommand(_bstr_t("ClearFill"), _bstr_t("Clear Fill"), _bstr_t("Clears fill from selected objects"), &success);
//LOGINFO("raw_AddPluginCommand({}) on ({})", success == VARIANT_TRUE ? "success" : "failed", __FUNCTION__);
//auto pCmds = m_pVGApplication->GetCommandBars();
//auto pCreate = pCmds->Add(_bstr_t("ClearFill"), VGCore::cuiBarPosition::cuiBarLeft, success);
//m_pVGApplication->AddPluginCommand(_bstr_t("ClearFill"), _bstr_t("Clear Fill"), _bstr_t("Clears fill from selected objects"));
//auto pControlPtr= m_pVGApplication->CommandBars->Item[_bstr_t("Standard")]->Controls->AddCustomButton(VGCore::cdrCmdCategoryPlugins, _bstr_t("ClearFill"), 0, VARIANT_TRUE);
/*VGCore::CommandBarControlPtr ctl = */
/*_bstr_t bstrPath(m_pVGApplication->Path + _bstr_t("Plugins\\ClearFill.bmp"));
pControlPtr->SetCustomIcon(bstrPath);*/
//m_lCookie = m_pVGApplication->AdviseEvents(this);
m_lCookie = m_pVGApplication->AdviseEvents(this);
} while (0);
LOGINFO("{}({}({}))", __FUNCTION__, "m_lCookie", m_lCookie);
return result;
}
COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE VGAppPlugin::raw_StopSession(void) {
HRESULT result = S_OK;
do {
result = m_pVGApplication->UnadviseEvents(m_lCookie);
} while (0);
LOGINFO("{}", __FUNCTION__);
return result;
}
COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE VGAppPlugin::raw_OnUnload(void) {
HRESULT result = S_FALSE;
do {
if (!m_pVGApplication)
break;
m_pVGApplication->Release();
m_pVGApplication = nullptr;
result = S_OK;
} while (0);
LOGINFO("{}", __FUNCTION__);
return result;
}
HRESULT STDMETHODCALLTYPE VGAppPlugin::QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR* __RPC_FAR* ppvObject) {
*ppvObject = nullptr;
HRESULT result = S_OK;
m_ulRefCount++;
if (riid == IID_IUnknown)
{
*ppvObject = (IUnknown*)this;
LOGINFO("{}({})", __FUNCTION__, R"(*ppvObject = (IUnknown*)this)");
}
else if (riid == IID_IDispatch)
{
*ppvObject = (IDispatch*)this;
LOGINFO("{}({})", __FUNCTION__, R"(*ppvObject = (IDispatch*)this)");
}
else if (riid == __uuidof(VGCore::IVGAppPlugin))
{
*ppvObject = (VGCore::IVGAppPlugin*)this;
LOGINFO("{}({})", __FUNCTION__, R"(*ppvObject = (VGCore::IVGAppPlugin*)this)");
}
else
{
m_ulRefCount--;
result = E_NOINTERFACE;
LOGINFO("{}({})", __FUNCTION__, R"(m_ulRefCount--)");
}
return result;
}
ULONG STDMETHODCALLTYPE VGAppPlugin::AddRef(void) {
ULONG result = 0;
do {
result = m_ulRefCount++;
} while (0);
LOGINFO("{}", __FUNCTION__);
return result;
}
ULONG STDMETHODCALLTYPE VGAppPlugin::Release(void) {
ULONG result = 0;
do {
ULONG ulCount = --m_ulRefCount;
if (ulCount <= 0)
delete this;
result = ulCount;
} while (0);
LOGINFO("{}", __FUNCTION__);
return result;
}
}///namespace local