merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / cppuhelper / test / testdefaultbootstrapping.cxx
blobfce0a1242a827be2fbfe7d1db83b4ec68cbeedcd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_cppuhelper.hxx"
32 #include <sal/main.h>
36 #include <cstdio>
38 #include <rtl/process.h>
39 #include <cppuhelper/bootstrap.hxx>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
43 using namespace ::cppu;
44 using namespace ::com::sun::star::lang;
45 using namespace ::com::sun::star::uno;
46 using namespace ::rtl;
49 SAL_IMPLEMENT_MAIN()
51 sal_Bool result = sal_True;
53 try {
54 Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext();
56 Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY);
58 for(sal_uInt32 i = 0; i < rtl_getAppCommandArgCount(); ++ i) {
59 OUString arg;
61 rtl_getAppCommandArg(i, &arg.pData);
62 if (arg.getLength())
64 Reference<XInterface> xInterface = smgr->createInstance(arg);
65 OString tmp = OUStringToOString(arg, RTL_TEXTENCODING_ASCII_US);
66 #if OSL_DEBUG_LEVEL > 1
67 fprintf(stderr, "got the %s service %p\n", tmp.getStr(), xInterface.get());
68 #endif
70 result = result && (xInterface.get() != 0);
74 catch(Exception & exception) {
75 OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
77 fprintf(stderr, "an exception occurred: %s\n", message.getStr());
80 #if OSL_DEBUG_LEVEL > 1
81 OSL_TRACE("---------------------------------- %i", result);
82 #endif
84 return result;
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */