bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / test / ole / cpptest / cpptest.cxx
blobd97489847399fe7b3e64b7651b7b4057b7933e96
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.
23 #ifdef _MSC_VER
24 #pragma once
25 #endif
26 #pragma warning(disable: 4917)
27 #include <comdef.h>
28 #include <atlbase.h>
29 #include <atlcom.h>
31 HRESULT doTest();
33 int main(int /*argc*/, char** /*argv*/)
35 HRESULT hr;
36 if( FAILED( hr=CoInitialize(NULL)))
38 printf("CoInitialize failed \n");
39 return -1;
42 if( FAILED(hr=doTest()))
44 _com_error err( hr);
45 const CHAR * errMsg= err.ErrorMessage();
46 MessageBoxA( NULL, errMsg, "Test failed", MB_ICONERROR);
49 CoUninitialize();
50 return 0;
53 HRESULT doTest()
55 HRESULT hr;
56 CComPtr<IUnknown> spUnkMgr;
59 if( FAILED(hr= spUnkMgr.CoCreateInstance(L"com.sun.star.ServiceManager")))
60 return hr;
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");
67 return hr;
69 // var starDesktop=starManager.createInstance("com.sun.star.frame.Desktop");
70 _variant_t varP1(L"com.sun.star.frame.Desktop");
71 _variant_t varRet;
72 CComDispatchDriver dispMgr(starManager);
73 if (FAILED(hr= dispMgr.Invoke1(L"createInstance", &varP1, &varRet)))
75 fprintf(stderr,"createInstance of Desktop failed\n");
76 return hr;
78 CComDispatchDriver dispDesk(varRet.pdispVal);
79 varP1.Clear();
80 varRet.Clear();
81 // var bOK=new Boolean(true);
83 // var noArgs=new Array();
84 // var oDoc=starDesktop.loadComponentFromURL("private:factory/swriter", "Test", 40, noArgs);
85 IDispatchPtr oDoc;
86 SAFEARRAY* ar= SafeArrayCreateVector(VT_DISPATCH, 0, 0);
87 _variant_t args[4];
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;
92 args[0].parray= ar;
93 if (FAILED(hr= dispDesk.InvokeN(L"loadComponentFromURL", args, 4, &varRet)))
95 fprintf(stderr,"loadComponentFromURL failed\n");
96 return hr;
98 CComDispatchDriver dispDoc(varRet.pdispVal);
99 varRet.Clear();
100 return S_OK;
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */