1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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.
25 #pragma warning(disable : 4917)
32 int main(int /*argc*/, char** /*argv*/)
35 if (FAILED(hr
= CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
)))
37 printf("CoInitializeEx failed \n");
41 if (FAILED(hr
= doTest()))
44 const CHAR
* errMsg
= err
.ErrorMessage();
45 MessageBoxA(NULL
, errMsg
, "Test failed", MB_ICONERROR
);
55 CComPtr
<IUnknown
> spUnkMgr
;
57 if (FAILED(hr
= spUnkMgr
.CoCreateInstance(L
"com.sun.star.ServiceManager")))
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");
67 // var starDesktop=starManager.createInstance("com.sun.star.frame.Desktop");
68 _variant_t
varP1(L
"com.sun.star.frame.Desktop");
70 CComDispatchDriver
dispMgr(starManager
);
71 if (FAILED(hr
= dispMgr
.Invoke1(L
"createInstance", &varP1
, &varRet
)))
73 fprintf(stderr
, "createInstance of Desktop failed\n");
76 CComDispatchDriver
dispDesk(varRet
.pdispVal
);
79 // var bOK=new Boolean(true);
81 // var noArgs=new Array();
82 // var oDoc=starDesktop.loadComponentFromURL("private:factory/swriter", "Test", 40, noArgs);
84 SAFEARRAY
* ar
= SafeArrayCreateVector(VT_DISPATCH
, 0, 0);
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
;
91 if (FAILED(hr
= dispDesk
.InvokeN(L
"loadComponentFromURL", args
, 4, &varRet
)))
93 fprintf(stderr
, "loadComponentFromURL failed\n");
96 CComDispatchDriver
dispDoc(varRet
.pdispVal
);
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */