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