tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / extensions / test / ole / unoTocomCalls / Test / Test.cpp
blobb10900dbcd63faaf2112622b25668ae05c17dd31
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 // Test.cpp : Defines the entry point for the console application.
22 #include "stdafx.h"
23 #include "../XCallback_Impl/XCallback_Impl.h"
24 #include "../XCallback_Impl/XCallback_Impl_i.c"
26 CComModule _Module;
27 BEGIN_OBJECT_MAP(ObjectMap)
28 END_OBJECT_MAP()
30 HRESULT doTest();
32 int main(int argc, char* argv[])
34 HRESULT hr;
35 if( FAILED( hr=CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
37 _tprintf(_T("CoInitializeEx failed \n"));
38 return -1;
42 _Module.Init( ObjectMap, GetModuleHandle( NULL));
44 if( FAILED(hr=doTest()))
46 _com_error err( hr);
47 const TCHAR * errMsg= err.ErrorMessage();
48 MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
52 _Module.Term();
53 CoUninitialize();
56 return 0;
60 HRESULT doTest()
62 HRESULT hr= S_OK;
64 CComPtr<IUnknown> spUnk;
65 hr= spUnk.CoCreateInstance(L"com.sun.star.ServiceManager");
66 if( FAILED( hr))
67 return hr;
69 CComDispatchDriver manager( spUnk);
70 CComVariant param( L"oletest.OleTest");
71 CComVariant retVal;
72 hr= manager.Invoke1((LPCOLESTR)L"createInstance", &param, &retVal );
74 CComDispatchDriver oletest( retVal.punkVal);
76 spUnk.Release();
78 hr= spUnk.CoCreateInstance(L"XCallback_Impl.Callback");
79 if( FAILED( hr))
80 return hr;
82 CComQIPtr<IDispatch> paramDisp(spUnk);
86 // out parameters
88 CComVariant param1( paramDisp);
89 CComVariant param2(1);
91 // oletest calls XCallback::func1
92 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
93 // XCallback::returnInterface
94 param2= 2;
95 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
96 // XCallback::outInterface
97 param2= 3;
98 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
99 // XCallback::outStruct
100 param2= 4;
101 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
102 // XCallback::outEnum
103 param2= 5;
104 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
105 // XCallback::outSeqAny
106 param2= 6;
107 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
108 // XCallback::outAny
109 param2= 7;
110 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
111 // XCallback::outBool
112 param2= 8;
113 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
114 // XCallback::outChar
115 param2= 9;
116 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
117 // XCallback::outString
118 param2= 10;
119 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
120 // XCallback::outFloat
121 param2= 11;
122 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
123 // XCallback::outDouble
124 param2= 12;
125 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
126 // XCallback::outByte
127 param2= 13;
128 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
129 // XCallback::outShort
130 param2= 14;
131 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
132 // XCallback::outLong
133 param2= 15;
134 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
135 // XCallback::outValuesMixed
136 param2= 30;
137 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
138 // XCallback::outValuesAll
139 param2= 31;
140 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
142 // XCallback::outSeqByte
143 // Does not work currently because Sequences are always converted to
144 // SAFEARRAY( VARIANT)
145 // param2= 32;
146 // hr= oletest.Invoke2(L"testInterface", &param1, &param2);
149 // in / out parameters
151 // XCallback::inoutInterface
152 param2= 100;
153 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
154 // XCallback::inoutStruct
155 param2= 101;
156 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
157 // XCallback::inoutEnum
158 param2= 102;
159 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
160 // XCallback::inoutSeqAny
161 param2= 103;
162 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
163 // XCallback::inoutAny
164 param2= 104;
165 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
166 // XCallback::inoutBool
167 param2= 105;
168 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
169 // XCallback::inoutChar
170 param2= 106;
171 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
172 // XCallback::inoutString
173 param2= 107;
174 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
175 // XCallback::inoutFloat
176 param2= 108;
177 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
178 // XCallback::inoutDouble
179 param2= 109;
180 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
181 // XCallback::inoutByte
182 param2= 110;
183 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
184 // XCallback::inoutShort
185 param2= 111;
186 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
187 // XCallback::inoutLong
188 param2= 112;
189 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
190 // XCallback::inoutValuesAll
191 param2=120;
192 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
194 // in parameters
196 // XCallback::inValues
197 param2= 200;
198 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
199 // XCallback::inSeqByte
200 // SAFEARRAY( VARIANT)
201 param2= 201;
202 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
203 //XCallback::inSeqXEventListener
204 param2= 202;
205 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
207 // The UNO test component OleTest calls on XCallback_Impl.Callback directly
208 // that is the COM object has not been past a parameter but rather OleTest
209 // creates the COM object itself
211 // XCallback::outValuesAll
212 // does not work currently
213 param2= 300;
214 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
215 // XCallback::inoutValuesAll
216 param2= 301;
217 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
218 // XCallback::inoutValues
219 param2= 302;
220 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
222 // XCallback::inValues
223 param2= 303;
224 hr= oletest.Invoke2(L"testInterface", &param1, &param2);
226 // Test a COM object which implements several interfaces.
229 CComQIPtr<IDispatch> dispSimple;
230 hr= dispSimple.CoCreateInstance(L"XCallback_Impl.Simple");
231 CComVariant varSimple( dispSimple);
232 param2= 0;
233 hr= oletest.Invoke2(L"testInterface2", &varSimple, &param2);
235 return hr;
237 // VARIANT CComVariant VT_UNKNOWN VT_DISPATCH V_UI1 CComDispatchDriver WINAPI
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */