diff options
Diffstat (limited to 'configmgr/source/cmdtools')
-rw-r--r-- | configmgr/source/cmdtools/makefile.mk | 63 | ||||
-rw-r--r-- | configmgr/source/cmdtools/setofficelang.cxx | 355 | ||||
-rw-r--r-- | configmgr/source/cmdtools/setofficelang.sh | 102 | ||||
-rw-r--r-- | configmgr/source/cmdtools/unomain.cxx | 145 | ||||
-rw-r--r-- | configmgr/source/cmdtools/unomain.hxx | 63 |
5 files changed, 0 insertions, 728 deletions
diff --git a/configmgr/source/cmdtools/makefile.mk b/configmgr/source/cmdtools/makefile.mk index 3ecec92fcf73..e69de29bb2d1 100644 --- a/configmgr/source/cmdtools/makefile.mk +++ b/configmgr/source/cmdtools/makefile.mk @@ -1,63 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2008 by Sun Microsystems, Inc. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.13 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ = ..$/.. -PRJNAME = configmgr -PRJINC = $(PRJ)$/source -TARGET = cmdtools -LIBTARGET = NO -ENABLE_EXCEPTIONS = TRUE - -# Targettype should be CUI, but we need to be able to run the tools on Windows -# without a shell: -.IF "$(GUI)" == "WNT" -TARGETTYPE = GUI -APP1NOSAL = TRUE -.ELSE -TARGETTYPE = CUI -.ENDIF - -.INCLUDE: settings.mk - -APP1TARGET = setofficelang -APP1OBJS = \ - $(OBJ)$/setofficelang.obj \ - $(OBJ)$/unomain.obj -APP1STDLIBS = \ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(SALLIB) - -OBJFILES = $(APP1OBJS) - -UNIXTEXT = $(MISC)/setofficelang.sh - -.INCLUDE: target.mk diff --git a/configmgr/source/cmdtools/setofficelang.cxx b/configmgr/source/cmdtools/setofficelang.cxx index 3fcff6363a21..e69de29bb2d1 100644 --- a/configmgr/source/cmdtools/setofficelang.cxx +++ b/configmgr/source/cmdtools/setofficelang.cxx @@ -1,355 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: setofficelang.cxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include <stdio.h> - -#include "unomain.hxx" - -#include <osl/thread.h> -#include <rtl/ustring.hxx> - -//============================================================================= -const int OPERATION_SUCCEEDED = 0; -const int ERROR_LANGUAGE_NOT_SUPPORTED = 1; -const int ERROR_INVALID_ARGS = 2; -const int ERROR_RUNTIME_FAILURE = 3; -//============================================================================= - -rtl::OUString const k_BaseSettingsPath( RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup")); -rtl::OUString const k_AppSettingsPath( RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Linguistic/General")); -rtl::OUString const k_LocaleListSetting( RTL_CONSTASCII_USTRINGPARAM("Office/InstalledLocales") ); -rtl::OUString const k_LocaleSetting( RTL_CONSTASCII_USTRINGPARAM("L10N/ooLocale") ); -rtl::OUString const k_UILocaleSetting( RTL_CONSTASCII_USTRINGPARAM("UILocale") ); - -//============================================================================= -static inline rtl::OString narrow(rtl::OUString const & aString) -{ - return rtl::OUStringToOString( aString, osl_getThreadTextEncoding() ); -} -//============================================================================= -static void usage() -{ - rtl::OString sApp = narrow( unoapp::getAppCommandPath() ); - - fprintf(stderr, "%s - set the user interface language " - "of a OpenOffice.org/StarOffice/StarSuite " - "installation\n", sApp.getStr()); - fprintf(stderr, "\nusage : %s [-afcpl] <language> ..\n", sApp.getStr()); - fprintf(stderr, "\n Options:" - "\n -a Change the default language of the installation. " - "\n This may require administrative rights. " - "\n -f Force selection of language. " - "\n Skips the check if this language is installed. " - "\n -c Display current active language. " - "\n -p Display current preferred language. " - "\n -l List all installed languages. "); - fprintf(stderr, "\n <language> - A language specified by its ISO code (e.g. 'en-US','de') or '-' for default. " - "\n This language must be supported by the office installation\n" - "\n If multiple languages are listed, the first one that is installed is used.\n"); - fprintf(stderr, "\nResult codes: 0 - Setting language successfull" - "\n 1 - The language is not supported by this office installation" - "\n 2 - Invalid arguments" - "\n 3 - An internal error occurred\n"); - fflush(stdout); -} - -//--------------------------------------------------------------------------- - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/util/XChangesBatch.hpp> -#include <com/sun/star/container/XNameReplace.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/beans/XPropertyState.hpp> -#include <com/sun/star/uno/Sequence.hxx> -namespace uno = ::com::sun::star::uno; -namespace lang = ::com::sun::star::lang; -namespace util = ::com::sun::star::util; -namespace beans = ::com::sun::star::beans; -namespace container = ::com::sun::star::container; -using rtl::OUString; -//--------------------------------------------------------------------------- - -static uno::Reference< lang::XMultiServiceFactory > createProvider(uno::Reference< uno::XComponentContext > const & xContext, bool bAdmin=false); -static uno::Reference< uno::XInterface > createView(uno::Reference< lang::XMultiServiceFactory > const & xProvider, OUString const & aNodepath, bool bUpdate = false); -static uno::Reference< util::XChangesBatch > createUpdateView(uno::Reference< lang::XMultiServiceFactory > const & xProvider, OUString const & aNodepath); -static void disposeComponent(uno::BaseReference const & xComp); -// -------------------------------------------------------------------------- - -int SAL_CALL unoapp::uno_main(uno::Reference< uno::XComponentContext > const & xContext) - SAL_THROW( (uno::Exception) ) -{ - // get args - uno::Sequence< OUString > const aArgs( getAppCommandArgs() ); - - sal_Int32 const nArgC = aArgs.getLength(); - - sal_Int32 ix = 0; - - // get options - bool bAdminMode = false; - bool bForce = false; - bool bShowCurrentLang = false; - bool bShowSelectedLang = false; - bool bListInstalledLangs = false; - - bool bInfoRequest = false; - - while (ix < nArgC && aArgs[ix].matchAsciiL("-",1)) - { - sal_Int32 const nOptCount = aArgs[ix].getLength() -1; - if (nOptCount <= 0) - { - // a lone "-" means set-to-default-locale - break; - } - - sal_Unicode const * const pOpts = aArgs[ix].getStr() + 1; - for (sal_Int32 opt = 0; opt < nOptCount; ++opt) - { - switch (pOpts[opt]) - { - case 'a': bAdminMode = true; break; - case 'f': bForce = true; break; - case 'c': bShowCurrentLang = true; bInfoRequest = true; break; - case 'p': bShowSelectedLang = true; bInfoRequest = true; break; - case 'l': bListInstalledLangs = true; bInfoRequest = true; break; - default: - usage(); - return ERROR_INVALID_ARGS; - } - } - - ++ix; - } - - if ((nArgC <= ix) && !bInfoRequest) - { - // no more remaining args and no info request - usage(); - return ERROR_INVALID_ARGS; - } - - try - { - uno::Reference< lang::XMultiServiceFactory > xProvider = createProvider(xContext); - uno::Reference< lang::XMultiServiceFactory > xAppProvider = createProvider(xContext,bAdminMode); - OSL_ASSERT( xProvider.is()); - OSL_ASSERT( xAppProvider.is()); - uno::Reference< container::XHierarchicalNameAccess > xBaseSettings( - createView(xProvider,k_BaseSettingsPath), uno::UNO_QUERY_THROW ); - - if (bShowCurrentLang) - { - rtl::OUString aCurrentLocaleU; - if (!(xBaseSettings->getByHierarchicalName(k_LocaleSetting) >>= aCurrentLocaleU) ) - return ERROR_RUNTIME_FAILURE; - - rtl::OString aCurrentLocale = ::rtl::OUStringToOString(aCurrentLocaleU, RTL_TEXTENCODING_ASCII_US); - printf("%s\n", aCurrentLocale.getStr()); - } - if (bShowSelectedLang) - { - uno::Reference< container::XNameAccess > xAppSettings( createView(xAppProvider,k_AppSettingsPath), uno::UNO_QUERY_THROW ); - rtl::OUString aSelectedLocaleU; - if (!(xAppSettings->getByName(k_UILocaleSetting) >>= aSelectedLocaleU) ) - return ERROR_RUNTIME_FAILURE; - - rtl::OString aSelectedLocale = ::rtl::OUStringToOString(aSelectedLocaleU, RTL_TEXTENCODING_ASCII_US); - if (aSelectedLocale.getLength() == 0) aSelectedLocale="-"; - printf("%s\n", aSelectedLocale.getStr()); - - disposeComponent(xAppSettings); - } - - uno::Reference< container::XNameAccess > xSupportedLocales; - xBaseSettings->getByHierarchicalName(k_LocaleListSetting) >>= xSupportedLocales; - - if (bListInstalledLangs) - { - if (!xSupportedLocales.is()) - return ERROR_RUNTIME_FAILURE; - - uno::Sequence< OUString > aSupportedLocales = xSupportedLocales->getElementNames(); - for (sal_Int32 i=0; i<aSupportedLocales.getLength(); ++i) - { - rtl::OString aLocale = ::rtl::OUStringToOString(aSupportedLocales[i], RTL_TEXTENCODING_ASCII_US); - printf("%s\n", aLocale.getStr()); - } - } - if (nArgC > ix) - { - bool bLocaleFound = false; - - uno::Reference< util::XChangesBatch > xAppView = createUpdateView(xAppProvider,k_AppSettingsPath); - uno::Reference< container::XNameReplace > xSettings(xAppView, uno::UNO_QUERY_THROW); - - if (!xSupportedLocales.is()) - return ERROR_RUNTIME_FAILURE; - - for ( ; ix < nArgC; ++ix) - { - OUString const aTargetLocale = aArgs[ix]; - if (aTargetLocale.equalsAscii("-")) - { - uno::Reference< beans::XPropertyState > xSettingsState(xSettings, uno::UNO_QUERY); - // if we can't reset, we treat this as unsupported language - if (!xSettingsState.is()) - continue; - - bLocaleFound = true; - xSettingsState->setPropertyToDefault(k_UILocaleSetting); - xAppView->commitChanges(); - break; - } - else if (bForce || xSupportedLocales->hasByName(aTargetLocale)) - { - bLocaleFound = true; - xSettings->replaceByName(k_UILocaleSetting, uno::makeAny(aTargetLocale)); - xAppView->commitChanges(); - break; - } - } - - disposeComponent(xAppView); - - if (!bLocaleFound) - return ERROR_LANGUAGE_NOT_SUPPORTED; - } - disposeComponent(xBaseSettings); - if (xAppProvider != xProvider) - disposeComponent(xAppProvider); - disposeComponent(xProvider); - } - catch (uno::Exception & e) - { - fprintf(stderr, "\nERROR: - An exception occurred: '%s'\n", narrow(e.Message).getStr()); - return ERROR_RUNTIME_FAILURE; - } - return OPERATION_SUCCEEDED; -} -// -------------------------------------------------------------------------- - -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/lang/ServiceNotRegisteredException.hpp> -#include <com/sun/star/beans/NamedValue.hpp> -#include <rtl/ustrbuf.hxx> -namespace lang = com::sun::star::lang; -namespace beans = com::sun::star::beans; - -// -------------------------------------------------------------------------- -static uno::Reference< uno::XInterface > createService(uno::Reference< uno::XComponentContext > const & xContext, OUString aService) -{ - - uno::Reference< lang::XMultiComponentFactory > xFactory = xContext->getServiceManager(); - if (!xFactory.is()) - { - rtl::OUStringBuffer sMsg; - sMsg.appendAscii("Missing object ! "); - sMsg.appendAscii("UNO context has no service manager."); - - throw uno::RuntimeException(sMsg.makeStringAndClear(),NULL); - } - - uno::Reference< uno::XInterface > xInstance = xFactory->createInstanceWithContext(aService,xContext); - if (!xInstance.is()) - { - rtl::OUStringBuffer sMsg; - sMsg.appendAscii("Missing service ! "); - sMsg.appendAscii("Service manager can't instantiate service "); - sMsg.append(aService).appendAscii(". "); - - throw lang::ServiceNotRegisteredException(sMsg.makeStringAndClear(),NULL); - } - - return xInstance; -} - -// -------------------------------------------------------------------------- -static uno::Reference< lang::XMultiServiceFactory > createProvider(uno::Reference< uno::XComponentContext > const & xContext, bool bAdmin) -{ - static const rtl::OUString kProvider( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")) ; - static const rtl::OUString kAdminProvider( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.AdministrationProvider")) ; - - const rtl::OUString & selectedProvider = bAdmin ? kAdminProvider : kProvider; - - uno::Reference< lang::XMultiServiceFactory > xRet( createService(xContext,selectedProvider), uno::UNO_QUERY_THROW ); - - return xRet; -} -// -------------------------------------------------------------------------- -static uno::Reference< uno::XInterface > createView(uno::Reference< lang::XMultiServiceFactory > const & xProvider, OUString const & aNodepath, bool bUpdate) -{ - static const OUString kInfoViewService( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")) ; - static const OUString kUpdateViewService( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")) ; - static const OUString kNodepath(RTL_CONSTASCII_USTRINGPARAM("nodepath")) ; - static const OUString kAsync(RTL_CONSTASCII_USTRINGPARAM("EnableAsync")) ; - - const OUString & kViewService = bUpdate ? kUpdateViewService : kInfoViewService; - uno::Sequence< uno::Any > aViewArgs(2); - aViewArgs[0] <<= beans::NamedValue( kNodepath, uno::makeAny(aNodepath) ); - aViewArgs[1] <<= beans::NamedValue( kAsync, uno::makeAny(sal_False) ); - - uno::Reference< uno::XInterface > xView( xProvider->createInstanceWithArguments(kViewService,aViewArgs) ); - return xView; -} -// -------------------------------------------------------------------------- -//#if OSL_DEBUG_LEVEL > 0 -#if 0 // currently not used in debug builds! -static uno::Reference< container::XHierarchicalNameAccess > createInfoView(uno::Reference< lang::XMultiServiceFactory > const & xProvider, OUString const & aNodepath) -{ - uno::Reference< container::XHierarchicalNameAccess > xView( createView(xProvider,aNodepath, false), uno::UNO_QUERY_THROW ); - return xView; -} -#endif -// -------------------------------------------------------------------------- -static uno::Reference< util::XChangesBatch > createUpdateView(uno::Reference< lang::XMultiServiceFactory > const & xProvider, OUString const & aNodepath) -{ - uno::Reference< util::XChangesBatch > xView( createView(xProvider,aNodepath,true), uno::UNO_QUERY_THROW ); - return xView; -} - -// -------------------------------------------------------------------------- -static void disposeComponent(uno::BaseReference const & xComp) -{ - uno::Reference< lang::XComponent > xComponent(xComp,uno::UNO_QUERY); - if (xComponent.is()) - xComponent->dispose(); -} - -// -------------------------------------------------------------------------- - - diff --git a/configmgr/source/cmdtools/setofficelang.sh b/configmgr/source/cmdtools/setofficelang.sh index 98664e4d84d4..e69de29bb2d1 100644 --- a/configmgr/source/cmdtools/setofficelang.sh +++ b/configmgr/source/cmdtools/setofficelang.sh @@ -1,102 +0,0 @@ -#!/bin/sh -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2008 by Sun Microsystems, Inc. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# $RCSfile: setofficelang.sh,v $ -# -# $Revision: 1.2 $ -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -# enable file locking -SAL_ENABLE_FILE_LOCKING=1 -export SAL_ENABLE_FILE_LOCKING - -# resolve installation directory -sd_cwd="`pwd`" -if [ -h "$0" ] ; then - sd_basename=`basename "$0"` - sd_script=`ls -l "$0" | sed "s/.*${sd_basename} -> //g"` - cd "`dirname "$0"`" - cd "`dirname "$sd_script"`" -else - cd "`dirname "$0"`" -fi - -sd_prog="`pwd`" - -cd .. -sd_binary=`basename "$0"`".bin" -sd_inst="`pwd`" - -# change back directory -cd "$sd_cwd" - -# check if all required patches are installed -if [ -x "$sd_prog/sopatchlevel.sh" ]; then - "$sd_prog/sopatchlevel.sh" - if [ $? -eq 1 ]; then - exit 0 - fi -fi - -# set search path for shared libraries -sd_platform=`uname -s` -case $sd_platform in - AIX) - LIBPATH=${sd_prog}${LIBPATH+:${LIBPATH}} - export LIBPATH - ;; - - Darwin) - DYLD_LIBRARY_PATH=${sd_prog}${DYLD_LIBRARY_PATH+:${DYLD_LIBRARY_PATH}} - export DYLD_LIBRARY_PATH - ;; - - HP-UX) - SHLIB_PATH=${sd_prog}:/usr/openwin/lib${SHLIB_PATH+:${SHLIB_PATH}} - export SHLIB_PATH - ;; - - IRIX*) - LD_LIBRARYN32_PATH=${sd_prog}${LD_LIBRARYN32_PATH+:${LD_LIBRARYN32_PATH}} - export LD_LIBRARYN32_PATH - ;; - - *) - LD_LIBRARY_PATH=${sd_prog}${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}} - export LD_LIBRARY_PATH - ;; -esac - -# misc. environment variables -unset XENVIRONMENT - -# set path so that other apps can be started just by name -PATH="$sd_prog":$PATH -export PATH - -# execute binary -exec "$sd_prog/$sd_binary" "$@" diff --git a/configmgr/source/cmdtools/unomain.cxx b/configmgr/source/cmdtools/unomain.cxx index 4d8647ed003e..e69de29bb2d1 100644 --- a/configmgr/source/cmdtools/unomain.cxx +++ b/configmgr/source/cmdtools/unomain.cxx @@ -1,145 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unomain.cxx,v $ - * $Revision: 1.7 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_configmgr.hxx" - -#include <stdio.h> - -#include "unomain.hxx" - -#include <sal/main.h> - -#include <com/sun/star/lang/XComponent.hpp> -#include <cppuhelper/bootstrap.hxx> - -#include <rtl/string.hxx> - -#include <rtl/process.h> -#include <osl/thread.h> -#include <osl/file.h> - -namespace uno = ::com::sun::star::uno; - -namespace -{ - struct AutoDispose - { - typedef uno::Reference< ::com::sun::star::lang::XComponent > Component; - AutoDispose() - : component() - {} - - ~AutoDispose() - { - if (component.is()) - component->dispose(); - } - - void set( Component const & xComp ) - { - component = xComp; - } - void set( uno::BaseReference const & xComp ) - { - component.set(xComp,uno::UNO_QUERY); - } - - Component component; - }; -} - -::rtl::OUString SAL_CALL unoapp::getAppCommandURL() -{ - rtl::OUString aURL; - OSL_VERIFY( osl_Process_E_None == osl_getExecutableFile(&aURL.pData) ); - return aURL; -} - -::rtl::OUString SAL_CALL unoapp::getAppCommandPath() -{ - rtl::OUString const aURL = getAppCommandURL(); - - rtl::OUString aPath; - OSL_VERIFY( osl_File_E_None == osl_getSystemPathFromFileURL(aURL.pData,&aPath.pData) ); - - return aPath; -} - -::rtl::OUString SAL_CALL unoapp::getAppCommandName() -{ - rtl::OUString aURL = getAppCommandURL(); - - sal_Int32 const nNameIndex = aURL.lastIndexOf( sal_Unicode('/') ); - - return aURL.copy(nNameIndex+1); -} - -uno::Sequence< ::rtl::OUString > SAL_CALL unoapp::getAppCommandArgs() -{ - sal_uInt32 const count = rtl_getAppCommandArgCount(); - - uno::Sequence< ::rtl::OUString > aResult( count ); - ::rtl::OUString * pResult = aResult.getArray(); - - for (sal_uInt32 i = 0; i < count; ++i) - { - rtl_getAppCommandArg( i, & pResult[i].pData); - } - - return aResult; -} - -bool unoapp::g_bQuiet = false; - -SAL_IMPLEMENT_MAIN() -{ - AutoDispose aDisposer; - try - { - uno::Reference< uno::XComponentContext > xUnoContext = cppu::defaultBootstrap_InitialComponentContext(); - - aDisposer.component.set( xUnoContext, uno::UNO_QUERY ); - - return unoapp::uno_main(xUnoContext); - } - catch (uno::Exception & e) - { - using namespace rtl; - OString sApp = OUStringToOString( unoapp::getAppCommandName(), osl_getThreadTextEncoding() ); - OString sMessage = OUStringToOString( e.Message, osl_getThreadTextEncoding() ); - - if (!unoapp::g_bQuiet) - fprintf( stderr, "%s - Unhandled exception caught in main: \"%s\"\n", sApp.getStr(), sMessage.getStr() ); - - return 42; - } -} - diff --git a/configmgr/source/cmdtools/unomain.hxx b/configmgr/source/cmdtools/unomain.hxx index 5714e3d964bd..e69de29bb2d1 100644 --- a/configmgr/source/cmdtools/unomain.hxx +++ b/configmgr/source/cmdtools/unomain.hxx @@ -1,63 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: unomain.hxx,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_UNOMAIN_HXX -#define INCLUDED_UNOMAIN_HXX - -#include <rtl/ustring.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/XComponentContext.hpp> - -namespace unoapp -{ -//----------------------------------------------------------------------------- - namespace uno = ::com::sun::star::uno; - - /// helper: retrieves the full file URL of the application - extern ::rtl::OUString SAL_CALL getAppCommandURL(); - /// helper: retrieves the full system path of the application - extern ::rtl::OUString SAL_CALL getAppCommandPath(); - /// helper: retrieves the name of the application - extern ::rtl::OUString SAL_CALL getAppCommandName(); - /// helper: retrieves all the commandline arguments of the application (skipping -env: arguments) - extern uno::Sequence< ::rtl::OUString > SAL_CALL getAppCommandArgs(); - - /// global variable that allows to suppress all error output from the unoapp launcher, if set to <TRUE/> - extern bool g_bQuiet; - - /// entrypoint that must be implemented by the application - extern int SAL_CALL uno_main( uno::Reference< uno::XComponentContext > const & xContext) - SAL_THROW( (uno::Exception) ); -//----------------------------------------------------------------------------- -} - - -#endif // INCLUDED_UNOMAIN_HXX |