LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/padmin/source - pamain.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2013-07-09 Functions: 0 9 0.0 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <stdio.h>
      21             : #include <unistd.h>
      22             : 
      23             : #include "vcl/svapp.hxx"
      24             : #include "vcl/vclmain.hxx"
      25             : #include "vcl/wrkwin.hxx"
      26             : #include "vcl/unowrap.hxx"
      27             : 
      28             : #include "padialog.hxx"
      29             : #include "helper.hxx"
      30             : #include "desktopcontext.hxx"
      31             : 
      32             : #include "cppuhelper/bootstrap.hxx"
      33             : #include "comphelper/processfactory.hxx"
      34             : #include "unotools/configmgr.hxx"
      35             : 
      36             : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
      37             : #include "com/sun/star/lang/XComponent.hpp"
      38             : #include "com/sun/star/ucb/UniversalContentBroker.hpp"
      39             : 
      40             : using namespace padmin;
      41             : using namespace cppu;
      42             : using namespace com::sun::star::uno;
      43             : using namespace com::sun::star::lang;
      44             : using namespace comphelper;
      45             : 
      46             : 
      47           0 : class MyApp : public Application
      48             : {
      49             : public:
      50             :     int Main();
      51             :     virtual sal_uInt16  Exception( sal_uInt16 nError );
      52             : 
      53             :     static OUString ReadStringHook( const OUString& );
      54             : };
      55             : 
      56           0 : void vclmain::createApplication()
      57             : {
      58           0 :     static MyApp aMyApp;
      59           0 : }
      60             : 
      61           0 : OUString MyApp::ReadStringHook( const OUString& rStr )
      62             : {
      63             :     return rStr.replaceAll(
      64           0 :         OUString("%PRODUCTNAME"), utl::ConfigManager::getProductName() );
      65             : };
      66             : 
      67             : 
      68             : // -----------------------------------------------------------------------
      69             : 
      70           0 : sal_uInt16 MyApp::Exception( sal_uInt16 nError )
      71             : {
      72           0 :     switch( nError & EXC_MAJORTYPE )
      73             :     {
      74             :         case EXC_RSCNOTLOADED:
      75           0 :             Abort( OUString( "Error: could not load language resources.\nPlease check your installation.\n" ) );
      76           0 :             break;
      77             :     }
      78           0 :     return 0;
      79             : }
      80             : 
      81           0 : int MyApp::Main()
      82             : {
      83             :     PADialog* pPADialog;
      84             : 
      85           0 :     EnableAutoHelpId();
      86             : 
      87             :     //-------------------------------------------------
      88             :     // create the global service-manager
      89             :     //-------------------------------------------------
      90           0 :     Reference< XComponentContext > xCtx;
      91           0 :     Reference< XMultiServiceFactory > xFactory;
      92             :     try
      93             :     {
      94           0 :         xCtx = defaultBootstrap_InitialComponentContext();
      95           0 :         xFactory = Reference< XMultiServiceFactory >(  xCtx->getServiceManager(), UNO_QUERY );
      96           0 :         if( xFactory.is() )
      97           0 :             setProcessServiceFactory( xFactory );
      98             :     }
      99           0 :     catch( const com::sun::star::uno::Exception& )
     100             :     {
     101             :     }
     102             : 
     103           0 :     if( ! xFactory.is() )
     104             :     {
     105           0 :         fprintf( stderr, "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
     106           0 :         exit( 1 );
     107             :     }
     108             : 
     109             :     // Detect desktop environment - need to do this as early as possible
     110             :     com::sun::star::uno::setCurrentContext(
     111           0 :         new DesktopContext( com::sun::star::uno::getCurrentContext() ) );
     112             : 
     113             :     // Create UCB (for backwards compatibility, in case some code still uses
     114             :     // plain createInstance w/o args directly to obtain an instance):
     115           0 :     com::sun::star::ucb::UniversalContentBroker::create(xCtx);
     116             : 
     117             :     /*
     118             :      * Initialize the Java UNO AccessBridge if accessibility is turned on
     119             :      */
     120             : 
     121           0 :     if( Application::GetSettings().GetMiscSettings().GetEnableATToolSupport() )
     122             :     {
     123             :         bool bQuitApp;
     124           0 :         if( !InitAccessBridge( true, bQuitApp ) )
     125           0 :             if( bQuitApp )
     126           0 :                 return EXIT_FAILURE;
     127             :     }
     128             : 
     129           0 :     ResMgr::SetReadStringHook( MyApp::ReadStringHook );
     130             : 
     131           0 :     pPADialog = PADialog::Create( NULL , sal_False );
     132           0 :     Application::SetDisplayName( pPADialog->GetText() );
     133           0 :     pPADialog->SetIcon(501);
     134           0 :     pPADialog->Execute();
     135           0 :     delete pPADialog;
     136             : 
     137             :     /*
     138             :      *  clean up UNO
     139             :      */
     140             :     try
     141             :     {
     142           0 :         Reference<XComponent> xComp(xCtx, UNO_QUERY_THROW);
     143           0 :         xComp->dispose();
     144             :     }
     145           0 :     catch(...)
     146             :     {
     147             :     }
     148             : 
     149           0 :     return EXIT_SUCCESS;
     150           0 : }
     151             : 
     152             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10