LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/desktop/source/lib - init.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 64 6.2 %
Date: 2013-07-09 Functions: 2 11 18.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  */
       9             : 
      10             : #include <liblibreoffice_impl.hxx>
      11             : 
      12             : #include <stdio.h>
      13             : 
      14             : #include <tools/errinf.hxx>
      15             : #include <osl/file.hxx>
      16             : #include <osl/process.h>
      17             : #include <rtl/strbuf.hxx>
      18             : #include <rtl/bootstrap.hxx>
      19             : #include <cppuhelper/bootstrap.hxx>
      20             : #include <comphelper/processfactory.hxx>
      21             : 
      22             : #include <com/sun/star/beans/XPropertySet.hpp>
      23             : #include <com/sun/star/frame/Desktop.hpp>
      24             : #include <com/sun/star/lang/Locale.hpp>
      25             : #include <com/sun/star/lang/XComponent.hpp>
      26             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      27             : #include <com/sun/star/ucb/XContentProvider.hpp>
      28             : #include <com/sun/star/ucb/XUniversalContentBroker.hpp>
      29             : 
      30             : #include <vcl/svapp.hxx>
      31             : #include <tools/resmgr.hxx>
      32             : #include <vcl/graphicfilter.hxx>
      33             : #include <unotools/syslocaleoptions.hxx>
      34             : 
      35             : using namespace ::com::sun::star;
      36             : 
      37             : // Wonder global state ...
      38          83 : static uno::Reference<css::uno::XComponentContext> xContext;
      39          83 : static uno::Reference<css::lang::XMultiServiceFactory> xSFactory;
      40          83 : static uno::Reference<css::lang::XMultiComponentFactory> xFactory;
      41             : 
      42             : LODocument *
      43           0 : LibLibreOffice_Impl::documentLoad( const char *docUrl )
      44             : {
      45           0 :     OUString sUrl = OUString::createFromAscii (docUrl);
      46           0 :     OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
      47             : 
      48             :     uno::Reference < css::frame::XDesktop2 > xComponentLoader =
      49           0 :             css::frame::Desktop::create(xContext);
      50             : 
      51           0 :     osl_getProcessWorkingDir(&sWorkingDir.pData);
      52           0 :     osl::FileBase::getFileURLFromSystemPath(sUrl, sDocPathUrl);
      53           0 :     osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
      54             : 
      55           0 :     uno::Reference < css::lang::XComponent > xComponent = xComponentLoader->loadComponentFromURL(
      56             :             sAbsoluteDocUrl, OUString("_blank"), 0,
      57           0 :             uno::Sequence < css::beans::PropertyValue >());
      58           0 :     return NULL;
      59             : }
      60             : 
      61             : bool
      62           0 : LibLibreOffice_Impl::documentSave( const char * )
      63             : {
      64           0 :     return 1;
      65             : }
      66             : 
      67             : static void
      68           0 : force_c_locale( void )
      69             : {
      70             :     // force locale (and resource files loaded) to en-US
      71           0 :     OUString aLangISO( "en-US" );
      72           0 :     LanguageTag aLocale( aLangISO );
      73           0 :     ResMgr::SetDefaultLocale( aLocale );
      74           0 :     SvtSysLocaleOptions aLocalOptions;
      75           0 :     aLocalOptions.SetLocaleConfigString( aLangISO );
      76           0 :     aLocalOptions.SetUILocaleConfigString( aLangISO );
      77           0 : }
      78             : 
      79             : static void
      80           0 : aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
      81             : {
      82           0 :     OStringBuffer aErr( "Unexpected dialog: " );
      83           0 :     aErr.append( OUStringToOString( rAction, RTL_TEXTENCODING_ASCII_US ) );
      84           0 :     aErr.append( " Error: " );
      85           0 :     aErr.append( OUStringToOString( rErr, RTL_TEXTENCODING_ASCII_US ) );
      86           0 :     fprintf( stderr, "Unexpected basic error dialog '%s'\n", aErr.getStr() );
      87           0 : }
      88             : 
      89             : static void
      90           0 : initialize_uno( const OUString &aAppURL )
      91             : {
      92           0 :     rtl::Bootstrap::setIniFilename( aAppURL + "/fundamentalrc" );
      93             : 
      94             :     rtl::Bootstrap::set( "CONFIGURATION_LAYERS",
      95             :                          "xcsxcu:${BRAND_BASE_DIR}/share/registry "
      96             :                          "res:${BRAND_BASE_DIR}/share/registry "
      97             : //                       "bundledext:${${BRAND_BASE_DIR}/program/unorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " );
      98             : //                       "sharedext:${${BRAND_BASE_DIR}/program/unorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
      99             : //                       "userext:${${BRAND_BASE_DIR}/program/unorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
     100             : //                         "user:${$BRAND_BASE_DIR/program/bootstraprc:UserInstallation}/user/registrymodifications.xcu"
     101           0 :                          );
     102             : 
     103           0 :     xContext = cppu::defaultBootstrap_InitialComponentContext();
     104           0 :     fprintf( stderr, "Uno initialized %d\n", xContext.is() );
     105           0 :     xFactory = xContext->getServiceManager();
     106           0 :     xSFactory = uno::Reference<lang::XMultiServiceFactory>(xFactory, uno::UNO_QUERY_THROW);
     107           0 :     comphelper::setProcessServiceFactory(xSFactory);
     108             : 
     109             :     // set UserInstallation to user profile dir in test/user-template
     110             : //    rtl::Bootstrap aDefaultVars;
     111             : //    aDefaultVars.set(OUString("UserInstallation"), aAppURL + "../registry" );
     112             :     // configmgr setup ?
     113           0 : }
     114             : 
     115             : bool
     116           0 : LibLibreOffice_Impl::initialize( const char *app_path )
     117             : {
     118             :     static bool bInitialized = false;
     119           0 :     if( bInitialized )
     120           0 :         return true;
     121             : 
     122           0 :     if( !app_path )
     123           0 :         return false;
     124             : 
     125           0 :     OUString aAppPath( app_path, strlen( app_path ), RTL_TEXTENCODING_UTF8 );
     126           0 :     OUString aAppURL;
     127           0 :     if( osl::FileBase::getFileURLFromSystemPath( aAppPath, aAppURL ) !=
     128             :         osl::FileBase::E_None )
     129           0 :         return false;
     130             : 
     131             :     try {
     132           0 :         initialize_uno( aAppURL );
     133           0 :         force_c_locale();
     134             : 
     135             :         // Force headless
     136           0 :         rtl::Bootstrap::set( "SAL_USE_VCLPLUGIN", "svp" );
     137           0 :         InitVCL();
     138           0 :         Application::EnableHeadlessMode(true);
     139             : 
     140           0 :         ErrorHandler::RegisterDisplay( aBasicErrorFunc );
     141             : 
     142           0 :         fprintf( stderr, "initialized\n" );
     143           0 :         bInitialized = true;
     144           0 :     } catch (css::uno::Exception & e) {
     145             :         fprintf( stderr, "bootstrapping exception '%s'\n",
     146           0 :                  OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
     147             :     }
     148           0 :     return bInitialized;
     149             : }
     150             : 
     151             : extern "C" {
     152             :     SAL_DLLPUBLIC_EXPORT LibLibreOffice *liblibreoffice_hook(void);
     153             : }
     154             : 
     155           0 : LibLibreOffice *liblibreoffice_hook(void)
     156             : {
     157           0 :     fprintf( stderr, "create libreoffice object\n" );
     158           0 :     return new LibLibreOffice_Impl();
     159             : }
     160             : 
     161           0 : LibLibreOffice_Impl::~LibLibreOffice_Impl ()
     162             : {
     163         249 : }
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10