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.
26 #pragma warning(disable: 4917)
33 int main(int /*argc*/, char** /*argv*/)
36 if( FAILED( hr
=CoInitialize(NULL
)))
38 printf("CoInitialize failed \n");
42 if( FAILED(hr
=doTest()))
45 const CHAR
* errMsg
= err
.ErrorMessage();
46 MessageBoxA( NULL
, errMsg
, "Test failed", MB_ICONERROR
);
56 CComPtr
<IUnknown
> spUnkMgr
;
59 if( FAILED(hr
= spUnkMgr
.CoCreateInstance(L
"com.sun.star.ServiceManager")))
62 IDispatchPtr starManager
;
63 // var starManager=new ActiveXObject("com.sun.star.ServiceManager");
64 if (FAILED(hr
= starManager
.CreateInstance(_T("com.sun.star.ServiceManager"))))
66 fprintf(stderr
, "creating ServiceManager failed\n");
69 // var starDesktop=starManager.createInstance("com.sun.star.frame.Desktop");
70 _variant_t
varP1(L
"com.sun.star.frame.Desktop");
72 CComDispatchDriver
dispMgr(starManager
);
73 if (FAILED(hr
= dispMgr
.Invoke1(L
"createInstance", &varP1
, &varRet
)))
75 fprintf(stderr
,"createInstance of Desktop failed\n");
78 CComDispatchDriver
dispDesk(varRet
.pdispVal
);
81 // var bOK=new Boolean(true);
83 // var noArgs=new Array();
84 // var oDoc=starDesktop.loadComponentFromURL("private:factory/swriter", "Test", 40, noArgs);
86 SAFEARRAY
* ar
= SafeArrayCreateVector(VT_DISPATCH
, 0, 0);
88 args
[3]= _variant_t(L
"private:factory/swriter");
89 args
[2]= _variant_t(L
"Test");
90 args
[1]= _variant_t((long) 40);
91 args
[0].vt
= VT_ARRAY
| VT_DISPATCH
;
93 if (FAILED(hr
= dispDesk
.InvokeN(L
"loadComponentFromURL", args
, 4, &varRet
)))
95 fprintf(stderr
,"loadComponentFromURL failed\n");
98 CComDispatchDriver
dispDoc(varRet
.pdispVal
);
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */