1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 // cpptest.cpp : Defines the entry point for the console application.
35 #endif // _MSC_VER > 1000
36 #pragma warning(disable: 4917)
44 int main(int /*argc*/, char** /*argv*/)
47 if( FAILED( hr
=CoInitialize(NULL
)))
49 _tprintf(_T("CoInitialize failed \n"));
53 if( FAILED(hr
=doTest()))
56 const TCHAR
* errMsg
= err
.ErrorMessage();
57 MessageBox( NULL
, errMsg
, "Test failed", MB_ICONERROR
);
67 CComPtr
<IUnknown
> spUnkMgr
;
70 if( FAILED(hr
= spUnkMgr
.CoCreateInstance(L
"com.sun.star.ServiceManager")))
73 IDispatchPtr starManager
;
74 // var starManager=new ActiveXObject("com.sun.star.ServiceManager");
75 if (FAILED(hr
= starManager
.CreateInstance(_T("com.sun.star.ServiceManager"))))
77 fprintf(stderr
, "creating ServiceManager failed\n");
80 // var starDesktop=starManager.createInstance("com.sun.star.frame.Desktop");
81 _variant_t
varP1(L
"com.sun.star.frame.Desktop");
83 CComDispatchDriver
dispMgr(starManager
);
84 if (FAILED(hr
= dispMgr
.Invoke1(L
"createInstance", &varP1
, &varRet
)))
86 fprintf(stderr
,"createInstance of Desktop failed\n");
89 CComDispatchDriver
dispDesk(varRet
.pdispVal
);
92 // var bOK=new Boolean(true);
94 // var noArgs=new Array();
95 // var oDoc=starDesktop.loadComponentFromURL("private:factory/swriter", "Test", 40, noArgs);
97 SAFEARRAY
* ar
= SafeArrayCreateVector(VT_DISPATCH
, 0, 0);
99 args
[3]= _variant_t(L
"private:factory/swriter");
100 args
[2]= _variant_t(L
"Test");
101 args
[1]= _variant_t((long) 40);
102 args
[0].vt
= VT_ARRAY
| VT_DISPATCH
;;
104 if (FAILED(hr
= dispDesk
.InvokeN(L
"loadComponentFromURL", args
, 4, &varRet
)))
106 fprintf(stderr
,"loadComponentFromURL failed\n");
109 CComDispatchDriver
dispDoc(varRet
.pdispVal
);