tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / extensions / test / ole / cpptest / cpptest.cxx
blobff083a05220c15827c3d9905d5c31c219266966c
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 .
20 // cpptest.cpp : Defines the entry point for the console application.
22 #ifdef _MSC_VER
23 #pragma once
24 #endif
25 #pragma warning(disable : 4917)
26 #include <comdef.h>
27 #include <atlbase.h>
28 #include <atlcom.h>
30 HRESULT doTest();
32 int main(int /*argc*/, char** /*argv*/)
34 HRESULT hr;
35 if (FAILED(hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
37 printf("CoInitializeEx failed \n");
38 return -1;
41 if (FAILED(hr = doTest()))
43 _com_error err(hr);
44 const CHAR* errMsg = err.ErrorMessage();
45 MessageBoxA(NULL, errMsg, "Test failed", MB_ICONERROR);
48 CoUninitialize();
49 return 0;
52 HRESULT doTest()
54 HRESULT hr;
55 CComPtr<IUnknown> spUnkMgr;
57 if (FAILED(hr = spUnkMgr.CoCreateInstance(L"com.sun.star.ServiceManager")))
58 return hr;
60 IDispatchPtr starManager;
61 // var starManager=new ActiveXObject("com.sun.star.ServiceManager");
62 if (FAILED(hr = starManager.CreateInstance(_T("com.sun.star.ServiceManager"))))
64 fprintf(stderr, "creating ServiceManager failed\n");
65 return hr;
67 // var starDesktop=starManager.createInstance("com.sun.star.frame.Desktop");
68 _variant_t varP1(L"com.sun.star.frame.Desktop");
69 _variant_t varRet;
70 CComDispatchDriver dispMgr(starManager);
71 if (FAILED(hr = dispMgr.Invoke1(L"createInstance", &varP1, &varRet)))
73 fprintf(stderr, "createInstance of Desktop failed\n");
74 return hr;
76 CComDispatchDriver dispDesk(varRet.pdispVal);
77 varP1.Clear();
78 varRet.Clear();
79 // var bOK=new Boolean(true);
81 // var noArgs=new Array();
82 // var oDoc=starDesktop.loadComponentFromURL("private:factory/swriter", "Test", 40, noArgs);
83 IDispatchPtr oDoc;
84 SAFEARRAY* ar = SafeArrayCreateVector(VT_DISPATCH, 0, 0);
85 _variant_t args[4];
86 args[3] = _variant_t(L"private:factory/swriter");
87 args[2] = _variant_t(L"Test");
88 args[1] = _variant_t((long)40);
89 args[0].vt = VT_ARRAY | VT_DISPATCH;
90 args[0].parray = ar;
91 if (FAILED(hr = dispDesk.InvokeN(L"loadComponentFromURL", args, 4, &varRet)))
93 fprintf(stderr, "loadComponentFromURL failed\n");
94 return hr;
96 CComDispatchDriver dispDoc(varRet.pdispVal);
97 varRet.Clear();
98 return S_OK;
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */